]> git.ipfire.org Git - collecty.git/blame - src/collecty/plugins/loadavg.py
Add dbus interface
[collecty.git] / src / 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
b1ea4956 28class GraphTemplateLoadAvg(base.GraphTemplate):
708c842f 29 name = "loadavg"
eed405de 30
73db5226
MT
31 rrd_graph = [
32 "DEF:load1=%(file)s:load1:AVERAGE",
33 "DEF:load5=%(file)s:load5:AVERAGE",
34 "DEF:load15=%(file)s:load15:AVERAGE",
35
36 "AREA:load1#ff0000:%s" % _("Load average 1m"),
37 "VDEF:load1min=load1,MINIMUM",
38 "VDEF:load1max=load1,MAXIMUM",
39 "VDEF:load1avg=load1,AVERAGE",
40 "GPRINT:load1max:%12s\:" % _("Maximum") + " %6.2lf",
41 "GPRINT:load1min:%12s\:" % _("Minimum") + " %6.2lf",
42 "GPRINT:load1avg:%12s\:" % _("Average") + " %6.2lf\\n",
43
44 "AREA:load5#ff9900:%s" % _("Load average 5m"),
45 "VDEF:load5min=load5,MINIMUM",
46 "VDEF:load5max=load5,MAXIMUM",
47 "VDEF:load5avg=load5,AVERAGE",
48 "GPRINT:load5max:%12s\:" % _("Maximum") + " %6.2lf",
49 "GPRINT:load5min:%12s\:" % _("Minimum") + " %6.2lf",
50 "GPRINT:load5avg:%12s\:" % _("Average") + " %6.2lf\\n",
51
52 "AREA:load15#ffff00:%s" % _("Load average 15m"),
53 "VDEF:load15min=load15,MINIMUM",
54 "VDEF:load15max=load15,MAXIMUM",
55 "VDEF:load15avg=load15,AVERAGE",
56 "GPRINT:load15max:%12s\:" % _("Maximum") + " %6.2lf",
57 "GPRINT:load15min:%12s\:" % _("Minimum") + " %6.2lf",
58 "GPRINT:load15avg:%12s\:" % _("Average") + " %6.2lf\\n",
59
60 "LINE:load5#dd8800",
61 "LINE:load1#dd0000",
62 ]
b1ea4956 63
73db5226
MT
64 rrd_graph_args = [
65 "--title", _("Load average"),
66 "--vertical-label", _("Load"),
67
68 "--lower-limit", "0", "--rigid",
69 ]
eed405de 70
b1ea4956 71
72364063 72class LoadAvgObject(base.Object):
b1ea4956 73 rrd_schema = [
de090041
MT
74 "DS:load1:GAUGE:0:U",
75 "DS:load5:GAUGE:0:U",
76 "DS:load15:GAUGE:0:U",
b1ea4956
MT
77 ]
78
72364063
MT
79 @property
80 def id(self):
81 return "default"
eed405de 82
72364063 83 def collect(self):
bba5cf66 84 return ":".join(["%.10f" % l for l in os.getloadavg()])
72364063
MT
85
86
87class LoadAvgPlugin(base.Plugin):
88 name = "loadavg"
89 description = "Load Average Plugin"
90
c968f6d9 91 templates = [GraphTemplateLoadAvg]
72364063
MT
92
93 interval = 30
94
95 @property
96 def objects(self):
97 return [LoadAvgObject(self)]