From 4a778b7ef1e4bf6e2aaa31a83280cd3efface400 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 4 May 2007 15:06:46 +0000 Subject: [PATCH] current testbed version as of may 2007 --- testbed/rrd/rrd-config.inc.php | 1026 +++++++++++++++++++++++++++ testbed/rrd/rrd-stat.php | 22 + testbed/rrd/rrd-test.php | 21 + testbed/rrd/rrd-update.php | 30 + testbed/rrd/rrdstat.php-class | 1196 ++++++++++++++++++++++++++++++++ testbed/ua_list.php | 63 ++ testbed/ua_list_raw.txt | 288 ++++++++ testbed/ua_test.php | 4 +- 8 files changed, 2648 insertions(+), 2 deletions(-) create mode 100644 testbed/rrd/rrd-config.inc.php create mode 100644 testbed/rrd/rrd-stat.php create mode 100644 testbed/rrd/rrd-test.php create mode 100644 testbed/rrd/rrd-update.php create mode 100755 testbed/rrd/rrdstat.php-class create mode 100644 testbed/ua_list.php create mode 100755 testbed/ua_list_raw.txt diff --git a/testbed/rrd/rrd-config.inc.php b/testbed/rrd/rrd-config.inc.php new file mode 100644 index 0000000..38613e1 --- /dev/null +++ b/testbed/rrd/rrd-config.inc.php @@ -0,0 +1,1026 @@ +index page for a full list of all available statistics'; +// $rrd_info['overview']['hidden'] = true; + +$rrd_info['cpu']['file'] = 'system.cpu.rrd'; +$rrd_info['cpu']['auto-update'] = true; +$rrd_info['cpu']['fields'][] = array('name' => 'user', 'type' => 'COUNTER', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['cpu']['fields'][] = array('name' => 'nice', 'type' => 'COUNTER', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['cpu']['fields'][] = array('name' => 'system', 'type' => 'COUNTER', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['cpu']['fields'][] = array('name' => 'idle', 'type' => 'COUNTER', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['cpu']['fields'][] = array('name' => 'iowait', 'type' => 'COUNTER', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['cpu']['fields'][] = array('name' => 'irq', 'type' => 'COUNTER', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['cpu']['fields'][] = array('name' => 'softirq', 'type' => 'COUNTER', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['cpu']['fields'][] = array('name' => 'total', 'type' => 'COUNTER', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['cpu']['update'] = + 'function { + $sdata = file("/proc/stat"); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/^\s*cpu\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/", $sline, $regs)) { + $udata = array("user"=>$regs[1],"nice"=>$regs[2],"system"=>$regs[3],"idle"=>$regs[4], + "iowait"=>$regs[5],"irq"=>$regs[6],"softirq"=>$regs[7],"total"=>array_sum($regs)); + } + } + return $udata; + }'; +$rrd_info['cpu']['graph']['rows'][] = array('name'=>'total', 'gType'=>''); +$rrd_info['cpu']['graph']['rows'][] = array('name'=>'softirq_tmp', 'dsname'=>'softirq', 'gType'=>''); +$rrd_info['cpu']['graph']['rows'][] = array('name'=>'irq_tmp', 'dsname'=>'irq', 'gType'=>''); +$rrd_info['cpu']['graph']['rows'][] = array('name'=>'iowait_tmp', 'dsname'=>'iowait', 'gType'=>''); +$rrd_info['cpu']['graph']['rows'][] = array('name'=>'system_tmp', 'dsname'=>'system', 'gType'=>''); +$rrd_info['cpu']['graph']['rows'][] = array('name'=>'nice_tmp', 'dsname'=>'nice', 'gType'=>''); +$rrd_info['cpu']['graph']['rows'][] = array('name'=>'user_tmp', 'dsname'=>'user', 'gType'=>''); +$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'); +$rrd_info['cpu']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'irq', 'rpn_expr'=>'irq_tmp,total,/,100,*', 'gType'=>'AREA', 'color'=>'#808080', 'legend'=>'IRQ', 'stack'=>true); +$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); +$rrd_info['cpu']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'system', 'rpn_expr'=>'system_tmp,total,/,100,*', 'gType'=>'AREA', 'color'=>'#FF0000', 'legend'=>'System', 'stack'=>true); +$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); +$rrd_info['cpu']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'user', 'rpn_expr'=>'user_tmp,total,/,100,*', 'gType'=>'AREA', 'color'=>'#0000FF', 'legend'=>'User', 'stack'=>true); +$rrd_info['cpu']['graph']['units_length'] = 4; +$rrd_info['cpu']['graph']['label_y'] = '% CPU-Auslastung'; +$rrd_info['cpu']['graph']['min_y'] = 0; +$rrd_info['cpu']['graph']['max_y'] = 100; +$rrd_info['cpu']['graph']['fix_scale_y'] = true; +// $rrd_info['cpu']['graph']['force_recreate'] = true; + +$rrd_info['cpu0'] = $rrd_info['cpu']; +$rrd_info['cpu0']['file'] = 'system.cpu0.rrd'; +$rrd_info['cpu0']['update'] = + 'function { + $sdata = file("/proc/stat"); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/^\s*cpu0\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/", $sline, $regs)) { + $udata = array("user"=>$regs[1],"nice"=>$regs[2],"system"=>$regs[3],"idle"=>$regs[4], + "iowait"=>$regs[5],"irq"=>$regs[6],"softirq"=>$regs[7],"total"=>array_sum($regs)); + } + } + return $udata; + }'; + +$rrd_info['cpu1'] = $rrd_info['cpu']; +$rrd_info['cpu1']['file'] = 'system.cpu1.rrd'; +$rrd_info['cpu1']['update'] = + 'function { + $sdata = file("/proc/stat"); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/^\s*cpu1\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/", $sline, $regs)) { + $udata = array("user"=>$regs[1],"nice"=>$regs[2],"system"=>$regs[3],"idle"=>$regs[4], + "iowait"=>$regs[5],"irq"=>$regs[6],"softirq"=>$regs[7],"total"=>array_sum($regs)); + } + } + return $udata; + }'; + +$rrd_info['mem']['file'] = 'system.mem.rrd'; +$rrd_info['mem']['auto-update'] = true; +$rrd_info['mem']['fields'][] = array('name' => 'total', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['mem']['fields'][] = array('name' => 'used', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['mem']['fields'][] = array('name' => 'buffers', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['mem']['fields'][] = array('name' => 'cached', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['mem']['fields'][] = array('name' => 'swap_total', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['mem']['fields'][] = array('name' => 'swap_used', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['mem']['update'] = + 'function { + $sdata = explode("\n", `/usr/bin/free -b -o`); + $udata = array("total"=>null,"used"=>null,"buffers"=>null,"cached"=>null, + "swap_total"=>null,"swap_used"=>null); + foreach ($sdata as $sline) { + if (preg_match("/Mem:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/", $sline, $regs)) { + $udata["total"] = $regs[1]; $udata["used"] = $regs[2]-$regs[5]-$regs[6]; + $udata["buffers"] = $regs[5]; $udata["cached"] = $regs[6]; + } + elseif (preg_match("/Swap:\s+(\d+)\s+(\d+)\s+(\d+)/", $sline, $regs)) { + $udata["swap_total"] = $regs[1]; $udata["swap_used"] = $regs[2]; + } + } + return $udata; + }'; +$rrd_info['mem']['graph']['rows'][] = array('name'=>'total', 'gType'=>'LINE1', 'color'=>'#000000', 'legend'=>'Available'); +$rrd_info['mem']['graph']['rows'][] = array('name'=>'used', 'gType'=>'AREA', 'color'=>'#0000FF', 'legend'=>'Used'); +$rrd_info['mem']['graph']['rows'][] = array('name'=>'buffers', 'gType'=>'AREA', 'color'=>'#FFFF00', 'legend'=>'Buffers', 'stack'=>true); +$rrd_info['mem']['graph']['rows'][] = array('name'=>'cached', 'gType'=>'AREA', 'color'=>'#008000', 'legend'=>'Cache', 'stack'=>true); +$rrd_info['mem']['graph']['rows'][] = array('name'=>'swap_total', 'gType'=>'LINE1', 'color'=>'#CCCCCC', 'legend'=>'Swap avail.'); +$rrd_info['mem']['graph']['rows'][] = array('name'=>'swap_used', 'gType'=>'LINE2', 'color'=>'#00FFFF', 'legend'=>'Swap used'); +$rrd_info['mem']['graph']['units_binary'] = true; +$rrd_info['mem']['graph']['units_exponent'] = 6; +$rrd_info['mem']['graph']['units_length'] = 6; +$rrd_info['mem']['graph']['label_y'] = 'Memory'; +$rrd_info['mem']['graph']['min_y'] = 0; +// $rrd_info['mem']['graph']['max_y'] = 100; +// $rrd_info['mem']['graph']['fix_scale_y'] = true; +// $rrd_info['mem']['graph']['force_recreate'] = true; +$rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'total', 'gType'=>''); +$rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'swap_total', 'gType'=>''); +$rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'used_tmp', 'dsname'=>'used', 'gType'=>''); +$rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'buffers_tmp', 'dsname'=>'buffers', 'gType'=>''); +$rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'cached_tmp', 'dsname'=>'cached', 'gType'=>''); +$rrd_info['mem']['graph.pct']['rows'][] = array('name'=>'swap_tmp', 'dsname'=>'swap_used', 'gType'=>''); +$rrd_info['mem']['graph.pct']['rows'][] = array('dType'=>'CDEF', 'name'=>'used', 'rpn_expr'=>'used_tmp,total,/,100,*', 'gType'=>'AREA', 'color'=>'#0000FF', 'legend'=>'Used'); +$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); +$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); +$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'); +$rrd_info['mem']['graph.pct']['units_exponent'] = 0; +$rrd_info['mem']['graph.pct']['units_length'] = 4; +$rrd_info['mem']['graph.pct']['label_y'] = '% Memory'; +$rrd_info['mem']['graph.pct']['min_y'] = 0; +$rrd_info['mem']['graph.pct']['max_y'] = 100; +$rrd_info['mem']['graph.pct']['fix_scale_y'] = true; +// $rrd_info['mem']['graph.pct']['force_recreate'] = true; +$rrd_info['mem']['page.pct']['graph_sub'] = 'pct'; + +$rrd_info['load']['file'] = 'system.load.rrd'; +$rrd_info['load']['auto-update'] = true; +$rrd_info['load']['fields'][] = array('name' => 'load1', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['load']['fields'][] = array('name' => 'load5', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['load']['fields'][] = array('name' => 'load15', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['load']['update'] = 'function { $sdata = explode(" ",file_get_contents("/proc/loadavg")); return array("load1"=>$sdata[0],"load5"=>$sdata[1],"load15"=>$sdata[2]); }'; +$rrd_info['load']['graph']['rows'][] = array('name'=>'load1', 'gType'=>'AREA', 'color'=>'#00CC00', 'legend'=>'1 Min.'); +$rrd_info['load']['graph']['rows'][] = array('name'=>'load5', 'gType'=>'LINE1', 'color'=>'#FF4000', 'legend'=>'5 Min.'); +$rrd_info['load']['graph']['rows'][] = array('name'=>'load15', 'gType'=>'LINE1', 'color'=>'#0000FF', 'legend'=>'15 Min.'); +$rrd_info['load']['graph']['units_length'] = 4; +$rrd_info['load']['graph']['units_exponent'] = 0; +$rrd_info['load']['graph']['label_y'] = 'Load average'; +$rrd_info['load']['graph']['min_y'] = 0; +// $rrd_info['load']['graph']['force_recreate'] = true; +$rrd_info['load']['page']['data_colorize'] = true; + +$rrd_info['hd']['graph-only'] = true; +$rrd_info['hd']['graph']['rows'][] = array('name'=>'root_used', 'dsname'=>'used', 'dsfile'=>'hd.root.rrd', 'gType'=>'',); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'root_total', 'dsname'=>'total', 'dsfile'=>'hd.root.rrd', 'gType'=>''); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'home_used', 'dsname'=>'used', 'dsfile'=>'hd.home.rrd', 'gType'=>'',); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'home_total', 'dsname'=>'total', 'dsfile'=>'hd.home.rrd', 'gType'=>''); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'backup_used', 'dsname'=>'used', 'dsfile'=>'hd.backup.rrd', 'gType'=>'',); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'backup_total', 'dsname'=>'total', 'dsfile'=>'hd.backup.rrd', 'gType'=>''); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'daten_used', 'dsname'=>'used', 'dsfile'=>'hd.daten.rrd', 'gType'=>'',); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'daten_total', 'dsname'=>'total', 'dsfile'=>'hd.daten.rrd', 'gType'=>''); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'media_used', 'dsname'=>'used', 'dsfile'=>'hd.media.rrd', 'gType'=>'',); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'media_total', 'dsname'=>'total', 'dsfile'=>'hd.media.rrd', 'gType'=>''); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'mozilla_used', 'dsname'=>'used', 'dsfile'=>'hd.mozilla.rrd', 'gType'=>'',); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'mozilla_total', 'dsname'=>'total', 'dsfile'=>'hd.mozilla.rrd', 'gType'=>''); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'temp_used', 'dsname'=>'used', 'dsfile'=>'hd.temp.rrd', 'gType'=>'',); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'temp_total', 'dsname'=>'total', 'dsfile'=>'hd.temp.rrd', 'gType'=>''); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'trans_used', 'dsname'=>'used', 'dsfile'=>'hd.trans.rrd', 'gType'=>'',); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'trans_total', 'dsname'=>'total', 'dsfile'=>'hd.trans.rrd', 'gType'=>''); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'video_used', 'dsname'=>'used', 'dsfile'=>'hd.video.rrd', 'gType'=>'',); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'video_total', 'dsname'=>'total', 'dsfile'=>'hd.video.rrd', 'gType'=>''); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'root_old_used', 'dsname'=>'used', 'dsfile'=>'hd.root_old.rrd', 'gType'=>'',); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'root_old_total', 'dsname'=>'total', 'dsfile'=>'hd.root_old.rrd', 'gType'=>''); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'win32sys_used', 'dsname'=>'used', 'dsfile'=>'hd.win32sys.rrd', 'gType'=>'',); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'win32sys_total', 'dsname'=>'total', 'dsfile'=>'hd.win32sys.rrd', 'gType'=>''); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'win1_used', 'dsname'=>'used', 'dsfile'=>'hd.win1.rrd', 'gType'=>'',); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'win1_total', 'dsname'=>'total', 'dsfile'=>'hd.win1.rrd', 'gType'=>''); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'win2_used', 'dsname'=>'used', 'dsfile'=>'hd.win2.rrd', 'gType'=>'',); +$rrd_info['hd']['graph']['rows'][] = array('name'=>'win2_total', 'dsname'=>'total', 'dsfile'=>'hd.win2.rrd', 'gType'=>''); +$rrd_info['hd']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'root', 'rpn_expr'=>'root_used,root_total,/,100,*', 'gType'=>'LINE1', 'color'=>'#0000FF', 'legend'=>'Root'); +$rrd_info['hd']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'home', 'rpn_expr'=>'home_used,home_total,/,100,*', 'gType'=>'LINE1', 'color'=>'#008000', 'legend'=>'Home'); +$rrd_info['hd']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'backup', 'rpn_expr'=>'backup_used,backup_total,/,100,*', 'gType'=>'LINE1', 'color'=>'#CCCC00', 'legend'=>'Backup'); +$rrd_info['hd']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'daten', 'rpn_expr'=>'daten_used,daten_total,/,100,*', 'gType'=>'LINE1', 'color'=>'#0080FF', 'legend'=>'Daten'); +$rrd_info['hd']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'media', 'rpn_expr'=>'media_used,media_total,/,100,*', 'gType'=>'LINE1', 'color'=>'#FF6000', 'legend'=>'Media'); +$rrd_info['hd']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'mozilla', 'rpn_expr'=>'mozilla_used,mozilla_total,/,100,*', 'gType'=>'LINE1', 'color'=>'#FF0000', 'legend'=>'Mozilla'); +$rrd_info['hd']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'temp', 'rpn_expr'=>'temp_used,temp_total,/,100,*', 'gType'=>'LINE1', 'color'=>'#000000', 'legend'=>'Temp'); +$rrd_info['hd']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'trans', 'rpn_expr'=>'trans_used,trans_total,/,100,*', 'gType'=>'LINE1', 'color'=>'#808080', 'legend'=>'Trans'); +$rrd_info['hd']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'video', 'rpn_expr'=>'video_used,video_total,/,100,*', 'gType'=>'LINE1', 'color'=>'#808000', 'legend'=>'Video'); +$rrd_info['hd']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'root_old', 'rpn_expr'=>'root_old_used,root_old_total,/,100,*', 'gType'=>'LINE1', 'color'=>'#CCCCCC', 'legend'=>'Old Root'); +$rrd_info['hd']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'win32sys', 'rpn_expr'=>'win32sys_used,win32sys_total,/,100,*', 'gType'=>'LINE1', 'color'=>'#00CC00', 'legend'=>'Old Win98'); +$rrd_info['hd']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'win1', 'rpn_expr'=>'win1_used,win1_total,/,100,*', 'gType'=>'LINE1', 'color'=>'#FF00CC', 'legend'=>'Win 1'); +$rrd_info['hd']['graph']['rows'][] = array('dType'=>'CDEF', 'name'=>'win2', 'rpn_expr'=>'win2_used,win2_total,/,100,*', 'gType'=>'LINE1', 'color'=>'#FF80CC', 'legend'=>'Win 2'); +// $rrd_info['hd.root']['graph']['units_length'] = 4; +$rrd_info['hd']['graph']['label_y'] = '% Used'; +$rrd_info['hd']['graph']['units_exponent'] = 0; +$rrd_info['hd']['graph']['units_length'] = 4; +$rrd_info['hd']['graph']['min_y'] = 0; +$rrd_info['hd']['graph']['max_y'] = 100; +$rrd_info['hd']['graph']['fix_scale_y'] = true; +// $rrd_info['hd']['graph']['force_recreate'] = true; +$rrd_info['hd']['page']['show_update'] = false; + +$rrd_info['hd.root']['file'] = 'hd.root.rrd'; +$rrd_info['hd.root']['auto-update'] = true; +$rrd_info['hd.root']['fields'][] = array('name' => 'used', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['hd.root']['fields'][] = array('name' => 'total', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['hd.root']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +$rrd_info['hd.root']['graph']['rows'][] = array('name'=>'used', 'gType'=>'AREA', 'color'=>'#00CC00', 'legend'=>'Used'); +$rrd_info['hd.root']['graph']['rows'][] = array('name'=>'total', 'gType'=>'LINE1', 'color'=>'#808080', 'legend'=>'Available'); +// $rrd_info['hd.root']['graph']['units_length'] = 4; +$rrd_info['hd.root']['graph']['label_y'] = 'Bytes'; +$rrd_info['hd.root']['graph']['units_binary'] = true; +$rrd_info['hd.root']['graph']['scale'] = 1024; +$rrd_info['hd.root']['graph']['min_y'] = 0; +// $rrd_info['hd.root']['graph']['force_recreate'] = true; + +$rrd_info['hd.home'] = $rrd_info['hd.root']; +$rrd_info['hd.home']['file'] = 'hd.home.rrd'; +$rrd_info['hd.home']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/home$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.home']['graph']['force_recreate'] = true; + +$rrd_info['hd.backup'] = $rrd_info['hd.home']; +$rrd_info['hd.backup']['file'] = 'hd.backup.rrd'; +$rrd_info['hd.backup']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/backup$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.backup']['graph']['force_recreate'] = true; + +$rrd_info['hd.backup-x'] = $rrd_info['hd.home']; +$rrd_info['hd.backup-x']['file'] = 'hd.backup-x.rrd'; +$rrd_info['hd.backup-x']['update'] = + 'print("L\nL");'; +// $rrd_info['hd.backup-x']['graph']['force_recreate'] = true; + +$rrd_info['hd.boot_old'] = $rrd_info['hd.home']; +$rrd_info['hd.boot_old']['file'] = 'hd.boot_old.rrd'; +$rrd_info['hd.boot_old']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/boot_old$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.boot_old']['graph']['force_recreate'] = true; + +$rrd_info['hd.daten'] = $rrd_info['hd.home']; +$rrd_info['hd.daten']['file'] = 'hd.daten.rrd'; +$rrd_info['hd.daten']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/daten$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.daten']['graph']['force_recreate'] = true; + +$rrd_info['hd.media'] = $rrd_info['hd.home']; +$rrd_info['hd.media']['file'] = 'hd.media.rrd'; +$rrd_info['hd.media']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/media$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.media']['graph']['force_recreate'] = true; + +$rrd_info['hd.mozilla'] = $rrd_info['hd.home']; +$rrd_info['hd.mozilla']['file'] = 'hd.mozilla.rrd'; +$rrd_info['hd.mozilla']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/mozilla$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.mozilla']['graph']['force_recreate'] = true; + +$rrd_info['hd.root_old'] = $rrd_info['hd.home']; +$rrd_info['hd.root_old']['file'] = 'hd.root_old.rrd'; +$rrd_info['hd.root_old']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/root_old$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.root_old']['graph']['force_recreate'] = true; + +$rrd_info['hd.temp'] = $rrd_info['hd.home']; +$rrd_info['hd.temp']['file'] = 'hd.temp.rrd'; +$rrd_info['hd.temp']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/temp$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.temp']['graph']['force_recreate'] = true; + +$rrd_info['hd.trans'] = $rrd_info['hd.home']; +$rrd_info['hd.trans']['file'] = 'hd.trans.rrd'; +$rrd_info['hd.trans']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/trans$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.trans']['graph']['force_recreate'] = true; + +$rrd_info['hd.video'] = $rrd_info['hd.home']; +$rrd_info['hd.video']['file'] = 'hd.video.rrd'; +$rrd_info['hd.video']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/video$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.video']['graph']['force_recreate'] = true; + +$rrd_info['hd.win1'] = $rrd_info['hd.home']; +$rrd_info['hd.win1']['file'] = 'hd.win1.rrd'; +$rrd_info['hd.win1']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/win1$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.win1']['graph']['force_recreate'] = true; + +$rrd_info['hd.win2'] = $rrd_info['hd.home']; +$rrd_info['hd.win2']['file'] = 'hd.win2.rrd'; +$rrd_info['hd.win2']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/win2$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.win2']['graph']['force_recreate'] = true; + +$rrd_info['hd.win32sys'] = $rrd_info['hd.root']; +$rrd_info['hd.win32sys']['file'] = 'hd.win32sys.rrd'; +$rrd_info['hd.win32sys']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/win32sys$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.win32sys']['graph']['force_recreate'] = true; + +$rrd_info['hd.old.root'] = $rrd_info['hd.root']; +$rrd_info['hd.old.root']['file'] = 'hd.old.root.rrd'; +$rrd_info['hd.old.root']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/old\/root$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.old.root']['graph']['force_recreate'] = true; + +$rrd_info['hd.old.home'] = $rrd_info['hd.root']; +$rrd_info['hd.old.home']['file'] = 'hd.old.home.rrd'; +$rrd_info['hd.old.home']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/old\/home$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.old.home']['graph']['force_recreate'] = true; + +$rrd_info['hd.old.backup'] = $rrd_info['hd.home']; +$rrd_info['hd.old.backup']['file'] = 'hd.old.backup.rrd'; +$rrd_info['hd.old.backup']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/old\/backup$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.old.backup']['graph']['force_recreate'] = true; + +$rrd_info['hd.backup-x'] = $rrd_info['hd.home']; +$rrd_info['hd.backup-x']['file'] = 'hd.backup-x.rrd'; +$rrd_info['hd.backup-x']['update'] = + 'print("L\nL");'; +// $rrd_info['hd.backup-x']['graph']['force_recreate'] = true; + +$rrd_info['hd.old.boot_old'] = $rrd_info['hd.home']; +$rrd_info['hd.old.boot_old']['file'] = 'hd.old.boot_old.rrd'; +$rrd_info['hd.old.boot_old']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/old\/boot_old$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.old.boot_old']['graph']['force_recreate'] = true; + +$rrd_info['hd.old.daten'] = $rrd_info['hd.home']; +$rrd_info['hd.old.daten']['file'] = 'hd.old.daten.rrd'; +$rrd_info['hd.old.daten']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/old\/daten$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.old.daten']['graph']['force_recreate'] = true; + +$rrd_info['hd.old.media'] = $rrd_info['hd.home']; +$rrd_info['hd.old.media']['file'] = 'hd.old.media.rrd'; +$rrd_info['hd.old.media']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/old\/media$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.old.media']['graph']['force_recreate'] = true; + +$rrd_info['hd.old.mozilla'] = $rrd_info['hd.home']; +$rrd_info['hd.old.mozilla']['file'] = 'hd.old.mozilla.rrd'; +$rrd_info['hd.old.mozilla']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/old\/mozilla$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.old.mozilla']['graph']['force_recreate'] = true; + +$rrd_info['hd.old.root_old'] = $rrd_info['hd.home']; +$rrd_info['hd.old.root_old']['file'] = 'hd.old.root_old.rrd'; +$rrd_info['hd.old.root_old']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/old\/root_old$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.old.root_old']['graph']['force_recreate'] = true; + +$rrd_info['hd.old.temp'] = $rrd_info['hd.home']; +$rrd_info['hd.old.temp']['file'] = 'hd.old.temp.rrd'; +$rrd_info['hd.old.temp']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/old\/temp$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.old.temp']['graph']['force_recreate'] = true; + +$rrd_info['hd.old.trans'] = $rrd_info['hd.home']; +$rrd_info['hd.old.trans']['file'] = 'hd.old.trans.rrd'; +$rrd_info['hd.old.trans']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/old\/trans$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.old.trans']['graph']['force_recreate'] = true; + +$rrd_info['hd.old.video'] = $rrd_info['hd.home']; +$rrd_info['hd.old.video']['file'] = 'hd.old.video.rrd'; +$rrd_info['hd.old.video']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/old\/video$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.old.video']['graph']['force_recreate'] = true; + +$rrd_info['hd.old.win1'] = $rrd_info['hd.home']; +$rrd_info['hd.old.win1']['file'] = 'hd.old.win1.rrd'; +$rrd_info['hd.old.win1']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/old\/win1$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.old.win1']['graph']['force_recreate'] = true; + +$rrd_info['hd.old.win2'] = $rrd_info['hd.home']; +$rrd_info['hd.old.win2']['file'] = 'hd.old.win2.rrd'; +$rrd_info['hd.old.win2']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/old\/win2$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.old.win2']['graph']['force_recreate'] = true; + +$rrd_info['hd.old.win32sys'] = $rrd_info['hd.root']; +$rrd_info['hd.old.win32sys']['file'] = 'hd.old.win32sys.rrd'; +$rrd_info['hd.old.win32sys']['update'] = + 'function { + $sdata = explode("\n", `/bin/df -k -l`); $udata = array(); + foreach ($sdata as $sline) { + if (preg_match("/(\d+)\s+(\d+)\s+\d+\s+\d+%\s+\/mnt\/old\/win32sys$/", $sline, $regs)) { + $udata = array("total"=>$regs[1], "used"=>$regs[2]); + } + } + return $udata; + }'; +// $rrd_info['hd.old.win32sys']['graph']['force_recreate'] = true; + +$rrd_info['hdd.temp']['file'] = 'hdd.temp.rrd'; +$rrd_info['hdd.temp']['auto-update'] = true; +$rrd_info['hdd.temp']['fields'][] = array('name' => 'ibm30', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['hdd.temp']['fields'][] = array('name' => 'hit160', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['hdd.temp']['fields'][] = array('name' => 'sg320', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['hdd.temp']['update'] = + 'function { + $sdata = explode("\n", `hddtemp /dev/sda /dev/hda /dev/hdb`); + $udata = array("ibm30"=>null,"hit160"=>null,"sg320"=>null); + foreach ($sdata as $sline) { + if (preg_match("/IBM-DTLA-307030:\s+([+-]?[\d\.]+)\s*.C/", $sline, $regs)) { $udata["ibm30"] = $regs[1]; } + elseif (preg_match("/HDS722516VLAT80:\s+([+-]?[\d\.]+)\s*.C/", $sline, $regs)) { $udata["hit160"] = $regs[1]; } + elseif (preg_match("/ST3320620AS:\s+([+-]?[\d\.]+)\s*.C/", $sline, $regs)) { $udata["sg320"] = $regs[1]; } + } + return $udata; + }'; +$rrd_info['hdd.temp']['graph']['rows'][] = array('name'=>'ibm30', 'gType'=>'LINE1', 'color'=>'#808080', 'legend'=>'IBM 30 GB'); +$rrd_info['hdd.temp']['graph']['rows'][] = array('name'=>'hit160', 'gType'=>'LINE1', 'color'=>'#FF0000', 'legend'=>'Hitachi 160 GB'); +$rrd_info['hdd.temp']['graph']['rows'][] = array('name'=>'sg320', 'gType'=>'LINE1', 'color'=>'#FF8000', 'legend'=>'Seagate 320 GB'); +$rrd_info['hdd.temp']['graph']['units_length'] = 4; +$rrd_info['hdd.temp']['graph']['label_y'] = '°C'; +// $rrd_info['hdd.temp']['graph']['max_y'] = 13; +// $rrd_info['hdd.temp']['graph']['min_y'] = -13; + +$rrd_info['video.temp']['file'] = 'video.temp.rrd'; +$rrd_info['video.temp']['auto-update'] = true; +$rrd_info['video.temp']['fields'][] = array('name' => 'gpu_core_temp', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['video.temp']['fields'][] = array('name' => 'gpu_temp', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['video.temp']['update'] = + 'function { + $udata = array("gpu_core_temp"=>null,"gpu_temp"=>null); + $sdata = explode("\n", `nvidia-settings --query GPUCoreTemp 2>&1`); + foreach ($sdata as $sline) { + if (preg_match("/Attribute .GPUCoreTemp.+:\s+([+-]?[\d\.]+)\./", $sline, $regs)) { + $udata["gpu_core_temp"] = $regs[1]; + } + } + $sdata = explode("\n", `nvclock -T`); + foreach ($sdata as $sline) { + if (preg_match("/GPU temperature:\s+([+-]?[\d\.]+)C/", $sline, $regs)) { + $udata["gpu_temp"] = $regs[1]; + } + } + return $udata; + }'; +$rrd_info['video.temp']['graph']['rows'][] = array('name'=>'gpu_core_temp', 'gType'=>'LINE1', 'color'=>'#808080', 'legend'=>'GPU Core Temp'); +$rrd_info['video.temp']['graph']['rows'][] = array('name'=>'gpu_temp', 'gType'=>'LINE1', 'color'=>'#FF8080', 'legend'=>'GPU Temp'); +$rrd_info['video.temp']['graph']['units_length'] = 4; +$rrd_info['video.temp']['graph']['label_y'] = '°C'; +// $rrd_info['video.temp']['graph']['max_y'] = 13; +// $rrd_info['video.temp']['graph']['min_y'] = -13; + +// SNMP interfaces +$rrd_info['eth0']['file'] = 'net.eth0.rrd'; +$rrd_info['eth0']['auto-update'] = true; +$rrd_info['eth0']['fields'][] = array('name'=>'incoming', 'type'=>'COUNTER', + 'heartbeat'=>600, 'min'=>'U', 'max'=>'U', 'update'=>'snmp-if:eth0:in', 'legend'=>'Incoming'); +$rrd_info['eth0']['fields'][] = array('name'=>'outgoing', 'type'=>'COUNTER', + 'heartbeat'=>600, 'min'=>'U', 'max'=>'U', 'update'=>'snmp-if:eth0:out', 'legend'=>'Outgoing'); +$rrd_info['eth0']['graph']['label_y'] = 'Bytes per second'; + +$rrd_info['eth1']['file'] = 'net.eth1.rrd'; +$rrd_info['eth1']['auto-update'] = true; +$rrd_info['eth1']['fields'][] = array('name'=>'incoming', 'type'=>'COUNTER', + 'heartbeat'=>600, 'min'=>'U', 'max'=>'U', 'update'=>'snmp-if:eth1:in', 'legend'=>'Incoming'); +$rrd_info['eth1']['fields'][] = array('name'=>'outgoing', 'type'=>'COUNTER', + 'heartbeat'=>600, 'min'=>'U', 'max'=>'U', 'update'=>'snmp-if:eth1:out', 'legend'=>'Outgoing'); +$rrd_info['eth1']['graph']['label_y'] = 'Bytes per second'; +// $rrd_info['eth1']['graph']['force_recreate'] = true; + +$rrd_info['loopback']['file'] = 'net.loopback.rrd'; +$rrd_info['loopback']['auto-update'] = true; +$rrd_info['loopback']['fields'][] = array('name'=>'incoming', 'type'=>'COUNTER', + 'heartbeat'=>600, 'min'=>'U', 'max'=>'U', 'update'=>'snmp-if:lo:in', 'legend'=>'Incoming'); +$rrd_info['loopback']['fields'][] = array('name'=>'outgoing', 'type'=>'COUNTER', + 'heartbeat'=>600, 'min'=>'U', 'max'=>'U', 'update'=>'snmp-if:lo:out', 'legend'=>'Outgoing'); +$rrd_info['loopback']['graph']['label_y'] = 'Bytes per second'; + +$rrd_info['connect']['file'] = 'net.connect.rrd'; +$rrd_info['connect']['auto-update'] = true; +$rrd_info['connect']['fields'][] = array('name' => 'listen', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['connect']['fields'][] = array('name' => 'run_http', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['connect']['fields'][] = array('name' => 'run_other', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['connect']['fields'][] = array('name' => 'rest_http', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['connect']['fields'][] = array('name' => 'rest_other', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['connect']['fields'][] = array('name' => 'udp', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['connect']['update'] = + 'function { + $sdata = explode("\n", `LANG=C /bin/netstat -n -a`); + $udata = array("listen"=>0,"run_http"=>0,"run_other"=>0,"rest_http"=>0,"rest_other"=>0,"udp"=>0); + foreach ($sdata as $sline) { + if (substr($sline, 0, 3) == "tcp") { + if (preg_match("/LISTEN\s*$/", $sline)) { $udata["listen"]++; } + elseif (preg_match("/:80\s+[\d\.:*]+\s+ESTABLISHED\s*/", $sline)) { $udata["run_http"]++; } + elseif (preg_match("/^tcp\s+\d+\s+\d+\s+[\d\.]+:80/", $sline)) { $udata["rest_http"]++; } + elseif (preg_match("/ESTABLISHED\s*$/", $sline)) { $udata["run_other"]++; } + else { $udata["rest_other"]++; } + } + elseif (substr($sline, 0, 3) == "udp") { $udata["udp"]++; } + } + return $udata; + }'; +$rrd_info['connect']['graph']['rows'][] = array('name'=>'listen', 'gType'=>'AREA', 'color'=>'#CCCCCC', + 'legend'=>'LISTEN', 'legend_long'=>'LISTEN-Verbindungen'); +$rrd_info['connect']['graph']['rows'][] = array('name'=>'run_http', 'gType'=>'AREA', 'color'=>'#0000FF', + 'legend'=>'HTTPconn', 'legend_long'=>'Aktive HTTP-Verbindungen', 'stack'=>true); +$rrd_info['connect']['graph']['rows'][] = array('name'=>'rest_http', 'gType'=>'AREA', 'color'=>'#8080FF', + 'legend'=>'HTTPwait', 'legend_long'=>'Wartende HTTP-Verbindungen', 'stack'=>true); +$rrd_info['connect']['graph']['rows'][] = array('name'=>'run_other', 'gType'=>'AREA', 'color'=>'#FF0000', + 'legend'=>'TCPconn', 'legend_long'=>'Aktive TCP-Verbindungen (außer HTTP)', 'stack'=>true); +$rrd_info['connect']['graph']['rows'][] = array('name'=>'rest_other', 'gType'=>'AREA', 'color'=>'#FF8080', + 'legend'=>'TCPwait', 'legend_long'=>'Wartende TCP-Verbindungen (außer HTTP)', 'stack'=>true); +$rrd_info['connect']['graph']['rows'][] = array('name'=>'udp', 'gType'=>'AREA', 'color'=>'#00CC00', + 'legend'=>'UDP', 'legend_long'=>'UDP-Verbindungen', 'stack'=>true); +$rrd_info['connect']['graph']['units_length'] = 4; +$rrd_info['connect']['graph']['label_y'] = 'Network Sockets'; +$rrd_info['connect']['graph']['min_y'] = 0; +// $rrd_info['connect']['graph']['force_recreate'] = true; + +$rrd_info['process']['file'] = 'system.process.rrd'; +$rrd_info['process']['auto-update'] = true; +$rrd_info['process']['fields'][] = array('name' => 'ps_httpd', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['process']['fields'][] = array('name' => 'ps_other', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['process']['fields'][] = array('name' => 'psnum', 'type' => 'DERIVE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U'); +$rrd_info['process']['update'] = + 'function { + $sdata = explode("\n", `LANG=C /bin/ps -e`); + $udata = array("ps_httpd"=>0,"ps_other"=>0); + foreach ($sdata as $sline) { + if (strpos($sline, "httpd2-prefork")) { $udata["ps_httpd"]++; } + else { $udata["ps_other"]++; } + } + $udata["psnum"] = posix_getpid(); + return $udata; + }'; +$rrd_info['process']['graph']['rows'][] = array('name'=>'ps_httpd', 'gType'=>'AREA', 'color'=>'#0000FF', 'legend'=>'HTTP'); +$rrd_info['process']['graph']['rows'][] = array('name'=>'ps_other', 'gType'=>'AREA', 'color'=>'#FF0000', 'legend'=>'other', 'stack'=>true); +$rrd_info['process']['graph']['rows'][] = array('name'=>'psnum', 'scale'=>3.6, 'gType'=>'LINE1', 'color'=>'#00CC00', 'legend'=>'k ps/hour'); +$rrd_info['process']['graph']['label_y'] = 'Processes'; +$rrd_info['process']['graph']['min_y'] = 0; +// $rrd_info['process']['graph']['force_recreate'] = true; +$rrd_info['process']['graph.ps']['rows'][] = array('name'=>'ps_httpd', 'gType'=>'AREA', 'color'=>'#0000FF', 'legend'=>'HTTP'); +$rrd_info['process']['graph.ps']['rows'][] = array('name'=>'ps_other', 'gType'=>'AREA', 'color'=>'#FF0000', 'legend'=>'other', 'stack'=>true); +$rrd_info['process']['graph.ps']['label_y'] = 'Processes'; +$rrd_info['process']['graph.ps']['min_y'] = 0; +// $rrd_info['process']['graph.ps']['force_recreate'] = true; +$rrd_info['process']['page.ps']['graph_sub'] = 'ps'; +$rrd_info['process']['graph.pi']['rows'][] = array('name'=>'psnum', 'scale'=>3600, 'gType'=>'LINE1', 'color'=>'#000000', 'legend'=>'started processes per hour'); +$rrd_info['process']['graph.pi']['label_y'] = ''; +$rrd_info['process']['graph.pi']['min_y'] = 0; +// $rrd_info['process']['graph.pi']['force_recreate'] = true; +$rrd_info['process']['page.pi']['graph_sub'] = 'pi'; + +$rrd_info['temp']['graph-only'] = true; +$rrd_info['temp']['graph']['rows'][] = array('name'=>'cpu_temp', 'dsfile'=>'sensors.temp.rrd', 'gType'=>'LINE1', + 'color'=>'#0000FF', 'legend'=>'CPU'); +$rrd_info['temp']['graph']['rows'][] = array('name'=>'mb_temp', 'dsfile'=>'sensors.temp.rrd', 'gType'=>'LINE1', + 'color'=>'#008000', 'legend'=>'MB'); +$rrd_info['temp']['graph']['rows'][] = array('name'=>'gpu_temp', 'dsfile'=>'video.temp.rrd', 'gType'=>'LINE1', + 'color'=>'#0080FF', 'legend'=>'GPU'); +$rrd_info['temp']['graph']['rows'][] = array('name'=>'ibm30', 'dsfile'=>'hdd.temp.rrd', 'gType'=>'LINE1', + 'color'=>'#808080', 'legend'=>'HD/IBM30'); +$rrd_info['temp']['graph']['rows'][] = array('name'=>'hit160', 'dsfile'=>'hdd.temp.rrd', 'gType'=>'LINE1', + 'color'=>'#FF0000', 'legend'=>'HD/HITACHI160'); +$rrd_info['temp']['graph']['rows'][] = array('name'=>'sg320', 'dsfile'=>'hdd.temp.rrd', 'gType'=>'LINE1', + 'color'=>'#FF8000', 'legend'=>'HD/Seagate320'); +$rrd_info['temp']['graph']['label_y'] = '°C'; +$rrd_info['temp']['graph']['units_exponent'] = 0; +$rrd_info['temp']['graph']['units_length'] = 4; +//$rrd_info['temp']['graph']['min_y'] = 0; +//$rrd_info['temp']['graph']['max_y'] = 100; +//$rrd_info['temp']['graph']['fix_scale_y'] = true; +// $rrd_info['temp']['graph']['force_recreate'] = true; +$rrd_info['temp']['page']['show_update'] = false; + +$rrd_info['ping.gateway']['file'] = 'net.ping.gateway.rrd'; +$rrd_info['ping.gateway']['auto-update'] = true; +$rrd_info['ping.gateway']['fields'][] = array('name' => 'single_min', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U'); +$rrd_info['ping.gateway']['fields'][] = array('name' => 'single_avg', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U'); +$rrd_info['ping.gateway']['fields'][] = array('name' => 'single_max', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U'); +$rrd_info['ping.gateway']['fields'][] = array('name' => 'single_loss', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 0, 'max' => 100); +$rrd_info['ping.gateway']['fields'][] = array('name' => 'flood_min', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U'); +$rrd_info['ping.gateway']['fields'][] = array('name' => 'flood_avg', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U'); +$rrd_info['ping.gateway']['fields'][] = array('name' => 'flood_max', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 0, 'max' => 'U'); +$rrd_info['ping.gateway']['fields'][] = array('name' => 'flood_loss', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 0, 'max' => 100); +$rrd_info['ping.gateway']['update'] = + 'function { + $pinghost = "83.65.88.1"; $pingnum = 20; + $sdata = array(); + $sdata["single"] = explode("\n", `LANG=C /bin/ping -q -c $pingnum -w 90 $pinghost 2>/dev/null`); + $sdata["flood"] = explode("\n", `LANG=C /bin/ping -qf -c $pingnum -w 30 $pinghost 2>/dev/null`); + $udata = array("single_min"=>0,"single_avg"=>0,"single_max"=>0,"single_loss"=>100, + "flood_min"=>0,"flood_avg"=>0,"flood_max"=>0,"flood_loss"=>100); + foreach (array("single","flood") as $mode) { + foreach ($sdata[$mode] as $sline) { + if (preg_match("/(\d+)% (?:packet )?loss/", $sline, $regs)) { $udata[$mode."_loss"] = $regs[1]; } + elseif (preg_match("/min\/avg\/max(?:\/mdev)? = ([\d\.]+)\/([\d\.]+)\/([\d\.]+)(?:\/[\d\.]+)? ms/", $sline, $regs)) { + $udata[$mode."_min"] = $regs[1]/1000; $udata[$mode."_avg"] = $regs[2]/1000; $udata[$mode."_max"] = $regs[3]/1000; + } + } + } + return $udata; + }'; +$rrd_info['ping.gateway']['graph']['rows'][] = array('name'=>'flood_min', 'gType'=>'LINE1', 'color'=>'#80FF80', 'legend'=>'f:min/max', 'desc'=>'f:min'); +$rrd_info['ping.gateway']['graph']['rows'][] = array('name'=>'flood_max', 'gType'=>'LINE1', 'color'=>'#80FF80', 'desc'=>'f:max'); +$rrd_info['ping.gateway']['graph']['rows'][] = array('name'=>'single_min', 'gType'=>'LINE1', 'color'=>'#CCCCFF', 'legend'=>'s:min/max', 'desc'=>'s:min'); +$rrd_info['ping.gateway']['graph']['rows'][] = array('name'=>'single_max', 'gType'=>'LINE1', 'color'=>'#CCCCFF', 'desc'=>'s:max'); +$rrd_info['ping.gateway']['graph']['rows'][] = array('name'=>'flood_avg', 'gType'=>'LINE1', 'color'=>'#008000', 'legend'=>'f:avg'); +$rrd_info['ping.gateway']['graph']['rows'][] = array('name'=>'single_avg', 'gType'=>'LINE1', 'color'=>'#0000FF', 'legend'=>'s:avg'); +$rrd_info['ping.gateway']['graph']['rows'][] = array('name'=>'flood_loss', 'scale'=>0.001, 'gType'=>'LINE1', 'color'=>'#000000', 'legend'=>'f:mloss'); +$rrd_info['ping.gateway']['graph']['rows'][] = array('name'=>'single_loss', 'scale'=>0.001, 'gType'=>'LINE1', 'color'=>'#FF0000', 'legend'=>'s:mloss'); +$rrd_info['ping.gateway']['graph']['label_y'] = 'Seconds'; +$rrd_info['ping.gateway']['graph']['min_y'] = 0; +// $rrd_info['ping.gateway']['graph']['force_recreate'] = true; +$rrd_info['ping.gateway']['page']['text_intro'] = 'Alternate graphs: totals, averages.'; +$rrd_info['ping.gateway']['graph.avg']['rows'][] = array('name'=>'flood_avg', 'gType'=>'LINE1', 'color'=>'#008000', + 'legend'=>'f:avg', 'legend_long'=>'Flood ping: average time (of 20 parallel pings)'); +$rrd_info['ping.gateway']['graph.avg']['rows'][] = array('name'=>'single_avg', 'gType'=>'LINE1', 'color'=>'#0000FF', + 'legend'=>'s:avg', 'legend_long'=>'Single ping: average time (of 20 sequential pings, 1s gap)'); +$rrd_info['ping.gateway']['graph.avg']['rows'][] = array('name'=>'flood_loss', 'scale'=>0.001, 'gType'=>'LINE1', 'color'=>'#000000', + 'legend'=>'f:mloss', 'legend_long'=>'Flood ping: packet loss (percent of 20 parallel pings)'); +$rrd_info['ping.gateway']['graph.avg']['rows'][] = array('name'=>'single_loss', 'scale'=>0.001, 'gType'=>'LINE1', 'color'=>'#FF0000', + 'legend'=>'s:mloss', 'legend_long'=>'Single ping: packet loss (percent of 20 sequential pings, 1s gap)'); +$rrd_info['ping.gateway']['graph']['label_y'] = 'Seconds'; +$rrd_info['ping.gateway']['graph']['min_y'] = 0; +$rrd_info['ping.gateway']['page.avg']['graph_sub'] = 'avg'; + +$rrd_info['ping.hirsch'] = $rrd_info['ping.gateway']; +$rrd_info['ping.hirsch']['file'] = 'net.ping.hirsch.rrd'; +$rrd_info['ping.hirsch']['update'] = + 'function { + $pinghost = "server.hirsch.sth.ac.at"; $pingnum = 20; + $sdata = array(); + $sdata["single"] = explode("\n", `LANG=C /bin/ping -q -c $pingnum -w 90 $pinghost 2>/dev/null`); + $sdata["flood"] = explode("\n", `LANG=C /bin/ping -qf -c $pingnum -w 30 $pinghost 2>/dev/null`); + $udata = array("single_min"=>0,"single_avg"=>0,"single_max"=>0,"single_loss"=>100, + "flood_min"=>0,"flood_avg"=>0,"flood_max"=>0,"flood_loss"=>100); + foreach (array("single","flood") as $mode) { + foreach ($sdata[$mode] as $sline) { + if (preg_match("/(\d+)% (?:packet )?loss/", $sline, $regs)) { $udata[$mode."_loss"] = $regs[1]; } + elseif (preg_match("/min\/avg\/max(?:\/mdev)? = ([\d\.]+)\/([\d\.]+)\/([\d\.]+)(?:\/[\d\.]+)? ms/", $sline, $regs)) { + $udata[$mode."_min"] = $regs[1]/1000; $udata[$mode."_avg"] = $regs[2]/1000; $udata[$mode."_max"] = $regs[3]/1000; + } + } + } + return $udata; + }'; +// $rrd_info['ping.hirsch']['graph']['force_recreate'] = true; +$rrd_info['ping.hirsch']['page']['text_intro'] = 'Alternate graphs: totals, averages.'; + +// mainboard sensors +/* +$rrd_info['sensors.power']['file'] = 'sensors.power.rrd'; +$rrd_info['sensors.power']['auto-update'] = true; +$rrd_info['sensors.power']['fields'][] = array('name' => 'vid', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['sensors.power']['fields'][] = array('name' => 'vcore1', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['sensors.power']['fields'][] = array('name' => 'p3x3v', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['sensors.power']['fields'][] = array('name' => 'p5v', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['sensors.power']['fields'][] = array('name' => 'p12v', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['sensors.power']['fields'][] = array('name' => 'm12v', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['sensors.power']['fields'][] = array('name' => 'm5v', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['sensors.power']['update'] = + 'function { + $sdata = explode("\n", `/usr/bin/sensors -A asb100-*`); + $udata = array("vid"=>null,"vcore1"=>null,"p3x3v"=>null, + "p5v"=>null,"p12v"=>null,"m12v"=>null,"m5v"=>null); + foreach ($sdata as $sline) { + if (preg_match("/^vid:\s+([+-]?[\d\.]+) V/", $sline, $regs)) { $udata["vid"] = $regs[1]; } + elseif (preg_match("/^VCore 1:\s+([+-]?[\d\.]+) V/", $sline, $regs)) { $udata["vcore1"] = $regs[1]; } + elseif (preg_match("/^\+3.3V:\s+([+-]?[\d\.]+) V/", $sline, $regs)) { $udata["p3x3v"] = $regs[1]; } + elseif (preg_match("/^\+5V:\s+([+-]?[\d\.]+) V/", $sline, $regs)) { $udata["p5v"] = $regs[1]; } + elseif (preg_match("/^\+12V:\s+([+-]?[\d\.]+) V/", $sline, $regs)) { $udata["p12v"] = $regs[1]; } + elseif (preg_match("/^-12V:\s+([+-]?[\d\.]+) V/", $sline, $regs)) { $udata["m12v"] = $regs[1]; } + elseif (preg_match("/^-5V:\s+([+-]?[\d\.]+) V/", $sline, $regs)) { $udata["m5v"] = $regs[1]; } + } + return $udata; + }'; +$rrd_info['sensors.power']['graph']['rows'][] = array('name'=>'vid', 'gType'=>'LINE1', 'color'=>'#808080', 'legend'=>'VID'); +$rrd_info['sensors.power']['graph']['rows'][] = array('name'=>'vcore1', 'gType'=>'LINE1', 'color'=>'#FF0000', 'legend'=>'VCore 1'); +$rrd_info['sensors.power']['graph']['rows'][] = array('name'=>'p12v', 'gType'=>'LINE1', 'color'=>'#0000FF', 'legend'=>'+12V'); +$rrd_info['sensors.power']['graph']['rows'][] = array('name'=>'p5v', 'gType'=>'LINE1', 'color'=>'#008000', 'legend'=>'+5V'); +$rrd_info['sensors.power']['graph']['rows'][] = array('name'=>'p3x3v', 'gType'=>'LINE1', 'color'=>'#000000', 'legend'=>'+3.3V'); +$rrd_info['sensors.power']['graph']['rows'][] = array('name'=>'m5v', 'gType'=>'LINE1', 'color'=>'#00CC00', 'legend'=>'-5V'); +$rrd_info['sensors.power']['graph']['rows'][] = array('name'=>'m12v', 'gType'=>'LINE1', 'color'=>'#8080FF', 'legend'=>'-12V'); +$rrd_info['sensors.power']['graph']['units_length'] = 4; +$rrd_info['sensors.power']['graph']['label_y'] = 'Volt'; +$rrd_info['sensors.power']['graph']['max_y'] = 13; +$rrd_info['sensors.power']['graph']['min_y'] = -13; +// $rrd_info['sensors.power']['graph']['force_recreate'] = true; +$rrd_info['sensors.power']['graph.rel']['rows'][] = array('name'=>'vid', 'gType'=>''); +$rrd_info['sensors.power']['graph.rel']['rows'][] = array('name'=>'vcore1_tmp', 'dsname'=>'vcore1', 'gType'=>''); +$rrd_info['sensors.power']['graph.rel']['rows'][] = array('name'=>'p12v_tmp', 'dsname'=>'p12v', 'gType'=>''); +$rrd_info['sensors.power']['graph.rel']['rows'][] = array('name'=>'p5v_tmp', 'dsname'=>'p5v', 'gType'=>''); +$rrd_info['sensors.power']['graph.rel']['rows'][] = array('name'=>'p3x3v_tmp', 'dsname'=>'p3x3v', 'gType'=>''); +$rrd_info['sensors.power']['graph.rel']['rows'][] = array('name'=>'m5v_tmp', 'dsname'=>'m5v', 'gType'=>''); +$rrd_info['sensors.power']['graph.rel']['rows'][] = array('name'=>'m12v_tmp', 'dsname'=>'m12v', 'gType'=>''); +$rrd_info['sensors.power']['graph.rel']['rows'][] = array('dType'=>'CDEF', 'name'=>'vcore1', 'rpn_expr'=>'vcore1_tmp,vid,-', 'gType'=>'LINE1', 'color'=>'#FF0000', 'legend'=>'VCore 1'); +$rrd_info['sensors.power']['graph.rel']['rows'][] = array('dType'=>'CDEF', 'name'=>'p3x3v', 'rpn_expr'=>'p3x3v_tmp,3.3,-', 'gType'=>'LINE1', 'color'=>'#000000', 'legend'=>'+3.3V'); +$rrd_info['sensors.power']['graph.rel']['rows'][] = array('dType'=>'CDEF', 'name'=>'p5v', 'rpn_expr'=>'p5v_tmp,5,-', 'gType'=>'LINE1', 'color'=>'#008000', 'legend'=>'+5V'); +$rrd_info['sensors.power']['graph.rel']['rows'][] = array('dType'=>'CDEF', 'name'=>'p12v', 'rpn_expr'=>'p12v_tmp,12,-', 'gType'=>'LINE1', 'color'=>'#0000FF', 'legend'=>'+12V'); +$rrd_info['sensors.power']['graph.rel']['rows'][] = array('dType'=>'CDEF', 'name'=>'m12v', 'rpn_expr'=>'m12v_tmp,12,+', 'gType'=>'LINE1', 'color'=>'#8080FF', 'legend'=>'-12V'); +$rrd_info['sensors.power']['graph.rel']['rows'][] = array('dType'=>'CDEF', 'name'=>'m5v', 'rpn_expr'=>'m5v_tmp,5,+', 'gType'=>'LINE1', 'color'=>'#00CC00', 'legend'=>'-5V'); +$rrd_info['sensors.power']['graph.rel']['units_length'] = 5; +$rrd_info['sensors.power']['graph.rel']['units_exponent'] = 0; +$rrd_info['sensors.power']['graph.rel']['label_y'] = 'Volts (diff)'; +$rrd_info['sensors.power']['graph.rel']['max_y'] = +0.3; +$rrd_info['sensors.power']['graph.rel']['min_y'] = -0.7; +// $rrd_info['sensors.power']['graph.rel']['force_recreate'] = true; +$rrd_info['sensors.power']['page.rel']['graph_sub'] = 'rel'; +$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('name'=>'vid', 'gType'=>''); +$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('name'=>'vcore1_tmp', 'dsname'=>'vcore1', 'gType'=>''); +$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('name'=>'p12v_tmp', 'dsname'=>'p12v', 'gType'=>''); +$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('name'=>'p5v_tmp', 'dsname'=>'p5v', 'gType'=>''); +$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('name'=>'p3x3v_tmp', 'dsname'=>'p3x3v', 'gType'=>''); +$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('name'=>'m5v_tmp', 'dsname'=>'m5v', 'gType'=>''); +$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('name'=>'m12v_tmp', 'dsname'=>'m12v', 'gType'=>''); +$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('dType'=>'CDEF', 'name'=>'vcore1', 'rpn_expr'=>'vcore1_tmp,vid,-,vid,/,100,*', 'gType'=>'LINE1', 'color'=>'#FF0000', 'legend'=>'VCore 1'); +$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('dType'=>'CDEF', 'name'=>'p3x3v', 'rpn_expr'=>'p3x3v_tmp,3.3,-,3.3,/,100,*', 'gType'=>'LINE1', 'color'=>'#000000', 'legend'=>'+3.3V'); +$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('dType'=>'CDEF', 'name'=>'p5v', 'rpn_expr'=>'p5v_tmp,5,-,5,/,100,*', 'gType'=>'LINE1', 'color'=>'#008000', 'legend'=>'+5V'); +$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('dType'=>'CDEF', 'name'=>'p12v', 'rpn_expr'=>'p12v_tmp,12,-,12,/,100,*', 'gType'=>'LINE1', 'color'=>'#0000FF', 'legend'=>'+12V'); +$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('dType'=>'CDEF', 'name'=>'m12v', 'rpn_expr'=>'m12v_tmp,12,+,12,/,100,*', 'gType'=>'LINE1', 'color'=>'#8080FF', 'legend'=>'-12V'); +$rrd_info['sensors.power']['graph.relpct']['rows'][] = array('dType'=>'CDEF', 'name'=>'m5v', 'rpn_expr'=>'m5v_tmp,5,+,5,/,100,*', 'gType'=>'LINE1', 'color'=>'#00CC00', 'legend'=>'-5V'); +$rrd_info['sensors.power']['graph.relpct']['units_length'] = 5; +$rrd_info['sensors.power']['graph.relpct']['units_exponent'] = 0; +$rrd_info['sensors.power']['graph.relpct']['label_y'] = 'diff%'; +$rrd_info['sensors.power']['graph.relpct']['max_y'] = +2; +$rrd_info['sensors.power']['graph.relpct']['min_y'] = -6; +// $rrd_info['sensors.power']['graph.relpct']['force_recreate'] = true; +$rrd_info['sensors.power']['page.relpct']['graph_sub'] = 'relpct'; + +$rrd_info['sensors.fan']['file'] = 'sensors.fan.rrd'; +$rrd_info['sensors.fan']['auto-update'] = true; +$rrd_info['sensors.fan']['fields'][] = array('name' => 'cpu_fan', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['sensors.fan']['fields'][] = array('name' => 'chassis_fan', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['sensors.fan']['fields'][] = array('name' => 'power_fan', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['sensors.fan']['update'] = + 'function { + $sdata = explode("\n", str_replace(":\n", ": ", `/usr/bin/sensors -A asb100-*`)); + $udata = array("cpu_fan"=>null,"chassis_fan"=>null,"power_fan"=>null); + foreach ($sdata as $sline) { + if (preg_match("/^CPU Fan:\s+([+-]?\d+) RPM/", $sline, $regs)) { $udata["cpu_fan"] = $regs[1]; } + elseif (preg_match("/^Chassis Fan:\s+([+-]?\d+) RPM/", $sline, $regs)) { $udata["chassis_fan"] = $regs[1]; } + elseif (preg_match("/^Power Fan:\s+([+-]?\d+) RPM/", $sline, $regs)) { $udata["power_fan"] = $regs[1]; } + } + return $udata; + }'; +$rrd_info['sensors.fan']['graph']['rows'][] = array('name'=>'cpu_fan', 'gType'=>'LINE1', 'color'=>'#0000FF', 'legend'=>'CPU Fan'); +$rrd_info['sensors.fan']['graph']['rows'][] = array('name'=>'chassis_fan', 'gType'=>'LINE1', 'color'=>'#00CC00', 'legend'=>'GPU Fan'); +$rrd_info['sensors.fan']['graph']['label_y'] = 'Rotations/min'; +$rrd_info['sensors.fan']['graph']['max_y'] = 6500; +$rrd_info['sensors.fan']['graph']['min_y'] = 2000; +// $rrd_info['sensors.fan']['graph']['force_recreate'] = true; + +$rrd_info['sensors.temp']['file'] = 'sensors.temp.rrd'; +$rrd_info['sensors.temp']['auto-update'] = true; +$rrd_info['sensors.temp']['fields'][] = array('name' => 'cpu_temp', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['sensors.temp']['fields'][] = array('name' => 'mb_temp', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['sensors.temp']['fields'][] = array('name' => 'power_temp', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['sensors.temp']['update'] = + 'function { + $sdata = explode("\n", `/usr/bin/sensors -A asb100-*`); + $udata = array("cpu_temp"=>null,"mb_temp"=>null,"power_temp"=>null); + foreach ($sdata as $sline) { + if (preg_match("/^CPU Temp:\s+([+-]?[\d\.]+).+?C/i", $sline, $regs)) { $udata["cpu_temp"] = $regs[1]; } + elseif (preg_match("/^MB Temp:\s+([+-]?[\d\.]+).+?C/i", $sline, $regs)) { $udata["mb_temp"] = $regs[1]; } + elseif (preg_match("/^Power Temp:\s+([+-]?[\d\.]+).+?C/i", $sline, $regs)) { $udata["power_temp"] = $regs[1]; } + } + return $udata; + }'; +$rrd_info['sensors.temp']['graph']['rows'][] = array('name'=>'cpu_temp', 'gType'=>'LINE1', 'color'=>'#0000FF', 'legend'=>'CPU Temp'); +$rrd_info['sensors.temp']['graph']['rows'][] = array('name'=>'mb_temp', 'gType'=>'LINE1', 'color'=>'#008000', 'legend'=>'MB Temp'); +$rrd_info['sensors.temp']['graph']['label_y'] = '°C'; +$rrd_info['sensors.temp']['graph']['max_y'] = 55; +$rrd_info['sensors.temp']['graph']['min_y'] = 30; +// $rrd_info['sensors.temp']['graph']['force_recreate'] = true; +*/ + +/* !!! be sure to call this one _last_ of all auto-update rrd stats */ +$rrd_info['rrdup']['file'] = 'test.rrdup.rrd'; +// $rrd_info['rrdup']['auto-update'] = true; +$rrd_info['rrdup']['fields'][] = array('name' => 'usertime', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['rrdup']['fields'][] = array('name' => 'systime', 'type' => 'GAUGE', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); +$rrd_info['rrdup']['update'] = 'function { $sdata = posix_times(); return array("usertime"=>$sdata["cutime"],"systime"=>$sdata["cstime"]); }'; +$rrd_info['rrdup']['graph']['rows'][] = array('name'=>'systime', 'gType'=>'AREA', 'color'=>'#FF0000', 'legend'=>'System CPU time'); +$rrd_info['rrdup']['graph']['rows'][] = array('name'=>'usertime', 'gType'=>'AREA', 'color'=>'#0000FF', 'legend'=>'User CPU time', 'stack'=>true); +$rrd_info['rrdup']['graph']['scale'] = 0.01; +$rrd_info['rrdup']['graph']['units_length'] = 4; +$rrd_info['rrdup']['graph']['units_exponent'] = 0; +$rrd_info['rrdup']['graph']['label_y'] = 'RRD update (seconds)'; +$rrd_info['rrdup']['graph']['min_y'] = 0; +// $rrd_info['rrdup']['graph']['force_recreate'] = true; + +// ***** MRTG-based graphs ***** +$rrd_info['mrtg.system.ram']['graph']['units_binary'] = true; +$rrd_info['mrtg.system.ram']['graph']['scale'] = 1024; +$rrd_info['mrtg.system.ram']['graph']['force_recreate'] = true; + +$rrd_info['mrtg.system.load']['graph']['scale'] = 0.001; +$rrd_info['mrtg.system.load']['graph']['force_recreate'] = true; + +?> diff --git a/testbed/rrd/rrd-stat.php b/testbed/rrd/rrd-stat.php new file mode 100644 index 0000000..c650ce9 --- /dev/null +++ b/testbed/rrd/rrd-stat.php @@ -0,0 +1,22 @@ +page($psub)); +?> diff --git a/testbed/rrd/rrd-test.php b/testbed/rrd/rrd-test.php new file mode 100644 index 0000000..9b2ee51 --- /dev/null +++ b/testbed/rrd/rrd-test.php @@ -0,0 +1,21 @@ +update(); +} +else { + print('this is a commandline app.'); +} +?> diff --git a/testbed/rrd/rrd-update.php b/testbed/rrd/rrd-update.php new file mode 100644 index 0000000..30b23b2 --- /dev/null +++ b/testbed/rrd/rrd-update.php @@ -0,0 +1,30 @@ +$rinfo) { + if (isset($rinfo['auto-update']) && $rinfo['auto-update']) { + $autoupdate[] = $iname; + } + } + $autoupdate[] = 'rrdup'; + foreach ($autoupdate as $rrdname) { + $rrd = new rrdstat($rrd_info, $rrdname); + $rrd->update(); + } +} +else { + print('this is a commandline app.'); +} +?> diff --git a/testbed/rrd/rrdstat.php-class b/testbed/rrd/rrdstat.php-class new file mode 100755 index 0000000..f0a89aa --- /dev/null +++ b/testbed/rrd/rrdstat.php-class @@ -0,0 +1,1196 @@ + + * + * ***** END LICENSE BLOCK ***** */ + +class rrdstat { + // rrdstat PHP class + // rrdtool statistics functions + // + // function __construct($rrdconfig, [$conf_id]) + // CONSTRUCTOR + // if $conf_id is set, $rrdconfig is a total configuration set + // else it's the configuration for this one RRD + // currently only a config array is supported, XML config is planned + // + // private $rrd_file + // RRD file name + // + // private $basename + // base name for this RRD (usually file name without .rrd) + // + // private $basedir + // base directory for this RRD (with a trailing slash) + // note that $rrd_file usually includes that path as well, but graph directory gets based on this value + // + // private $config_all + // complete, raw configuration array set + // + // private $config_raw + // configuration array set for current RRD + // + // private $config_graph + // configuration array set for default graph in this RRD + // + // private $config_page + // configuration array set for default page in this RRD + // + // private $rrd_fields + // definition of this RRD's fields + // + // private $rra_base + // definition of this RRD's base RRAs + // + // private $rrd_step + // basic stepping of this RRD in seconds (default: 300) + // + // private $rra_add_max + // should RRAs for MAX be added for every base RRA? (bool, default: true) + // + // private $status + // status of the RRD (unused/ok/readonly/graphonly) + // note that most functions require certain status values + // (e.g. update only works if status is ok, graph for ok/readonly/graphonly) + // + // private $mod_textdomain + // GNU gettext domain for this module + // + // private function set_def($rrdconfig, [$conf_id]) + // set definitions based on given configuration + // [intended for internal use, called by the constructor] + // + // public function rrd_version() { + // get RRDtool version string + // + // public function create() + // create RRD file according to set config + // + // public function update([$upArray]) + // feed new data into RRD (either use given array of values or use auto-update info from config) + // + // public function fetch([$cf] = 'AVERAGE', $resolution = null, $start = null, $end = null) + // fetch data from the defined RRD + // using given consolidation function [default is AVERAGE], + // resolution (seconds, default is the RRD's stepping), + // start and end times (unix epoch, defaults are the RRD's last update time) + // + // public function last_update() + // fetch time of last update in this RRD file + // + // public function graph([$timeframe], [$sub], [$extra]) + // create a RRD graph (and return all meta info in a flat string) + // for given timeframe (day [default]/week/month/year), + // sub-graph ID (if given) and extra config options (if given) + // + // public function graph_plus([$timeframe], [$sub], [$extra]) + // create a RRD graph (see above) and return meta info as a ready-to-use array + // + // public function page([$sub], [$page_extras], [$graph_extras]) + // create a (HTML) page and return it in a string + // for given sub-page ID (if given, default is a simple HTML page) + // and extra page and graph config options (if given) + // + // public function simple_html([$sub], [$page_extras], [$graph_extras]) + // create a simple (MRTG-like) HTML page and return it in a string + // XXX: this is here temporarily for compat only, it's preferred to use page()! + // + // private function page_index($pconf) + // create a bare, very simple index list HTML page and return it in a string + // using given page config options + // [intended for internal use, called by page()] + // + // private function page_overview($pconf, [$graph_extras]) + // create an overview HTML page (including graphs) and return it in a string + // using given page config options and extra graph options (if given) + // [intended for internal use, called by page()] + // + // private function page_simple($pconf, [$graph_extras]) + // create a simple (MRTG-like) HTML page and return it in a string + // using given page config options and extra graph options (if given) + // [intended for internal use, called by page()] + // + // private function h_page_statsArray($pconf) + // return array of stats to list on a page, using given page config options + // [intended for internal use, called by page_*()] + // + // private function h_page_footer() + // return generic page footer + // [intended for internal use, called by page_*()] + // + // private function text_quote($text) + // return a quoted/escaped text for use in rrdtool commandline text fields + + private $rrd_file = null; + private $basename = null; + private $basedir = null; + + private $config_all = null; + private $config_raw = null; + private $config_graph = null; + private $config_page = null; + + private $rrd_fields = array(); + private $rra_base = array(); + private $rrd_step = 300; + private $rra_add_max = true; + + private $status = 'unused'; + + private $mod_textdomain; + + function __construct($rrdconfig, $conf_id = null) { + // ***** init RRD stat module ***** + $this->mod_textdomain = 'class_rrdstat'; + $mod_charset = 'iso-8859-15'; + + bindtextdomain($this->mod_textdomain, class_exists('baseutils')?baseutils::getDir('locale'):'locale/'); + bind_textdomain_codeset($this->mod_textdomain, $mod_charset); + + $this->set_def($rrdconfig, $conf_id); + + if (($this->status == 'unused') && !is_null($this->rrd_file)) { + if (!is_writeable($this->rrd_file)) { + if (!file_exists($this->rrd_file)) { + if (@touch($this->rrd_file)) { $this->create(); } + else { trigger_error('RRD file can not be created', E_USER_WARNING); } + } + else { + if (is_readable($this->rrd_file)) { $this->status = 'readonly'; } + else { trigger_error('RRD file is not readable', E_USER_WARNING); } + } + } + else { + $this->status = 'ok'; + } + } + } + + private function set_def($rrdconfig, $conf_id = null) { + if (is_array($rrdconfig)) { + // we have an array in the format we like to have + $complete_conf =& $rrdconfig; + } + else { + // we have something else (XML data?), try to generate the iinfo aray from it + $complete_conf =& $rrdconfig; + } + + if (!is_null($conf_id)) { + $iinfo = isset($complete_conf[$conf_id])?$complete_conf[$conf_id]:array(); + if (isset($complete_conf['*'])) { + $iinfo = (array)$iinfo + (array)$complete_conf['*']; + if (isset($complete_conf['*']['graph'])) { $iinfo['graph'] = (array)$iinfo['graph'] + (array)$complete_conf['*']['graph']; } + if (isset($complete_conf['*']['page'])) { $iinfo['page'] = (array)$iinfo['page'] + (array)$complete_conf['*']['page']; } + } + } + else { + $iinfo = $complete_conf; + } + + if (isset($iinfo['path']) && strlen($iinfo['path'])) { + $this->basedir = $iinfo['path']; + if (substr($this->basedir, -1) != '/') { $this->basedir .= '/'; } + } + + if (isset($iinfo['graph-only']) && $iinfo['graph-only'] && !is_null($conf_id)) { + $this->basename = $conf_id; + $this->status = 'graphonly'; + } + elseif (isset($iinfo['file'])) { + $this->rrd_file = (($iinfo['file']{0} != '/')?$this->basedir:'').$iinfo['file']; + $this->basename = basename((substr($this->rrd_file, -4) == '.rrd')?substr($this->rrd_file, 0, -4):$this->rrd_file); + } + elseif (!is_null($conf_id) && file_exists($conf_id.'.rrd')) { + $this->rrd_file = (($iinfo['file']{0} != '/')?$this->basedir:'').$conf_id.'.rrd'; + $this->basename = $conf_id; + } + else { + $this->basename = !is_null($conf_id)?$conf_id:'xxx.unknown'; + } + + if (!is_null($this->rrd_file)) { + // fields (data sources, DS) + // name - DS name + // type - one of COUNTER, GAUGE, DERIVE, ABSOLUTE + // heartbeat - if no sample recieved for that time, store UNKNOWN + // min - U (unconstrained) or minimum value + // max - U (unconstrained) or maximum value + // update - this string will be fed into eval() for updating this field + if (isset($iinfo['fields']) && is_array($iinfo['fields'])) { + $this->rrd_fields = $iinfo['fields']; + } + else { + $this->rrd_fields[] = array('name' => 'ds0', 'type' => 'COUNTER', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); + $this->rrd_fields[] = array('name' => 'ds1', 'type' => 'COUNTER', 'heartbeat' => 600, 'min' => 'U', 'max' => 'U'); + } + + + // MRTG-style RRD "database", see http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/tut/rrdtutorial.en.html + // + // archives (RRAs): + // 600 samples of 5 minutes (2 days and 2 hours) + // 700 samples of 30 minutes (2 days and 2 hours, plus 12.5 days) + // 775 samples of 2 hours (above + 50 days) + // 797 samples of 1 day (above + 732 days, rounded up to 797) + + $this->rrd_step = isset($iinfo['rrd_step'])?$iinfo['rrd_step']:300; + + if (isset($iinfo['rra_base']) && is_array($iinfo['rra_base'])) { + $this->rra_base = $iinfo['rra_base']; + } + else { + $this->rra_base[] = array('step' => 1, 'rows' => 600); + $this->rra_base[] = array('step' => 6, 'rows' => 700); + $this->rra_base[] = array('step' => 24, 'rows' => 775); + $this->rra_base[] = array('step' => 288, 'rows' => 797); + } + + $this->rra_add_max = isset($iinfo['rra_add_max'])?$iinfo['rra_add_max']:true; + } + + if (isset($iinfo['graph'])) { $this->config_graph = $iinfo['graph']; } + if (isset($iinfo['page'])) { $this->config_page = $iinfo['page']; } + $this->config_raw = $iinfo; + $this->config_all = $complete_conf; + } + + public function rrd_version() { + // return RRDtool version + static $version; + if (!isset($version)) { + $create_cmd = 'rrdtool --version'; + $return = `$create_cmd 2>&1`; + if (strpos($return, 'ERROR') !== false) { + trigger_error($this->rrd_file.' - rrd version error: '.$return, E_USER_WARNING); + } + + if (preg_match('/^\s*RRDtool ([\d\.]+)\s+/', $return, $regs)) { + $version = $regs[1]; + } + else { + $version = '0.0'; + } + } + return $version; + } + + public function create() { + // create RRD file + + // compose create command + $create_cmd = 'rrdtool create '.$this->rrd_file.' --step '.$this->rrd_step; + foreach ($this->rrd_fields as $ds) { + if (!isset($ds['type'])) { $ds['type'] = 'COUNTER'; } + if (!isset($ds['heartbeat'])) { $ds['heartbeat'] = 2*$this->rrd_step; } + if (!isset($ds['min'])) { $ds['min'] = 'U'; } + if (!isset($ds['max'])) { $ds['max'] = 'U'; } + $create_cmd .= ' DS:'.$ds['name'].':'.$ds['type'].':'.$ds['heartbeat'].':'.$ds['min'].':'.$ds['max']; + } + foreach ($this->rra_base as $rra) { + if (!isset($rra['cf'])) { $rra['cf'] = 'AVERAGE'; } + if (!isset($rra['xff'])) { $rra['xff'] = 0.5; } + if (!isset($rra['step'])) { $rra['step'] = 1; } + if (!isset($rra['rows'])) { $rra['rows'] = 600; } + $create_cmd .= ' RRA:'.$rra['cf'].':'.$rra['xff'].':'.$rra['step'].':'.$rra['rows']; + } + if ($this->rra_add_max) { + foreach ($this->rra_base as $rra) { + if (!isset($rra['cf'])) { + // only rows that have no CF set will be looked at here + $rra['cf'] = 'MAX'; + if (!isset($rra['xff'])) { $rra['xff'] = 0.5; } + if (!isset($rra['step'])) { $rra['step'] = 1; } + if (!isset($rra['rows'])) { $rra['rows'] = 600; } + $create_cmd .= ' RRA:'.$rra['cf'].':'.$rra['xff'].':'.$rra['step'].':'.$rra['rows']; + } + } + } + $return = `$create_cmd 2>&1`; + if (strpos($return, 'ERROR') !== false) { + trigger_error($this->rrd_file.' - rrd create error: '.$return, E_USER_WARNING); + } + else { $this->status = 'ok'; } + } + + public function update($upArray = null) { + // feed new data into RRD + if ($this->status != 'ok') { trigger_error('Cannot update non-writeable file', E_USER_WARNING); return false; } + $upvals = array(); + if (isset($this->config_raw['update'])) { + if (preg_match('/^\s*function\s+{(.*)}\s*$/is', $this->config_raw['update'], $regs)) { + $upfunc = create_function('', $regs[1]); + $upvals = $upfunc(); + } + else { + $evalcode = $this->config_raw['update']; + if (!is_null($evalcode)) { + ob_start(); + eval($evalcode); + $ret = ob_get_contents(); + if (strlen($ret)) { $upvals = explode("\n", $ret); } + ob_end_clean(); + } + } + } + else { + foreach ($this->rrd_fields as $ds) { + if (is_array($upArray) && isset($upArray[$ds['name']])) { $val = $upArray[$ds['name']]; } + elseif (isset($ds['update'])) { + $val = null; $evalcode = null; + if (substr($ds['update'], 0, 4) == 'val:') { + $evalcode = 'function { return trim('.substr($ds['update'], 4).')); }'; + } + elseif (substr($ds['update'], 0, 8) == 'snmp-if:') { + $snmphost = 'localhost'; $snmpcomm = 'public'; + list($nix, $ifname, $valtype) = explode(':', $ds['update'], 3); + $iflist = explode("\n", `snmpwalk -v2c -c $snmpcomm $snmphost interfaces.ifTable.ifEntry.ifDescr`); + $ifnr = null; + foreach ($iflist as $ifdesc) { + if (preg_match('/ifDescr\.(\d+) = STRING: '.$ifname.'/', $ifdesc, $regs)) { $ifnr = $regs[1]; } + } + $oid = null; + if ($valtype == 'in') { $oid = '1.3.6.1.2.1.2.2.1.10.'.$ifnr; } + elseif ($valtype == 'out') { $oid = '1.3.6.1.2.1.2.2.1.16.'.$ifnr; } + if (!is_null($ifnr) && !is_null($oid)) { + $evalcode = 'function { return trim(substr(strrchr(`snmpget -v2c -c '.$snmpcomm.' '.$snmphost.' '.$oid.'`,":"),1)); }'; + } + } + else { $evalcode = $ds['update']; } + if (preg_match('/^\s*function\s+{(.*)}\s*$/is', $evalcode, $regs)) { + $upfunc = create_function('', $regs[1]); + $val = $upfunc(); + } + elseif (!is_null($evalcode)) { + ob_start(); + eval($evalcode); + $val = ob_get_contents(); + ob_end_clean(); + } + } + else { $val = null; } + $upvals[$ds['name']] = $val; + } + } + $key_names = (!is_numeric(array_shift(array_keys($upvals)))); + if (in_array('L', $upvals, true)) { + // for at least one value, we need to set the same as the last recorded value + $fvals = $this->fetch(); + $rowids = array_shift($fvals); + $lastvals = array_shift($fvals); + foreach (array_keys($upvals, 'L') as $akey) { + $upvals[$akey] = $key_names?$lastvals[$akey]:$lastvals[$rowids[$akey]]; + } + } + $walkfunc = create_function('&$val,$key', '$val = is_numeric(trim($val))?trim($val):"U";'); + array_walk($upvals, $walkfunc); + $return = null; + if (count($upvals)) { + $update_cmd = 'rrdtool update '.$this->rrd_file.($key_names?' --template '.implode(':', array_keys($upvals)):'').' N:'.implode(':', $upvals); + $return = `$update_cmd 2>&1`; + } + + if (strpos($return, 'ERROR') !== false) { + trigger_error($this->rrd_file.' - rrd update error: '.$return, E_USER_WARNING); + $success = false; + } + else { $success = true; } + return $success; + } + + public function fetch($cf = 'AVERAGE', $resolution = null, $start = null, $end = null) { + // fetch data from a RRD + if (!in_array($this->status, array('ok','readonly'))) { trigger_error('Error: rrd status is '.$this->status, E_USER_WARNING); return false; } + + if (!in_array($cf, array('AVERAGE','MIN','MAX','LAST'))) { $cf = 'AVERAGE'; } + if (!is_numeric($resolution)) { $resolution = $this->rrd_step; } + if (!is_numeric($end)) { $end = $this->last_update(); } + elseif ($end < 0) { $end += $this->last_update(); } + $end = intval($end/$resolution)*$resolution; + if (!is_numeric($start)) { $start = $end; } + elseif ($start < 0) { $start += $end; } + $start = intval($start/$resolution)*$resolution; + + $fetch_cmd = 'rrdtool fetch '.$this->rrd_file.' '.$cf.' --resolution '.$resolution.' --start '.$start.' --end '.$end; + $return = `$fetch_cmd 2>&1`; + + if (strpos($return, 'ERROR') !== false) { + trigger_error($this->rrd_file.' - rrd fetch error: '.$return, E_USER_WARNING); + $fresult = false; + } + else { + $fresult = array(); + $rows = explode("\n", $return); + $fields = preg_split('/\s+/', array_shift($rows)); + if (array_shift($fields) == 'timestamp') { + $fresult[0] = $fields; + foreach ($rows as $row) { + if (strlen(trim($row))) { + $rvals = preg_split('/\s+/', $row); + $rtime = str_replace(':', '', array_shift($rvals)); + $rv_array = array(); + foreach ($rvals as $key=>$rval) { + $rv_array[$fields[$key]] = ($rval=='nan')?null:floatval($rval); + } + $fresult[$rtime] = $rv_array; + } + } + } + } + return $fresult; + } + + public function last_update() { + // fetch time of last update in this RRD file + static $last_update; + if (!isset($last_update) && in_array($this->status, array('ok','readonly'))) { + $last_cmd = 'rrdtool last '.$this->rrd_file; + $return = trim(`$last_cmd 2>&1`); + $last_update = is_numeric($return)?$return:null; + } + return isset($last_update)?$last_update:null; + } + + public function graph($timeframe = 'day', $sub = null, $extra = null) { + // create a RRD graph + static $gColors; + if (!isset($gColors)) { + $gColors = array('#00CC00','#0000FF','#000000','#FF0000','#00FF00','#FFFF00','#FF00FF','#00FFFF','#808080','#800000','#008000','#000080','#808000','#800080','#008080','#C0C0C0'); + } + + if (!in_array($this->status, array('ok','readonly','graphonly'))) { trigger_error('Error: rrd status is '.$this->status, E_USER_WARNING); return false; } + + // assemble configuration + $gconf = (array)$extra; + if (!is_null($sub) && is_array($this->config_raw['graph.'.$sub])) { + $gconf = $gconf + $this->config_raw['graph.'.$sub]; + } + $gconf = $gconf + (array)$this->config_graph; + + if (isset($gconf['format']) && ($gconf['format'] == 'SVG')) { + $format = $gconf['format']; $fmt_ext = '.svg'; + } + elseif (isset($gconf['format']) && ($gconf['format'] == 'EPS')) { + $format = $gconf['format']; $fmt_ext = '.eps'; + } + elseif (isset($gconf['format']) && ($gconf['format'] == 'PDF')) { + $format = $gconf['format']; $fmt_ext = '.pdf'; + } + else { + $format = 'PNG'; $fmt_ext = '.png'; + } + + if (isset($gconf['filename'])) { $fname = $gconf['filename']; } + else { $fname = $this->basename.(is_null($sub)?'':'-%s').'-%t%f'; } + $fname = str_replace('%s', strval($sub), $fname); + $fname = str_replace('%t', $timeframe, $fname); + $fname = str_replace('%f', $fmt_ext, $fname); + if (substr($fname, -strlen($fmt_ext)) != $fmt_ext) { $fname .= $fmt_ext; } + if (isset($gconf['path']) && ($fname{0} != '/')) { $fname = $gconf['path'].'/'.$fname; } + if ($fname{0} != '/') { $fname = $this->basedir.$fname; } + $fname = str_replace('//', '/', $fname); + + $graphrows = array(); $specialrows = array(); $gC = 0; + $gDefs = ''; $gGraphs = ''; $addSpecial = ''; + + // the default size for the graph area has a width of 400px, so use 400 slices by default + if ($timeframe == 'day') { + $slice = isset($gconf['slice'])?$gconf['slice']:300; // 5 minutes + $duration = isset($gconf['duration'])?$gconf['duration']:400*$slice; // 33.33 hours + // vertical lines at day borders + $addSpecial .= ' VRULE:'.strtotime(date('Y-m-d')).'#FF0000'; + $addSpecial .= ' VRULE:'.strtotime(date('Y-m-d').' -1 day').'#FF0000'; + if (!isset($gconf['grid_x'])) { $gconf['grid_x'] = 'HOUR:1:HOUR:6:HOUR:2:0:%-H'; } + } + elseif ($timeframe == 'week') { + $slice = isset($gconf['slice'])?$gconf['slice']:1800; // 30 minutes + $duration = isset($gconf['duration'])?$gconf['duration']:400*$slice; // 8.33 days + // vertical lines at week borders + $addSpecial .= ' VRULE:'.strtotime(date('Y-m-d').' '.(-date('w')+1).' day').'#FF0000'; + $addSpecial .= ' VRULE:'.strtotime(date('Y-m-d').' '.(-date('w')-6).' day').'#FF0000'; + } + elseif ($timeframe == 'month') { + $slice = isset($gconf['slice'])?$gconf['slice']:7200; // 2 hours + $duration = isset($gconf['duration'])?$gconf['duration']:400*$slice; // 33.33 days + // vertical lines at month borders + $addSpecial .= ' VRULE:'.strtotime(date('Y-m-01')).'#FF0000'; + $addSpecial .= ' VRULE:'.strtotime(date('Y-m-01').' -1 month').'#FF0000'; + } + elseif ($timeframe == 'year') { + $slice = isset($gconf['slice'])?$gconf['slice']:86400; // 1 day + $duration = isset($gconf['duration'])?$gconf['duration']:400*$slice; // 400 days + // vertical lines at month borders + $addSpecial .= ' VRULE:'.strtotime(date('Y-01-01 12:00:00')).'#FF0000'; + $addSpecial .= ' VRULE:'.strtotime(date('Y-01-01 12:00:00').' -1 year').'#FF0000'; + } + else { + $duration = isset($gconf['duration'])?$gconf['duration']:$this->rrd_step*500; // 500 steps + $slice = isset($gconf['slice'])?$gconf['slice']:$this->rrd_step; // whatever our step is + } + + $use_gcrows = (isset($gconf['rows']) && count($gconf['rows'])); + if ($use_gcrows) { $grow_def =& $gconf['rows']; } + else { $grow_def =& $this->rrd_fields; } + foreach ($grow_def as $key=>$erow) { + if (isset($erow['name']) && strlen($erow['name'])) { + if (!isset($erow['scale']) && isset($gconf['scale'])) { $erow['scale'] = $gconf['scale']; } + if (!isset($erow['scale_time_src']) && isset($gconf['scale_time_src'])) { $erow['scale_time_src'] = $gconf['scale_time_src']; } + if (!isset($erow['scale_time_tgt']) && isset($gconf['scale_time_tgt'])) { $erow['scale_time_tgt'] = $gconf['scale_time_tgt']; } + foreach (array('scale_time_src','scale_time_tgt') as $st) { + if (!isset($erow[$st]) || !is_numeric($erow[$st])) { + switch (@$erow[$st]) { + case 'dyn': + case 'auto': + $erow[$st] = $slice; + break; + case 'day': + $erow[$st] = 24*3600; + break; + case '2hr': + case '2hours': + $erow[$st] = 7200; + break; + case 'hr': + case 'hour': + $erow[$st] = 3600; + break; + case '30min': + $erow[$st] = 1800; + break; + case '5min': + $erow[$st] = 300; + break; + case 'min': + $erow[$st] = 60; + break; + case 's': + case 'sec': + default: + $erow[$st] = 1; + break; + } + } + } + $scale_time_factor = $erow['scale_time_tgt']/$erow['scale_time_src']; + if ($scale_time_factor != 1) { $erow['scale'] = (isset($erow['scale'])?$erow['scale']:1)*$scale_time_factor; } + $grow = array(); + $grow['dType'] = ($use_gcrows && isset($erow['dType']))?$erow['dType']:'DEF'; + $grow['name'] = $erow['name'].(isset($erow['scale'])?'_tmp':''); + if ($grow['dType'] == 'DEF') { + $grow['dsname'] = ($use_gcrows && isset($erow['dsname']))?$erow['dsname']:$erow['name']; + if ($use_gcrows && isset($erow['dsfile'])) { $grow['dsfile'] = $erow['dsfile']; } + $grow['cf'] = ($use_gcrows && isset($erow['cf']))?$erow['cf']:'AVERAGE'; + } + else { + $grow['rpn_expr'] = isset($erow['rpn_expr'])?$erow['rpn_expr']:'0'; + } + if (isset($erow['scale'])) { + $graphrows[] = $grow; + $grow = array(); + $grow['dType'] = 'CDEF'; + $grow['name'] = $erow['name']; + $grow['rpn_expr'] = $erow['name'].'_tmp,'.$erow['scale'].',*'; + } + if ($use_gcrows) { $grow['gType'] = isset($erow['gType'])?$erow['gType']:'LINE1'; } + else { $grow['gType'] = ((count($grow_def)==2) && ($key==0))?'AREA':'LINE1'; } + $grow['color'] = isset($erow['color'])?$erow['color']:$gColors[$gC++]; + $grow['color_bg'] = isset($erow['color_bg'])?$erow['color_bg']:''; + if ($gC >= count($gColors)) { $gC = 0; } + if (isset($erow['legend'])) { + $grow['legend'] = $erow['legend']; + if (!isset($gconf['show_legend'])) { $gconf['show_legend'] = true; } + } + if (isset($erow['stack'])) { $grow['stack'] = ($erow['stack'] == true); } + if (isset($erow['desc'])) { $grow['desc'] = $erow['desc']; } + if (isset($erow['legend_long'])) { $grow['legend_long'] = $erow['legend_long']; } + $graphrows[] = $grow; + } + } + + if (isset($gconf['special']) && count($gconf['special'])) { + foreach ($gconf['special'] as $crow) { + $srow = array(); + $srow['sType'] = isset($crow['sType'])?$crow['sType']:'COMMENT'; + if ($grow['sType'] != 'COMMENT') { + // XXX: use line below and remove cf var once we have rrdtol 1.2 + if ($this->rrd_version() >= '1.2') { + $srow['name'] = $crow['name'].(isset($crow['cf'])?'_'.$crow['cf']:''); + } + else { + $srow['name'] = $crow['name']; + $srow['cf'] = isset($crow['cf'])?$crow['cf']:'AVERAGE'; + } + if (isset($crow['cf'])) { + if ($this->rrd_version() >= '1.2') { + $graphrows[] = array('dType'=>'VDEF', 'name'=>$srow['name'].'_'.$crow['cf'], 'rpn_expr'=>$srow['name'].','.$crow['cf']); + } + } + elseif (isset($crow['rpn_expr'])) { + if ($this->rrd_version() >= '1.2') { + $graphrows[] = array('dType'=>'VDEF', 'name'=>$srow['name'], 'rpn_expr'=>$crow['rpn_expr']); + } + } + } + $srow['text'] = isset($crow['text'])?$crow['text']:''; + $specialrows[] = $srow; + } + } + else { + $td = $this->mod_textdomain; + foreach ($graphrows as $grow) { + if (isset($grow['gType']) && strlen($grow['gType'])) { + $textprefix = isset($grow['desc'])?$grow['desc']:(isset($grow['legend'])?$grow['legend']:$grow['name']); + if ($this->rrd_version() >= '1.2') { + $graphrows[] = array('dType'=>'VDEF', 'name'=>'_'.$grow['name'].'__max', 'rpn_expr'=>$grow['name'].',MAXIMUM'); + $specialrows[] = array('sType'=>'PRINT', 'name'=>'_'.$grow['name'].'__max', 'text'=>$textprefix.'|'.dgettext($td, 'Maximum').'|%.2lf%s'); + $graphrows[] = array('dType'=>'VDEF', 'name'=>'_'.$grow['name'].'__avg', 'rpn_expr'=>$grow['name'].',AVERAGE'); + $specialrows[] = array('sType'=>'PRINT', 'name'=>'_'.$grow['name'].'__avg', 'text'=>$textprefix.'|'.dgettext($td, 'Average').'|%.2lf%s'); + $graphrows[] = array('dType'=>'VDEF', 'name'=>'_'.$grow['name'].'__last', 'rpn_expr'=>$grow['name'].',LAST'); + $specialrows[] = array('sType'=>'PRINT', 'name'=>'_'.$grow['name'].'__last', 'text'=>$textprefix.'|'.dgettext($td, 'Current').'|%.2lf%s'); + } + else { + $specialrows[] = array('sType'=>'PRINT', 'name'=>$grow['name'], 'cf'=>'MAX', 'text'=>$textprefix.'|'.dgettext($td, 'Maximum').'|%.2lf%s'); + $specialrows[] = array('sType'=>'PRINT', 'name'=>$grow['name'], 'cf'=>'AVERAGE', 'text'=>$textprefix.'|'.dgettext($td, 'Average').'|%.2lf%s'); + $specialrows[] = array('sType'=>'PRINT', 'name'=>$grow['name'], 'cf'=>'LAST', 'text'=>$textprefix.'|'.dgettext($td, 'Current').'|%.2lf%s'); + } + } + } + } + + $endtime = isset($gconf['time_end'])?$gconf['time_end']:(is_numeric($this->last_update())?$this->last_update():time()); + $gOpts = ' --start '.($endtime-$duration).' --end '.$endtime.' --step '.$slice; + if (isset($gconf['label_top'])) { $gOpts .= ' --title '.$this->text_quote($gconf['label_top']); } + if (isset($gconf['label_y'])) { $gOpts .= ' --vertical-label '.$this->text_quote($gconf['label_y']); } + if (isset($gconf['width'])) { $gOpts .= ' --width '.$gconf['width']; } + if (isset($gconf['height'])) { $gOpts .= ' --height '.$gconf['height']; + if (($gconf['height'] <= 32) && isset($gconf['thumb']) && ($gconf['thumb'])) { $gOpts .= ' --only-graph'; } + } + if (!isset($gconf['show_legend']) || (!$gconf['show_legend'])) { $gOpts .= ' --no-legend'; } + if (isset($gconf['logarithmic']) && $gconf['logarithmic']) { $gOpts .= ' --logarithmic'; } + if (isset($gconf['min_y'])) { $gOpts .= ' --lower-limit '.$gconf['min_y']; } + if (isset($gconf['max_y'])) { $gOpts .= ' --upper-limit '.$gconf['max_y']; } + if (isset($gconf['fix_scale_y']) && $gconf['fix_scale_y']) { $gOpts .= ' --rigid'; } + if (isset($gconf['grid_x'])) { $gOpts .= ' --x-grid '.$gconf['grid_x']; } + if (isset($gconf['grid_y'])) { $gOpts .= ' --y-grid '.$gconf['grid_y']; } + if (isset($gconf['gridfit']) && (!$gconf['gridfit'])) { $gOpts .= ' --no-gridfit'; } + if (isset($gconf['calc_scale_y']) && $gconf['calc_scale_y']) { $gOpts .= ' --alt-autoscale'; } + if (isset($gconf['calc_max_y']) && $gconf['calc_max_y']) { $gOpts .= ' --alt-autoscale-max'; } + if (isset($gconf['units_exponent'])) { $gOpts .= ' --units-exponent '.$gconf['units_exponent']; } + if (isset($gconf['units_length'])) { $gOpts .= ' --units-length '.$gconf['units_length']; } + if (($this->rrd_version() < '1.2') || !count($specialrows)) { + // lazy graphics omit all print reporting in RRDtool 1.2! + // --> so don't use them there when we want to print stuff + if (!isset($gconf['force_recreate']) || (!$gconf['force_recreate'])) { $gOpts .= ' --lazy'; } + } + if (isset($gconf['force_color']) && is_array($gconf['force_color'])) { + foreach ($gconf['force_color'] as $ctag=>$cval) { $gOpts .= ' --color '.$ctag.$cval; } + } + if (isset($gconf['force_font']) && is_array($gconf['force_font'])) { + foreach ($gconf['force_font'] as $ctag=>$cval) { $gOpts .= ' --font '.$ctag.$cval; } + } + if (isset($gconf['units_binary']) && $gconf['units_binary']) { $gOpts .= ' --base 1024'; } + + foreach ($graphrows as $grow) { + if (isset($grow['dType']) && strlen($grow['dType'])) { + $gDefs .= ' '.$grow['dType'].':'.$grow['name'].'='; + if ($grow['dType'] == 'DEF') { + $gDefs .= isset($grow['dsfile'])?$grow['dsfile']:$this->rrd_file; + $gDefs .= ':'.$grow['dsname'].':'.$grow['cf']; + } + else { $gDefs .= $grow['rpn_expr']; } + } + if (isset($grow['gType']) && strlen($grow['gType'])) { + // XXX: change from STACK type to STACK flag once we have rrdtool 1.2 + if ($this->rrd_version() < '1.2') { + // rrdtool 1.0 only know STACK type + if (isset($grow['stack']) && $grow['stack']) { $grow['gType'] = 'STACK'; } + } + $gGraphs .= ' '.$grow['gType'].':'.$grow['name'].$grow['color']; + if (isset($grow['legend'])) { $gGraphs .= ':'.$this->text_quote($grow['legend']); } + if ($this->rrd_version() >= '1.2') { + // rrdtool 1.2 and above have STACK flag + if (isset($grow['stack']) && $grow['stack']) { $gGraphs .= ':STACK'; } + } + } + } + + foreach ($specialrows as $srow) { + $addSpecial .= ' '.$srow['sType']; + if ($this->rrd_version() >= '1.2') { + $addSpecial .= (($srow['sType']!='COMMENT')?':'.$srow['name']:''); + } + else { + $addSpecial .= (($srow['sType']!='COMMENT')?':'.$srow['name'].':'.$srow['cf']:''); + } + $addSpecial .= ':'.$this->text_quote($srow['text']); + } + + $graph_cmd = 'rrdtool graph '.str_replace('*', '\*', $fname.$gOpts.$gDefs.$gGraphs.$addSpecial); + $return = `$graph_cmd 2>&1`; + + if (strpos($return, 'ERROR') !== false) { + trigger_error($this->rrd_file.' - rrd graph error: '.$return, E_USER_WARNING); + $return = 'command:'.$graph_cmd."\n\n".$return; + } + if (0) { + // debug output + $return = 'command:'.$graph_cmd."\n\n".$return; + } + $legendlines = ''; + foreach ($graphrows as $grow) { + $legendline = isset($grow['desc'])?$grow['desc']:(isset($grow['legend'])?$grow['legend']:$grow['name']); + $legendline .= '|'.@$grow['color']; + $legendline .= '|'.(isset($grow['color_bg'])?$grow['color_bg']:''); + $legendline .= '|'.(isset($grow['legend_long'])?$grow['legend_long']:''); + $legendlines .= 'legend:'.$legendline."\n"; + } + $return = 'file:'.$fname."\n".$legendlines.$return; + return $return; + } + + public function graph_plus($timeframe = 'day', $sub = null, $extra = null) { + // create a RRD graph and return meta info as a ready-to-use array + $gmeta = array('filename'=>null,'legends_long'=>false,'default_colorize'=>false); + $ret = $this->graph($timeframe, $sub, $extra); + if (0) { + // debug output + $gmeta['ret'] = $ret; + } + $grout = explode("\n", $ret); + foreach ($grout as $gline) { + if (preg_match('/^command:(.+)$/', $gline, $regs)) { + $gmeta['graph_cmd'] = $regs[1]; + } + elseif (preg_match('/^file:(.+)$/', $gline, $regs)) { + $gmeta['filename'] = $regs[1]; + } + elseif (preg_match('/^legend:([^\|]+)\|([^|]*)\|([^\|]*)\|(.*)$/', $gline, $regs)) { + $gmeta['legend'][$regs[1]] = array('color'=>$regs[2], 'color_bg'=>$regs[3], 'desc_long'=>$regs[4]); + if (strlen($regs[4])) { $gmeta['legends_long'] = true; } + if (strlen($regs[3]) || strlen($regs[4])) { $gmeta['default_colorize'] = true; } + } + elseif (preg_match('/^(\d+)x(\d+)$/', $gline, $regs)) { + $gmeta['width'] = $regs[1]; $gmeta['height'] = $regs[2]; + } + elseif (preg_match('/^([^\|]+)\|([^|]+)\|([^\|]*)$/', $gline, $regs)) { + $gmeta['data'][$regs[1]][$regs[2]] = $regs[3]; + } + elseif (preg_match('/^([^\|]+)\|([^\|]*)$/', $gline, $regs)) { + $gmeta['var'][$regs[1]] = $regs[2]; + } + elseif (strlen(trim($gline))) { + $gmeta['info'][] = $gline; + } + } + if (is_null($gmeta['filename'])) { + $gmeta['filename'] = $this->basename.(!is_null($sub)?'-'.$sub:'').'-'.$timeframe.'.png'; + } + return $gmeta; + } + + public function page($sub = null, $page_extras = null, $graph_extras = null) { + // create a (HTML) page and return it in a string + + // assemble configuration + $pconf = (array)$page_extras; + if (!is_null($sub) && is_array($this->config_raw['page.'.$sub])) { + $pconf = $pconf + $this->config_raw['page.'.$sub]; + } + $pconf = $pconf + (array)$this->config_page; + + $return = null; + switch (@$pconf['type']) { + case 'index': + $return = $this->page_index($pconf); + break; + case 'overview': + $return = $this->page_overview($pconf, $graph_extras); + break; + case 'simple': + default: + $return = $this->page_simple($pconf, $graph_extras); + break; + } + return $return; + } + + public function simple_html($sub = null, $page_extras = null, $graph_extras = null) { + // create a simple (MRTG-like) HTML page and return it in a string + // XXX: this is here temporarily for compat only, it's preferred to use page()! + trigger_error(__CLASS__.'::'.__METHOD__.' is deprecated, use page() instead.', E_USER_NOTICE); + + // assemble configuration + $pconf = (array)$page_extras; + if (!is_null($sub) && is_array($this->config_raw['page.'.$sub])) { + $pconf = $pconf + $this->config_raw['page.'.$sub]; + } + $pconf = $pconf + (array)$this->config_page; + + return $this->page_simple($pconf, $graph_extras); + } + + private function page_index($pconf) { + // create a bare, very simple index list HTML page and return it in a string + $td = $this->mod_textdomain; + $ptitle = isset($pconf['title_page'])?$pconf['title_page']:dgettext($td, 'RRD statistics index'); + + $out = ''."\n"; + $out .= ''.$ptitle.''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + + $out .= '

'.$ptitle.'

'."\n"; + if (isset($pconf['text_intro']) && strlen($pconf['text_intro'])) { + $out .= '

'.$pconf['text_intro'].'

'."\n"; + } + elseif (!isset($pconf['text_intro'])) { + $out .= '

'.dgettext($td, 'The following RRD stats are available:').'

'."\n"; + } + + $stats = $this->h_page_statsArray($pconf); + + if (isset($pconf['stats_url'])) { $sURL_base = $pconf['stats_url']; } + else { $sURL_base = '?stat=%i%a'; } + + if (isset($pconf['stats_url_add'])) { $sURL_add = $pconf['stats_url_add']; } + else { $sURL_add = '&sub=%s'; } + + $out .= ''."\n"; + + $out .= $this->h_page_footer(); + $out .= ''."\n"; + return $out; + } + + private function page_overview($pconf, $graph_extras = null) { + // create an overview HTML page (including graphs) and return it in a string + $td = $this->mod_textdomain; + $ptitle = isset($pconf['title_page'])?$pconf['title_page']:dgettext($td, 'RRD statistics overview'); + + $out = ''."\n"; + $out .= ''.$ptitle.''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + + $out .= '

'.$ptitle.'

'."\n"; + if (isset($pconf['text_intro']) && strlen($pconf['text_intro'])) { $out .= '

'.$pconf['text_intro'].'

'; } + + $stats = $this->h_page_statsArray($pconf); + + if (isset($pconf['stats_url'])) { $sURL_base = $pconf['stats_url']; } + else { $sURL_base = '?stat=%i%a'; } + + if (isset($pconf['stats_url_add'])) { $sURL_add = $pconf['stats_url_add']; } + else { $sURL_add = '&sub=%s'; } + + $num_rows = is_numeric($pconf['num_rows'])?$pconf['num_rows']:2; + $num_cols = ceil(count($stats)/$num_rows); + + $out .= ''."\n"; + for ($col = 0; $col < $num_cols; $col++) { + $out .= ''."\n"; + for ($row = 0; $row < $num_rows; $row++) { + $idx = $col * $num_rows + $row; + $out .= ''."\n"; + } + $out .= ''."\n"; + } + $out .= '
'."\n"; + if ($idx < count($stats)) { + @list($sname, $s_psub) = explode('|', $stats[$idx]['name'], 2); + $s_psname = 'page'.(isset($s_psub)?'.'.$s_psub:''); + $g_sub = @$this->config_all[$sname][$s_psname]['graph_sub']; + + if (isset($this->config_all[$sname][$s_psname]['title_page'])) { + $s_ptitle = $this->config_all[$sname][$s_psname]['title_page']; + } + elseif (isset($this->config_all[$sname]['page']['title_page'])) { + $s_ptitle = $this->config_all[$sname]['page']['title_page']; + } + else { + $s_ptitle = isset($s_psub)?sprintf(dgettext($td, '%s (%s) statistics'), $sname, $s_psub):sprintf(dgettext($td, '%s statistics'), $sname); + } + if (!isset($pconf['hide_titles']) || !$pconf['hide_titles']) { + $out .= '

'.$s_ptitle.'

'."\n"; + } + + $s_rrd = new rrdstat($this->config_all, $sname); + if (in_array($s_rrd->status, array('ok','readonly','graphonly'))) { + $tframe = isset($pconf['graph_timeframe'])?$pconf['graph_timeframe']:'day'; + $gmeta = $s_rrd->graph_plus($tframe, $g_sub); + if (isset($pconf['graph_url'])) { + $gURL = $pconf['graph_url']; + $gURL = str_replace('%f', basename($gmeta['filename']), $gURL); + $gURL = str_replace('%p', $gmeta['filename'], $gURL); + if (substr($gURL, -1) == '/') { $gURL .= $gmeta['filename']; } + } + else { + $gURL = $gmeta['filename']; + } + $sURL = str_replace('%i', $sname, $sURL_base); + $sURL = str_replace('%a', isset($s_psub)?$sURL_add:'', $sURL); + $sURL = str_replace('%s', isset($s_psub)?$s_psub:'', $sURL); + $out .= ''; + $out .= 'basename.(!is_null($g_sub)?' - '.$g_sub:'').' - '.$tframe.'" class="rrdgraph"'; + if (isset($gmeta['width']) && isset($gmeta['height'])) { $out .= ' style="width:'.$gmeta['width'].'px;height:'.$gmeta['height'].'px;"'; } + $out .= '>'."\n"; + } + else { + $out .= sprintf(dgettext($td, 'RRD error: status is "%s"'), $s_rrd->status)."\n"; + } + } + else { + $out .= ' '; + } + $out .= '
'."\n"; + + $out .= $this->h_page_footer(); + $out .= ''."\n"; + return $out; + } + + private function page_simple($pconf, $graph_extras = null) { + // create a simple (MRTG-like) HTML page and return it in a string + $td = $this->mod_textdomain; + + $ptitle = isset($pconf['title_page'])?$pconf['title_page']:sprintf(dgettext($td, '%s - RRD statistics'),$this->basename); + $gtitle = array(); + $gtitle['day'] = isset($pconf['title_day'])?$pconf['title_day']:dgettext($td, 'Day overview (scaling 5 minutes)'); + $gtitle['week'] = isset($pconf['title_week'])?$pconf['title_week']:dgettext($td, 'Week overview (scaling 30 minutes)'); + $gtitle['month'] = isset($pconf['title_month'])?$pconf['title_month']:dgettext($td, 'Month overview (scaling 2 hours)'); + $gtitle['year'] = isset($pconf['title_year'])?$pconf['title_year']:dgettext($td, 'Year overview (scaling 1 day)'); + $ltitle = isset($pconf['title_legend'])?$pconf['title_legend']:dgettext($td, 'Legend:'); + + $out = ''."\n"; + $out .= ''.$ptitle.''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; + + $out .= '

