From ca8e57dd106ad02a56c46bd82f9ee2aa8a98c2ce Mon Sep 17 00:00:00 2001 From: "Bala.FA" Date: Wed, 13 Jul 2011 16:16:04 +0530 Subject: Added get_rrd_net_details.py to be used to get rrd data of given network device. Signed-off-by: Bala.FA --- .../src/get_rrd_net_details.py | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 src/com.gluster.storage.management.server.scripts/src/get_rrd_net_details.py (limited to 'src') diff --git a/src/com.gluster.storage.management.server.scripts/src/get_rrd_net_details.py b/src/com.gluster.storage.management.server.scripts/src/get_rrd_net_details.py new file mode 100755 index 00000000..01777a9b --- /dev/null +++ b/src/com.gluster.storage.management.server.scripts/src/get_rrd_net_details.py @@ -0,0 +1,52 @@ +#!/usr/bin/python +# Copyright (C) 2010 Gluster, Inc. +# This file is part of Gluster Storage Platform. +# +# Gluster Storage Platform is free software; you can redistribute it +# and/or modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 3 of +# the License, or (at your option) any later version. +# +# Gluster Storage Platform 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 License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see +# . +import os +import sys +from XmlHandler import ResponseXml +import Utils + +def main(): + if len(sys.argv) != 3: + sys.stderr.write("usage: %s \n" % os.path.basename(sys.argv[0])) + sys.exit(-1) + + device = sys.argv[0] + period = sys.argv[1] + + rs = ResponseXml() + command = "rrdtool xport --start -%s \ + DEF:received=/var/lib/rrd/network-%s.rrd:received:AVERAGE \ + DEF:transmitted=/var/lib/rrd/network-%s.rrd:transmitted:AVERAGE \ + CDEF:total=received,transmitted,+ \ + XPORT:received:received \ + XPORT:transmitted:transmitted \ + XPORT:total:total" % (period, device, device) + rv = Utils.runCommand(command, output=True, root=True) + message = Utils.stripEmptyLines(rv["Stdout"]) + if rv["Stderr"]: + error = Utils.stripEmptyLines(rv["Stderr"]) + message += "Error: [%s]" % (error) + Utils.log("failed to get RRD information of device %s" % file) + rs.appendTagRoute("status.code", rv["Status"]) + rs.appendTagRoute("status.message", message) + print rs.toxml() + print rv["Stdout"] + sys.exit(0) + +if __name__ == "__main__": + main() -- cgit