]> git.ipfire.org Git - collecty.git/blame - collecty/plugins/loadavg.py
plugins: Split all plugins into separate files.
[collecty.git] / collecty / plugins / loadavg.py
CommitLineData
eed405de
MT
1#!/usr/bin/python
2###############################################################################
3# #
4# collecty - A system statistics collection daemon for IPFire #
5# Copyright (C) 2012 IPFire development team #
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
21
22import os
23
24import base
25
26from ..i18n import _
27
28class PluginLoadAvg(base.Plugin):
29 _name = "Loadaverage Plugin"
30 _type = "load"
31
32 _rrd = ["DS:load1:GAUGE:120:0:U",
33 "DS:load5:GAUGE:120:0:U",
34 "DS:load15:GAUGE:120:0:U",
35 "RRA:AVERAGE:0.5:1:2160",
36 "RRA:AVERAGE:0.5:5:2016",
37 "RRA:AVERAGE:0.5:15:2880",
38 "RRA:AVERAGE:0.5:60:8760" ]
39
40 _graph = [ "DEF:load1=%(file)s:load1:AVERAGE",
41 "DEF:load5=%(file)s:load5:AVERAGE",
42 "DEF:load15=%(file)s:load15:AVERAGE",
43 "AREA:load1#ff0000:%s" % _("Load average 1m"),
44 "VDEF:load1min=load1,MINIMUM",
45 "VDEF:load1max=load1,MAXIMUM",
46 "VDEF:load1avg=load1,AVERAGE",
47 "GPRINT:load1max:%12s\:" % _("Maximum") + " %6.2lf" ,
48 "GPRINT:load1min:%12s\:" % _("Minimum") + " %6.2lf",
49 "GPRINT:load1avg:%12s\:" % _("Average") + " %6.2lf\\n",
50 "AREA:load5#ff9900:%s" % _("Load average 5m"),
51 "VDEF:load5min=load5,MINIMUM",
52 "VDEF:load5max=load5,MAXIMUM",
53 "VDEF:load5avg=load5,AVERAGE",
54 "GPRINT:load5max:%12s\:" % _("Maximum") + " %6.2lf" ,
55 "GPRINT:load5min:%12s\:" % _("Minimum") + " %6.2lf",
56 "GPRINT:load5avg:%12s\:" % _("Average") + " %6.2lf\\n",
57 "AREA:load15#ffff00:%s" % _("Load average 15m"),
58 "VDEF:load15min=load15,MINIMUM",
59 "VDEF:load15max=load15,MAXIMUM",
60 "VDEF:load15avg=load15,AVERAGE",
61 "GPRINT:load15max:%12s\:" % _("Maximum") + " %6.2lf" ,
62 "GPRINT:load15min:%12s\:" % _("Minimum") + " %6.2lf",
63 "GPRINT:load15avg:%12s\:" % _("Average") + " %6.2lf\\n",
64 "LINE:load5#dd8800",
65 "LINE:load1#dd0000", ]
66
67 def __init__(self, collecty, **kwargs):
68 Plugin.__init__(self, collecty, **kwargs)
69
70 def collect(self):
71 ret = "%s" % self.time()
72 for load in os.getloadavg():
73 ret += ":%s" % load
74 return ret