7 const char blank[] = "COMMENT: ";
8 #define numfmt " % 8.2lf "
10 #define SYSINFO_PATH "./"
11 #define SYSINFO_RRD_PATH SYSINFO_PATH "sysinfo.rrd"
12 #define SYSINFO_IMAGES_PATH SYSINFO_PATH "images/"
14 #define SYSTEMP_RRD_PATH "/root/systemp/systemp.rrd"
16 #define NETWORK_RRD_PATH SYSINFO_PATH "network.rrd"
18 const char *cputext[] = {
19 "DEF:us=" SYSINFO_RRD_PATH ":User:AVERAGE",
20 "DEF:ni=" SYSINFO_RRD_PATH ":Nice:AVERAGE",
21 "DEF:sy=" SYSINFO_RRD_PATH ":Sys:AVERAGE",
22 "DEF:id=" SYSINFO_RRD_PATH ":Idle:AVERAGE",
23 "DEF:wa=" SYSINFO_RRD_PATH ":Wait:AVERAGE",
24 "DEF:in=" SYSINFO_RRD_PATH ":IRQ:AVERAGE",
25 "DEF:so=" SYSINFO_RRD_PATH ":SoftIRQ:AVERAGE",
29 "MIN MAX AVG Last\\n",
31 "AREA:sy#ff0000:System ",
32 "GPRINT:sy:MIN:" numfmt,
33 "GPRINT:sy:MAX:" numfmt,
34 "GPRINT:sy:AVERAGE:" numfmt,
35 "GPRINT:sy:LAST:" numfmt "\\n",
37 "STACK:us#0000ff:User ",
38 "GPRINT:us:MIN:" numfmt,
39 "GPRINT:us:MAX:" numfmt,
40 "GPRINT:us:AVERAGE:" numfmt,
41 "GPRINT:us:LAST:" numfmt "\\n",
43 "STACK:ni#00ff00:Nice ",
44 "GPRINT:ni:MIN:" numfmt,
45 "GPRINT:ni:MAX:" numfmt,
46 "GPRINT:ni:AVERAGE:" numfmt,
47 "GPRINT:ni:LAST:" numfmt "\\n",
49 "STACK:id#ffffff:Idle ",
50 "GPRINT:id:MIN:" numfmt,
51 "GPRINT:id:MAX:" numfmt,
52 "GPRINT:id:AVERAGE:" numfmt,
53 "GPRINT:id:LAST:" numfmt "\\n",
55 "STACK:wa#ff00ff:IO wait ",
56 "GPRINT:wa:MIN:" numfmt,
57 "GPRINT:wa:MAX:" numfmt,
58 "GPRINT:wa:AVERAGE:" numfmt,
59 "GPRINT:wa:LAST:" numfmt "\\n",
61 "STACK:in#ffff00:IRQ ",
62 "GPRINT:in:MIN:" numfmt,
63 "GPRINT:in:MAX:" numfmt,
64 "GPRINT:in:AVERAGE:" numfmt,
65 "GPRINT:in:LAST:" numfmt "\\n",
67 "STACK:so#00ffff:Soft IRQ ",
68 "GPRINT:so:MIN:" numfmt,
69 "GPRINT:so:MAX:" numfmt,
70 "GPRINT:so:AVERAGE:" numfmt,
71 "GPRINT:so:LAST:" numfmt "\\n",
76 const char *memtext[] = {
77 "DEF:fr=" SYSINFO_RRD_PATH ":Free:AVERAGE",
78 "DEF:bu=" SYSINFO_RRD_PATH ":Buffers:AVERAGE",
79 "DEF:ca=" SYSINFO_RRD_PATH ":Cached:AVERAGE",
80 "DEF:an=" SYSINFO_RRD_PATH ":Anon:AVERAGE",
81 "DEF:sl=" SYSINFO_RRD_PATH ":Slab:AVERAGE",
82 "DEF:ta=" SYSINFO_RRD_PATH ":Tables:AVERAGE",
83 "DEF:ot=" SYSINFO_RRD_PATH ":Other:AVERAGE",
84 "DEF:sw=" SYSINFO_RRD_PATH ":Swap:AVERAGE",
88 "MIN MAX AVG Last\\n",
90 "AREA:bu#ffff00:Buffers ",
91 "GPRINT:bu:MIN:" numfmt,
92 "GPRINT:bu:MAX:" numfmt,
93 "GPRINT:bu:AVERAGE:" numfmt,
94 "GPRINT:bu:LAST:" numfmt "\\n",
96 "STACK:an#000000:AnonPages ",
97 "GPRINT:an:MIN:" numfmt,
98 "GPRINT:an:MAX:" numfmt,
99 "GPRINT:an:AVERAGE:" numfmt,
100 "GPRINT:an:LAST:" numfmt "\\n",
102 "STACK:ca#00ff00:Cached ",
103 "GPRINT:ca:MIN:" numfmt,
104 "GPRINT:ca:MAX:" numfmt,
105 "GPRINT:ca:AVERAGE:" numfmt,
106 "GPRINT:ca:LAST:" numfmt "\\n",
108 "STACK:fr#ffffff:Free ",
109 "GPRINT:fr:MIN:" numfmt,
110 "GPRINT:fr:MAX:" numfmt,
111 "GPRINT:fr:AVERAGE:" numfmt,
112 "GPRINT:fr:LAST:" numfmt "\\n",
114 "STACK:sl#00ffff:Slab ",
115 "GPRINT:sl:MIN:" numfmt,
116 "GPRINT:sl:MAX:" numfmt,
117 "GPRINT:sl:AVERAGE:" numfmt,
118 "GPRINT:sl:LAST:" numfmt "\\n",
120 "STACK:ta#0000ff:PageTables ",
121 "GPRINT:ta:MIN:" numfmt,
122 "GPRINT:ta:MAX:" numfmt,
123 "GPRINT:ta:AVERAGE:" numfmt,
124 "GPRINT:ta:LAST:" numfmt "\\n",
126 "STACK:ot#a0a0a0:Other ",
127 "GPRINT:ot:MIN:" numfmt,
128 "GPRINT:ot:MAX:" numfmt,
129 "GPRINT:ot:AVERAGE:" numfmt,
130 "GPRINT:ot:LAST:" numfmt "\\n",
132 "STACK:sw#ff0000:Swap ",
133 "GPRINT:sw:MIN:" numfmt,
134 "GPRINT:sw:MAX:" numfmt,
135 "GPRINT:sw:AVERAGE:" numfmt,
136 "GPRINT:sw:LAST:" numfmt "\\n",
141 const char *eth0text[] = {
142 "DEF:rxb=" NETWORK_RRD_PATH ":eth0rxb:AVERAGE",
143 "DEF:txb=" NETWORK_RRD_PATH ":eth0txb:AVERAGE",
147 "MIN MAX AVG Last\\n",
149 "LINE1:rxb#0000FF:eth0 receive ",
150 "GPRINT:rxb:MIN: % 3.2lf %sB",
151 "GPRINT:rxb:MAX: % 3.2lf %sB",
152 "GPRINT:rxb:AVERAGE: % 3.2lf %sB",
153 "GPRINT:rxb:LAST: % 3.2lf %sB\\n",
155 "LINE1:txb#00FF00:eth0 transmit ",
156 "GPRINT:txb:MIN: % 3.2lf %sB",
157 "GPRINT:txb:MAX: % 3.2lf %sB",
158 "GPRINT:txb:AVERAGE: % 3.2lf %sB",
159 "GPRINT:txb:LAST: % 3.2lf %sB\\n",
164 const char *eth1text[] = {
165 "DEF:rxb=" NETWORK_RRD_PATH ":eth1rxb:AVERAGE",
166 "DEF:txb=" NETWORK_RRD_PATH ":eth1txb:AVERAGE",
170 "MIN MAX AVG Last\\n",
172 "LINE1:rxb#0000FF:eth1 receive ",
173 "GPRINT:rxb:MIN: % 3.2lf %sB",
174 "GPRINT:rxb:MAX: % 3.2lf %sB",
175 "GPRINT:rxb:AVERAGE: % 3.2lf %sB",
176 "GPRINT:rxb:LAST: % 3.2lf %sB\\n",
178 "LINE1:txb#00FF00:eth1 transmit ",
179 "GPRINT:txb:MIN: % 3.2lf %sB",
180 "GPRINT:txb:MAX: % 3.2lf %sB",
181 "GPRINT:txb:AVERAGE: % 3.2lf %sB",
182 "GPRINT:txb:LAST: % 3.2lf %sB\\n",
187 const char *systemptext[] = {
188 "DEF:sda_c=" SYSTEMP_RRD_PATH ":sda:AVERAGE",
189 "DEF:SYS_c=" SYSTEMP_RRD_PATH ":SYS:AVERAGE",
190 "DEF:CPU_c=" SYSTEMP_RRD_PATH ":CPU:AVERAGE",
194 "MIN MAX AVG Last\\n",
196 "LINE1:sda_c#0000FF:SAMSUNG HD501LJ ",
197 "GPRINT:sda_c:MIN: %5.2lf °C",
198 "GPRINT:sda_c:MAX: %5.2lf °C",
199 "GPRINT:sda_c:AVERAGE: %5.2lf °C",
200 "GPRINT:sda_c:LAST: %5.2lf °C\\n",
202 "LINE1:SYS_c#00FF00:Sys Temp ",
203 "GPRINT:SYS_c:MIN: %5.2lf °C",
204 "GPRINT:SYS_c:MAX: %5.2lf °C",
205 "GPRINT:SYS_c:AVERAGE: %5.2lf °C",
206 "GPRINT:SYS_c:LAST: %5.2lf °C\\n",
208 "LINE1:CPU_c#FF0000:Intel Core2 Quad ",
209 "GPRINT:CPU_c:MIN: %5.2lf °C",
210 "GPRINT:CPU_c:MAX: %5.2lf °C",
211 "GPRINT:CPU_c:AVERAGE: %5.2lf °C",
212 "GPRINT:CPU_c:LAST: %5.2lf °C\\n",
217 const char *cpuoptions[] = {
218 "--alt-autoscale-max",
219 "--lower-limit", "0",
225 const char *memoptions[] = {
226 "--alt-autoscale-max",
227 "--lower-limit", "0",
230 "--units-exponent", "0",
235 const char *eth0options[] = {
236 "--alt-autoscale-max",
237 "--vertical-label", "Bytes",
238 "--lower-limit", "0",
242 const char *eth1options[] = {
243 "--alt-autoscale-max",
244 "--vertical-label", "Bytes",
245 "--lower-limit", "0",
249 const char *systempoptions[] = {
251 "--vertical-label", "Temp °C",
255 #define DEFINE_IMAGE(rrdname, _filename, _width, _height, time) \
256 static struct rrd_image rrdname ## daily = { \
257 .image_filename = _filename "_daily.png", \
260 .timestart = "end-" #time "d", \
262 .imageformat = "PNG", \
263 .options = (const char **)&rrdname ## options, \
264 .text = (const char **)&rrdname ## text, \
266 static struct rrd_image rrdname ## weekly = { \
267 .image_filename = _filename "_weekly.png", \
270 .timestart = "end-" #time "w", \
272 .imageformat = "PNG", \
273 .options = (const char **)&rrdname ## options, \
274 .text = (const char **)&rrdname ## text, \
276 static struct rrd_image rrdname ## monthly = { \
277 .image_filename = _filename "_monthly.png", \
280 .timestart = "end-" #time "m", \
282 .imageformat = "PNG", \
283 .options = (const char **)&rrdname ## options, \
284 .text = (const char **)&rrdname ## text, \
286 static struct rrd_image rrdname ## yearly = { \
287 .image_filename = _filename "_yearly.png", \
290 .timestart = "end-" #time "y", \
292 .imageformat = "PNG", \
293 .options = (const char **)&rrdname ## options, \
294 .text = (const char **)&rrdname ## text, \
297 DEFINE_IMAGE(cpu, SYSINFO_PATH "/images/cpu", 720, 480, 1);
298 DEFINE_IMAGE(mem, SYSINFO_PATH "/images/mem", 720, 480, 1);
299 DEFINE_IMAGE(systemp, SYSINFO_PATH "/images/systemp", 720,480,1);
300 DEFINE_IMAGE(eth0, SYSINFO_PATH "/images/eth0", 720, 200, 1);
301 DEFINE_IMAGE(eth1, SYSINFO_PATH "/images/eth1", 720, 200, 1);
303 static struct rrd_image *cpu_mem_images[] = {
315 static struct rrd_image *network_images[] = {
327 static struct rrd_image *systemp_images[] = {
335 #define SOURCE_ENTRY(_name, _type, _heartbeat, _min, _max) \
339 .heartbeat = _heartbeat, \
344 #define ARCHIVE_ENTRY(_type, _xff, _steps, _rows) \
352 struct rrd_data_source cpumem_sources[] = {
353 SOURCE_ENTRY("User", "COUNTER", 240, 0, 1200)
354 SOURCE_ENTRY("Nice", "COUNTER", 240, 0, 1200)
355 SOURCE_ENTRY("Sys", "COUNTER", 240, 0, 1200)
356 SOURCE_ENTRY("Idle", "COUNTER", 240, 0, 1200)
357 SOURCE_ENTRY("Wait", "COUNTER", 240, 0, 1200)
358 SOURCE_ENTRY("IRQ", "COUNTER", 240, 0, 1200)
359 SOURCE_ENTRY("SoftIRQ", "COUNTER", 240, 0, 1200)
360 SOURCE_ENTRY("Free", "GAUGE", 240, 0, 32768)
361 SOURCE_ENTRY("Buffers", "GAUGE", 240, 0, 32768)
362 SOURCE_ENTRY("Cached", "GAUGE", 240, 0, 32768)
363 SOURCE_ENTRY("Active", "GAUGE", 240, 0, 32768)
364 SOURCE_ENTRY("Inactive","GAUGE", 240, 0, 32768)
365 SOURCE_ENTRY("SwapFree","GAUGE", 240, 0, 32768)
366 SOURCE_ENTRY("Anon", "GAUGE", 240, 0, 32768)
367 SOURCE_ENTRY("Slab", "GAUGE", 240, 0, 32768)
368 SOURCE_ENTRY("Tables", "GAUGE", 240, 0, 32768)
369 SOURCE_ENTRY("Other", "GAUGE", 240, 0, 32768)
370 SOURCE_ENTRY("Swap", "GAUGE", 240, 0, 32768)
374 struct rrd_archive cpumem_archives[] = {
375 ARCHIVE_ENTRY("AVERAGE", 0.5, 1, 720)
376 ARCHIVE_ENTRY("AVERAGE", 0.5, 7, 720)
377 ARCHIVE_ENTRY("AVERAGE", 0.5, 31, 720)
378 ARCHIVE_ENTRY("AVERAGE", 0.5, 365, 720)
379 ARCHIVE_ENTRY("MIN", 0.5, 1, 720)
380 ARCHIVE_ENTRY("MIN", 0.5, 7, 720)
381 ARCHIVE_ENTRY("MIN", 0.5, 31, 720)
382 ARCHIVE_ENTRY("MIN", 0.5, 365, 720)
383 ARCHIVE_ENTRY("MAX", 0.5, 1, 720)
384 ARCHIVE_ENTRY("MAX", 0.5, 7, 720)
385 ARCHIVE_ENTRY("MAX", 0.5, 31, 720)
386 ARCHIVE_ENTRY("MAX", 0.5, 365, 720)
390 struct rrd_data_source network_sources[] = {
391 SOURCE_ENTRY("eth0rxb", "COUNTER", 240, 0, 120000000000)
392 SOURCE_ENTRY("eth0rxp", "COUNTER", 240, 0, 120000000000)
393 SOURCE_ENTRY("eth0txb", "COUNTER", 240, 0, 120000000000)
394 SOURCE_ENTRY("eth0txp", "COUNTER", 240, 0, 120000000000)
395 SOURCE_ENTRY("eth1rxb", "COUNTER", 240, 0, 120000000000)
396 SOURCE_ENTRY("eth1rxp", "COUNTER", 240, 0, 120000000000)
397 SOURCE_ENTRY("eth1txb", "COUNTER", 240, 0, 120000000000)
398 SOURCE_ENTRY("eth1txp", "COUNTER", 240, 0, 120000000000)
402 struct rrd_archive network_archives[] = {
403 ARCHIVE_ENTRY("AVERAGE", 0.5, 1, 720)
404 ARCHIVE_ENTRY("AVERAGE", 0.5, 7, 720)
405 ARCHIVE_ENTRY("AVERAGE", 0.5, 31, 720)
406 ARCHIVE_ENTRY("AVERAGE", 0.5, 365, 720)
407 ARCHIVE_ENTRY("MIN", 0.5, 1, 720)
408 ARCHIVE_ENTRY("MIN", 0.5, 7, 720)
409 ARCHIVE_ENTRY("MIN", 0.5, 31, 720)
410 ARCHIVE_ENTRY("MIN", 0.5, 365, 720)
411 ARCHIVE_ENTRY("MAX", 0.5, 1, 720)
412 ARCHIVE_ENTRY("MAX", 0.5, 7, 720)
413 ARCHIVE_ENTRY("MAX", 0.5, 31, 720)
414 ARCHIVE_ENTRY("MAX", 0.5, 365, 720)
418 static struct rrd_database cpumem_rrd = {
419 .filename = SYSINFO_RRD_PATH,
421 .parse = cpu_mem_parser,
422 .images = (struct rrd_image **)&cpu_mem_images,
423 .sources = cpumem_sources,
424 .archives = cpumem_archives,
428 static struct rrd_database systemp_rrd = {
432 .images = (struct rrd_image **)&systemp_images,
436 const char *network_interfaces[] = {
442 static struct rrd_database network_rrd = {
444 .filename = NETWORK_RRD_PATH,
446 .parse = netstats_parser,
447 .sources = network_sources,
448 .archives = network_archives,
449 .parser_data = network_interfaces,
450 .images = network_images,
453 static struct rrd_database *default_rrds[] = {