'.$ptitle.'

'."\n"; + if (isset($pconf['text_intro']) && strlen($pconf['text_intro'])) { $out .= '

'.$pconf['text_intro'].'

'."\n"; } + if (!isset($pconf['show_update']) || $pconf['show_update']) { + $out .= '

'; + if (is_null($this->last_update())) { $up_time = dgettext($td, 'unknown'); } + elseif (class_exists('baseutils')) { $up_time = baseutils::dateFormat($this->last_update(), 'short'); } + else { $up_time = date('Y-m-d H:i:s', $this->last_update()); } + $out .= sprintf(dgettext($td, 'Last Update: %s'), $up_time); + $out .= '

'."\n"; + } + + $g_sub = isset($pconf['graph_sub'])?$pconf['graph_sub']:null; + if (in_array($this->status, array('ok','readonly','graphonly'))) { + foreach (array('day','week','month','year') as $tframe) { + $gmeta = $this->graph_plus($tframe, $g_sub, $graph_extras); + if (isset($pconf['graph_url'])) { + $gURL = $pconf['graph_url']; + $gURL = str_replace('%f', basename($gmeta['filename']), $gURL); + $gURL = str_replace('%p', $gmeta['filename'], $gURL); + if (substr($gURL, -1) == '/') { $gURL .= $gmeta['filename']; } + } + else { + $gURL = $gmeta['filename']; + } + $out .= '
'."\n"; + if (0) { + // debug output + ob_start(); + print_r($gmeta); + $buffer = ob_get_contents(); + ob_end_clean(); + $out .= '

