From: David Howells Date: Fri, 11 Apr 2014 14:15:39 +0000 (+0100) Subject: Implement "vos monitor" X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=b662759569423c692b92cbb94ce0d715f6ba06a7;p=users%2Fdhowells%2Fkafs-utils.git Implement "vos monitor" Signed-off-by: David Howells --- diff --git a/suite/commands/vos/status.py b/suite/commands/vos/status.py new file mode 100644 index 0000000..c2bcc29 --- /dev/null +++ b/suite/commands/vos/status.py @@ -0,0 +1,84 @@ +# +# AFS Volume management toolkit: Report server status +# -*- coding: utf-8 -*- +# + +__copyright__ = """ +Copyright (C) 2014 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 version 2 as +published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public Licence for more details. + +You should have received a copy of the GNU General Public Licence +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +""" + +from afs.argparse import * +import afs.lib.partition as partition +import kafs + +help = "Report a volume server's status" + +command_arguments = [ + [ "server", get_volserver, "rs", "" ], + [ "cell", get_cell, "os", "" ], + [ "noauth", get_auth, "fn" ], + [ "localauth", get_auth, "fn" ], + [ "verbose", get_dummy, "fn" ], + [ "encrypt", get_dummy, "fn" ], + [ "noresolve", get_dummy, "fn" ], +] + +cant_combine_arguments = [ + ( "cell", "localauth" ), + ( "noauth", "localauth" ), +] + +description = r""" +Report a volume server's status +""" + +def main(params): + cell = params["cell"] + vol_conn = cell.open_volume_server(params["server"], params) + + ret = kafs.VOLSER_AFSVolMonitor(vol_conn) + results = ret.result + if len(results) == 0: + print("No active transactions on", params["server"].name()) + return + + print("--------------------------------------------") + for trans in results: + print("transaction: {:d} created: {:s}".format(trans.tid, afs_time(trans.creationTime))) + print("lastActiveTime:", afs_time(trans.time)) + if iflag & kafs.ITOffline: + attach_mode = "offline" + elif iflag & kafs.ITBusy: + attach_mode = "busy" + elif iflag & kafs.ITReadOnly: + attach_mode = "readonly" + elif iflag & kafs.ITCreate: + attach_mode = "create" + elif iflag & kafs.ITCreateVolID: + attach_mode = "createvolid" + else: + attach_mode = "{:d}".format(trans.iflags) + print("attachFlags:", attach_mode) + print("volume: {:d} partition {:s} procedure {:s}".format( + trans.volid, + partition.id2part(trans.partition), + lastProcName)) + print("packetRead:", trans.readNext, + "lastReceiveTime:", trans.lastReceiveTime, + "packetSend:", trans.transmitNext) + print(" lastSendTime:", trans.lastSendTime) + print("--------------------------------------------")