--- /dev/null
+/* The "vos status" command
+ *
+ * Copyright (C) 2020 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+
+#include "kafs.H"
+#include "arg_parse.H"
+#include "volservice.H"
+#include "afs_xg.H"
+#include "display.H"
+#include <fmt/core.h>
+
+using rxrpc::ref;
+
+static void dump_transactions(kafs::Vol_transaction_info_list &transactions)
+{
+ fmt::print("--------------------------------------------\n");
+ for (unsigned int i = 0; i < transactions.size(); i++) {
+ kafs::Vol_transaction_info &trans = transactions[i];
+ std::string attach_mode;
+ unsigned int iflags = trans.iflags;
+
+ fmt::print("transaction: {:d} created: {:s}\n",
+ trans.tid, kafs::sprint_time(trans.creation_time));
+ fmt::print("lastActiveTime: {}\n", kafs::sprint_time(trans.time));
+ if (iflags & kafs::afs::ITOffline)
+ attach_mode = "offline";
+ else if (iflags & kafs::afs::ITBusy)
+ attach_mode = "busy";
+ else if (iflags & kafs::afs::ITReadOnly)
+ attach_mode = "readonly";
+ else if (iflags & kafs::afs::ITCreate)
+ attach_mode = "create";
+ else if (iflags & kafs::afs::ITCreateVolID)
+ attach_mode = "createvolid";
+ else
+ attach_mode = fmt::format("{:d}", trans.iflags);
+ fmt::print("attachFlags: {}\n", attach_mode);
+ fmt::print("volume: {:d} partition {:s} procedure {:s}",
+ trans.volid,
+ kafs::sprint_partition(trans.partition),
+ trans.last_proc_name);
+ fmt::print("packetRead: {} lastReceiveTime: {} packetSend: {}\n",
+ trans.read_next,
+ trans.last_receive_time.seconds(),
+ trans.transmit_next);
+ fmt::print(" lastSendTime: ", trans.last_send_time.seconds(), "\n");
+ fmt::print("--------------------------------------------\n");
+ }
+}
+
+/***
+ * COMMAND: vos status - Report a volume server's status
+ * ARG: "-server <machine name>"
+ * ARG: "[-cell <cell name>]"
+ * ARG: "[-noauth]" - Auth
+ * ARG: "[-localauth]" - Auth
+ * ARG: "[-verbose]"
+ * ARG: "[-encrypt]" - Auth
+ * ARG: "[-noresolve]"
+ *
+ * Report a volume server's status
+ */
+void COMMAND_vos_status(
+ kafs::Context *ctx,
+ kafs::Volserver_spec &a_server,
+ bool a_verbose,
+ bool a_noresolve)
+{
+ kafs::Vol_transaction_info_list transactions;
+ ref<kafs::Volserver> server;
+ ref<kafs::FS_site> site;
+
+ _enter("");
+
+ ctx->no_resolve = a_noresolve;
+
+ site = kafs::resolve_server_spec(ctx, a_server);
+ server = new kafs::Volserver(ctx, site);
+ server->vol_monitor_transaction(transactions);
+
+ if (transactions.size() == 0)
+ fmt::print("No active transactions on {}\n", server->name());
+ else
+ dump_transactions(transactions);
+}