add a LICENSE and a README to things are all nice at GitHub :)
[php-utility-classes.git] / examples / rrd / rrd-config / hostname.inc.php
CommitLineData
7b9ebce7
RK
1<?php
2// RRD info for CPU info
3$rrd_info = array();
4$rrd_info['*']['graph']['path'] = 'graphs';
5// $rrd_info['*']['page']['graph_url'] = 'http://127.0.0.1/testbed/rrd/';
6$rrd_info['*']['graph']['units_length'] = 6;
7// $rrd_info['*']['graph']['force_recreate'] = true;
8
9$rrd_info['index']['page']['type'] = 'index';
10// $rrd_info['index']['page']['index_ids'] = 'hd,-hd.root';
11// $rrd_info['index']['page']['scan_config'] = false;
12$rrd_info['index']['page']['scan_files'] = true;
13$rrd_info['index']['hidden'] = true;
14
15$rrd_info['overview']['page']['type'] = 'overview';
16$rrd_info['overview']['page']['index_ids'] = 'cpu,cpu.frequency,load,temp,hd,mem|pct,eth0,connect,loopback,sensors.power|relpct,ping.gateway,rrdup';
17$rrd_info['overview']['page']['scan_config'] = false;
18$rrd_info['overview']['page']['text_intro'] = 'Go to the <a href="?stat=index">index page</a> for a full list of all available statistics. Also see <a href="?stat=cpu-overview">CPU</a> overview.';
19// $rrd_info['overview']['hidden'] = true;
20
21$rrd_info['cpu-overview']['page']['type'] = 'overview';
22$rrd_info['cpu-overview']['page']['title_page'] = 'CPU statistics - total + per cpu core';
23$rrd_info['cpu-overview']['page']['index_ids'] = 'cpu,cpu.frequency,cpu0,cpu1,cpu2,cpu3,cpu4,cpu5,cpu6,cpu7';
24$rrd_info['cpu-overview']['page']['scan_config'] = false;
25// $rrd_info['cpu-overview']['hidden'] = true;
26
27$rrd_info['cpu']['file'] = 'system.cpu.rrd';
28$rrd_info['cpu']['auto-update'] = true;
29$rrd_info['cpu']['fields'][] = array('name' => 'user', 'type' => 'DERIVE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U');
30$rrd_info['cpu']['fields'][] = array('name' => 'nice', 'type' => 'DERIVE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U');
31$rrd_info['cpu']['fields'][] = array('name' => 'system', 'type' => 'DERIVE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U');
32$rrd_info['cpu']['fields'][] = array('name' => 'idle', 'type' => 'DERIVE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U');
33$rrd_info['cpu']['fields'][] = array('name' => 'iowait', 'type' => 'DERIVE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U');
34$rrd_info['cpu']['fields'][] = array('name' => 'irq', 'type' => 'DERIVE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U');
35$rrd_info['cpu']['fields'][] = array('name' => 'softirq', 'type' => 'DERIVE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U');
36$rrd_info['cpu']['fields'][] = array('name' => 'total', 'type' => 'DERIVE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U');
37$rrd_info['cpu']['update'] =
38 'function {
39 $udata = array("user"=>null,"nice"=>null,"system"=>null,"idle"=>null,
40 "iowait"=>null,"irq"=>null,"softirq"=>null, "total"=>null);
41 $sdata = file("/proc/stat");
42 foreach ($sdata as $sline) {
43 if (preg_match("/^\s*cpu\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/", $sline, $regs)) {
44 $udata = array("user"=>$regs[1],"nice"=>$regs[2],"system"=>$regs[3],"idle"=>$regs[4],
45 "iowait"=>$regs[5],"irq"=>$regs[6],"softirq"=>$regs[7],
46 "total"=>$regs[1]+$regs[2]+$regs[3]+$regs[4]+$regs[5]+$regs[6]+$regs[7]);
47 }
48 }
49 return $udata;
50 }';
51$rrd_info['cpu']['graph']['rows'][] = array('name'=>'total', 'gType'=>'');
52$rrd_info['cpu']['graph']['rows'][] = array('name'=>'softirq_tmp', 'dsname'=>'softirq', 'gType'=>'');
53$rrd_info['cpu']['graph']['rows'][] = array('name'=>'irq_tmp', 'dsname'=>'irq', 'gType'=>'');
54$rrd_info['cpu']['graph']['rows'][] = array('name'=>'iowait_tmp', 'dsname'=>'iowait', 'gType'=>'');
55$rrd_info['cpu']['graph']['rows'][] = array('name'=>'system_tmp', 'dsname'=>'system', 'gType'=>'');
56$rrd_info['cpu']['graph']['rows'][] = array('name'=>'nice_tmp', 'dsname'=>'nice', 'gType'=>'');
57$rrd_info['cpu']['graph']['rows'][] = array('name'=>'user_tmp', 'dsname'=>'user', 'gType'=>'');
58$rrd_info['cpu']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'softirq', 'rpn_expr'=>'softirq_tmp,total,/,100,*', 'gType'=>'AREA', 'color'=>'#CCCCCC', 'color_bg'=>'#606060', 'legend'=>'softIRQ');
59$rrd_info['cpu']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'irq', 'rpn_expr'=>'irq_tmp,total,/,100,*', 'gType'=>'AREA', 'color'=>'#808080', 'legend'=>'IRQ', 'stack'=>true);
60$rrd_info['cpu']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'iowait', 'rpn_expr'=>'iowait_tmp,total,/,100,*', 'gType'=>'AREA', 'color'=>'#FF00FF', 'legend'=>'I/O wait', 'stack'=>true);
61$rrd_info['cpu']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'system', 'rpn_expr'=>'system_tmp,total,/,100,*', 'gType'=>'AREA', 'color'=>'#FF0000', 'legend'=>'System', 'stack'=>true);
62$rrd_info['cpu']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'nice', 'rpn_expr'=>'nice_tmp,total,/,100,*', 'gType'=>'AREA', 'color'=>'#FFFF00', 'color_bg'=>'#606060', 'legend'=>'Nice', 'stack'=>true);
63$rrd_info['cpu']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'user', 'rpn_expr'=>'user_tmp,total,/,100,*', 'gType'=>'AREA', 'color'=>'#0000FF', 'legend'=>'User', 'stack'=>true);
64$rrd_info['cpu']['graph']['units_length'] = 4;
65$rrd_info['cpu']['graph']['label_y'] = '% CPU Usage';
66$rrd_info['cpu']['graph']['min_y'] = 0;
67$rrd_info['cpu']['graph']['max_y'] = 100;
68$rrd_info['cpu']['graph']['fix_scale_y'] = true;
69// $rrd_info['cpu']['graph']['force_recreate'] = true;
70
71$rrd_info['cpu.frequency.proto']['hidden'] = true;
72$rrd_info['cpu.frequency.proto']['auto-update'] = false;
73$rrd_info['cpu.frequency.proto']['fields'][] = array('name' => 'cur_frequency', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
74$rrd_info['cpu.frequency.proto']['fields'][] = array('name' => 'min_frequency', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
75$rrd_info['cpu.frequency.proto']['fields'][] = array('name' => 'max_frequency', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
76$rrd_info['cpu.frequency.proto']['graph']['rows'][] = array('name'=>'cur_frequency', 'gType'=>'LINE1', 'color'=>'#00CC00', 'legend'=>'Current');
77$rrd_info['cpu.frequency.proto']['graph']['rows'][] = array('name'=>'min_frequency', 'gType'=>'LINE1', 'color'=>'#CCCCCC', 'legend'=>'Min');
78$rrd_info['cpu.frequency.proto']['graph']['rows'][] = array('name'=>'max_frequency', 'gType'=>'LINE1', 'color'=>'#808080', 'legend'=>'Max');
79$rrd_info['cpu.frequency.proto']['graph']['units_length'] = 5;
80//$rrd_info['cpu.frequency.proto']['graph']['units_exponent'] = 0;
81$rrd_info['cpu.frequency.proto']['graph']['scale'] = 1000;
82$rrd_info['cpu.frequency.proto']['graph']['label_y'] = 'Hz';
83$rrd_info['cpu.frequency.proto']['graph']['min_y'] = 0;
84// $rrd_info['cpu.frequency.proto']['graph']['force_recreate'] = true;
85
86for ($i = 0; $i < 8; $i++) {
87 $rrd_info['cpu'.$i] = $rrd_info['cpu'];
88 $rrd_info['cpu'.$i]['file'] = 'system.cpu'.$i.'.rrd';
89 $rrd_info['cpu'.$i]['update'] =
90 'function {
91 $udata = array("user"=>null,"nice"=>null,"system"=>null,"idle"=>null,
92 "iowait"=>null,"irq"=>null,"softirq"=>null, "total"=>null);
93 $sdata = file("/proc/stat");
94 foreach ($sdata as $sline) {
95 if (preg_match("/^\s*cpu'.$i.'\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/", $sline, $regs)) {
96 $udata = array("user"=>$regs[1],"nice"=>$regs[2],"system"=>$regs[3],"idle"=>$regs[4],
97 "iowait"=>$regs[5],"irq"=>$regs[6],"softirq"=>$regs[7],
98 "total"=>$regs[1]+$regs[2]+$regs[3]+$regs[4]+$regs[5]+$regs[6]+$regs[7]);
99 }
100 }
101 return $udata;
102 }';
103
104 $rrd_info['cpu'.$i.'.frequency'] = $rrd_info['cpu.frequency.proto'];
105 $rrd_info['cpu'.$i.'.frequency']['hidden'] = false;
106 $rrd_info['cpu'.$i.'.frequency']['file'] = 'system.cpu'.$i.'.freq.rrd';
107 $rrd_info['cpu'.$i.'.frequency']['auto-update'] = true;
108 $rrd_info['cpu'.$i.'.frequency']['update'] =
109 'function {
110 $udata = array("cur_frequency"=>null,"min_frequency"=>null,"max_frequency"=>null);
111 sleep(1);
112 $sdata = trim(file_get_contents("/sys/devices/system/cpu/cpu'.$i.'/cpufreq/cpuinfo_cur_freq"));
113 if (is_numeric($sdata)) { $udata["cur_frequency"] = intval($sdata); }
114 $sdata = trim(file_get_contents("/sys/devices/system/cpu/cpu'.$i.'/cpufreq/cpuinfo_min_freq"));
115 if (is_numeric($sdata)) { $udata["min_frequency"] = intval($sdata); }
116 $sdata = trim(file_get_contents("/sys/devices/system/cpu/cpu'.$i.'/cpufreq/cpuinfo_max_freq"));
117 if (is_numeric($sdata)) { $udata["max_frequency"] = intval($sdata); }
118 return $udata;
119 }';
120}
121
122$rrd_info['cpu.frequency']['graph-only'] = true;
123$rrd_info['cpu.frequency']['graph']['rows'][] = array('name'=>'freq_cpu0', 'dsname'=>'cur_frequency', 'dsfile'=>'system.cpu0.freq.rrd',
124 'gType'=>'LINE1', 'color'=>'#00CC00', 'legend'=>'CPU0');
125$rrd_info['cpu.frequency']['graph']['rows'][] = array('name'=>'freq_cpu1', 'dsname'=>'cur_frequency', 'dsfile'=>'system.cpu1.freq.rrd',
126 'gType'=>'LINE1', 'color'=>'#008000', 'legend'=>'CPU1');
127$rrd_info['cpu.frequency']['graph']['rows'][] = array('name'=>'freq_cpu2', 'dsname'=>'cur_frequency', 'dsfile'=>'system.cpu2.freq.rrd',
128 'gType'=>'LINE1', 'color'=>'#8080FF', 'legend'=>'CPU2');
129$rrd_info['cpu.frequency']['graph']['rows'][] = array('name'=>'freq_cpu3', 'dsname'=>'cur_frequency', 'dsfile'=>'system.cpu3.freq.rrd',
130 'gType'=>'LINE1', 'color'=>'#0000FF', 'legend'=>'CPU3');
131$rrd_info['cpu.frequency']['graph']['rows'][] = array('name'=>'freq_cpu4', 'dsname'=>'cur_frequency', 'dsfile'=>'system.cpu4.freq.rrd',
132 'gType'=>'LINE1', 'color'=>'#FF8080', 'legend'=>'CPU4');
133$rrd_info['cpu.frequency']['graph']['rows'][] = array('name'=>'freq_cpu5', 'dsname'=>'cur_frequency', 'dsfile'=>'system.cpu5.freq.rrd',
134 'gType'=>'LINE1', 'color'=>'#FFCCCC', 'legend'=>'CPU5');
135$rrd_info['cpu.frequency']['graph']['rows'][] = array('name'=>'freq_cpu6', 'dsname'=>'cur_frequency', 'dsfile'=>'system.cpu6.freq.rrd',
136 'gType'=>'LINE1', 'color'=>'#CCCCCC', 'legend'=>'CPU6');
137$rrd_info['cpu.frequency']['graph']['rows'][] = array('name'=>'freq_cpu7', 'dsname'=>'cur_frequency', 'dsfile'=>'system.cpu7.freq.rrd',
138 'gType'=>'LINE1', 'color'=>'#808080', 'legend'=>'CPU7');
139$rrd_info['cpu.frequency']['graph']['units_length'] = 5;
140//$rrd_info['cpu.frequency']['graph']['units_exponent'] = 0;
141$rrd_info['cpu.frequency']['graph']['scale'] = 1000;
142$rrd_info['cpu.frequency']['graph']['label_y'] = 'Hz';
143$rrd_info['cpu.frequency']['graph']['min_y'] = 0;
144// $rrd_info['cpu.frequency']['graph']['force_recreate'] = true;
145
146$rrd_info['cpu.coretemp']['file'] = 'cpu.coretemp.rrd';
147$rrd_info['cpu.coretemp']['auto-update'] = true;
148$rrd_info['cpu.coretemp']['fields'][] = array('name' => 'core0_temp', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
149$rrd_info['cpu.coretemp']['fields'][] = array('name' => 'core1_temp', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
150$rrd_info['cpu.coretemp']['fields'][] = array('name' => 'core2_temp', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
151$rrd_info['cpu.coretemp']['fields'][] = array('name' => 'core3_temp', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
152$rrd_info['cpu.coretemp']['update'] =
153 'function {
154 $udata = array("core0_temp"=>null,"core1_temp"=>null);
155 $sdata = explode("\n", `/usr/bin/sensors -A coretemp-isa-*`);
156 foreach ($sdata as $sline) {
157 if (preg_match("/Core 0:\s+([+-]?[\d\.]+).+?C/i", $sline, $regs)) {
158 $udata["core0_temp"] = $regs[1];
159 }
160 elseif (preg_match("/Core 1:\s+([+-]?[\d\.]+).+?C/i", $sline, $regs)) {
161 $udata["core1_temp"] = $regs[1];
162 }
163 elseif (preg_match("/Core 2:\s+([+-]?[\d\.]+).+?C/i", $sline, $regs)) {
164 $udata["core2_temp"] = $regs[1];
165 }
166 elseif (preg_match("/Core 3:\s+([+-]?[\d\.]+).+?C/i", $sline, $regs)) {
167 $udata["core3_temp"] = $regs[1];
168 }
169 }
170 return $udata;
171 }';
172$rrd_info['cpu.coretemp']['graph']['rows'][] = array('name'=>'core0_temp', 'gType'=>'LINE1', 'color'=>'#80CC80', 'legend'=>'Core 0 Temp');
173$rrd_info['cpu.coretemp']['graph']['rows'][] = array('name'=>'core1_temp', 'gType'=>'LINE1', 'color'=>'#8080CC', 'legend'=>'Core 1 Temp');
174$rrd_info['cpu.coretemp']['graph']['rows'][] = array('name'=>'core2_temp', 'gType'=>'LINE1', 'color'=>'#CC8080', 'legend'=>'Core 2 Temp');
175$rrd_info['cpu.coretemp']['graph']['rows'][] = array('name'=>'core3_temp', 'gType'=>'LINE1', 'color'=>'#808080', 'legend'=>'Core 3 Temp');
176$rrd_info['cpu.coretemp']['graph']['units_length'] = 4;
177$rrd_info['cpu.coretemp']['graph']['label_y'] = '°C';
178// $rrd_info['cpu.coretemp']['graph']['max_y'] = 13;
179// $rrd_info['cpu.coretemp']['graph']['min_y'] = -13;
180
181$rrd_info['mem']['file'] = 'system.mem.rrd';
182$rrd_info['mem']['auto-update'] = true;
183$rrd_info['mem']['fields'][] = array('name' => 'total', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
184$rrd_info['mem']['fields'][] = array('name' => 'used', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
185$rrd_info['mem']['fields'][] = array('name' => 'buffers', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
186$rrd_info['mem']['fields'][] = array('name' => 'cached', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
187$rrd_info['mem']['fields'][] = array('name' => 'swap_total', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
188$rrd_info['mem']['fields'][] = array('name' => 'swap_used', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
189$rrd_info['mem']['update'] =
190 'function {
191 $sdata = explode("\n", `/usr/bin/free -wb`);
192 $udata = array("total"=>null,"used"=>null,"buffers"=>null,"cached"=>null,
193 "swap_total"=>null,"swap_used"=>null);
194 foreach ($sdata as $sline) {
195 if (preg_match("/Mem:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/", $sline, $regs)) {
196 $udata["total"] = $regs[1];
197 $udata["used"] = $regs[2];
198 $udata["buffers"] = $regs[5];
199 $udata["cached"] = $regs[6];
200 }
201 elseif (preg_match("/Swap:\s+(\d+)\s+(\d+)\s+(\d+)/", $sline, $regs)) {
202 $udata["swap_total"] = $regs[1];
203 $udata["swap_used"] = $regs[2];
204 }
205 }
206 return $udata;
207 }';
208$rrd_info['mem']['graph']['rows'][] = array('name'=>'total', 'gType'=>'LINE1', 'color'=>'#000000', 'legend'=>'Available');
209$rrd_info['mem']['graph']['rows'][] = array('name'=>'used', 'gType'=>'AREA', 'color'=>'#0000FF', 'legend'=>'Used');
210$rrd_info['mem']['graph']['rows'][] = array('name'=>'buffers', 'gType'=>'AREA', 'color'=>'#FFFF00', 'legend'=>'Buffers', 'stack'=>true);
211$rrd_info['mem']['graph']['rows'][] = array('name'=>'cached', 'gType'=>'AREA', 'color'=>'#008000', 'legend'=>'Cache', 'stack'=>true);
212$rrd_info['mem']['graph']['rows'][] = array('name'=>'swap_total', 'gType'=>'LINE1', 'color'=>'#CCCCCC', 'legend'=>'Swap avail.');
213$rrd_info['mem']['graph']['rows'][] = array('name'=>'swap_used', 'gType'=>'LINE2', 'color'=>'#00FFFF', 'legend'=>'Swap used');
214$rrd_info['mem']['graph']['units_binary'] = true;
215$rrd_info['mem']['graph']['units_exponent'] = 6;
216$rrd_info['mem']['graph']['units_length'] = 6;
217$rrd_info['mem']['graph']['label_y'] = 'Memory';
218$rrd_info['mem']['graph']['min_y'] = 0;
219// $rrd_info['mem']['graph']['max_y'] = 100;
220// $rrd_info['mem']['graph']['fix_scale_y'] = true;
221// $rrd_info['mem']['graph']['force_recreate'] = true;
222$rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'total', 'gType'=>'');
223$rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'swap_total', 'gType'=>'');
224$rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'used_tmp', 'dsname'=>'used', 'gType'=>'');
225$rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'buffers_tmp', 'dsname'=>'buffers', 'gType'=>'');
226$rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'cached_tmp', 'dsname'=>'cached', 'gType'=>'');
227$rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'swap_tmp', 'dsname'=>'swap_used', 'gType'=>'');
228$rrd_info['mem']['graph.pct']['rows'][] = array('dType'=>'CDEF', 'name'=>'used', 'rpn_expr'=>'used_tmp,total,/,100,*', 'gType'=>'AREA', 'color'=>'#0000FF', 'legend'=>'Used');
229$rrd_info['mem']['graph.pct']['rows'][] = array('dType'=>'CDEF', 'name'=>'buffers', 'rpn_expr'=>'buffers_tmp,total,/,100,*', 'gType'=>'AREA', 'color'=>'#FFFF00', 'legend'=>'Buffers', 'stack'=>true);
230$rrd_info['mem']['graph.pct']['rows'][] = array('dType'=>'CDEF', 'name'=>'cached', 'rpn_expr'=>'cached_tmp,total,/,100,*', 'gType'=>'AREA', 'color'=>'#008000', 'legend'=>'Cache', 'stack'=>true);
231$rrd_info['mem']['graph.pct']['rows'][] = array('dType'=>'CDEF', 'name'=>'swap_used', 'rpn_expr'=>'swap_tmp,swap_total,/,100,*', 'gType'=>'LINE2', 'color'=>'#00FFFF', 'legend'=>'Swap');
232$rrd_info['mem']['graph.pct']['units_exponent'] = 0;
233$rrd_info['mem']['graph.pct']['units_length'] = 4;
234$rrd_info['mem']['graph.pct']['label_y'] = '% Memory';
235$rrd_info['mem']['graph.pct']['min_y'] = 0;
236$rrd_info['mem']['graph.pct']['max_y'] = 100;
237$rrd_info['mem']['graph.pct']['fix_scale_y'] = true;
238// $rrd_info['mem']['graph.pct']['force_recreate'] = true;
239$rrd_info['mem']['page.pct']['graph_sub'] = 'pct';
240
241$rrd_info['load']['file'] = 'system.load.rrd';
242$rrd_info['load']['auto-update'] = true;
243$rrd_info['load']['fields'][] = array('name' => 'load1', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
244$rrd_info['load']['fields'][] = array('name' => 'load5', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
245$rrd_info['load']['fields'][] = array('name' => 'load15', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
246$rrd_info['load']['update'] = 'function { $sdata = explode(" ",file_get_contents("/proc/loadavg")); return array("load1"=>$sdata[0],"load5"=>$sdata[1],"load15"=>$sdata[2]); }';
247$rrd_info['load']['graph']['rows'][] = array('name'=>'load1', 'gType'=>'AREA', 'color'=>'#00CC00', 'legend'=>'1 Min.');
248$rrd_info['load']['graph']['rows'][] = array('name'=>'load5', 'gType'=>'LINE1', 'color'=>'#FF4000', 'legend'=>'5 Min.');
249$rrd_info['load']['graph']['rows'][] = array('name'=>'load15', 'gType'=>'LINE1', 'color'=>'#0000FF', 'legend'=>'15 Min.');
250$rrd_info['load']['graph']['units_length'] = 4;
251$rrd_info['load']['graph']['units_exponent'] = 0;
252$rrd_info['load']['graph']['label_y'] = 'Load average';
253$rrd_info['load']['graph']['min_y'] = 0;
254// $rrd_info['load']['graph']['force_recreate'] = true;
255$rrd_info['load']['page']['data_colorize'] = true;
256
257$rrd_info['hd']['graph-only'] = true;
258$rrd_info['hd']['graph']['rows'][] = array('name'=>'boot_used', 'dsname'=>'used', 'dsfile'=>'hd.boot.rrd', 'gType'=>'',);
259$rrd_info['hd']['graph']['rows'][] = array('name'=>'boot_total', 'dsname'=>'total', 'dsfile'=>'hd.boot.rrd', 'gType'=>'');
260$rrd_info['hd']['graph']['rows'][] = array('name'=>'root_used', 'dsname'=>'used', 'dsfile'=>'hd.root.rrd', 'gType'=>'',);
261$rrd_info['hd']['graph']['rows'][] = array('name'=>'root_total', 'dsname'=>'total', 'dsfile'=>'hd.root.rrd', 'gType'=>'');
262$rrd_info['hd']['graph']['rows'][] = array('name'=>'home_used', 'dsname'=>'used', 'dsfile'=>'hd.home.rrd', 'gType'=>'',);
263$rrd_info['hd']['graph']['rows'][] = array('name'=>'home_total', 'dsname'=>'total', 'dsfile'=>'hd.home.rrd', 'gType'=>'');
264$rrd_info['hd']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'boot', 'rpn_expr'=>'boot_used,boot_total,/,100,*',
265 'gType'=>'LINE1', 'color'=>'#808080', 'legend'=>'Boot');
266$rrd_info['hd']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'root', 'rpn_expr'=>'root_used,root_total,/,100,*',
267 'gType'=>'LINE1', 'color'=>'#0000FF', 'legend'=>'Root');
268$rrd_info['hd']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'home', 'rpn_expr'=>'home_used,home_total,/,100,*',
269 'gType'=>'LINE1', 'color'=>'#00E000', 'legend'=>'Home');
270// $rrd_info['hd.root']['graph']['units_length'] = 4;
271$rrd_info['hd']['graph']['label_y'] = '% Used';
272$rrd_info['hd']['graph']['units_exponent'] = 0;
273$rrd_info['hd']['graph']['units_length'] = 4;
274$rrd_info['hd']['graph']['min_y'] = 0;
275$rrd_info['hd']['graph']['max_y'] = 100;
276$rrd_info['hd']['graph']['fix_scale_y'] = true;
277// $rrd_info['hd']['graph']['force_recreate'] = true;
278$rrd_info['hd']['page']['show_update'] = false;
279
280// Every other HD config section copies from this definition
281$rrd_info['hd.root']['file'] = 'hd.root.rrd';
282$rrd_info['hd.root']['auto-update'] = true;
283$rrd_info['hd.root']['fields'][] = array('name' => 'used', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
284$rrd_info['hd.root']['fields'][] = array('name' => 'total', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
285$rrd_info['hd.new.root']['update'] =
286 'function {
287 $sdata = explode("\n", `/bin/df -k -l`); $udata = array();
288 foreach ($sdata as $sline) {
289 if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/$/", $sline, $regs)) {
290 $udata = array("total"=>$regs[1], "used"=>$regs[2]);
291 }
292 }
293 return $udata;
294 }';
295$rrd_info['hd.root']['graph']['rows'][] = array('name'=>'used', 'gType'=>'AREA', 'color'=>'#00CC00', 'legend'=>'Used');
296$rrd_info['hd.root']['graph']['rows'][] = array('name'=>'total', 'gType'=>'LINE1', 'color'=>'#808080', 'legend'=>'Available');
297// $rrd_info['hd.root']['graph']['units_length'] = 4;
298$rrd_info['hd.root']['graph']['label_y'] = 'Bytes';
299$rrd_info['hd.root']['graph']['units_binary'] = true;
300$rrd_info['hd.root']['graph']['scale'] = 1024;
301$rrd_info['hd.root']['graph']['min_y'] = 0;
302// $rrd_info['hd.root']['graph']['force_recreate'] = true;
303
304$rrd_info['hd.boot'] = $rrd_info['hd.root'];
305$rrd_info['hd.boot']['file'] = 'hd.boot.rrd';
306$rrd_info['hd.boot']['update'] =
307 'function {
308 $sdata = explode("\n", `/bin/df -k -l`); $udata = array();
309 foreach ($sdata as $sline) {
310 if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/boot$/", $sline, $regs)) {
311 $udata = array("total"=>$regs[1], "used"=>$regs[2]);
312 }
313 }
314 return $udata;
315 }';
316// $rrd_info['hd.boot']['graph']['force_recreate'] = true;
317
318$rrd_info['hd.home'] = $rrd_info['hd.root'];
319$rrd_info['hd.home']['file'] = 'hd.home.rrd';
320$rrd_info['hd.home']['update'] =
321 'function {
322 $sdata = explode("\n", `/bin/df -k -l`); $udata = array();
323 foreach ($sdata as $sline) {
324 if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/home$/", $sline, $regs)) {
325 $udata = array("total"=>$regs[1], "used"=>$regs[2]);
326 }
327 }
328 return $udata;
329 }';
330// $rrd_info['hd.home']['graph']['force_recreate'] = true;
331
332// BTRFS stats
333$rrd_info['hd.btrfs.root']['file'] = 'hd.btrfs.root.rrd';
334$rrd_info['hd.btrfs.root']['auto-update'] = true;
335$rrd_info['hd.btrfs.root']['fields'][] = array('name' => 'total', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
336$rrd_info['hd.btrfs.root']['fields'][] = array('name' => 'used_bytes', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
337$rrd_info['hd.btrfs.root']['fields'][] = array('name' => 'used_fs', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
338$rrd_info['hd.btrfs.root']['update'] =
339 'function {
340 $sdata = explode("\n", `btrfs fi show f00dbeef-f51d-b33f-f00d-beeff00df51d`);
341 $udata = array("total"=>null,"used_bytes"=>null,"used_fs"=>null);
342 $hdata = array("total"=>null,"used_bytes"=>null,"used_fs"=>null);
343 foreach ($sdata as $sline) {
344 if (preg_match("/\s+devid\s+1\ssize\s([\d\.]+(?:GiB|MiB|KiB|B))\sused\s([\d\.]+(?:GiB|MiB|KiB|B))\spath\s\//", $sline, $regs)) {
345 $hdata["total"] = $regs[1]; $hdata["used_fs"] = $regs[2]; }
346 if (preg_match("/\s+Total\sdevices\s1\sFS\sbytes\sused\s([\d\.]+(?:GiB|MiB|KiB|B))/", $sline, $regs)) { $hdata["used_bytes"] = $regs[1]; }
347 }
348 foreach ($hdata as $key=>$sizestring) {
349 if (preg_match("/^([\d\.]+)(GiB|MiB|KiB|B)$/", $sizestring, $regs)) {
350 if ($regs[2] == "GiB") { $udata[$key] = $regs[1] * 1024 * 1024 * 1024; }
351 elseif ($regs[2] == "MiB") { $udata[$key] = $regs[1] * 1024 * 1024; }
352 elseif ($regs[2] == "KiB") { $udata[$key] = $regs[1] * 1024; }
353 elseif ($regs[2] == "B") { $udata[$key] = $regs[1]; }
354 }
355 }
356 return $udata;
357 }';
358$rrd_info['hd.btrfs.root']['graph']['rows'][] = array('name'=>'used_fs', 'gType'=>'AREA', 'color'=>'#FF8080', 'legend'=>'Used/FS');
359$rrd_info['hd.btrfs.root']['graph']['rows'][] = array('name'=>'used_bytes', 'gType'=>'AREA', 'color'=>'#00CC00', 'legend'=>'Used/Bytes');
360$rrd_info['hd.btrfs.root']['graph']['rows'][] = array('name'=>'total', 'gType'=>'LINE1', 'color'=>'#808080', 'legend'=>'Total');
361// $rrd_info['hd.btrfs.root']['graph']['units_length'] = 4;
362$rrd_info['hd.btrfs.root']['graph']['label_y'] = 'Bytes';
363$rrd_info['hd.btrfs.root']['graph']['units_binary'] = true;
364$rrd_info['hd.btrfs.root']['graph']['min_y'] = 0;
365// $rrd_info['hd.btrfs.root']['graph']['force_recreate'] = true;
366
367$rrd_info['hdd.smart.rotdisk']['file'] = 'hdd.smart.rotdisk.rrd';
368$rrd_info['hdd.smart.rotdisk']['auto-update'] = true;
369$rrd_info['hdd.smart.rotdisk']['fields'][] = array('name' => 'load_cycle', 'type' => 'COUNTER', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
370$rrd_info['hdd.smart.rotdisk']['fields'][] = array('name' => 'start_stop', 'type' => 'COUNTER', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
371$rrd_info['hdd.smart.rotdisk']['fields'][] = array('name' => 'power_cycle', 'type' => 'COUNTER', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
372$rrd_info['hdd.smart.rotdisk']['fields'][] = array('name' => 'temp', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
373$rrd_info['hdd.smart.rotdisk']['update'] =
374 'function {
375 $sdata = explode("\n", `smartctl -A /dev/disk/by-id/ata-WHATEVER-THE_DISK-ID`);
376 $udata = array("load_cycle"=>null,"start_stop"=>null,"power_cycle"=>null,"temp"=>null);
377 foreach ($sdata as $sline) {
378 if (preg_match("/Load_Cycle_Count\s.+-\s+([\d]+)/", $sline, $regs)) { $udata["load_cycle"] = $regs[1]; }
379 if (preg_match("/Start_Stop_Count\s.+-\s+([\d]+)/", $sline, $regs)) { $udata["start_stop"] = $regs[1]; }
380 if (preg_match("/Power_Cycle_Count\s.+-\s+([\d]+)/", $sline, $regs)) { $udata["power_cycle"] = $regs[1]; }
381 if (preg_match("/Temperature_Celsius\s.+-\s+([\d\.]+)/", $sline, $regs)) { $udata["temp"] = $regs[1]; }
382 }
383 return $udata;
384 }';
385$rrd_info['hdd.smart.rotdisk']['graph']['rows'][] = array('name'=>'load_cycle', 'gType'=>'LINE1', 'color'=>'#000000',
386 'legend'=>'Load cycle');
387$rrd_info['hdd.smart.rotdisk']['graph']['rows'][] = array('name'=>'start_stop', 'gType'=>'LINE1', 'color'=>'#0000FF',
388 'legend'=>'Start-Stop');
389$rrd_info['hdd.smart.rotdisk']['graph']['rows'][] = array('name'=>'power_cycle', 'gType'=>'LINE1', 'color'=>'#008000',
390 'legend'=>'Power cycle');
391$rrd_info['hdd.smart.rotdisk']['graph']['rows'][] = array('name'=>'temp', 'gType'=>'LINE1', 'color'=>'#FF0000',
392 'legend'=>'Temperature');
393$rrd_info['hdd.smart.rotdisk']['graph']['units_length'] = 4;
394$rrd_info['hdd.smart.rotdisk']['graph']['label_y'] = 'units';
395// $rrd_info['hdd.smart.rotdisk']['graph']['max_y'] = 13;
396// $rrd_info['hdd.smart.rotdisk']['graph']['min_y'] = -13;
397// $rrd_info['hdd.smart.rotdisk']['graph']['force_recreate'] = true;
398
399// SNMP interfaces
400$rrd_info['eth0']['file'] = 'net.eth0.rrd';
401$rrd_info['eth0']['auto-update'] = true;
402$rrd_info['eth0']['fields'][] = array('name'=>'incoming', 'type'=>'COUNTER',
403 'heartbeat'=>600, 'min'=>'U', 'max'=>'U', 'update'=>'snmp-if:eth0:in', 'legend'=>'Incoming');
404$rrd_info['eth0']['fields'][] = array('name'=>'outgoing', 'type'=>'COUNTER',
405 'heartbeat'=>600, 'min'=>'U', 'max'=>'U', 'update'=>'snmp-if:eth0:out', 'legend'=>'Outgoing');
406$rrd_info['eth0']['graph']['label_y'] = 'Bytes per second';
407// $rrd_info['eth0']['graph']['force_recreate'] = true;
408
409$rrd_info['connect']['file'] = 'net.connect.rrd';
410$rrd_info['connect']['auto-update'] = true;
411$rrd_info['connect']['fields'][] = array('name' => 'listen', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
412$rrd_info['connect']['fields'][] = array('name' => 'run_http', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
413$rrd_info['connect']['fields'][] = array('name' => 'run_other', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
414$rrd_info['connect']['fields'][] = array('name' => 'rest_http', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
415$rrd_info['connect']['fields'][] = array('name' => 'rest_other', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
416$rrd_info['connect']['fields'][] = array('name' => 'udp', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
417$rrd_info['connect']['update'] =
418 'function {
419 $sdata = explode("\n", `LANG=C /bin/netstat -n -a`);
420 $udata = array("listen"=>0,"run_http"=>0,"run_other"=>0,"rest_http"=>0,"rest_other"=>0,"udp"=>0);
421 foreach ($sdata as $sline) {
422 if (substr($sline, 0, 3) == "tcp") {
423 if (preg_match("/LISTEN\s*$/", $sline)) { $udata["listen"]++; }
424 elseif (preg_match("/:(80|443)\s+[\d\.:*]+\s+ESTABLISHED\s*/", $sline)) { $udata["run_http"]++; }
425 elseif (preg_match("/^tcp\s+\d+\s+\d+\s+[\d\.]+:(80|443)/", $sline)) { $udata["rest_http"]++; }
426 elseif (preg_match("/ESTABLISHED\s*$/", $sline)) { $udata["run_other"]++; }
427 else { $udata["rest_other"]++; }
428 }
429 elseif (substr($sline, 0, 3) == "udp") { $udata["udp"]++; }
430 }
431 return $udata;
432 }';
433$rrd_info['connect']['graph']['rows'][] = array('name'=>'listen', 'gType'=>'AREA', 'color'=>'#CCCCCC', 'color_bg'=>'#606060',
434 'legend'=>'LISTEN', 'legend_long'=>'LISTEN-Verbindungen');
435$rrd_info['connect']['graph']['rows'][] = array('name'=>'run_http', 'gType'=>'AREA', 'color'=>'#0000FF',
436 'legend'=>'HTTPconn', 'legend_long'=>'Aktive HTTP-Verbindungen', 'stack'=>true);
437$rrd_info['connect']['graph']['rows'][] = array('name'=>'rest_http', 'gType'=>'AREA', 'color'=>'#8080FF',
438 'legend'=>'HTTPwait', 'legend_long'=>'Wartende HTTP-Verbindungen', 'stack'=>true);
439$rrd_info['connect']['graph']['rows'][] = array('name'=>'run_other', 'gType'=>'AREA', 'color'=>'#FF0000',
440 'legend'=>'TCPconn', 'legend_long'=>'Aktive TCP-Verbindungen (außer HTTP)', 'stack'=>true);
441$rrd_info['connect']['graph']['rows'][] = array('name'=>'rest_other', 'gType'=>'AREA', 'color'=>'#FF8080',
442 'legend'=>'TCPwait', 'legend_long'=>'Wartende TCP-Verbindungen (außer HTTP)', 'stack'=>true);
443$rrd_info['connect']['graph']['rows'][] = array('name'=>'udp', 'gType'=>'AREA', 'color'=>'#00CC00',
444 'legend'=>'UDP', 'legend_long'=>'UDP-Verbindungen', 'stack'=>true);
445$rrd_info['connect']['graph']['units_length'] = 4;
446$rrd_info['connect']['graph']['label_y'] = 'Network Sockets';
447$rrd_info['connect']['graph']['min_y'] = 0;
448// $rrd_info['connect']['graph']['force_recreate'] = true;
449
450$rrd_info['process']['file'] = 'system.process.rrd';
451$rrd_info['process']['auto-update'] = true;
452$rrd_info['process']['fields'][] = array('name' => 'ps_httpd', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
453$rrd_info['process']['fields'][] = array('name' => 'ps_other', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
454$rrd_info['process']['fields'][] = array('name' => 'psnum', 'type' => 'DERIVE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U');
455$rrd_info['process']['update'] =
456 'function {
457 $sdata = explode("\n", `LANG=C /bin/ps -e`);
458 $udata = array("ps_httpd"=>0,"ps_other"=>0);
459 foreach ($sdata as $sline) {
460 if (strpos($sline, "httpd-prefork")) { $udata["ps_httpd"]++; }
461 else { $udata["ps_other"]++; }
462 }
463 $udata["psnum"] = posix_getpid();
464 return $udata;
465 }';
466$rrd_info['process']['graph']['rows'][] = array('name'=>'ps_httpd', 'gType'=>'AREA', 'color'=>'#0000FF', 'legend'=>'HTTP');
467$rrd_info['process']['graph']['rows'][] = array('name'=>'ps_other', 'gType'=>'AREA', 'color'=>'#FF0000', 'legend'=>'other', 'stack'=>true);
468$rrd_info['process']['graph']['rows'][] = array('name'=>'psnum', 'scale'=>3.6, 'gType'=>'LINE1', 'color'=>'#00CC00', 'legend'=>'k ps/hour');
469$rrd_info['process']['graph']['label_y'] = 'Processes';
470$rrd_info['process']['graph']['min_y'] = 0;
471// $rrd_info['process']['graph']['force_recreate'] = true;
472$rrd_info['process']['graph.ps']['rows'][] = array('name'=>'ps_httpd', 'gType'=>'AREA', 'color'=>'#0000FF', 'legend'=>'HTTP');
473$rrd_info['process']['graph.ps']['rows'][] = array('name'=>'ps_other', 'gType'=>'AREA', 'color'=>'#FF0000', 'legend'=>'other', 'stack'=>true);
474$rrd_info['process']['graph.ps']['label_y'] = 'Processes';
475$rrd_info['process']['graph.ps']['min_y'] = 0;
476// $rrd_info['process']['graph.ps']['force_recreate'] = true;
477$rrd_info['process']['page.ps']['graph_sub'] = 'ps';
478$rrd_info['process']['graph.pi']['rows'][] = array('name'=>'psnum', 'scale'=>3600, 'gType'=>'LINE1', 'color'=>'#000000', 'legend'=>'started processes per hour');
479$rrd_info['process']['graph.pi']['label_y'] = '';
480$rrd_info['process']['graph.pi']['min_y'] = 0;
481// $rrd_info['process']['graph.pi']['force_recreate'] = true;
482$rrd_info['process']['page.pi']['graph_sub'] = 'pi';
483
484$rrd_info['temp']['graph-only'] = true;
485$rrd_info['temp']['graph']['rows'][] = array('name'=>'core0_temp', 'dsfile'=>'cpu.coretemp.rrd', 'gType'=>'LINE1',
486 'color'=>'#606060', 'legend'=>'C0', 'legend_long'=>'CPU Core 0 internal sensor');
487$rrd_info['temp']['graph']['rows'][] = array('name'=>'core1_temp', 'dsfile'=>'cpu.coretemp.rrd', 'gType'=>'LINE1',
488 'color'=>'#808080', 'legend'=>'C1', 'legend_long'=>'CPU Core 1 internal sensor');
489$rrd_info['temp']['graph']['rows'][] = array('name'=>'core2_temp', 'dsfile'=>'cpu.coretemp.rrd', 'gType'=>'LINE1',
490 'color'=>'#A0A0A0', 'legend'=>'C2', 'legend_long'=>'CPU Core 2 internal sensor');
491$rrd_info['temp']['graph']['rows'][] = array('name'=>'core3_temp', 'dsfile'=>'cpu.coretemp.rrd', 'gType'=>'LINE1',
492 'color'=>'#C0C0C0', 'legend'=>'C3', 'legend_long'=>'CPU Core 3 internal sensor');
493$rrd_info['temp']['graph']['rows'][] = array('name'=>'cpu_temp', 'dsfile'=>'sensors.temp.rrd', 'gType'=>'LINE1',
494 'color'=>'#000000', 'legend'=>'CPU', 'legend_long'=>'CPU sensor');
495$rrd_info['temp']['graph']['rows'][] = array('name'=>'mb_temp', 'dsfile'=>'sensors.temp.rrd', 'gType'=>'LINE1',
496 'color'=>'#008000', 'legend'=>'SYS', 'legend_long'=>'Mainboard/system sensor');
497$rrd_info['temp']['graph']['rows'][] = array('name'=>'rotdisk_temp', 'dsname'=>'temp', 'dsfile'=>'hdd.smart.rotdisk.rrd', 'gType'=>'LINE1',
498 'color'=>'#FFB000', 'legend'=>'WDblack', 'legend_long'=>'Harddisk');
499$rrd_info['temp']['graph']['label_y'] = '°C';
500$rrd_info['temp']['graph']['units_exponent'] = 0;
501$rrd_info['temp']['graph']['units_length'] = 4;
502//$rrd_info['temp']['graph']['min_y'] = 0;
503//$rrd_info['temp']['graph']['max_y'] = 100;
504//$rrd_info['temp']['graph']['fix_scale_y'] = true;
505// $rrd_info['temp']['graph']['force_recreate'] = true;
506$rrd_info['temp']['page']['show_update'] = false;
507
508$rrd_info['ping.gateway']['file'] = 'net.ping.gateway.rrd';
509$rrd_info['ping.gateway']['auto-update'] = true;
510$rrd_info['ping.gateway']['fields'][] = array('name' => 'single_min', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U');
511$rrd_info['ping.gateway']['fields'][] = array('name' => 'single_avg', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U');
512$rrd_info['ping.gateway']['fields'][] = array('name' => 'single_max', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U');
513$rrd_info['ping.gateway']['fields'][] = array('name' => 'single_loss', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 0, 'max' => 100);
514$rrd_info['ping.gateway']['fields'][] = array('name' => 'flood_min', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U');
515$rrd_info['ping.gateway']['fields'][] = array('name' => 'flood_avg', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U');
516$rrd_info['ping.gateway']['fields'][] = array('name' => 'flood_max', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U');
517$rrd_info['ping.gateway']['fields'][] = array('name' => 'flood_loss', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 0, 'max' => 100);
518$rrd_info['ping.gateway']['update'] =
519 'function {
520 $pinghost = "10.0.0.1"; $pingnum = 20;
521 $sdata = array();
522 $sdata["single"] = explode("\n", `LANG=C /usr/bin/ping -q -c $pingnum -w 90 $pinghost 2>/dev/null`);
523 $sdata["flood"] = explode("\n", `LANG=C /usr/bin/ping -qf -c $pingnum -w 30 $pinghost 2>/dev/null`);
524 $udata = array("single_min"=>0,"single_avg"=>0,"single_max"=>0,"single_loss"=>100,
525 "flood_min"=>0,"flood_avg"=>0,"flood_max"=>0,"flood_loss"=>100);
526 foreach (array("single","flood") as $mode) {
527 foreach ($sdata[$mode] as $sline) {
528 if (preg_match("/(\d+)% (?:packet )?loss/", $sline, $regs)) { $udata[$mode."_loss"] = $regs[1]; }
529 elseif (preg_match("/min\/avg\/max(?:\/mdev)? = ([\d\.]+)\/([\d\.]+)\/([\d\.]+)(?:\/[\d\.]+)? ms/", $sline, $regs)) {
530 $udata[$mode."_min"] = $regs[1]/1000; $udata[$mode."_avg"] = $regs[2]/1000; $udata[$mode."_max"] = $regs[3]/1000;
531 }
532 }
533 }
534 return $udata;
535 }';
536$rrd_info['ping.gateway']['graph']['rows'][] = array('name'=>'flood_min', 'gType'=>'LINE1', 'color'=>'#80FF80', 'legend'=>'f:min/max', 'desc'=>'f:min');
537$rrd_info['ping.gateway']['graph']['rows'][] = array('name'=>'flood_max', 'gType'=>'LINE1', 'color'=>'#80FF80', 'desc'=>'f:max');
538$rrd_info['ping.gateway']['graph']['rows'][] = array('name'=>'single_min', 'gType'=>'LINE1', 'color'=>'#CCCCFF', 'legend'=>'s:min/max', 'desc'=>'s:min');
539$rrd_info['ping.gateway']['graph']['rows'][] = array('name'=>'single_max', 'gType'=>'LINE1', 'color'=>'#CCCCFF', 'desc'=>'s:max');
540$rrd_info['ping.gateway']['graph']['rows'][] = array('name'=>'flood_avg', 'gType'=>'LINE1', 'color'=>'#008000', 'legend'=>'f:avg');
541$rrd_info['ping.gateway']['graph']['rows'][] = array('name'=>'single_avg', 'gType'=>'LINE1', 'color'=>'#0000FF', 'legend'=>'s:avg');
542$rrd_info['ping.gateway']['graph']['rows'][] = array('name'=>'flood_loss', 'scale'=>0.001, 'gType'=>'LINE1', 'color'=>'#000000', 'legend'=>'f:mloss');
543$rrd_info['ping.gateway']['graph']['rows'][] = array('name'=>'single_loss', 'scale'=>0.001, 'gType'=>'LINE1', 'color'=>'#FF0000', 'legend'=>'s:mloss');
544$rrd_info['ping.gateway']['graph']['label_y'] = 'Seconds';
545$rrd_info['ping.gateway']['graph']['min_y'] = 0;
546// $rrd_info['ping.gateway']['graph']['force_recreate'] = true;
547$rrd_info['ping.gateway']['page']['text_intro'] = 'Alternate graphs: <a href="?stat=ping.gateway">totals</a>, <a href="?stat=ping.gateway&sub=avg">averages</a>.';
548$rrd_info['ping.gateway']['graph.avg']['rows'][] = array('name'=>'flood_avg', 'gType'=>'LINE1', 'color'=>'#008000',
549 'legend'=>'f:avg', 'legend_long'=>'Flood ping: average time (of 20 parallel pings)');
550$rrd_info['ping.gateway']['graph.avg']['rows'][] = array('name'=>'single_avg', 'gType'=>'LINE1', 'color'=>'#0000FF',
551 'legend'=>'s:avg', 'legend_long'=>'Single ping: average time (of 20 sequential pings, 1s gap)');
552$rrd_info['ping.gateway']['graph.avg']['rows'][] = array('name'=>'flood_loss', 'scale'=>0.001, 'gType'=>'LINE1', 'color'=>'#000000',
553 'legend'=>'f:mloss', 'legend_long'=>'Flood ping: packet loss (percent of 20 parallel pings)');
554$rrd_info['ping.gateway']['graph.avg']['rows'][] = array('name'=>'single_loss', 'scale'=>0.001, 'gType'=>'LINE1', 'color'=>'#FF0000',
555 'legend'=>'s:mloss', 'legend_long'=>'Single ping: packet loss (percent of 20 sequential pings, 1s gap)');
556$rrd_info['ping.gateway']['graph.avg']['label_y'] = 'Seconds';
557$rrd_info['ping.gateway']['graph.avg']['min_y'] = 0;
558$rrd_info['ping.gateway']['page.avg']['graph_sub'] = 'avg';
559
560// mainboard sensors
561$rrd_info['sensors.power']['file'] = 'sensors.power.rrd';
562$rrd_info['sensors.power']['auto-update'] = true;
563$rrd_info['sensors.power']['fields'][] = array('name' => 'vcore', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
564$rrd_info['sensors.power']['fields'][] = array('name' => 'p3x3v', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
565$rrd_info['sensors.power']['fields'][] = array('name' => 'p5v', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
566$rrd_info['sensors.power']['fields'][] = array('name' => 'p12v', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
567$rrd_info['sensors.power']['fields'][] = array('name' => 'avcc', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
568$rrd_info['sensors.power']['fields'][] = array('name' => 'vsb', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
569$rrd_info['sensors.power']['fields'][] = array('name' => 'vbat', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
570$rrd_info['sensors.power']['fields'][] = array('name' => 'memvcc', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
571$rrd_info['sensors.power']['fields'][] = array('name' => 'pchvcc', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
572$rrd_info['sensors.power']['fields'][] = array('name' => 'vid', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
573$rrd_info['sensors.power']['update'] =
574 'function {
575 $sdata = explode("\n", `/usr/bin/sensors -A mysensor-*`);
576 $udata = array("vcore"=>null,"p3x3v"=>null,"p5v"=>null,"p12v"=>null,
577 "avcc"=>null,"vsb"=>null,"vbat"=>null,"memvcc"=>null,
578 "pchvcc"=>null,"vid"=>null);
579 foreach ($sdata as $sline) {
580 if (preg_match("/^Vcore:\s+([+-]?[\d\.]+) V/", $sline, $regs)) { $udata["vcore"] = $regs[1]; }
581 elseif (preg_match("/^\+3\.3V:\s+([+-]?[\d\.]+) V/", $sline, $regs)) { $udata["p3x3v"] = $regs[1]; }
582 elseif (preg_match("/^\+5V:\s+([+-]?[\d\.]+) V/", $sline, $regs)) { $udata["p5v"] = $regs[1]; }
583 elseif (preg_match("/^\+12V:\s+([+-]?[\d\.]+) V/", $sline, $regs)) { $udata["p12v"] = $regs[1]; }
584 elseif (preg_match("/^AVCC:\s+([+-]?[\d\.]+) V/", $sline, $regs)) { $udata["avcc"] = $regs[1]; }
585 elseif (preg_match("/^3VSB:\s+([+-]?[\d\.]+) V/", $sline, $regs)) { $udata["vsb"] = $regs[1]; }
586 elseif (preg_match("/^Vbat:\s+([+-]?[\d\.]+) V/", $sline, $regs)) { $udata["vbat"] = $regs[1]; }
587 elseif (preg_match("/^Memory Vcc:\s+([+-]?[\d\.]+) V/", $sline, $regs)) { $udata["memvcc"] = $regs[1]; }
588 elseif (preg_match("/^PCH Vcc:\s+([+-]?[\d\.]+) V/", $sline, $regs)) { $udata["pchvcc"] = $regs[1]; }
589 elseif (preg_match("/^cpu0_vid:\s+([+-]?[\d\.]+) V/", $sline, $regs)) { $udata["vid"] = $regs[1]; }
590 }
591 return $udata;
592 }';
593
594$rrd_info['sensors.power']['graph']['rows'][] = array('name'=>'vcore', 'gType'=>'LINE1', 'color'=>'#FF0000', 'legend'=>'VCore');
595$rrd_info['sensors.power']['graph']['rows'][] = array('name'=>'p12v', 'gType'=>'LINE1', 'color'=>'#0000FF', 'legend'=>'+12V');
596$rrd_info['sensors.power']['graph']['rows'][] = array('name'=>'p5v', 'gType'=>'LINE1', 'color'=>'#008000', 'legend'=>'+5V');
597$rrd_info['sensors.power']['graph']['rows'][] = array('name'=>'p3x3v', 'gType'=>'LINE1', 'color'=>'#000000', 'legend'=>'+3.3V');
598$rrd_info['sensors.power']['graph']['rows'][] = array('name'=>'avcc', 'gType'=>'LINE1', 'color'=>'#808080', 'legend'=>'AVCC');
599$rrd_info['sensors.power']['graph']['rows'][] = array('name'=>'vsb', 'gType'=>'LINE1', 'color'=>'#8080FF', 'legend'=>'3VSB');
600$rrd_info['sensors.power']['graph']['rows'][] = array('name'=>'vbat', 'gType'=>'LINE1', 'color'=>'#00CC00', 'legend'=>'VBat');
601$rrd_info['sensors.power']['graph']['rows'][] = array('name'=>'memvcc', 'gType'=>'LINE1', 'color'=>'#808080', 'legend'=>'Memory Vcc');
602$rrd_info['sensors.power']['graph']['rows'][] = array('name'=>'pchvcc', 'gType'=>'LINE1', 'color'=>'#808080', 'legend'=>'PCH Vcc');
603$rrd_info['sensors.power']['graph']['rows'][] = array('name'=>'vid', 'gType'=>'LINE1', 'color'=>'#808080', 'legend'=>'CPU0-VID');
604$rrd_info['sensors.power']['graph']['units_length'] = 4;
605$rrd_info['sensors.power']['graph']['label_y'] = 'Volt';
606$rrd_info['sensors.power']['graph']['max_y'] = 13;
607$rrd_info['sensors.power']['graph']['min_y'] = 0;
608// $rrd_info['sensors.power']['graph']['force_recreate'] = true;
609$rrd_info['sensors.power']['graph.rel']['rows'][] = array('name'=>'vcore_tmp', 'dsname'=>'vcore', 'gType'=>'');
610$rrd_info['sensors.power']['graph.rel']['rows'][] = array('name'=>'p12v_tmp', 'dsname'=>'p12v', 'gType'=>'');
611$rrd_info['sensors.power']['graph.rel']['rows'][] = array('name'=>'p5v_tmp', 'dsname'=>'p5v', 'gType'=>'');
612$rrd_info['sensors.power']['graph.rel']['rows'][] = array('name'=>'p3x3v_tmp', 'dsname'=>'p3x3v', 'gType'=>'');
613$rrd_info['sensors.power']['graph.rel']['rows'][] = array('name'=>'avcc_tmp', 'dsname'=>'vsb', 'gType'=>'');
614$rrd_info['sensors.power']['graph.rel']['rows'][] = array('name'=>'vsb_tmp', 'dsname'=>'vsb', 'gType'=>'');
615$rrd_info['sensors.power']['graph.rel']['rows'][] = array('name'=>'vbat_tmp', 'dsname'=>'vbat', 'gType'=>'');
616$rrd_info['sensors.power']['graph.rel']['rows'][] = array('name'=>'memvcc_tmp', 'dsname'=>'memvcc', 'gType'=>'');
617$rrd_info['sensors.power']['graph.rel']['rows'][] = array('name'=>'pchvcc_tmp', 'dsname'=>'pchvcc', 'gType'=>'');
618$rrd_info['sensors.power']['graph.rel']['rows'][] = array('name'=>'vid_tmp', 'dsname'=>'vid', 'gType'=>'');
619$rrd_info['sensors.power']['graph.rel']['rows'][] = array('dType'=>'CDEF', 'name'=>'vcore',
620 'rpn_expr'=>'vcore_tmp,1,-', 'gType'=>'LINE1', 'color'=>'#FF0000', 'legend'=>'VCore');
621$rrd_info['sensors.power']['graph.rel']['rows'][] = array('dType'=>'CDEF', 'name'=>'p3x3v',
622 'rpn_expr'=>'p3x3v_tmp,3.3,-', 'gType'=>'LINE1', 'color'=>'#000000', 'legend'=>'+3.3V');
623$rrd_info['sensors.power']['graph.rel']['rows'][] = array('dType'=>'CDEF', 'name'=>'p5v',
624 'rpn_expr'=>'p5v_tmp,5,-', 'gType'=>'LINE1', 'color'=>'#008000', 'legend'=>'+5V');
625$rrd_info['sensors.power']['graph.rel']['rows'][] = array('dType'=>'CDEF', 'name'=>'p12v',
626 'rpn_expr'=>'p12v_tmp,12,-', 'gType'=>'LINE1', 'color'=>'#0000FF', 'legend'=>'+12V');
627$rrd_info['sensors.power']['graph.rel']['rows'][] = array('dType'=>'CDEF', 'name'=>'avcc',
628 'rpn_expr'=>'avcc_tmp,3.3,-', 'gType'=>'LINE1', 'color'=>'#808080', 'legend'=>'AVCC');
629$rrd_info['sensors.power']['graph.rel']['rows'][] = array('dType'=>'CDEF', 'name'=>'vsb',
630 'rpn_expr'=>'vsb_tmp,3.3,-', 'gType'=>'LINE1', 'color'=>'#8080FF', 'legend'=>'3VSB');
631$rrd_info['sensors.power']['graph.rel']['rows'][] = array('dType'=>'CDEF', 'name'=>'vbat',
632 'rpn_expr'=>'vbat_tmp,3.3,-', 'gType'=>'LINE1', 'color'=>'#00CC00', 'legend'=>'VBat');
633$rrd_info['sensors.power']['graph.rel']['rows'][] = array('dType'=>'CDEF', 'name'=>'memvcc',
634 'rpn_expr'=>'memvcc_tmp,1.5,-', 'gType'=>'LINE1', 'color'=>'#808080', 'legend'=>'Memory Vcc');
635$rrd_info['sensors.power']['graph.rel']['rows'][] = array('dType'=>'CDEF', 'name'=>'pchvcc',
636 'rpn_expr'=>'pchvcc_tmp,1,-', 'gType'=>'LINE1', 'color'=>'#808080', 'legend'=>'PCH Vcc');
637$rrd_info['sensors.power']['graph.rel']['rows'][] = array('dType'=>'CDEF', 'name'=>'vid',
638 'rpn_expr'=>'vid_tmp,2,-', 'gType'=>'LINE1', 'color'=>'#808080', 'legend'=>'CPU0-VID');
639$rrd_info['sensors.power']['graph.rel']['units_length'] = 5;
640$rrd_info['sensors.power']['graph.rel']['units_exponent'] = 0;
641$rrd_info['sensors.power']['graph.rel']['label_y'] = 'Volts (diff)';
642$rrd_info['sensors.power']['graph.rel']['max_y'] = +0.3;
643$rrd_info['sensors.power']['graph.rel']['min_y'] = -0.7;
644// $rrd_info['sensors.power']['graph.rel']['force_recreate'] = true;
645$rrd_info['sensors.power']['page.rel']['graph_sub'] = 'rel';
646$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('name'=>'vcore_tmp', 'dsname'=>'vcore', 'gType'=>'');
647$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('name'=>'p12v_tmp', 'dsname'=>'p12v', 'gType'=>'');
648$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('name'=>'p5v_tmp', 'dsname'=>'p5v', 'gType'=>'');
649$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('name'=>'p3x3v_tmp', 'dsname'=>'p3x3v', 'gType'=>'');
650$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('name'=>'avcc_tmp', 'dsname'=>'vsb', 'gType'=>'');
651$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('name'=>'vsb_tmp', 'dsname'=>'vsb', 'gType'=>'');
652$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('name'=>'vbat_tmp', 'dsname'=>'vbat', 'gType'=>'');
653$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('name'=>'memvcc_tmp', 'dsname'=>'memvcc', 'gType'=>'');
654$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('name'=>'pchvcc_tmp', 'dsname'=>'pchvcc', 'gType'=>'');
655$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('name'=>'vid_tmp', 'dsname'=>'vid', 'gType'=>'');
656$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('dType'=>'CDEF', 'name'=>'vcore',
657 'rpn_expr'=>'vcore_tmp,1,-,1,/,100,*', 'gType'=>'LINE1', 'color'=>'#FF0000', 'legend'=>'VCore');
658$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('dType'=>'CDEF', 'name'=>'p3x3v',
659 'rpn_expr'=>'p3x3v_tmp,3.3,-,3.3,/,100,*', 'gType'=>'LINE1', 'color'=>'#000000', 'legend'=>'+3.3V');
660$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('dType'=>'CDEF', 'name'=>'p5v',
661 'rpn_expr'=>'p5v_tmp,5,-,5,/,100,*', 'gType'=>'LINE1', 'color'=>'#008000', 'legend'=>'+5V');
662$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('dType'=>'CDEF', 'name'=>'p12v',
663 'rpn_expr'=>'p12v_tmp,12,-,12,/,100,*', 'gType'=>'LINE1', 'color'=>'#0000FF', 'legend'=>'+12V');
664$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('dType'=>'CDEF', 'name'=>'avcc',
665 'rpn_expr'=>'avcc_tmp,3.3,-,3.3,/,100,*', 'gType'=>'LINE1', 'color'=>'#808080', 'legend'=>'AVCC');
666$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('dType'=>'CDEF', 'name'=>'vsb',
667 'rpn_expr'=>'vsb_tmp,3.3,-,3.3,/,100,*', 'gType'=>'LINE1', 'color'=>'#8080FF', 'legend'=>'3VSB');
668$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('dType'=>'CDEF', 'name'=>'vbat',
669 'rpn_expr'=>'vbat_tmp,3.3,-,3.3,/,100,*', 'gType'=>'LINE1', 'color'=>'#00CC00', 'legend'=>'VBat');
670$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('dType'=>'CDEF', 'name'=>'memvcc',
671 'rpn_expr'=>'memvcc_tmp,1.5,-,1.5,/,100,*', 'gType'=>'LINE1', 'color'=>'#808080', 'legend'=>'Memory Vcc');
672$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('dType'=>'CDEF', 'name'=>'pchvcc',
673 'rpn_expr'=>'pchvcc_tmp,1,-,1,/,100,*', 'gType'=>'LINE1', 'color'=>'#808080', 'legend'=>'PCH Vcc');
674$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('dType'=>'CDEF', 'name'=>'vid',
675 'rpn_expr'=>'vid_tmp,2,-,2,/,100,*', 'gType'=>'LINE1', 'color'=>'#808080', 'legend'=>'CPU0-VID');
676$rrd_info['sensors.power']['graph.relpct']['units_length'] = 5;
677$rrd_info['sensors.power']['graph.relpct']['units_exponent'] = 0;
678$rrd_info['sensors.power']['graph.relpct']['label_y'] = 'diff%';
679$rrd_info['sensors.power']['graph.relpct']['max_y'] = +2;
680$rrd_info['sensors.power']['graph.relpct']['min_y'] = -6;
681// $rrd_info['sensors.power']['graph.relpct']['force_recreate'] = true;
682$rrd_info['sensors.power']['page.relpct']['graph_sub'] = 'relpct';
683
684$rrd_info['sensors.fan']['file'] = 'sensors.fan.rrd';
685$rrd_info['sensors.fan']['auto-update'] = true;
686$rrd_info['sensors.fan']['fields'][] = array('name' => 'cpu_fan', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
687$rrd_info['sensors.fan']['fields'][] = array('name' => 'chassis_fan', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
688$rrd_info['sensors.fan']['fields'][] = array('name' => 'power_fan', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
689$rrd_info['sensors.fan']['update'] =
690 'function {
691 $sdata = explode("\n", str_replace(":\n", ": ", `/usr/bin/sensors -A mysensor-*`));
692 $udata = array("cpu_fan"=>null,"chassis_fan"=>null,"power_fan"=>null);
693 foreach ($sdata as $sline) {
694 if (preg_match("/^fan2:\s+([+-]?\d+) RPM/", $sline, $regs)) { $udata["cpu_fan"] = $regs[1]; }
695 elseif (preg_match("/^CHASSIS1 FAN Speed:\s+([+-]?\d+) RPM/", $sline, $regs)) { $udata["chassis_fan"] = $regs[1]; }
696 elseif (preg_match("/^POWER FAN Speed:\s+([+-]?\d+) RPM/", $sline, $regs)) { $udata["power_fan"] = $regs[1]; }
697 }
698 return $udata;
699 }';
700$rrd_info['sensors.fan']['graph']['rows'][] = array('name'=>'cpu_fan', 'gType'=>'LINE1', 'color'=>'#0000FF', 'legend'=>'CPU Fan');
701$rrd_info['sensors.fan']['graph']['rows'][] = array('name'=>'chassis_fan', 'gType'=>'LINE1', 'color'=>'#00CC00', 'legend'=>'GPU Fan');
702$rrd_info['sensors.fan']['graph']['label_y'] = 'Rotations/min';
703$rrd_info['sensors.fan']['graph']['max_y'] = 2000;
704$rrd_info['sensors.fan']['graph']['min_y'] = 500;
705// $rrd_info['sensors.fan']['graph']['force_recreate'] = true;
706
707$rrd_info['sensors.temp']['file'] = 'sensors.temp.rrd';
708$rrd_info['sensors.temp']['auto-update'] = true;
709$rrd_info['sensors.temp']['fields'][] = array('name' => 'cpu_temp', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
710$rrd_info['sensors.temp']['fields'][] = array('name' => 'mb_temp', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
711$rrd_info['sensors.temp']['fields'][] = array('name' => 'power_temp', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
712$rrd_info['sensors.temp']['update'] =
713 'function {
714 $sdata = explode("\n", `/usr/bin/sensors -A mysensor-*`);
715 $udata = array("cpu_temp"=>null,"mb_temp"=>null,"power_temp"=>null);
716 foreach ($sdata as $sline) {
717 if (preg_match("/^CPUTIN:\s+([+-]?[\d\.]+).+?C/i", $sline, $regs)) { $udata["cpu_temp"] = $regs[1]; }
718 elseif (preg_match("/^SYSTIN:\s+([+-]?[\d\.]+).+?C/i", $sline, $regs)) { $udata["mb_temp"] = $regs[1]; }
719 elseif (preg_match("/^AUXTIN:\s+([+-]?[\d\.]+).+?C/i", $sline, $regs)) { $udata["power_temp"] = $regs[1]; }
720 }
721 return $udata;
722 }';
723$rrd_info['sensors.temp']['graph']['rows'][] = array('name'=>'cpu_temp', 'gType'=>'LINE1', 'color'=>'#0000FF', 'legend'=>'CPU Temp');
724$rrd_info['sensors.temp']['graph']['rows'][] = array('name'=>'mb_temp', 'gType'=>'LINE1', 'color'=>'#008000', 'legend'=>'MB Temp');
725$rrd_info['sensors.temp']['graph']['label_y'] = '°C';
726$rrd_info['sensors.temp']['graph']['max_y'] = 55;
727$rrd_info['sensors.temp']['graph']['min_y'] = 30;
728// $rrd_info['sensors.temp']['graph']['force_recreate'] = true;
729
730/* !!! be sure to call this one _last_ of all auto-update rrd stats */
731$rrd_info['rrdup']['file'] = 'test.rrdup.rrd';
732// $rrd_info['rrdup']['auto-update'] = true;
733$rrd_info['rrdup']['fields'][] = array('name' => 'usertime', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
734$rrd_info['rrdup']['fields'][] = array('name' => 'systime', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U');
735$rrd_info['rrdup']['update'] = 'function { $sdata = posix_times(); return array("usertime"=>$sdata["cutime"],"systime"=>$sdata["cstime"]); }';
736$rrd_info['rrdup']['graph']['rows'][] = array('name'=>'systime', 'gType'=>'AREA', 'color'=>'#FF0000', 'legend'=>'System CPU time');
737$rrd_info['rrdup']['graph']['rows'][] = array('name'=>'usertime', 'gType'=>'AREA', 'color'=>'#0000FF', 'legend'=>'User CPU time', 'stack'=>true);
738$rrd_info['rrdup']['graph']['scale'] = 0.01;
739$rrd_info['rrdup']['graph']['units_length'] = 4;
740$rrd_info['rrdup']['graph']['units_exponent'] = 0;
741$rrd_info['rrdup']['graph']['label_y'] = 'RRD update (seconds)';
742$rrd_info['rrdup']['graph']['min_y'] = 0;
743// $rrd_info['rrdup']['graph']['force_recreate'] = true;
744
745?>