]>
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 ###############################################################################
24 from ..colours
import *
27 class GraphTemplateProcessor(base
.GraphTemplate
):
32 _
= self
.locale
.translate
35 "AREA:user%s:%-15s" % (CPU_USER
, _("User")),
36 "GPRINT:user_max:%12s\:" % _("Maximum") + " %6.2lf" ,
37 "GPRINT:user_min:%12s\:" % _("Minimum") + " %6.2lf",
38 "GPRINT:user_avg:%12s\:" % _("Average") + " %6.2lf\\n",
40 "STACK:nice%s:%-15s" % (CPU_NICE
, _("Nice")),
41 "GPRINT:nice_max:%12s\:" % _("Maximum") + " %6.2lf" ,
42 "GPRINT:nice_min:%12s\:" % _("Minimum") + " %6.2lf",
43 "GPRINT:nice_avg:%12s\:" % _("Average") + " %6.2lf\\n",
45 "STACK:sys%s:%-15s" % (CPU_SYS
, _("System")),
46 "GPRINT:sys_max:%12s\:" % _("Maximum") + " %6.2lf" ,
47 "GPRINT:sys_min:%12s\:" % _("Minimum") + " %6.2lf",
48 "GPRINT:sys_avg:%12s\:" % _("Average") + " %6.2lf\\n",
50 "STACK:wait%s:%-15s" % (CPU_WAIT
, _("Wait")),
51 "GPRINT:wait_max:%12s\:" % _("Maximum") + " %6.2lf" ,
52 "GPRINT:wait_min:%12s\:" % _("Minimum") + " %6.2lf",
53 "GPRINT:wait_avg:%12s\:" % _("Average") + " %6.2lf\\n",
55 "STACK:irq%s:%-15s" % (CPU_IRQ
, _("Interrupt")),
56 "GPRINT:irq_max:%12s\:" % _("Maximum") + " %6.2lf" ,
57 "GPRINT:irq_min:%12s\:" % _("Minimum") + " %6.2lf",
58 "GPRINT:irq_avg:%12s\:" % _("Average") + " %6.2lf\\n",
60 "STACK:sirq%s:%-15s" % (CPU_SIRQ
, _("Soft Interrupt")),
61 "GPRINT:sirq_max:%12s\:" % _("Maximum") + " %6.2lf" ,
62 "GPRINT:sirq_min:%12s\:" % _("Minimum") + " %6.2lf",
63 "GPRINT:sirq_avg:%12s\:" % _("Average") + " %6.2lf\\n",
65 "STACK:idle%s:%-15s" % (CPU_IDLE
, _("Idle")),
66 "GPRINT:idle_max:%12s\:" % _("Maximum") + " %6.2lf" ,
67 "GPRINT:idle_min:%12s\:" % _("Minimum") + " %6.2lf",
68 "GPRINT:idle_avg:%12s\:" % _("Average") + " %6.2lf\\n",
74 def graph_title(self
):
75 _
= self
.locale
.translate
76 return _("Processor Usage")
79 def graph_vertical_label(self
):
80 _
= self
.locale
.translate
84 class ProcessorObject(base
.Object
):
106 f
= open("/proc/stat")
108 for line
in f
.readlines():
109 if not line
.startswith("cpu"):
112 columns
= line
.split()
130 class ProcessorPlugin(base
.Plugin
):
132 description
= "Processor Usage Plugin"
134 templates
= [GraphTemplateProcessor
]
138 yield ProcessorObject(self
)