]> git.ipfire.org Git - collecty.git/blame - src/collecty/plugins/loadavg.py
Add some magic to collecty that makes the graph templates smaller
[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 [
cb74e9e9 36 "AREA:load1#ff0000:%s" % _("Load average 1m"),
cd8bba0b
MT
37 "GPRINT:load1_max:%12s\:" % _("Maximum") + " %6.2lf",
38 "GPRINT:load1_min:%12s\:" % _("Minimum") + " %6.2lf",
39 "GPRINT:load1_avg:%12s\:" % _("Average") + " %6.2lf\\n",
cb74e9e9
MT
40
41 "AREA:load5#ff9900:%s" % _("Load average 5m"),
cd8bba0b
MT
42 "GPRINT:load5_max:%12s\:" % _("Maximum") + " %6.2lf",
43 "GPRINT:load5_min:%12s\:" % _("Minimum") + " %6.2lf",
44 "GPRINT:load5_avg:%12s\:" % _("Average") + " %6.2lf\\n",
cb74e9e9
MT
45
46 "AREA:load15#ffff00:%s" % _("Load average 15m"),
cd8bba0b
MT
47 "GPRINT:load15_max:%12s\:" % _("Maximum") + " %6.2lf",
48 "GPRINT:load15_min:%12s\:" % _("Minimum") + " %6.2lf",
49 "GPRINT:load15_avg:%12s\:" % _("Average") + " %6.2lf\\n",
cb74e9e9
MT
50
51 "LINE:load5#dd8800",
52 "LINE:load1#dd0000",
53 ]
b1ea4956 54
f181246a 55 lower_limit = 0
73db5226 56
f181246a
MT
57 @property
58 def graph_title(self):
cb74e9e9 59 _ = self.locale.translate
f181246a
MT
60 return _("Load average")
61
62 @property
63 def graph_vertical_label(self):
cb74e9e9 64 _ = self.locale.translate
f181246a 65 return _("Load")
eed405de 66
b1ea4956 67
72364063 68class LoadAvgObject(base.Object):
b1ea4956 69 rrd_schema = [
de090041
MT
70 "DS:load1:GAUGE:0:U",
71 "DS:load5:GAUGE:0:U",
72 "DS:load15:GAUGE:0:U",
b1ea4956
MT
73 ]
74
72364063
MT
75 @property
76 def id(self):
77 return "default"
eed405de 78
72364063 79 def collect(self):
f648421a 80 return os.getloadavg()
72364063
MT
81
82
83class LoadAvgPlugin(base.Plugin):
84 name = "loadavg"
85 description = "Load Average Plugin"
86
c968f6d9 87 templates = [GraphTemplateLoadAvg]
72364063 88
72364063
MT
89 @property
90 def objects(self):
91 return [LoadAvgObject(self)]