4a778b7e |
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'; |
4d8d65db |
16 | $rrd_info['overview']['page']['index_ids'] = 'cpu,load,mem,rrdup'; |
4a778b7e |
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'; |
19 | // $rrd_info['overview']['hidden'] = true; |
20 | |
21 | $rrd_info['cpu']['file'] = 'system.cpu.rrd'; |
22 | $rrd_info['cpu']['auto-update'] = true; |
23 | $rrd_info['cpu']['fields'][] = array('name' => 'user', 'type' => 'COUNTER', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
24 | $rrd_info['cpu']['fields'][] = array('name' => 'nice', 'type' => 'COUNTER', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
25 | $rrd_info['cpu']['fields'][] = array('name' => 'system', 'type' => 'COUNTER', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
26 | $rrd_info['cpu']['fields'][] = array('name' => 'idle', 'type' => 'COUNTER', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
27 | $rrd_info['cpu']['fields'][] = array('name' => 'iowait', 'type' => 'COUNTER', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
28 | $rrd_info['cpu']['fields'][] = array('name' => 'irq', 'type' => 'COUNTER', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
29 | $rrd_info['cpu']['fields'][] = array('name' => 'softirq', 'type' => 'COUNTER', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
30 | $rrd_info['cpu']['fields'][] = array('name' => 'total', 'type' => 'COUNTER', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
31 | $rrd_info['cpu']['update'] = |
32 | 'function { |
33 | $sdata = file("/proc/stat"); $udata = array(); |
34 | foreach ($sdata as $sline) { |
35 | if (preg_match("/^\s*cpu\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/", $sline, $regs)) { |
36 | $udata = array("user"=>$regs[1],"nice"=>$regs[2],"system"=>$regs[3],"idle"=>$regs[4], |
37 | "iowait"=>$regs[5],"irq"=>$regs[6],"softirq"=>$regs[7],"total"=>array_sum($regs)); |
38 | } |
39 | } |
40 | return $udata; |
41 | }'; |
42 | $rrd_info['cpu']['graph']['rows'][] = array('name'=>'total', 'gType'=>''); |
43 | $rrd_info['cpu']['graph']['rows'][] = array('name'=>'softirq_tmp', 'dsname'=>'softirq', 'gType'=>''); |
44 | $rrd_info['cpu']['graph']['rows'][] = array('name'=>'irq_tmp', 'dsname'=>'irq', 'gType'=>''); |
45 | $rrd_info['cpu']['graph']['rows'][] = array('name'=>'iowait_tmp', 'dsname'=>'iowait', 'gType'=>''); |
46 | $rrd_info['cpu']['graph']['rows'][] = array('name'=>'system_tmp', 'dsname'=>'system', 'gType'=>''); |
47 | $rrd_info['cpu']['graph']['rows'][] = array('name'=>'nice_tmp', 'dsname'=>'nice', 'gType'=>''); |
48 | $rrd_info['cpu']['graph']['rows'][] = array('name'=>'user_tmp', 'dsname'=>'user', 'gType'=>''); |
49 | $rrd_info['cpu']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'softirq', 'rpn_expr'=>'softirq_tmp,total,/,100,*', 'gType'=>'AREA', 'color'=>'#CCCCCC', 'color_bg'=>'#808080', 'legend'=>'softIRQ'); |
50 | $rrd_info['cpu']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'irq', 'rpn_expr'=>'irq_tmp,total,/,100,*', 'gType'=>'AREA', 'color'=>'#808080', 'legend'=>'IRQ', 'stack'=>true); |
51 | $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); |
52 | $rrd_info['cpu']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'system', 'rpn_expr'=>'system_tmp,total,/,100,*', 'gType'=>'AREA', 'color'=>'#FF0000', 'legend'=>'System', 'stack'=>true); |
53 | $rrd_info['cpu']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'nice', 'rpn_expr'=>'nice_tmp,total,/,100,*', 'gType'=>'AREA', 'color'=>'#FFFF00', 'color_bg'=>'#808080', 'legend'=>'Nice', 'stack'=>true); |
54 | $rrd_info['cpu']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'user', 'rpn_expr'=>'user_tmp,total,/,100,*', 'gType'=>'AREA', 'color'=>'#0000FF', 'legend'=>'User', 'stack'=>true); |
55 | $rrd_info['cpu']['graph']['units_length'] = 4; |
56 | $rrd_info['cpu']['graph']['label_y'] = '% CPU-Auslastung'; |
57 | $rrd_info['cpu']['graph']['min_y'] = 0; |
58 | $rrd_info['cpu']['graph']['max_y'] = 100; |
59 | $rrd_info['cpu']['graph']['fix_scale_y'] = true; |
60 | // $rrd_info['cpu']['graph']['force_recreate'] = true; |
61 | |
4a778b7e |
62 | $rrd_info['mem']['file'] = 'system.mem.rrd'; |
63 | $rrd_info['mem']['auto-update'] = true; |
64 | $rrd_info['mem']['fields'][] = array('name' => 'total', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
65 | $rrd_info['mem']['fields'][] = array('name' => 'used', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
66 | $rrd_info['mem']['fields'][] = array('name' => 'buffers', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
67 | $rrd_info['mem']['fields'][] = array('name' => 'cached', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
68 | $rrd_info['mem']['fields'][] = array('name' => 'swap_total', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
69 | $rrd_info['mem']['fields'][] = array('name' => 'swap_used', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
70 | $rrd_info['mem']['update'] = |
71 | 'function { |
72 | $sdata = explode("\n", `/usr/bin/free -b -o`); |
73 | $udata = array("total"=>null,"used"=>null,"buffers"=>null,"cached"=>null, |
74 | "swap_total"=>null,"swap_used"=>null); |
75 | foreach ($sdata as $sline) { |
76 | if (preg_match("/Mem:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/", $sline, $regs)) { |
77 | $udata["total"] = $regs[1]; $udata["used"] = $regs[2]-$regs[5]-$regs[6]; |
78 | $udata["buffers"] = $regs[5]; $udata["cached"] = $regs[6]; |
79 | } |
80 | elseif (preg_match("/Swap:\s+(\d+)\s+(\d+)\s+(\d+)/", $sline, $regs)) { |
81 | $udata["swap_total"] = $regs[1]; $udata["swap_used"] = $regs[2]; |
82 | } |
83 | } |
84 | return $udata; |
85 | }'; |
86 | $rrd_info['mem']['graph']['rows'][] = array('name'=>'total', 'gType'=>'LINE1', 'color'=>'#000000', 'legend'=>'Available'); |
87 | $rrd_info['mem']['graph']['rows'][] = array('name'=>'used', 'gType'=>'AREA', 'color'=>'#0000FF', 'legend'=>'Used'); |
88 | $rrd_info['mem']['graph']['rows'][] = array('name'=>'buffers', 'gType'=>'AREA', 'color'=>'#FFFF00', 'legend'=>'Buffers', 'stack'=>true); |
89 | $rrd_info['mem']['graph']['rows'][] = array('name'=>'cached', 'gType'=>'AREA', 'color'=>'#008000', 'legend'=>'Cache', 'stack'=>true); |
90 | $rrd_info['mem']['graph']['rows'][] = array('name'=>'swap_total', 'gType'=>'LINE1', 'color'=>'#CCCCCC', 'legend'=>'Swap avail.'); |
91 | $rrd_info['mem']['graph']['rows'][] = array('name'=>'swap_used', 'gType'=>'LINE2', 'color'=>'#00FFFF', 'legend'=>'Swap used'); |
92 | $rrd_info['mem']['graph']['units_binary'] = true; |
93 | $rrd_info['mem']['graph']['units_exponent'] = 6; |
94 | $rrd_info['mem']['graph']['units_length'] = 6; |
95 | $rrd_info['mem']['graph']['label_y'] = 'Memory'; |
96 | $rrd_info['mem']['graph']['min_y'] = 0; |
97 | // $rrd_info['mem']['graph']['max_y'] = 100; |
98 | // $rrd_info['mem']['graph']['fix_scale_y'] = true; |
99 | // $rrd_info['mem']['graph']['force_recreate'] = true; |
100 | $rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'total', 'gType'=>''); |
101 | $rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'swap_total', 'gType'=>''); |
102 | $rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'used_tmp', 'dsname'=>'used', 'gType'=>''); |
103 | $rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'buffers_tmp', 'dsname'=>'buffers', 'gType'=>''); |
104 | $rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'cached_tmp', 'dsname'=>'cached', 'gType'=>''); |
105 | $rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'swap_tmp', 'dsname'=>'swap_used', 'gType'=>''); |
106 | $rrd_info['mem']['graph.pct']['rows'][] = array('dType'=>'CDEF', 'name'=>'used', 'rpn_expr'=>'used_tmp,total,/,100,*', 'gType'=>'AREA', 'color'=>'#0000FF', 'legend'=>'Used'); |
107 | $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); |
108 | $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); |
109 | $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'); |
110 | $rrd_info['mem']['graph.pct']['units_exponent'] = 0; |
111 | $rrd_info['mem']['graph.pct']['units_length'] = 4; |
112 | $rrd_info['mem']['graph.pct']['label_y'] = '% Memory'; |
113 | $rrd_info['mem']['graph.pct']['min_y'] = 0; |
114 | $rrd_info['mem']['graph.pct']['max_y'] = 100; |
115 | $rrd_info['mem']['graph.pct']['fix_scale_y'] = true; |
116 | // $rrd_info['mem']['graph.pct']['force_recreate'] = true; |
117 | $rrd_info['mem']['page.pct']['graph_sub'] = 'pct'; |
118 | |
119 | $rrd_info['load']['file'] = 'system.load.rrd'; |
120 | $rrd_info['load']['auto-update'] = true; |
121 | $rrd_info['load']['fields'][] = array('name' => 'load1', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
122 | $rrd_info['load']['fields'][] = array('name' => 'load5', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
123 | $rrd_info['load']['fields'][] = array('name' => 'load15', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
124 | $rrd_info['load']['update'] = 'function { $sdata = explode(" ",file_get_contents("/proc/loadavg")); return array("load1"=>$sdata[0],"load5"=>$sdata[1],"load15"=>$sdata[2]); }'; |
125 | $rrd_info['load']['graph']['rows'][] = array('name'=>'load1', 'gType'=>'AREA', 'color'=>'#00CC00', 'legend'=>'1 Min.'); |
126 | $rrd_info['load']['graph']['rows'][] = array('name'=>'load5', 'gType'=>'LINE1', 'color'=>'#FF4000', 'legend'=>'5 Min.'); |
127 | $rrd_info['load']['graph']['rows'][] = array('name'=>'load15', 'gType'=>'LINE1', 'color'=>'#0000FF', 'legend'=>'15 Min.'); |
128 | $rrd_info['load']['graph']['units_length'] = 4; |
129 | $rrd_info['load']['graph']['units_exponent'] = 0; |
130 | $rrd_info['load']['graph']['label_y'] = 'Load average'; |
131 | $rrd_info['load']['graph']['min_y'] = 0; |
132 | // $rrd_info['load']['graph']['force_recreate'] = true; |
133 | $rrd_info['load']['page']['data_colorize'] = true; |
134 | |
4a778b7e |
135 | /* !!! be sure to call this one _last_ of all auto-update rrd stats */ |
136 | $rrd_info['rrdup']['file'] = 'test.rrdup.rrd'; |
137 | // $rrd_info['rrdup']['auto-update'] = true; |
138 | $rrd_info['rrdup']['fields'][] = array('name' => 'usertime', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
139 | $rrd_info['rrdup']['fields'][] = array('name' => 'systime', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
140 | $rrd_info['rrdup']['update'] = 'function { $sdata = posix_times(); return array("usertime"=>$sdata["cutime"],"systime"=>$sdata["cstime"]); }'; |
141 | $rrd_info['rrdup']['graph']['rows'][] = array('name'=>'systime', 'gType'=>'AREA', 'color'=>'#FF0000', 'legend'=>'System CPU time'); |
142 | $rrd_info['rrdup']['graph']['rows'][] = array('name'=>'usertime', 'gType'=>'AREA', 'color'=>'#0000FF', 'legend'=>'User CPU time', 'stack'=>true); |
143 | $rrd_info['rrdup']['graph']['scale'] = 0.01; |
144 | $rrd_info['rrdup']['graph']['units_length'] = 4; |
145 | $rrd_info['rrdup']['graph']['units_exponent'] = 0; |
146 | $rrd_info['rrdup']['graph']['label_y'] = 'RRD update (seconds)'; |
147 | $rrd_info['rrdup']['graph']['min_y'] = 0; |
148 | // $rrd_info['rrdup']['graph']['force_recreate'] = true; |
149 | |
4a778b7e |
150 | ?> |