diff options
| author | Bala.FA <bala@gluster.com> | 2011-07-13 16:16:04 +0530 |
|---|---|---|
| committer | Bala.FA <bala@gluster.com> | 2011-07-13 16:17:37 +0530 |
| commit | ca8e57dd106ad02a56c46bd82f9ee2aa8a98c2ce (patch) | |
| tree | 49714379af3703239060b53f01af1c8a6aa462d5 /src/com.gluster.storage.management.server.scripts | |
| parent | 8a80d2b14830f7881631e62b1088f3af9d492bbd (diff) | |
Added get_rrd_net_details.py to be used to get rrd data of given network device.
Signed-off-by: Bala.FA <bala@gluster.com>
Diffstat (limited to 'src/com.gluster.storage.management.server.scripts')
| -rwxr-xr-x | src/com.gluster.storage.management.server.scripts/src/get_rrd_net_details.py | 52 |
1 files changed, 52 insertions, 0 deletions
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. <http://www.gluster.com> +# 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 +# <http://www.gnu.org/licenses/>. +import os +import sys +from XmlHandler import ResponseXml +import Utils + +def main(): + if len(sys.argv) != 3: + sys.stderr.write("usage: %s <DEVICE> <PERIOD>\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() |
