diff options
author | Philip Knirsch <pknirsch@hamburg.stuttgart.redhat.com> | 2009-02-02 14:55:24 +0100 |
---|---|---|
committer | Philip Knirsch <pknirsch@hamburg.stuttgart.redhat.com> | 2009-02-02 14:55:24 +0100 |
commit | 28bd83e0d262ba1164d52fa1d9a551caab2e31e6 (patch) | |
tree | 138a0babb79e5b2c7abe1b3539c30c3ffbdb663e /monitorplugins | |
parent | dad7d76884d3558f14e4f61334b08cf0d1d7c81a (diff) | |
download | tuned-28bd83e0d262ba1164d52fa1d9a551caab2e31e6.tar.gz tuned-28bd83e0d262ba1164d52fa1d9a551caab2e31e6.tar.xz tuned-28bd83e0d262ba1164d52fa1d9a551caab2e31e6.zip |
- Added copyright notices to files
- Added GPL COPYING license file
Diffstat (limited to 'monitorplugins')
-rw-r--r-- | monitorplugins/__init__.py | 17 | ||||
-rw-r--r-- | monitorplugins/disk.py | 18 | ||||
-rw-r--r-- | monitorplugins/network.py | 45 |
3 files changed, 59 insertions, 21 deletions
diff --git a/monitorplugins/__init__.py b/monitorplugins/__init__.py index e69de29..de1aa0f 100644 --- a/monitorplugins/__init__.py +++ b/monitorplugins/__init__.py @@ -0,0 +1,17 @@ +# Copyright (C) 2008, 2009 Red Hat, Inc. +# Authors: Phil Knirsch +# +# This program 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 2 +# of the License, or (at your option) any later version. +# +# 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 License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# diff --git a/monitorplugins/disk.py b/monitorplugins/disk.py index cde18d1..fb9eb56 100644 --- a/monitorplugins/disk.py +++ b/monitorplugins/disk.py @@ -1,3 +1,21 @@ +# Copyright (C) 2008, 2009 Red Hat, Inc. +# Authors: Phil Knirsch +# +# This program 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 2 +# of the License, or (at your option) any later version. +# +# 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 License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + import os class DiskMonitor: diff --git a/monitorplugins/network.py b/monitorplugins/network.py index cde18d1..64c493a 100644 --- a/monitorplugins/network.py +++ b/monitorplugins/network.py @@ -1,23 +1,26 @@ +# Copyright (C) 2008, 2009 Red Hat, Inc. +# Authors: Phil Knirsch +# +# This program 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 2 +# of the License, or (at your option) any later version. +# +# 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 License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + import os -class DiskMonitor: +class NetMonitor: def __init__(self): self.devices = {} - dnames = os.listdir("/sys/block/") - for d in dnames: - try: - v = open("/sys/block/"+d+"/device/vendor").read().strip() - except: - v = None - if v != "ATA" and v != "SCSI": - continue - self.devices[d] = {} - self.devices[d]["new"] = ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'] - self.devices[d]["max"] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] - self.__updateStat__(d) - self.devices[d]["max"] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] - print self.devices - def __calcdiff__(self, dev): l = [] @@ -42,11 +45,11 @@ class DiskMonitor: def getLoad(self): self.__update__() ret = {} - ret["DISK"] = {} + ret["NET"] = {} for dev in self.devices.keys(): - ret["DISK"][dev] = {} - ret["DISK"][dev]["READ"] = float(self.devices[dev]["diff"][1]) / float(self.devices[dev]["max"][1]) - ret["DISK"][dev]["WRITE"] = float(self.devices[dev]["diff"][5]) / float(self.devices[dev]["max"][5]) + ret["NET"][dev] = {} + ret["NET"][dev]["READ"] = float(self.devices[dev]["diff"][1]) / float(self.devices[dev]["max"][1]) + ret["NET"][dev]["WRITE"] = float(self.devices[dev]["diff"][5]) / float(self.devices[dev]["max"][5]) return ret -_plugin = DiskMonitor() +_plugin = NetMonitor() |