]>
git.ipfire.org Git - collecty.git/blob - src/collecty/plugins/processor.py
2 ###############################################################################
4 # collecty - A system statistics collection daemon for IPFire #
5 # Copyright (C) 2012 IPFire development team #
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. #
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. #
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/>. #
20 ###############################################################################
28 class GraphTemplateProcessor(base
.GraphTemplate
):
33 _
= self
.locale
.translate
36 "AREA:user#90EE90:%-15s" % _("User"),
37 "GPRINT:user_max:%12s\:" % _("Maximum") + " %6.2lf" ,
38 "GPRINT:user_min:%12s\:" % _("Minimum") + " %6.2lf",
39 "GPRINT:user_avg:%12s\:" % _("Average") + " %6.2lf\\n",
41 "STACK:nice#4169E1:%-15s" % _("Nice"),
42 "GPRINT:nice_max:%12s\:" % _("Maximum") + " %6.2lf" ,
43 "GPRINT:nice_min:%12s\:" % _("Minimum") + " %6.2lf",
44 "GPRINT:nice_avg:%12s\:" % _("Average") + " %6.2lf\\n",
46 "STACK:sys#DC143C:%-15s" % _("System"),
47 "GPRINT:sys_max:%12s\:" % _("Maximum") + " %6.2lf" ,
48 "GPRINT:sys_min:%12s\:" % _("Minimum") + " %6.2lf",
49 "GPRINT:sys_avg:%12s\:" % _("Average") + " %6.2lf\\n",
51 "STACK:wait#483D8B:%-15s" % _("Wait"),
52 "GPRINT:wait_max:%12s\:" % _("Maximum") + " %6.2lf" ,
53 "GPRINT:wait_min:%12s\:" % _("Minimum") + " %6.2lf",
54 "GPRINT:wait_avg:%12s\:" % _("Average") + " %6.2lf\\n",
56 "STACK:irq#DAA520:%-15s" % _("Interrupt"),
57 "GPRINT:irq_max:%12s\:" % _("Maximum") + " %6.2lf" ,
58 "GPRINT:irq_min:%12s\:" % _("Minimum") + " %6.2lf",
59 "GPRINT:irq_avg:%12s\:" % _("Average") + " %6.2lf\\n",
61 "STACK:sirq#FFD700:%-15s" % _("Soft interrupt"),
62 "GPRINT:sirq_max:%12s\:" % _("Maximum") + " %6.2lf" ,
63 "GPRINT:sirq_min:%12s\:" % _("Minimum") + " %6.2lf",
64 "GPRINT:sirq_avg:%12s\:" % _("Average") + " %6.2lf\\n",
66 "STACK:idle#EFEFEF:%-15s" % _("Idle"),
67 "GPRINT:idle_max:%12s\:" % _("Maximum") + " %6.2lf" ,
68 "GPRINT:idle_min:%12s\:" % _("Minimum") + " %6.2lf",
69 "GPRINT:idle_avg:%12s\:" % _("Average") + " %6.2lf\\n",
75 def graph_title(self
):
76 _
= self
.locale
.translate
77 return _("Processor Usage")
80 def graph_vertical_label(self
):
81 _
= self
.locale
.translate
85 class ProcessorObject(base
.Object
):
107 f
= open("/proc/stat")
109 for line
in f
.readlines():
110 if not line
.startswith("cpu"):
113 columns
= line
.split()
131 class ProcessorPlugin(base
.Plugin
):
133 description
= "Processor Usage Plugin"
135 templates
= [GraphTemplateProcessor
]
139 yield ProcessorObject(self
)