| 1 | <?php |
| 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
| 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
| 4 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 5 | |
| 6 | // RRD info for CPU info |
| 7 | $rrd_info = array(); |
| 8 | $rrd_info['*']['graph']['path'] = 'graphs'; |
| 9 | // $rrd_info['*']['page']['graph_url'] = 'http://127.0.0.1/testbed/rrd/'; |
| 10 | $rrd_info['*']['graph']['units_length'] = 6; |
| 11 | // $rrd_info['*']['graph']['force_recreate'] = true; |
| 12 | |
| 13 | $rrd_info['index']['page']['type'] = 'index'; |
| 14 | // $rrd_info['index']['page']['index_ids'] = 'hd,-hd.root'; |
| 15 | // $rrd_info['index']['page']['scan_config'] = false; |
| 16 | $rrd_info['index']['page']['scan_files'] = true; |
| 17 | $rrd_info['index']['hidden'] = true; |
| 18 | |
| 19 | $rrd_info['overview']['page']['type'] = 'overview'; |
| 20 | $rrd_info['overview']['page']['index_ids'] = 'cpu,load,mem,rrdup'; |
| 21 | $rrd_info['overview']['page']['scan_config'] = false; |
| 22 | $rrd_info['overview']['page']['text_intro'] = 'Go to the <a href="?stat=index">index page</a> for a full list of all available statistics'; |
| 23 | // $rrd_info['overview']['hidden'] = true; |
| 24 | |
| 25 | $rrd_info['cpu']['file'] = 'system.cpu.rrd'; |
| 26 | $rrd_info['cpu']['auto-update'] = true; |
| 27 | $rrd_info['cpu']['fields'][] = array('name' => 'user', 'type' => 'DERIVE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U'); |
| 28 | $rrd_info['cpu']['fields'][] = array('name' => 'nice', 'type' => 'DERIVE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U'); |
| 29 | $rrd_info['cpu']['fields'][] = array('name' => 'system', 'type' => 'DERIVE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U'); |
| 30 | $rrd_info['cpu']['fields'][] = array('name' => 'idle', 'type' => 'DERIVE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U'); |
| 31 | $rrd_info['cpu']['fields'][] = array('name' => 'iowait', 'type' => 'DERIVE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U'); |
| 32 | $rrd_info['cpu']['fields'][] = array('name' => 'irq', 'type' => 'DERIVE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U'); |
| 33 | $rrd_info['cpu']['fields'][] = array('name' => 'softirq', 'type' => 'DERIVE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U'); |
| 34 | $rrd_info['cpu']['fields'][] = array('name' => 'total', 'type' => 'DERIVE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U'); |
| 35 | $rrd_info['cpu']['update'] = |
| 36 | 'function { |
| 37 | $udata = array("user"=>null,"nice"=>null,"system"=>null,"idle"=>null, |
| 38 | "iowait"=>null,"irq"=>null,"softirq"=>null, "total"=>null); |
| 39 | $sdata = file("/proc/stat"); |
| 40 | foreach ($sdata as $sline) { |
| 41 | if (preg_match("/^\s*cpu\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/", $sline, $regs)) { |
| 42 | $udata = array("user"=>$regs[1],"nice"=>$regs[2],"system"=>$regs[3],"idle"=>$regs[4], |
| 43 | "iowait"=>$regs[5],"irq"=>$regs[6],"softirq"=>$regs[7], |
| 44 | "total"=>$regs[1]+$regs[2]+$regs[3]+$regs[4]+$regs[5]+$regs[6]+$regs[7]); |
| 45 | } |
| 46 | } |
| 47 | return $udata; |
| 48 | }'; |
| 49 | $rrd_info['cpu']['graph']['rows'][] = array('name'=>'total', 'gType'=>''); |
| 50 | $rrd_info['cpu']['graph']['rows'][] = array('name'=>'softirq_tmp', 'dsname'=>'softirq', 'gType'=>''); |
| 51 | $rrd_info['cpu']['graph']['rows'][] = array('name'=>'irq_tmp', 'dsname'=>'irq', 'gType'=>''); |
| 52 | $rrd_info['cpu']['graph']['rows'][] = array('name'=>'iowait_tmp', 'dsname'=>'iowait', 'gType'=>''); |
| 53 | $rrd_info['cpu']['graph']['rows'][] = array('name'=>'system_tmp', 'dsname'=>'system', 'gType'=>''); |
| 54 | $rrd_info['cpu']['graph']['rows'][] = array('name'=>'nice_tmp', 'dsname'=>'nice', 'gType'=>''); |
| 55 | $rrd_info['cpu']['graph']['rows'][] = array('name'=>'user_tmp', 'dsname'=>'user', 'gType'=>''); |
| 56 | $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'); |
| 57 | $rrd_info['cpu']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'irq', 'rpn_expr'=>'irq_tmp,total,/,100,*', 'gType'=>'AREA', 'color'=>'#808080', 'legend'=>'IRQ', 'stack'=>true); |
| 58 | $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); |
| 59 | $rrd_info['cpu']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'system', 'rpn_expr'=>'system_tmp,total,/,100,*', 'gType'=>'AREA', 'color'=>'#FF0000', 'legend'=>'System', 'stack'=>true); |
| 60 | $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); |
| 61 | $rrd_info['cpu']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'user', 'rpn_expr'=>'user_tmp,total,/,100,*', 'gType'=>'AREA', 'color'=>'#0000FF', 'legend'=>'User', 'stack'=>true); |
| 62 | $rrd_info['cpu']['graph']['units_length'] = 4; |
| 63 | $rrd_info['cpu']['graph']['label_y'] = '% CPU Usage'; |
| 64 | $rrd_info['cpu']['graph']['min_y'] = 0; |
| 65 | $rrd_info['cpu']['graph']['max_y'] = 100; |
| 66 | $rrd_info['cpu']['graph']['fix_scale_y'] = true; |
| 67 | // $rrd_info['cpu']['graph']['force_recreate'] = true; |
| 68 | |
| 69 | $rrd_info['mem']['file'] = 'system.mem.rrd'; |
| 70 | $rrd_info['mem']['auto-update'] = true; |
| 71 | $rrd_info['mem']['fields'][] = array('name' => 'total', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
| 72 | $rrd_info['mem']['fields'][] = array('name' => 'used', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
| 73 | $rrd_info['mem']['fields'][] = array('name' => 'buffers', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
| 74 | $rrd_info['mem']['fields'][] = array('name' => 'cached', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
| 75 | $rrd_info['mem']['fields'][] = array('name' => 'swap_total', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
| 76 | $rrd_info['mem']['fields'][] = array('name' => 'swap_used', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
| 77 | $rrd_info['mem']['update'] = |
| 78 | 'function { |
| 79 | $sdata = explode("\n", `/usr/bin/free -wb`); |
| 80 | $udata = array("total"=>null,"used"=>null,"buffers"=>null,"cached"=>null, |
| 81 | "swap_total"=>null,"swap_used"=>null); |
| 82 | foreach ($sdata as $sline) { |
| 83 | if (preg_match("/Mem:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/", $sline, $regs)) { |
| 84 | $udata["total"] = $regs[1]; |
| 85 | $udata["used"] = $regs[2]; |
| 86 | $udata["buffers"] = $regs[5]; |
| 87 | $udata["cached"] = $regs[6]; |
| 88 | } |
| 89 | elseif (preg_match("/Swap:\s+(\d+)\s+(\d+)\s+(\d+)/", $sline, $regs)) { |
| 90 | $udata["swap_total"] = $regs[1]; |
| 91 | $udata["swap_used"] = $regs[2]; |
| 92 | } |
| 93 | } |
| 94 | return $udata; |
| 95 | }'; |
| 96 | $rrd_info['mem']['graph']['rows'][] = array('name'=>'total', 'gType'=>'LINE1', 'color'=>'#000000', 'legend'=>'Available'); |
| 97 | $rrd_info['mem']['graph']['rows'][] = array('name'=>'used', 'gType'=>'AREA', 'color'=>'#0000FF', 'legend'=>'Used'); |
| 98 | $rrd_info['mem']['graph']['rows'][] = array('name'=>'buffers', 'gType'=>'AREA', 'color'=>'#FFFF00', 'legend'=>'Buffers', 'stack'=>true); |
| 99 | $rrd_info['mem']['graph']['rows'][] = array('name'=>'cached', 'gType'=>'AREA', 'color'=>'#008000', 'legend'=>'Cache', 'stack'=>true); |
| 100 | $rrd_info['mem']['graph']['rows'][] = array('name'=>'swap_total', 'gType'=>'LINE1', 'color'=>'#CCCCCC', 'legend'=>'Swap avail.'); |
| 101 | $rrd_info['mem']['graph']['rows'][] = array('name'=>'swap_used', 'gType'=>'LINE2', 'color'=>'#00FFFF', 'legend'=>'Swap used'); |
| 102 | $rrd_info['mem']['graph']['units_binary'] = true; |
| 103 | $rrd_info['mem']['graph']['units_exponent'] = 6; |
| 104 | $rrd_info['mem']['graph']['units_length'] = 6; |
| 105 | $rrd_info['mem']['graph']['label_y'] = 'Memory'; |
| 106 | $rrd_info['mem']['graph']['min_y'] = 0; |
| 107 | // $rrd_info['mem']['graph']['max_y'] = 100; |
| 108 | // $rrd_info['mem']['graph']['fix_scale_y'] = true; |
| 109 | // $rrd_info['mem']['graph']['force_recreate'] = true; |
| 110 | $rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'total', 'gType'=>''); |
| 111 | $rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'swap_total', 'gType'=>''); |
| 112 | $rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'used_tmp', 'dsname'=>'used', 'gType'=>''); |
| 113 | $rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'buffers_tmp', 'dsname'=>'buffers', 'gType'=>''); |
| 114 | $rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'cached_tmp', 'dsname'=>'cached', 'gType'=>''); |
| 115 | $rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'swap_tmp', 'dsname'=>'swap_used', 'gType'=>''); |
| 116 | $rrd_info['mem']['graph.pct']['rows'][] = array('dType'=>'CDEF', 'name'=>'used', 'rpn_expr'=>'used_tmp,total,/,100,*', 'gType'=>'AREA', 'color'=>'#0000FF', 'legend'=>'Used'); |
| 117 | $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); |
| 118 | $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); |
| 119 | $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'); |
| 120 | $rrd_info['mem']['graph.pct']['units_exponent'] = 0; |
| 121 | $rrd_info['mem']['graph.pct']['units_length'] = 4; |
| 122 | $rrd_info['mem']['graph.pct']['label_y'] = '% Memory'; |
| 123 | $rrd_info['mem']['graph.pct']['min_y'] = 0; |
| 124 | $rrd_info['mem']['graph.pct']['max_y'] = 100; |
| 125 | $rrd_info['mem']['graph.pct']['fix_scale_y'] = true; |
| 126 | // $rrd_info['mem']['graph.pct']['force_recreate'] = true; |
| 127 | $rrd_info['mem']['page.pct']['graph_sub'] = 'pct'; |
| 128 | |
| 129 | $rrd_info['load']['file'] = 'system.load.rrd'; |
| 130 | $rrd_info['load']['auto-update'] = true; |
| 131 | $rrd_info['load']['fields'][] = array('name' => 'load1', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
| 132 | $rrd_info['load']['fields'][] = array('name' => 'load5', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
| 133 | $rrd_info['load']['fields'][] = array('name' => 'load15', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
| 134 | $rrd_info['load']['update'] = 'function { $sdata = explode(" ",file_get_contents("/proc/loadavg")); return array("load1"=>$sdata[0],"load5"=>$sdata[1],"load15"=>$sdata[2]); }'; |
| 135 | $rrd_info['load']['graph']['rows'][] = array('name'=>'load1', 'gType'=>'AREA', 'color'=>'#00CC00', 'legend'=>'1 Min.'); |
| 136 | $rrd_info['load']['graph']['rows'][] = array('name'=>'load5', 'gType'=>'LINE1', 'color'=>'#FF4000', 'legend'=>'5 Min.'); |
| 137 | $rrd_info['load']['graph']['rows'][] = array('name'=>'load15', 'gType'=>'LINE1', 'color'=>'#0000FF', 'legend'=>'15 Min.'); |
| 138 | $rrd_info['load']['graph']['units_length'] = 4; |
| 139 | $rrd_info['load']['graph']['units_exponent'] = 0; |
| 140 | $rrd_info['load']['graph']['label_y'] = 'Load average'; |
| 141 | $rrd_info['load']['graph']['min_y'] = 0; |
| 142 | // $rrd_info['load']['graph']['force_recreate'] = true; |
| 143 | $rrd_info['load']['page']['data_colorize'] = true; |
| 144 | |
| 145 | /* !!! be sure to call this one _last_ of all auto-update rrd stats */ |
| 146 | $rrd_info['rrdup']['file'] = 'test.rrdup.rrd'; |
| 147 | // $rrd_info['rrdup']['auto-update'] = true; |
| 148 | $rrd_info['rrdup']['fields'][] = array('name' => 'usertime', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
| 149 | $rrd_info['rrdup']['fields'][] = array('name' => 'systime', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); |
| 150 | $rrd_info['rrdup']['update'] = 'function { $sdata = posix_times(); return array("usertime"=>$sdata["cutime"],"systime"=>$sdata["cstime"]); }'; |
| 151 | $rrd_info['rrdup']['graph']['rows'][] = array('name'=>'systime', 'gType'=>'AREA', 'color'=>'#FF0000', 'legend'=>'System CPU time'); |
| 152 | $rrd_info['rrdup']['graph']['rows'][] = array('name'=>'usertime', 'gType'=>'AREA', 'color'=>'#0000FF', 'legend'=>'User CPU time', 'stack'=>true); |
| 153 | $rrd_info['rrdup']['graph']['scale'] = 0.01; |
| 154 | $rrd_info['rrdup']['graph']['units_length'] = 4; |
| 155 | $rrd_info['rrdup']['graph']['units_exponent'] = 0; |
| 156 | $rrd_info['rrdup']['graph']['label_y'] = 'RRD update (seconds)'; |
| 157 | $rrd_info['rrdup']['graph']['min_y'] = 0; |
| 158 | // $rrd_info['rrdup']['graph']['force_recreate'] = true; |
| 159 | |
| 160 | ?> |