]> git.ipfire.org Git - collecty.git/blame - src/collecty/plugins/loadavg.py
loadavg: Localise plugin
[collecty.git] / src / collecty / plugins / loadavg.py
CommitLineData
f37913e8 1#!/usr/bin/python3
eed405de
MT
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
f37913e8 24from . import base
eed405de
MT
25
26from ..i18n import _
27
b1ea4956 28class GraphTemplateLoadAvg(base.GraphTemplate):
708c842f 29 name = "loadavg"
eed405de 30
cb74e9e9
MT
31 @property
32 def rrd_graph(self):
33 _ = self.locale.translate
34
35 return [
36 "DEF:load1=%(file)s:load1:AVERAGE",
37 "DEF:load5=%(file)s:load5:AVERAGE",
38 "DEF:load15=%(file)s:load15:AVERAGE",
39
40 "AREA:load1#ff0000:%s" % _("Load average 1m"),
41 "VDEF:load1min=load1,MINIMUM",
42 "VDEF:load1max=load1,MAXIMUM",
43 "VDEF:load1avg=load1,AVERAGE",
44 "GPRINT:load1max:%12s\:" % _("Maximum") + " %6.2lf",
45 "GPRINT:load1min:%12s\:" % _("Minimum") + " %6.2lf",
46 "GPRINT:load1avg:%12s\:" % _("Average") + " %6.2lf\\n",
47
48 "AREA:load5#ff9900:%s" % _("Load average 5m"),
49 "VDEF:load5min=load5,MINIMUM",
50 "VDEF:load5max=load5,MAXIMUM",
51 "VDEF:load5avg=load5,AVERAGE",
52 "GPRINT:load5max:%12s\:" % _("Maximum") + " %6.2lf",
53 "GPRINT:load5min:%12s\:" % _("Minimum") + " %6.2lf",
54 "GPRINT:load5avg:%12s\:" % _("Average") + " %6.2lf\\n",
55
56 "AREA:load15#ffff00:%s" % _("Load average 15m"),
57 "VDEF:load15min=load15,MINIMUM",
58 "VDEF:load15max=load15,MAXIMUM",
59 "VDEF:load15avg=load15,AVERAGE",
60 "GPRINT:load15max:%12s\:" % _("Maximum") + " %6.2lf",
61 "GPRINT:load15min:%12s\:" % _("Minimum") + " %6.2lf",
62 "GPRINT:load15avg:%12s\:" % _("Average") + " %6.2lf\\n",
63
64 "LINE:load5#dd8800",
65 "LINE:load1#dd0000",
66 ]
b1ea4956 67
f181246a 68 lower_limit = 0
73db5226 69
f181246a
MT
70 @property
71 def graph_title(self):
cb74e9e9 72 _ = self.locale.translate
f181246a
MT
73 return _("Load average")
74
75 @property
76 def graph_vertical_label(self):
cb74e9e9 77 _ = self.locale.translate
f181246a 78 return _("Load")
eed405de 79
b1ea4956 80
72364063 81class LoadAvgObject(base.Object):
b1ea4956 82 rrd_schema = [
de090041
MT
83 "DS:load1:GAUGE:0:U",
84 "DS:load5:GAUGE:0:U",
85 "DS:load15:GAUGE:0:U",
b1ea4956
MT
86 ]
87
72364063
MT
88 @property
89 def id(self):
90 return "default"
eed405de 91
72364063 92 def collect(self):
f648421a 93 return os.getloadavg()
72364063
MT
94
95
96class LoadAvgPlugin(base.Plugin):
97 name = "loadavg"
98 description = "Load Average Plugin"
99
c968f6d9 100 templates = [GraphTemplateLoadAvg]
72364063 101
72364063
MT
102 @property
103 def objects(self):
104 return [LoadAvgObject(self)]