'.nl2br($buffer).'

'; + } + $out .= '

'.$gtitle[$tframe].'

'."\n"; + $out .= 'basename.(!is_null($g_sub)?' - '.$g_sub:'').' - '.$tframe.'" class="rrdgraph"'; + if (isset($gmeta['width']) && isset($gmeta['height'])) { $out .= ' style="width:'.$gmeta['width'].'px;height:'.$gmeta['height'].'px;"'; } + $out .= '>'."\n"; + $colorize_data = (isset($pconf['data_colorize']) && $pconf['data_colorize']) || (!isset($pconf['data_colorize']) && $gmeta['default_colorize']); + if (isset($gmeta['data']) && count($gmeta['data'])) { + $out .= ''."\n"; + foreach ($gmeta['data'] as $field=>$gdata) { + $out .= ''; + foreach ($gdata as $gkey=>$gval) { + $out .= ''; + } + $out .= ''."\n"; + } + $out .= '
'.$gkey.': '.$gval.'
'."\n"; + } + if (isset($gmeta['var']) && count($gmeta['var'])) { + foreach ($gmeta['var'] as $gkey=>$gval) { + $out .= '

'.$gkey.': '.$gval.'

'."\n"; + } + } + if (isset($gmeta['info']) && count($gmeta['info'])) { + foreach ($gmeta['info'] as $gval) { + $out .= '

'.$gval.'

'."\n"; + } + } + $out .= '
'."\n"; + } + if ($gmeta['legends_long'] && (!isset($pconf['show_legend']) || $pconf['show_legend'])) { + $out .= '
'."\n"; + $out .= '

'.$ltitle.'

'."\n"; + $out .= ''."\n"; + foreach ($gmeta['legend'] as $field=>$legend) { + if (strlen($legend['desc_long'])) { + $out .= ''; + $out .= ''; + $out .= ''."\n"; + } + } + $out .= '
'.$legend['desc_long'].'
'."\n"; + $out .= '
'."\n"; + } + } + else { + $out .= sprintf(dgettext($td, 'RRD error: status is "%s"'), $this->status)."\n"; + } + + $out .= $this->h_page_footer(); + $out .= ''."\n"; + return $out; + } + + private function h_page_statsArray($pconf) { + // return array of stats to list on a page + $stats = array(); + $snames = array(); $s_exclude = array(); $sfiles = array(); + if (isset($pconf['index_ids'])) { + foreach (explode(',', $pconf['index_ids']) as $iid) { + if ($iid{0} == '-') { $s_exclude[] = substr($iid, 1); } + else { $snames[] = $iid; } + } + } + if (!isset($pconf['scan_config']) || $pconf['scan_config']) { + foreach ($this->config_all as $iname=>$rinfo) { + if (($iname != '*') && !(isset($rinfo['hidden']) && $rinfo['hidden']) && + !(in_array($iname, $snames)) && !(in_array($iname, $s_exclude))) { + $snames[] = $iname; + } + } + } + foreach ($snames as $iname) { + $newstat = array('name'=>$iname); + $sfiles[] = isset($this->config_all[$iname]['file'])?$this->config_all[$iname]['file']:$iname.'.rrd'; + if (is_array($this->config_all[$iname])) { + foreach ($this->config_all[$iname] as $key=>$val) { + if (substr($key, 0, 5) == 'page.') { $newstat['sub'][] = substr($key, 5); } + } + } + $stats[] = $newstat; + } + if (isset($pconf['scan_files']) && $pconf['scan_files']) { + $rrdfiles = glob('*.rrd'); + foreach ($rrdfiles as $rrdfile) { + $iname = (substr($rrdfile, -4) == '.rrd')?substr($rrdfile, 0, -4):$rrdfile; + if (!in_array($rrdfile, $sfiles) && !(in_array($iname, $s_exclude))) { + $stats[] = array('name'=>$iname, 'class'=>'scanfile'); + } + } + } + return $stats; + } + + private function h_page_footer() { + // return generic page footer + $out = ''."\n"; + return $out; + } + + private function text_quote($text) { + $trans = array('"' => '\"', ':' => '\:'); + $qtext = '"'.strtr($text, $trans).'"'; + return $qtext; + } +} +?> diff --git a/testbed/ua_list.php b/testbed/ua_list.php new file mode 100644 index 0000000..9781fbf --- /dev/null +++ b/testbed/ua_list.php @@ -0,0 +1,63 @@ +pgtop('User Agents', $mycss); + +print('

User Agents

'."\n"); + +$ualist = is_readable($uafile)?file($uafile):array(); + +if (count($ualist)) { + print(''."\n"); + print(' '."\n"); + print(' '."\n"); + print(' '."\n"); + print(' '."\n"); + print(' '."\n"); + print(' '."\n"); + print(' '."\n"); + print(' '."\n"); + print(' '."\n"); + print(' '."\n"); + print(' '."\n"); + + foreach ($ualist as $uastring) { + $uastring = trim($uastring); + if (substr($uastring, 0, 1) == '#') { + // comment + print(' '."\n"); + print(' '."\n"); + print(' '."\n"); + } + else { + $ua = new userAgent($uastring); + print(' '."\n"); + print(' '."\n"); + print(' '."\n"); + print(' '."\n"); + print(' '."\n"); + print(' '."\n"); + print(' '."\n"); + print(' '."\n"); + print(' '."\n"); + print(' '."\n"); + print(' '."\n"); + } + } + print('
User Agent stringBrandVersionBotEngineeVerOSPlatformLang
'.substr($uastring, 1).'
'.$ua->getUAString().''.$ua->getBrand().''.$ua->getVersion().''.($ua->isBot()?'x':'-').''.$ua->getEngine().''.$ua->getEngineVersion().''.$ua->getOS().''.$ua->getPlatform().''.$ua->getLanguage().'
'."\n"); +} +else { + print('No User Agent strings found in file "'.$uafile.'".'."\n"); +} + +$wrapper->pgbottom(); +?> diff --git a/testbed/ua_list_raw.txt b/testbed/ua_list_raw.txt new file mode 100755 index 0000000..084cb89 --- /dev/null +++ b/testbed/ua_list_raw.txt @@ -0,0 +1,288 @@ +# collection of some known User Agent Strings: +# see also: +# http://www.pgts.com.au/pgtsj/pgtsj0208c.html http://www.psychedelix.com/agents/index.shtml http://en.wikipedia.org/wiki/User_agent +Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.3b) Gecko/20030114 +Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0rc3) Gecko/20020523 +Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.1) Gecko/20021005 +Mozilla/5.0 (X11; U; Linux ppc; en-US; rv:1.0.0) Gecko/20020622 Debian/1.0.0-0.woody.1 +Mozilla/5.0 (X11; U; Linux sparc64; en-US; rv:0.9.4) Gecko/20011029 +Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.5) Gecko/20031016 +Mozilla/5.0 (X11; U; NetBSD i386; en-US; rv:1.6) Gecko/20040315 +Mozilla/5.0 (X11; U; AIX 0006FADF4C00; en-US; rv:1.7b) Gecko/20040318 +Mozilla/5.0 (OS/2; U; Warp 4.5; de-AT; rv:1.7a) Gecko/20040225 +Mozilla/5.0 (X11; U; OpenVMS AlphaServer_ES40; en-US; rv:1.4) Gecko/20030826 SWB/V1.4 (HP) +Mozilla/5.0 (X11; U; HP-UX 9000/785; en-US; rv:1.4) Gecko/20030730 +Mozilla/5.0 (X11; Slackware; Linux i686; en-US; rv:1.7) Gecko/20040618 +Mozilla/5.0 (X11; U; Linux i686; rv:1.7.7) Gecko/20050414 +Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.6; f33eed1469017fe8b64dc7f3261eb135;) Gecko/20040113 +Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.7.5) Gecko/20050101 Firefox/1.0 +Mozilla/5.0 (Gameboy Color; U; Gameboy OS 2005; de-DE) Gecko/20041107 Firefox/1.0 +Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.5) Gecko/20041111 Firefox/1.0 +Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040618 MultiZilla/1.6.2.1d +Mozilla/5.0 (Linux; U; de, DE, de_DE@euro; m18) Gecko/20001010 +Mozilla/5.0 (Windows; U; Win 9x 4.90; de-DE; m18) Gecko/20010131 Netscape6/6.01 +Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.0.1) Gecko/20020823 Netscape/7.0 +Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:1.3a) Gecko/20021207 Phoenix/0.5 +Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4b) Gecko/20030516 Mozilla Firebird/0.6 +Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.5a) Gecko/20030728 Mozilla Firebird/0.6.1 +Mozilla/5.0 (Windows; U; Win95; en-US; rv:1.5a) Gecko/20030728 Mozilla Firebird/0.6.1 +Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7a) Gecko/20040216 Firefox/0.8.0+ +Mozilla/5.0 (BeOS; U; BeOS BePC; en-US; rv:1.7b) Gecko/20040228 Firefox/0.8.0+ (Mozilla/4.7 [en] (Win95; I)) +Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1 +Mozilla/5.0 (X11; Linux i686; rv:1.7.5) Gecko/20041108 Firefox/1.0 +Mozilla/5.0 (X11; U; Linux i686; chrome://navigator/locale/navigator.properties; rv:1.7.5) Gecko/20041107 Firefox/1.0 +Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.5) Gecko/20041217 Firefox/1.0.4 +Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.8b2) Gecko/20050324 SeaMonkey/1.0a +Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:1.0.1) Gecko/20021109 Chimera/0.6+ +Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7b) Gecko/20040302 Camino/0.7+ +Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031016 K-Meleon/0.8.1 +Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.7.13) Gecko/20050610 K-Meleon/0.9 +Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:1.0.1) Gecko/20020730 AOL/7.0 +Mozilla/5.0 (Windows; U; Windows CE 4.21; rv:1.8b4) Gecko/20050720 Minimo/0.007 +Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20061031 Firefox/1.5.0.7 Flock/0.7.7 +Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1) Gecko/20061024 Iceweasel/2.0 (Debian-2.0+dfsg-1) +Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031019 Epiphany/1.0.6 +Mozilla/5.0 (X11; U; Linux x86_64; en-GB; rv:1.8.0.4) Gecko/20060608 Ubuntu/dapper-security Epiphany/2.14 +Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.6) Gecko/20040402 Galeon/1.3.14 +Mozilla/5.0 (X11; U; Linux i686) Gecko/20040319 Galeon/1.3.7 +Mozilla/5.0 Galeon/1.2.7 (X11; Linux i686; U;) Gecko/20021204 +Galeon/1.3.7 (IE4 compatible; I; Windows XP) Galeon/1.3.7 Debian/1.3.7.20030803-1 +Microsoft Internet Explorer/4.0b1 (Windows 95) +Mozilla/1.22 (compatible; MSIE 1.5; Windows NT) +Mozilla/2.0 (compatible; MSIE 3.01; Windows 95) +Mozilla/4.0 (compatible; MSIE 5.0; Windows 95; DigExt) +Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90) +Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) +Mozilla/4.0 (compatible; MSIE 6.02; Windows 98) +Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; IE5.x/Winxx/EZN/xx; .NET CLR 1.1.4322) +Mozilla/4.0 (compatible ; MSIE 6.0; Windows NT 5.1) +Mozilla/4.0 (compatible; MSIE 5.5; Windows 98; Win 9x 4.90; T312461) +Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; YPC 3.0.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) +Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; Smartphone; 176x220) +Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Hotbar 4.5.1.0; MSN 6.1; MSNbMSFT; MSNmen-au; MSNc00; v5m) +Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; MSN 9.0;MSN 9.1; MSNbVZ02; MSNmen-us; MSNcOTH; MPLUS) +Mozilla/4.0 (compatible; MSIE 6.0; MSN 2.5; Windows 98) +Mozilla/4.0 (compatible; MSIE 5.12; Mac_PowerPC) +Mozilla/4.0 (compatible; MSIE 4.01; AOL 5.0; Mac_PPC) +Mozilla/4.0 (compatible; MSIE 4.01; AOL 4.0; Windows 95; Toshiba Corporation) +Mozilla/4.0 (compatible; MSIE 5.5; AOL 6.0;TargetAOL6.0; Windows 98) +Mozilla/4.0 (compatible; MSIE 6.0; AOL 9.0; Windows NT 5.1; {D2F65954-6A14-43B5-86BE-42556275B763}) +Mozilla/4.0 (compatible; MSIE 6.0; America Online Browser 1.1; rev1.5; Windows NT 5.1;) +Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; FunWebProducts; .NET CLR 1.1.4322) Netscape/8.0.1 +Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Crazy Browser 1.0.5) +Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; MyIE2; iRider 2.10.0008) +Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; MyIE2; Maxthon; .NET CLR 1.0.3705; .NET CLR 1.1.4322) +Microsoft Pocket Internet Explorer/0.6 +Mozilla/1.1 (compatible; MSPIE 2.0; Windows CE) +Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x320) +Advanced Browser (http://www.avantbrowser.com) +Avant Browser/1.2.789rel1 (http://www.avantbrowser.com) +Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Avant Browser [avantbrowser.com]) +AOL 8.0 (compatible; AOL 8.0; DOS; .NET CLR 1.1.4322) +MSFrontPage/6.0 +Mozilla/4.0 (compatible; MS FrontPage 6.0) +Mozilla/5.0 (compatible; Konqueror/3; Linux 2.4.18; X11; i686) +Mozilla/5.0 (compatible; Konqueror/3.1; Linux 2.4.22-10mdk; X11; i686; fr, fr_FR) +Mozilla/5.0 (compatible; Konqueror/3.2; Linux 2.6.5; X11; i686; en_US, es, fr, it, en_US.UTF-8, en) (KHTML, like Gecko) +Mozilla/5.0 (compatible; Konqueror/2.0.1; X11); Supports MD5-Digest; Supports gzip encoding +Mozilla/5.0 (compatible; Konqueror/3.2; Darwin) (KHTML, like Gecko) +Mozilla/5.0 (compatible; Konqueror/3.1; CYGWIN_NT-5.1) +Mozilla/5.0 (compatible; Konqueror/3.2; OpenBSD) (KHTML, like Gecko) +Mozilla/5.0 (compatible; Konqueror/3.4; Linux) KHTML/3.4.0 (like Gecko) +Mozilla/5.0 (compatible; Konqueror/3.3; Linux; X11; i686; es, en_US) KHTML/3.3.2 (like Gecko) +Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/51 (like Gecko) Safari/51 +Mozilla/4.0 (compatible; MSIE 5.12; Mac_PowerPC) OmniWeb/4.1.1-v424.6 +Mozilla/4.5 (compatible; OmniWeb/4.1.1-v423; Mac_PowerPC) +Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US) AppleWebKit/85 (KHTML, like Gecko) OmniWeb/v540 +Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US) AppleWebKit/125.4 (KHTML, like Gecko, Safari) OmniWeb/v563.51 +Mozilla/5.0 (Macintosh; U; PPC Mac OS X; de-de) AppleWebKit/418 (KHTML, like Gecko) Shiira/1.2.2 Safari/125 +Mozilla/5.0 (SymbianOS/9.1; U; en-us) AppleWebKit/413 (KHTML, like Gecko) Safari/413 +Opera/5.12 (Windows 2000; U) [de] +Mozilla/4.0 (compatible; MSIE 5.0; Windows XP) Opera 6.05 [ja] +Mozilla/4.0 (compatible; MSIE 6.0; X11; Linux i586) Opera 7.23 [en] +Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Opera 7.54 [de] +Mozilla/4.78 (Windows NT 5.1; U) Opera 7.21 [en] +Mozilla/5.0 (Windows NT 5.0; U; en) Opera 8.0 +Mozilla/4.0 (compatible; MSIE 6.0; Mac_PowerPC Mac OS X; en) Opera 8.0 +Opera/8.00 (Windows NT 5.1; U; en) +Opera/8.01 (X11; Linux i686; U; de) +Mozilla/5.0 (X11; Linux i686; U; en) Opera 8.01 +Mozilla/4.0 (compatible; MSIE 5.0; Mac_PowerPC) Opera 6.0 [de] +Mozilla/4.1 (compatible; MSIE 5.0; Symbian OS; Nokia 6600;423) Opera 6.10 [de] +Mozilla/4.0 (compatible; MSIE 6.0; Symbian OS; Nokia 6630/4.03.38; 6937) Opera 8.50 [es] +Mozilla/4.0 (compatible; MSIE 6.0; ; Linux armv5tejl; U) Opera 8.02 [en_US] Maemo browser 0.4.31 N770/SU-18 +Mozilla/4.0 (compatible; MSIE 6.0; Nitro) Opera 8.50 [ja] +Opera/9.00 (Wii; U; ; 1038-58; Wii Shop Channel/1.0; en) +Opera/8.01 (J2ME/MIDP; Opera Mini/2.0.4509/1316; fi; U; ssr) +Opera/2.0.3920 (J2ME/MIDP; Opera Mini; en; U; ssr) +Mozilla/4.75 [de] (Win98; U) +Mozilla/1.6 [en] (Windows NT 5.1; U) +Mozilla/1.0 (CP/M; 8-bit .NET) +Mozilla/3.01Gold (Win95; I) +Mozilla/4.08 (Macintosh; U; 68K) +Mozilla/4.76 [en]C-CCK-MCD cf476 (Windows NT 5.0; U) +Mozilla/4.8 [de] (X11; U; Linux 2.4.20-4GB i686) +Mozilla/4.61 [ja] (X11; I; Linux 2.2.13-33cmc1 i686) +Mozilla/4.7C-CCK-MCD {C-UDP; EBM-APPLE} (Macintosh; I; PPC) +Dillo/0.8.5-pre +ELinks/0.9.3 (textmode; Linux 2.6.8.1 i686; 118x82) +ELinks (0.4pre18; Linux 2.2.22 i686; 80x25) +Links (2.1pre11; Linux 2.4.20-20.7asp i686; 80x24) +Links (0.92; Linux 2.2.14-5.0 i586) +Links (2.1pre14; FreeBSD 4.9-RELEASE i386; x) +Links (2.1pre15; CYGWIN_NT-5.0 1.3.1(0.38/3/2) i686; x) +Links (1.00pre12; Linux 2.6.10-grsec i686; 139x54) (Debian pkg 0.99+1.00pre12-1) +Mozilla/5.0 (compatible; iCab 2.9.8; Macintosh; U, PPC; Mac OS X) +iCab/2.9.8 (Macintosh; U; PPC) +Mozilla/4.5 (compatible; iCab 2.9.8; Macintosh; U; PPC) +Lynx/2.8.4rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.6g +NCSA_Mosaic/2.0 (Windows 3.1) +NCSA_Mosaic/1.0 (X11; FreeBSD 1.2.0 i286) via proxy gateway CERN-HTTPD/1.0 +NCSA Mosaic/2-7-6 (X11;OpenVMS V7.2 VAX) +NCSA_Mosaic/2.6 (X11;IRIX 4.0.5F IP12) +Mozilla/4.0 (compatible; Voyager; AmigaOS) +Arexx (compatible; AmigaVoyager/2.95; AmigaOS +Mozilla/4.0 (compatible; ARexx; AmigaOS) +Mozilla/4.0 (compatible; MSIE 5.5; arexx) +Mozilla/4.0 (compatible; alpha 06; AmigaOS) +Mozilla/4.0 (compatible; AWEB 3.4 SE; AmigaOS) +IBrowse/2.3 (AmigaOS 3.9) +Mozilla/4.0 (compatible; MSIE 5.5; AmigaOS4.0) IBrowse 2.3 +Mozilla/4.0 (compatible; IBrowse 3.0; AmigaOS4.0) +Mozilla/4.0 (compatible; X 10.0; Commodore 64) +ICE Browser/v5_4_3_1 (Java 1.4.2_01; Windows XP 5.1 x86) +Mozilla/5.0 (NetWare; U; NetWare 6.0.04; en-PL) ICEbrowser/5.4.3 NovellViewPort/3.4.0 +Mozilla/3.0 (compatible; NetPositive/2.2) +Mozilla/4.76 [en] (PalmOS; U; WebPro/3.0.1a; Palm-Arz1) +Mozilla/4.7 (compatible; OffByOne; Windows 2000) +Mozilla/4.0 (PSP (PlayStation Portable); 2.00) +Mozilla/5.0 (PLAYSTATION 3; 1.00) +Mozilla/4.0 (compatible; DB Browse 4.3; DB OS 6.0) +Mozilla/4.75 compatible +Mozilla/5.0 +Mozilla/5.0 ( ; ; ; de; ) Firefox +Mozilla/5.0 (000000000; 0; 000 000 00 0 000000; 00000; 000000000) 00000000000000 +IBM-WebExplorer-DLL/v1.1h +Java/1.4.1_02 +LWP::Simple/5.79 +PHP/4.2.3 +w3m/0.5.1 +SonyEricssonK700i/R2AE SEMC-Browser/4.0.3 Profile/MIDP-2.0 Configuration/CLDC-1.1 UP.Link/6.2.3.15.0 (Google WAP Proxy/1.0) +SonyEricssonT610/R201 Profile/MIDP-1.0 Configuration/CLDC-1.0 (Google WAP Proxy/1.0) +Nokia3510i/1.0 (04.01) Profile/MIDP-1.0 Configuration/CLDC-1.0 UP.Link/5.1.1.5a (Google WAP Proxy/1.0) +Nokia7650/1.0 SymbianOS/6.1 Series60/0.9 Profile/MIDP-1.0 Configuration/CLDC-1.0 (Google WAP Proxy/1.0) +Nokia6630/1.0 (3.45.113) SymbianOS/8.0 Series60/2.6 Profile/MIDP-2.0 Configuration/CLDC-1.1 (Google WAP Proxy/1.0) +SIE-C60/12 UP.Browser/6.1.0.5.c.6 (GUI) MMP/1.0 (Google WAP Proxy/1.0) +OPWV-SDK/62 UP.Browser/6.2.2.1.208 (GUI) MMP/2.0 +Mozilla/4.0 (MobilePhone MM-8300/US/1.0) NetFront/3.1 MMP/2.0 +Mozilla/4.0 (MobilePhone SCP-5500/US/1.0) NetFront/3.0 MMP/2.0 FAKE (compatible; Googlebot/2.1; +http://www.google.com/bot.html) +Samsung-SPHA920 AU-MIC-A920/2.0 MMP/2.0 +MOT-E398/0E.20.59R MIB/2.2.1 Profile/MIDP-2.0 Configuration/CLDC-1.0 +Mozilla/4.0 (compatible; 240x320) IXI/Q05A2.4 +Mozilla/4.0 (compatible; AvantGo 6.0; FreeBSD) +curl/7.7.2 (powerpc-apple-darwin6.0) libcurl 7.7.2 (OpenSSL 0.9.6b) +curl/7.10.6 (i386-redhat-linux-gnu) libcurl/7.10.6 OpenSSL/0.9.7a ipv6 zlib/1.2.0.7 +amaya/8.3 libwww/5.4.0 +Python-urllib/1.15 +w3m/0.3.1 +Wget/1.8.2 modified +wget 1.1 +Mozilla/4.0 (compatible; Win32; WinHttp.WinHttpRequest.5) +GetRight/5.0.2 +FlashGet +Watchcat 2.3 Linux +Space Bison/0.02 [fu] (Win67; X; SK) +Anonymisiert durch Steganos Internet Anonym +Anonymisiert durch Steganos Internet Anonym Pro 6 +Mozilla/4.0 (compatible; BorderManager 3.0) +Mozilla/5.0 WebWasher 3.4 +Mozilla/5.0 (SaferSurf) Firefox 1.5 +# search bots: +W3C_Validator/1.305.2.12 libwww-perl/5.64 +Scooter/3.3 +Spinne/2.0 med_AH +Vagabondo/2.0 MT (webagent at wise-guys dot nl) +TurnitinBot/1.5 ( ">http://www.turnitin.com/robot/crawlerinfo.html) +FAST-WebCrawler/3.x Multimedia (mm dash crawler at fast dot no) +Firefly/1.0 (compatible; Mozilla 4.0; MSIE 5.5) +Googlebot/2.1 (+ ">http://www.googlebot.com/bot.html) +Googlebot (+http://www.google.com/bot.html) +Scrubby/2.2 ( ">http://www.scrubtheweb.com/) +psbot/0.1 (+ ">http://www.picsearch.com/bot.html) +NutchCVS/0.06-dev (Nutch; http://www.nutch.org/docs/en/bot.html; nutch-agent@lists.sourceforge.net) +ObjectsSearch/0.06 (ObjectsSearch; http://www.ObjectsSearch.com/bot.html; support@thesoftwareobjects.com) +NG/1.0 +URL_Spider_Pro/3.0 ( ">http://www.innerprise.net/usp-spider.asp)" +Pompos/1.3 ">http://dir.com/pompos.html +Szukacz/1.5 (robot; www.szukacz.pl/jakdzialarobot.html; info@szukacz.pl) +ASPseek/1.2.10 +NPBot-1/2.0 +NetResearchServer/2.7(loopimprovements.com/robot.html) +dloader(NaverRobot)/1.0 +Webchat/2.0 (www.webchat.de user crawler) +msnbot/1.0 (+http://search.msn.com/msnbot.htm) +Gigabot/2.0 +Mediapartners-Google/2.1 +Schmozilla/v9.14 Platinum +OmniExplorer_Bot/1.07 (+http://www.omni-explorer.com) Internet Categorizer +findlinks/0.926 (+http://wortschatz.uni-leipzig.de/findlinks/) +DataCha0s/2.0 +Amfibibot/0.07 (Amfibi Robot; http://www.amfibi.com; agent@amfibi.com) +aipbot/1.0 (aipbot; http://www.aipbot.com; aipbot@aipbot.com) +Mozilla/4.0 compatible ZyBorg/1.0 Daily Refresh Beta-d03 (wn.zyborg@looksmart.net; +Mozilla/2.0 (compatible; Ask Jeeves/Teoma) +Mozilla/5.0 (Slurp/si; slurp@inktomi.com; ">http://www.inktomi.com/slurp.html) +Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)" +Mozilla/5.0 (compatible; Synoobot/0.9; http://www.synoo.com/search/bot.html) +Mozilla/5.0 [en] (compatible; Gulper Web Bot 0.2.4 www.ecsl.cs.sunysb.edu/~maxim/cgi-bin/Link/GulperBot) +Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; Girafabot; girafabot at girafa dot com; +Mozilla/5.0 (compatible; Exabot/3.0; +http://www.exabot.com/go/robot) +Mozilla/5.0 (compatible; GalaxyBot/2.0; +http://www.galaxy.com/) +Mozilla/4.0 (compatible; NaverBot/1.0; http://help.naver.com/delete_main.asp) +Mozilla/5.0 (compatible;FindITAnswersbot/1.0; http://search.it-influentials.com/bot.htm) +Mozilla/5.0 (compatible: Nebullabot/2.2) +Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1) VoilaBot BETA 1.2 (http://www.voila.com/) +Mozilla/4.0 (efp@gmx.net) +Mozilla/4.5 (compatible; HTTrack 3.0x; Windows 98) +Mozilla/5.0 (Twiceler-0.9 http://www.cuill.com/twiceler/robot.html) +Mozilla/4.0 (compatible; Arachmo) +Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.) +Mozilla/5.0 (compatible; heritrix/1.12.0 +http://www.accelobot.com) +Mozilla/2.0 compatible; Check&Get 1.14 (Windows NT) +Mozilla/3.0 (compatible; WebCapture 2.0; Auto; Windows) +Mozilla/3.0 (compatible; WebMon 1.0.11; Windows XP) +Mozilla/4.0 (compatible; Powermarks/3.5; Windows 95/98/2000/NT) +Mozilla/3.0 (compatible; Linkman) +Mozilla/5.0 (Sage) +Mozilla/5.0 (compatible; http://www.livedir.net) +Mozilla/4.0 (WebClipping.com) +Mozilla/5.0 (compatible; OsO; http://oso.octopodus.com/abot.html) +Mozilla/5.0 (compatible; Yoono; http://www.yoono.com/) +Mozilla/3.0 (compatible; Indy Library) +Mozilla/5.0 (compatible; Google Desktop) +PingALink Monitoring Services 1.0 (http://www.pingalink.com) +IlTrovatore-Setaccio (+ ">http://www.iltrovatore.it) +Mercator-2.0 +appie 1.1 (www.walhello.com) +larbin_2.6.2 (larbin2.6.2@unspecified.mail) +OWR_Crawler 0.1 +search.ch V1.4.2 (spiderman@search.ch; +WebFilter Robot 1.0 +WWWeasel Robot v1.00 (http://wwweasel.de) +2.0_AC-Plug - http://www.iOpus.com +Openfind data gatherer, Openbot/3.0+(robot-response@openfind.com.tw;+ +Baiduspider+(+http://www.baidu.com/search/spider.htm) +BaiDuSpider +LinkWalker +Internet Explorer 5.5 +Mozilla/4.0 (compatible; B-l-i-t-z-B-O-T) +B l i t z B O T @ t r i c u s . n e t (Mozilla compatible) +sitecheck.internetseer.com (For more info see: ">http://sitecheck.internetseer.com) +http://www.almaden.ibm.com/cs/crawler   [c01] +ia_archiver +Nutch +NutchCVS +Mozilla +HeinrichderMiragoRobot +dumbBot +42_HAL diff --git a/testbed/ua_test.php b/testbed/ua_test.php index e398bdb..30b485a 100644 --- a/testbed/ua_test.php +++ b/testbed/ua_test.php @@ -25,7 +25,7 @@ print("
The engine version is reported as "".$ua->getEngineVersion(). print("
The operating system is reported as "".$ua->getOS().""\n"); print("
The system platform is reported as "".$ua->getPlatform().""\n"); print("
The browser language is reported as "".$ua->getLanguage().""\n"); -if ($ua->geckobased()) { print("
The Gecko date is reported as "".$ua->getGeckoDate().""\n"); } +if ($ua->hasEngine('gecko')) { print("
The Gecko date is reported as "".$ua->getGeckoDate().""\n"); } print("

I conclude this must be ".$ua->getBrand()." ".$ua->getVersion()."\n"); print("
This is ".($ua->isBot()?"an":"no")." automated robot.\n"); @@ -36,7 +36,7 @@ print("\n"); print("

Test the following UA string (leave empty to read it from your browser):\n"); print("

\n"); -print("uastring)."\" size=\"80\" maxlength=\"150\">\n"); +print("getUAString())."\" size=\"80\" maxlength=\"150\">\n"); print("

\n"); $wrapper->pgbottom(); ?> -- 2.43.0