]> www.infradead.org Git - users/dhowells/kafs-utils.git/commitdiff
Implement "vos status"
authorDavid Howells <dhowells@redhat.com>
Mon, 6 Jul 2020 09:37:26 +0000 (10:37 +0100)
committerDavid Howells <dhowells@redhat.com>
Fri, 5 May 2023 10:53:26 +0000 (11:53 +0100)
Signed-off-by: David Howells <dhowells@redhat.com>
kafs/Makefile
kafs/vos_status.C [new file with mode: 0644]

index 95973a2ce1b30ceb724a432c81f3492538372939..5dcad5669f3c46b97f4c370922028c798d2532cc 100644 (file)
@@ -33,7 +33,8 @@ PTS_SRCS := \
 VOS_SRCS := \
        vos.C \
        vos_help.C \
-       vos_listvldb.C
+       vos_listvldb.C \
+       vos_status.C
 
 CORE_OBJS := $(patsubst %.C,%.o,$(CORE_SRCS))
 BOS_OBJS  :=  $(patsubst %.C,%.o,$(BOS_SRCS))
diff --git a/kafs/vos_status.C b/kafs/vos_status.C
new file mode 100644 (file)
index 0000000..2ef51ae
--- /dev/null
@@ -0,0 +1,92 @@
+/* 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);
+}