8 const char blank[] = "COMMENT: ";
9 #define numfmt " % 8.2lf "
11 #define SYSINFO_PATH "/home/kaapeli/rrdd/sysinfo/"
12 #define SYSINFO_RRD_PATH SYSINFO_PATH "sysinfo.rrd"
13 #define SYSINFO_IMAGES_PATH SYSINFO_PATH "images/"
15 #define SYSTEMP_RRD_PATH "/root/systemp/systemp.rrd"
17 #define NETWORK_RRD_PATH SYSINFO_PATH "network.rrd"
19 const char *cputext[] = {
20 "DEF:us=" SYSINFO_RRD_PATH ":User:AVERAGE",
21 "DEF:ni=" SYSINFO_RRD_PATH ":Nice:AVERAGE",
22 "DEF:sy=" SYSINFO_RRD_PATH ":Sys:AVERAGE",
23 "DEF:id=" SYSINFO_RRD_PATH ":Idle:AVERAGE",
24 "DEF:wa=" SYSINFO_RRD_PATH ":Wait:AVERAGE",
25 "DEF:in=" SYSINFO_RRD_PATH ":IRQ:AVERAGE",
26 "DEF:so=" SYSINFO_RRD_PATH ":SoftIRQ:AVERAGE",
30 "MIN MAX AVG Last\\n",
32 "AREA:sy#ff0000:System ",
33 "GPRINT:sy:MIN:" numfmt,
34 "GPRINT:sy:MAX:" numfmt,
35 "GPRINT:sy:AVERAGE:" numfmt,
36 "GPRINT:sy:LAST:" numfmt "\\n",
38 "STACK:us#0000ff:User ",
39 "GPRINT:us:MIN:" numfmt,
40 "GPRINT:us:MAX:" numfmt,
41 "GPRINT:us:AVERAGE:" numfmt,
42 "GPRINT:us:LAST:" numfmt "\\n",
44 "STACK:ni#00ff00:Nice ",
45 "GPRINT:ni:MIN:" numfmt,
46 "GPRINT:ni:MAX:" numfmt,
47 "GPRINT:ni:AVERAGE:" numfmt,
48 "GPRINT:ni:LAST:" numfmt "\\n",
50 "STACK:id#ffffff:Idle ",
51 "GPRINT:id:MIN:" numfmt,
52 "GPRINT:id:MAX:" numfmt,
53 "GPRINT:id:AVERAGE:" numfmt,
54 "GPRINT:id:LAST:" numfmt "\\n",
56 "STACK:wa#ff00ff:IO wait ",
57 "GPRINT:wa:MIN:" numfmt,
58 "GPRINT:wa:MAX:" numfmt,
59 "GPRINT:wa:AVERAGE:" numfmt,
60 "GPRINT:wa:LAST:" numfmt "\\n",
62 "STACK:in#ffff00:IRQ ",
63 "GPRINT:in:MIN:" numfmt,
64 "GPRINT:in:MAX:" numfmt,
65 "GPRINT:in:AVERAGE:" numfmt,
66 "GPRINT:in:LAST:" numfmt "\\n",
68 "STACK:so#00ffff:Soft IRQ ",
69 "GPRINT:so:MIN:" numfmt,
70 "GPRINT:so:MAX:" numfmt,
71 "GPRINT:so:AVERAGE:" numfmt,
72 "GPRINT:so:LAST:" numfmt "\\n",
77 const char *memtext[] = {
78 "DEF:fr=" SYSINFO_RRD_PATH ":Free:AVERAGE",
79 "DEF:bu=" SYSINFO_RRD_PATH ":Buffers:AVERAGE",
80 "DEF:ca=" SYSINFO_RRD_PATH ":Cached:AVERAGE",
81 "DEF:an=" SYSINFO_RRD_PATH ":Anon:AVERAGE",
82 "DEF:sl=" SYSINFO_RRD_PATH ":Slab:AVERAGE",
83 "DEF:ta=" SYSINFO_RRD_PATH ":Tables:AVERAGE",
84 "DEF:ot=" SYSINFO_RRD_PATH ":Other:AVERAGE",
85 "DEF:sw=" SYSINFO_RRD_PATH ":Swap:AVERAGE",
89 "MIN MAX AVG Last\\n",
91 "AREA:bu#ffff00:Buffers ",
92 "GPRINT:bu:MIN:" numfmt,
93 "GPRINT:bu:MAX:" numfmt,
94 "GPRINT:bu:AVERAGE:" numfmt,
95 "GPRINT:bu:LAST:" numfmt "\\n",
97 "STACK:an#000000:AnonPages ",
98 "GPRINT:an:MIN:" numfmt,
99 "GPRINT:an:MAX:" numfmt,
100 "GPRINT:an:AVERAGE:" numfmt,
101 "GPRINT:an:LAST:" numfmt "\\n",
103 "STACK:ca#00ff00:Cached ",
104 "GPRINT:ca:MIN:" numfmt,
105 "GPRINT:ca:MAX:" numfmt,
106 "GPRINT:ca:AVERAGE:" numfmt,
107 "GPRINT:ca:LAST:" numfmt "\\n",
109 "STACK:fr#ffffff:Free ",
110 "GPRINT:fr:MIN:" numfmt,
111 "GPRINT:fr:MAX:" numfmt,
112 "GPRINT:fr:AVERAGE:" numfmt,
113 "GPRINT:fr:LAST:" numfmt "\\n",
115 "STACK:sl#00ffff:Slab ",
116 "GPRINT:sl:MIN:" numfmt,
117 "GPRINT:sl:MAX:" numfmt,
118 "GPRINT:sl:AVERAGE:" numfmt,
119 "GPRINT:sl:LAST:" numfmt "\\n",
121 "STACK:ta#0000ff:PageTables ",
122 "GPRINT:ta:MIN:" numfmt,
123 "GPRINT:ta:MAX:" numfmt,
124 "GPRINT:ta:AVERAGE:" numfmt,
125 "GPRINT:ta:LAST:" numfmt "\\n",
127 "STACK:ot#a0a0a0:Other ",
128 "GPRINT:ot:MIN:" numfmt,
129 "GPRINT:ot:MAX:" numfmt,
130 "GPRINT:ot:AVERAGE:" numfmt,
131 "GPRINT:ot:LAST:" numfmt "\\n",
133 "STACK:sw#ff0000:Swap ",
134 "GPRINT:sw:MIN:" numfmt,
135 "GPRINT:sw:MAX:" numfmt,
136 "GPRINT:sw:AVERAGE:" numfmt,
137 "GPRINT:sw:LAST:" numfmt "\\n",
142 const char *eth0text[] = {
143 "DEF:rxb=" NETWORK_RRD_PATH ":eth0rxb:AVERAGE",
144 "DEF:txb=" NETWORK_RRD_PATH ":eth0txb:AVERAGE",
148 "MIN MAX AVG Last\\n",
150 "LINE1:rxb#0000FF:eth0 receive ",
151 "GPRINT:rxb:MIN: % 3.2lf %sB",
152 "GPRINT:rxb:MAX: % 3.2lf %sB",
153 "GPRINT:rxb:AVERAGE: % 3.2lf %sB",
154 "GPRINT:rxb:LAST: % 3.2lf %sB\\n",
156 "LINE1:txb#00FF00:eth0 transmit ",
157 "GPRINT:txb:MIN: % 3.2lf %sB",
158 "GPRINT:txb:MAX: % 3.2lf %sB",
159 "GPRINT:txb:AVERAGE: % 3.2lf %sB",
160 "GPRINT:txb:LAST: % 3.2lf %sB\\n",
165 const char *eth1text[] = {
166 "DEF:rxb=" NETWORK_RRD_PATH ":eth1rxb:AVERAGE",
167 "DEF:txb=" NETWORK_RRD_PATH ":eth1txb:AVERAGE",
171 "MIN MAX AVG Last\\n",
173 "LINE1:rxb#0000FF:eth1 receive ",
174 "GPRINT:rxb:MIN: % 3.2lf %sB",
175 "GPRINT:rxb:MAX: % 3.2lf %sB",
176 "GPRINT:rxb:AVERAGE: % 3.2lf %sB",
177 "GPRINT:rxb:LAST: % 3.2lf %sB\\n",
179 "LINE1:txb#00FF00:eth1 transmit ",
180 "GPRINT:txb:MIN: % 3.2lf %sB",
181 "GPRINT:txb:MAX: % 3.2lf %sB",
182 "GPRINT:txb:AVERAGE: % 3.2lf %sB",
183 "GPRINT:txb:LAST: % 3.2lf %sB\\n",
188 const char *systemptext[] = {
189 "DEF:sda_c=" SYSTEMP_RRD_PATH ":sda:AVERAGE",
190 "DEF:SYS_c=" SYSTEMP_RRD_PATH ":SYS:AVERAGE",
191 "DEF:CPU_c=" SYSTEMP_RRD_PATH ":CPU:AVERAGE",
195 "MIN MAX AVG Last\\n",
197 "LINE1:sda_c#0000FF:SAMSUNG HD501LJ ",
198 "GPRINT:sda_c:MIN: %5.2lf °C",
199 "GPRINT:sda_c:MAX: %5.2lf °C",
200 "GPRINT:sda_c:AVERAGE: %5.2lf °C",
201 "GPRINT:sda_c:LAST: %5.2lf °C\\n",
203 "LINE1:SYS_c#00FF00:Sys Temp ",
204 "GPRINT:SYS_c:MIN: %5.2lf °C",
205 "GPRINT:SYS_c:MAX: %5.2lf °C",
206 "GPRINT:SYS_c:AVERAGE: %5.2lf °C",
207 "GPRINT:SYS_c:LAST: %5.2lf °C\\n",
209 "LINE1:CPU_c#FF0000:Intel Core2 Quad ",
210 "GPRINT:CPU_c:MIN: %5.2lf °C",
211 "GPRINT:CPU_c:MAX: %5.2lf °C",
212 "GPRINT:CPU_c:AVERAGE: %5.2lf °C",
213 "GPRINT:CPU_c:LAST: %5.2lf °C\\n",
218 const char *cpuoptions[] = {
219 "--alt-autoscale-max",
220 "--lower-limit", "0",
226 const char *memoptions[] = {
227 "--alt-autoscale-max",
228 "--lower-limit", "0",
231 "--units-exponent", "0",
236 const char *eth0options[] = {
237 "--alt-autoscale-max",
238 "--vertical-label", "Bytes",
239 "--lower-limit", "0",
243 const char *eth1options[] = {
244 "--alt-autoscale-max",
245 "--vertical-label", "Bytes",
246 "--lower-limit", "0",
250 const char *systempoptions[] = {
252 "--vertical-label", "Temp °C",
256 #define xstr(s) str(s)
259 #define DEFINE_IMAGE(rrdname, _filename, _width, _height, time) \
260 static struct rrd_image rrdname ## daily = { \
261 .image_filename = _filename "_daily.png", \
264 .timestart = "end-" #time "d", \
266 .imageformat = "PNG", \
267 .options = (const char **)&rrdname ## options, \
268 .text = (const char **)&rrdname ## text, \
270 static struct rrd_image rrdname ## weekly = { \
271 .image_filename = _filename "_weekly.png", \
274 .timestart = "end-" #time "w", \
276 .imageformat = "PNG", \
277 .options = (const char **)&rrdname ## options, \
278 .text = (const char **)&rrdname ## text, \
280 static struct rrd_image rrdname ## monthly = { \
281 .image_filename = _filename "_monthly.png", \
284 .timestart = "end-" #time "m", \
286 .imageformat = "PNG", \
287 .options = (const char **)&rrdname ## options, \
288 .text = (const char **)&rrdname ## text, \
290 static struct rrd_image rrdname ## yearly = { \
291 .image_filename = _filename "_yearly.png", \
294 .timestart = "end-" #time "y", \
296 .imageformat = "PNG", \
297 .options = (const char **)&rrdname ## options, \
298 .text = (const char **)&rrdname ## text, \
301 DEFINE_IMAGE(cpu, SYSINFO_PATH "/images/cpu", 720, 480, 1);
302 DEFINE_IMAGE(mem, SYSINFO_PATH "/images/mem", 720, 480, 1);
303 DEFINE_IMAGE(systemp, SYSINFO_PATH "/images/systemp", 720,480,1);
304 DEFINE_IMAGE(eth0, SYSINFO_PATH "/images/eth0", 720, 200, 1);
305 DEFINE_IMAGE(eth1, SYSINFO_PATH "/images/eth1", 720, 200, 1);
307 static struct rrd_image *cpu_mem_images[] = {
319 static struct rrd_image *network_images[] = {
331 static struct rrd_image *systemp_images[] = {
339 #define SOURCE_ENTRY(_name, _type, _heartbeat, _min, _max) \
343 .heartbeat = _heartbeat, \
348 #define ARCHIVE_ENTRY(_type, _xff, _steps, _rows) \
356 struct rrd_data_source cpumem_sources[] = {
357 SOURCE_ENTRY("User", "COUNTER", 240, 0, 1200)
358 SOURCE_ENTRY("Nice", "COUNTER", 240, 0, 1200)
359 SOURCE_ENTRY("Sys", "COUNTER", 240, 0, 1200)
360 SOURCE_ENTRY("Idle", "COUNTER", 240, 0, 1200)
361 SOURCE_ENTRY("Wait", "COUNTER", 240, 0, 1200)
362 SOURCE_ENTRY("IRQ", "COUNTER", 240, 0, 1200)
363 SOURCE_ENTRY("SoftIRQ", "COUNTER", 240, 0, 1200)
364 SOURCE_ENTRY("Free", "GAUGE", 240, 0, 32768)
365 SOURCE_ENTRY("Buffers", "GAUGE", 240, 0, 32768)
366 SOURCE_ENTRY("Cached", "GAUGE", 240, 0, 32768)
367 SOURCE_ENTRY("Active", "GAUGE", 240, 0, 32768)
368 SOURCE_ENTRY("Inactive","GAUGE", 240, 0, 32768)
369 SOURCE_ENTRY("SwapFree","GAUGE", 240, 0, 32768)
370 SOURCE_ENTRY("Anon", "GAUGE", 240, 0, 32768)
371 SOURCE_ENTRY("Slab", "GAUGE", 240, 0, 32768)
372 SOURCE_ENTRY("Tables", "GAUGE", 240, 0, 32768)
373 SOURCE_ENTRY("Other", "GAUGE", 240, 0, 32768)
374 SOURCE_ENTRY("Swap", "GAUGE", 240, 0, 32768)
378 struct rrd_archive cpumem_archives[] = {
379 ARCHIVE_ENTRY("AVERAGE", 0.5, 1, 720)
380 ARCHIVE_ENTRY("AVERAGE", 0.5, 7, 720)
381 ARCHIVE_ENTRY("AVERAGE", 0.5, 31, 720)
382 ARCHIVE_ENTRY("AVERAGE", 0.5, 365, 720)
383 ARCHIVE_ENTRY("MIN", 0.5, 1, 720)
384 ARCHIVE_ENTRY("MIN", 0.5, 7, 720)
385 ARCHIVE_ENTRY("MIN", 0.5, 31, 720)
386 ARCHIVE_ENTRY("MIN", 0.5, 365, 720)
387 ARCHIVE_ENTRY("MAX", 0.5, 1, 720)
388 ARCHIVE_ENTRY("MAX", 0.5, 7, 720)
389 ARCHIVE_ENTRY("MAX", 0.5, 31, 720)
390 ARCHIVE_ENTRY("MAX", 0.5, 365, 720)
394 struct rrd_data_source network_sources[] = {
395 SOURCE_ENTRY("eth0rxb", "COUNTER", 240, 0, 120000000000)
396 SOURCE_ENTRY("eth0rxp", "COUNTER", 240, 0, 120000000000)
397 SOURCE_ENTRY("eth0txb", "COUNTER", 240, 0, 120000000000)
398 SOURCE_ENTRY("eth0txp", "COUNTER", 240, 0, 120000000000)
399 SOURCE_ENTRY("eth1rxb", "COUNTER", 240, 0, 120000000000)
400 SOURCE_ENTRY("eth1rxp", "COUNTER", 240, 0, 120000000000)
401 SOURCE_ENTRY("eth1txb", "COUNTER", 240, 0, 120000000000)
402 SOURCE_ENTRY("eth1txp", "COUNTER", 240, 0, 120000000000)
406 struct rrd_archive network_archives[] = {
407 ARCHIVE_ENTRY("AVERAGE", 0.5, 1, 720)
408 ARCHIVE_ENTRY("AVERAGE", 0.5, 7, 720)
409 ARCHIVE_ENTRY("AVERAGE", 0.5, 31, 720)
410 ARCHIVE_ENTRY("AVERAGE", 0.5, 365, 720)
411 ARCHIVE_ENTRY("MIN", 0.5, 1, 720)
412 ARCHIVE_ENTRY("MIN", 0.5, 7, 720)
413 ARCHIVE_ENTRY("MIN", 0.5, 31, 720)
414 ARCHIVE_ENTRY("MIN", 0.5, 365, 720)
415 ARCHIVE_ENTRY("MAX", 0.5, 1, 720)
416 ARCHIVE_ENTRY("MAX", 0.5, 7, 720)
417 ARCHIVE_ENTRY("MAX", 0.5, 31, 720)
418 ARCHIVE_ENTRY("MAX", 0.5, 365, 720)
422 static struct rrd_database cpumem_rrd = {
423 .filename = SYSINFO_RRD_PATH,
425 .parse = cpu_mem_parser,
426 .images = (struct rrd_image **)&cpu_mem_images,
427 .sources = cpumem_sources,
428 .archives = cpumem_archives,
432 static struct rrd_database systemp_rrd = {
436 .images = (struct rrd_image **)&systemp_images,
440 const char *network_interfaces[] = {
446 static struct rrd_database network_rrd = {
448 .filename = NETWORK_RRD_PATH,
450 .parse = netstats_parser,
451 .sources = network_sources,
452 .archives = network_archives,
453 .parser_data = network_interfaces,
454 .images = network_images,
457 #include "power_database.h"
459 static struct rrd_database *default_rrds[] = {