rrd based system stats
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

897 lines
40 KiB

  1. <?php
  2. define('CONFIG', '%%WWW_CONFIG%%');
  3. define('BASE_DIR', '%%DATA_DIR%%');
  4. define('RRDTOOL', '/usr/bin/rrdtool');
  5. function setup_html($conf) {
  6. echo "<html><head><title>sammler graph setup</title>\n";
  7. echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-15\"/>\n";
  8. echo "</head><body>\n";
  9. echo "<form method=\"POST\" action=\"{$_SERVER['SCRIPT_NAME']}?action=setup\">\n";
  10. echo "<table>\n";
  11. echo "<tr><td><b>Graph Height:</b></td>\n";
  12. echo "<td><input type=\"text\" name=\"height\" value=\"{$conf['height']}\"></td></tr>\n";
  13. echo "<tr><td><b>Graph Width:</b></td>\n";
  14. echo "<td><input type=\"text\" name=\"width\" value=\"{$conf['width']}\"></td></tr>\n";
  15. echo "<tr><td colspan=\"4\"><hr></td></tr>\n";
  16. echo "<tr><td><b>Available Views:</b></td><td colspan=\"2\"></td><td><b>default</b></td></tr>\n";
  17. foreach ($conf['views'] as $name => $value) {
  18. echo "<tr><td>({$value}s)</td>\n";
  19. echo "<td><input type=\"text\" name=\"views[$value]\" value=\"{$name}\"></td><td></td>\n";
  20. if ($conf['default_view'] == $value)
  21. echo "<td><input type=\"radio\" name=\"default_view\" value=\"{$value}\" checked=\"checked\"></td>\n";
  22. else
  23. echo "<td><input type=\"radio\" name=\"default_view\" value=\"{$value}\"></td>\n";
  24. echo "</tr>\n";
  25. }
  26. echo "<tr><td><b>add view:</b></td><td><input type=\"text\" name=\"views[new]\"></td></tr>\n";
  27. echo "<tr><td colspan=\"4\"><hr></td></tr>\n";
  28. foreach ($conf['hosts'] as $hostid => $host) {
  29. echo "<tr><td><b>Hostname:</b></td>\n";
  30. echo "<td><input type=\"text\" name=\"hosts[{$hostid}][hostname]\" value=\"{$host['hostname']}\"></td>\n";
  31. echo "<td><a href=\"{$_SERVER['SCRIPT_NAME']}?action=setup&sub=move_host_up&host={$hostid}\">up</a>&nbsp;\n";
  32. echo "<a href=\"{$_SERVER['SCRIPT_NAME']}?action=setup&sub=move_host_down&host={$hostid}\">down</a></td>\n";
  33. if ($host['show'])
  34. echo "<td><input type=\"checkbox\" name=\"hosts[{$hostid}][show]\" checked=\"checked\">show</td>";
  35. else
  36. echo "<td><input type=\"checkbox\" name=\"hosts[{$hostid}][show]\">show</td>";
  37. echo "</tr>\n";
  38. foreach ($host['rrds'] as $rrdid => $rrd) {
  39. echo "<tr><td>&nbsp;&nbsp;{$rrd['rrd']}</td>\n";
  40. echo "<td><input type=\"text\" name=\"hosts[{$hostid}][rrds][{$rrdid}][title]\" value=\"{$rrd['title']}\"></td>\n";
  41. echo "<td><a href=\"{$_SERVER['SCRIPT_NAME']}?action=setup&sub=move_rrd_up&host={$hostid}&rrd={$rrdid}\">up</a>&nbsp;\n";
  42. echo "<a href=\"{$_SERVER['SCRIPT_NAME']}?action=setup&sub=move_rrd_down&host={$hostid}&rrd={$rrdid}\">down</a></td>\n";
  43. if ($rrd['show'])
  44. echo "<td><input type=\"checkbox\" name=\"hosts[{$hostid}][rrds][{$rrdid}][show]\" checked=\"checked\">show</td>";
  45. else
  46. echo "<td><input type=\"checkbox\" name=\"hosts[{$hostid}][rrds][{$rrdid}][show]\">show</td>";
  47. echo "</tr>\n";
  48. }
  49. echo "<tr><td colspan=\"4\"><hr></td></tr>\n";
  50. }
  51. echo "<tr><td colspan=\"4\" align=\"center\">\n";
  52. echo "<input type=\"button\" value=\"Show\" onClick=\"javascript:window.location.href='{$_SERVER['SCRIPT_NAME']}?action=show'\">&nbsp\n";
  53. echo "<input type=\"submit\" value=\"Save Config\">&nbsp\n";
  54. echo "<input type=\"button\" value=\"Rebuild Config\" onClick=\"javascript:window.location.href='{$_SERVER['SCRIPT_NAME']}?action=init'\">\n";
  55. echo "</td></tr>\n";
  56. echo "</table></form>\n";
  57. echo "</body></html>\n";
  58. }
  59. function show_html($conf) {
  60. echo "<html><head><title>Stats</title>\n";
  61. echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-15\"/>\n";
  62. echo "</head><body>\n";
  63. $hostid = isset($_GET['host']) ? $_GET['host'] : 0;
  64. $view = isset($_GET['view']) ? $_GET['view'] : $conf['default_view'];
  65. echo "<b>Select Host:</b>\n";
  66. echo "<select name=\"host\" OnChange=\"document.location.href='{$_SERVER['SCRIPT_NAME']}?action=show&host='+this.value+'&view={$view}'\">\n";
  67. foreach ($conf['hosts'] as $id => $host) {
  68. if (!$host['show'])
  69. continue;
  70. if ($hostid == $id)
  71. echo "<option value=\"{$id}\" selected=\"selected\">{$host['hostname']}</option>\n";
  72. else
  73. echo "<option value=\"{$id}\">{$host['hostname']}</option>\n";
  74. }
  75. echo "</select>&nbsp;\n";
  76. echo "<td><select name=\"view\" OnChange=\"document.location.href='{$_SERVER['SCRIPT_NAME']}?action=show&host={$hostid}&view='+this.value\">\n";
  77. foreach ($conf['views'] as $name => $value) {
  78. if ($view == $value)
  79. echo "<option value=\"{$value}\" selected=\"selected\">{$name}</option>\n";
  80. else
  81. echo "<option value=\"{$value}\">{$name}</option>\n";
  82. }
  83. echo "</select><br><br>\n";
  84. foreach ($conf['hosts'][$hostid]['rrds'] as $rrdid => $rrd) {
  85. if (!$rrd['show'])
  86. continue;
  87. echo "<img src=\"{$_SERVER['SCRIPT_NAME']}?action=rrd&host={$hostid}&rrd={$rrdid}&view={$view}\" border=\"0\"><br><br>\n";
  88. }
  89. echo "</body></html>\n";
  90. }
  91. function read_config($filename) {
  92. $handle = @fopen($filename, "r");
  93. if ($handle !== false && filesize($filename) > 0) {
  94. $contents = fread($handle, filesize($filename));
  95. fclose($handle);
  96. return unserialize($contents);
  97. }
  98. }
  99. function write_config($filename, $config) {
  100. $handle = fopen($filename, "w+");
  101. if ($handle !== false) {
  102. $contents = serialize($config);
  103. fwrite($handle, $contents);
  104. fclose($handle);
  105. }
  106. }
  107. function get_hostdirs() {
  108. $retval = array();
  109. $dh = opendir(BASE_DIR);
  110. while (($file = readdir($dh)) !== false)
  111. if (is_dir(BASE_DIR.$file) && $file != "." && $file != "..")
  112. $retval[] = $file;
  113. closedir($dh);
  114. natsort($retval);
  115. return $retval;
  116. }
  117. function get_rrdfiles($directory) {
  118. $retval = array();
  119. $dh = opendir(BASE_DIR.$directory);
  120. while (($file = readdir($dh)) !== false) {
  121. if (is_dir(BASE_DIR.$file))
  122. continue;
  123. if (strstr($file, "rrd") !== false)
  124. $retval[] = $file;
  125. }
  126. closedir($dh);
  127. natsort($retval);
  128. return $retval;
  129. }
  130. function get_rrd_type($filename) {
  131. $types = array_flip(array(
  132. "cpu",
  133. "load",
  134. "memory",
  135. "swap",
  136. "proc",
  137. "vmstat",
  138. "random",
  139. "uptime",
  140. "hwmon",
  141. "alixusv",
  142. "net",
  143. "rtstat",
  144. "rtcache",
  145. "ctstat",
  146. "conntrack",
  147. "disk",
  148. "mount",
  149. "apache",
  150. "mysql",
  151. "ts2"
  152. ));
  153. $tmp1 = explode('-', $filename);
  154. $tmp2 = explode('_', $tmp1[0]);
  155. $type = $tmp2[0];
  156. if (isset($types[$type]))
  157. return $types[$type];
  158. return $filename;
  159. }
  160. function rrd_sort($a, $b) {
  161. if (!is_numeric($a['type']) && !is_numeric($b['type']))
  162. return strcmp($a['type'], $b['type']);
  163. if (is_numeric($a['type']) && !is_numeric($b['type']))
  164. return -1;
  165. if (!is_numeric($a['type']) && is_numeric($b['type']))
  166. return +1;
  167. if ($a['type'] > $b['type'])
  168. return +1;
  169. if ($a['type'] < $b['type'])
  170. return -1;
  171. return strcmp($a['title'], $b['title']);
  172. }
  173. function create_config() {
  174. $conf = array();
  175. $conf['default_view'] = 86400;
  176. $conf['views'] = array("1 hour" => 3600,
  177. "6 hours" => 21600,
  178. "1 day" => 86400,
  179. "1 week" => 604800,
  180. "1 month" => 2678400);
  181. $conf['height'] = 120;
  182. $conf['width'] = 800;
  183. $conf['hosts'] = array();
  184. $hosts = get_hostdirs();
  185. foreach ($hosts as $host) {
  186. $rrds = array();
  187. $tmp = get_rrdfiles($host);
  188. foreach ($tmp as $file) {
  189. $basename = str_replace(".rrd", "", basename($file));
  190. $rrds[] = array(
  191. 'show' => true,
  192. 'title' => $basename,
  193. 'rrd' => "$host/$file",
  194. 'type' => get_rrd_type($basename),
  195. );
  196. }
  197. uasort($rrds, rrd_sort);
  198. $conf['hosts'][] = array(
  199. 'hostname' => $host,
  200. 'show' => true,
  201. 'rrds' => $rrds,
  202. );
  203. }
  204. return $conf;
  205. }
  206. function setup($conf) {
  207. if (isset($_GET['sub']) && $_GET['sub'] == "move_host_up") {
  208. $hostid = isset($_GET['host']) ? $_GET['host'] : -1;
  209. if (isset($conf['hosts'][$hostid]) && isset($conf['hosts'][$hostid -1])) {
  210. $a = $conf['hosts'][$hostid];
  211. $b = $conf['hosts'][$hostid -1];
  212. $conf['hosts'][$hostid] = $b;
  213. $conf['hosts'][$hostid -1] = $a;
  214. }
  215. return $conf;
  216. } else if (isset($_GET['sub']) && $_GET['sub'] == "move_host_down") {
  217. $hostid = isset($_GET['host']) ? $_GET['host'] : -1;
  218. if (isset($conf['hosts'][$hostid]) && isset($conf['hosts'][$hostid +1])) {
  219. $a = $conf['hosts'][$hostid];
  220. $b = $conf['hosts'][$hostid +1];
  221. $conf['hosts'][$hostid] = $b;
  222. $conf['hosts'][$hostid +1] = $a;
  223. }
  224. return $conf;
  225. } else if (isset($_GET['sub']) && $_GET['sub'] == "move_rrd_up") {
  226. $hostid = isset($_GET['host']) ? $_GET['host'] : -1;
  227. $rrdid = isset($_GET['rrd']) ? $_GET['rrd'] : -1;
  228. if (isset($conf['hosts'][$hostid]['rrds'][$rrdid]) && isset($conf['hosts'][$hostid]['rrds'][$rrdid -1])) {
  229. $a = $conf['hosts'][$hostid]['rrds'][$rrdid];
  230. $b = $conf['hosts'][$hostid]['rrds'][$rrdid -1];
  231. $conf['hosts'][$hostid]['rrds'][$rrdid] = $b;
  232. $conf['hosts'][$hostid]['rrds'][$rrdid -1] = $a;
  233. }
  234. return $conf;
  235. } else if (isset($_GET['sub']) && $_GET['sub'] == "move_rrd_down") {
  236. $hostid = isset($_GET['host']) ? $_GET['host'] : -1;
  237. $rrdid = isset($_GET['rrd']) ? $_GET['rrd'] : -1;
  238. if (isset($conf['hosts'][$hostid]['rrds'][$rrdid]) && isset($conf['hosts'][$hostid]['rrds'][$rrdid +1])) {
  239. $a = $conf['hosts'][$hostid]['rrds'][$rrdid];
  240. $b = $conf['hosts'][$hostid]['rrds'][$rrdid +1];
  241. $conf['hosts'][$hostid]['rrds'][$rrdid] = $b;
  242. $conf['hosts'][$hostid]['rrds'][$rrdid +1] = $a;
  243. }
  244. return $conf;
  245. } else if (!empty($_POST)) {
  246. $conf['default_view'] = $_POST['default_view'];
  247. $conf['height'] = $_POST['height'];
  248. $conf['width'] = $_POST['width'];
  249. $conf['views'] = array();
  250. foreach ($_POST['views'] as $name) {
  251. if (empty($name))
  252. continue;
  253. $tmp = strtotime($name);
  254. if ($tmp != -1)
  255. $conf['views'][$name] = $tmp - time();
  256. }
  257. natsort($conf['views']);
  258. foreach ($_POST['hosts'] as $hostid => $host) {
  259. $conf['hosts'][$hostid]['hostname'] = $host['hostname'];
  260. $conf['hosts'][$hostid]['show'] = ($host['show'] == "on");
  261. foreach ($host['rrds'] as $rrdid => $rrd) {
  262. $conf['hosts'][$hostid]['rrds'][$rrdid]['title'] = $_POST['hosts'][$hostid]['rrds'][$rrdid]['title'];
  263. $conf['hosts'][$hostid]['rrds'][$rrdid]['show'] = ($_POST['hosts'][$hostid]['rrds'][$rrdid]['show'] == "on");
  264. }
  265. }
  266. return $conf;
  267. } else {
  268. setup_html($conf);
  269. }
  270. }
  271. function show_rrd($conf) {
  272. $hostid = isset($_GET['host']) ? $_GET['host'] : -1;
  273. $rrdid = isset($_GET['rrd']) ? $_GET['rrd'] : -1;
  274. if (!isset($conf['hosts'][$hostid]['rrds'][$rrdid]['rrd']))
  275. return;
  276. $view = isset($_GET['view']) ? -$_GET['view'] : -$conf['default_view'];
  277. $rrdfile = BASE_DIR.$conf['hosts'][$hostid]['rrds'][$rrdid]['rrd'];
  278. $title = $conf['hosts'][$hostid]['rrds'][$rrdid]['title'];
  279. $height = $conf['height'];
  280. $width = $conf['width'];
  281. $cmd = RRDTOOL." graph - --imgformat PNG --start {$view} --end -10 --title \"{$title}\" --rigid ";
  282. $tmp1 = explode('-', basename($rrdfile));
  283. $tmp2 = explode('_', $tmp1[0]);
  284. $tmp3 = explode('.', $tmp2[0]);
  285. switch ($tmp3[0]) {
  286. case 'alixusv':
  287. $height *= 2;
  288. $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale --vertical-label=\"Voltage\" ".
  289. "DEF:a={$rrdfile}:ibat:AVERAGE ".
  290. "DEF:b={$rrdfile}:ubat:AVERAGE ".
  291. "DEF:c={$rrdfile}:uin:AVERAGE ".
  292. 'CDEF:aa=a,50,/ '.
  293. 'CDEF:bb=b,1000,/ '.
  294. 'CDEF:cc=c,1000,/ '.
  295. 'CDEF:perr=aa,UN,INF,UNKN,IF CDEF:nerr=aa,UN,-INF,UNKN,IF '.
  296. 'HRULE:0#808080 AREA:perr#FFD0D0 AREA:nerr#FFD0D0 '.
  297. 'LINE2:aa#FF0000:"Ibat " GPRINT:a:LAST:"Current\:%7.0lf%smA" GPRINT:a:MIN:"Minimum\:%7.0lf%smA" GPRINT:a:MAX:"Maximum\:%7.0lf%smA\n" '.
  298. 'LINE2:bb#00CF00:"Ubat " GPRINT:bb:LAST:"Current\:%7.3lf%s V" GPRINT:bb:MIN:"Minimum\:%7.3lf%s V" GPRINT:bb:MAX:"Maximum\:%7.3lf%s V\n" '.
  299. 'LINE2:cc#0000FF:"Uin " GPRINT:cc:LAST:"Current\:%7.3lf%s V" GPRINT:cc:MIN:"Minimum\:%7.3lf%s V" GPRINT:cc:MAX:"Maximum\:%7.3lf%s V\n" '.
  300. '';
  301. break;
  302. case 'apache':
  303. $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"Workers\" ".
  304. "DEF:aa={$rrdfile}:total_accesses:AVERAGE ".
  305. "DEF:b={$rrdfile}:total_kbytes:AVERAGE ".
  306. "DEF:c={$rrdfile}:busy_workers:AVERAGE ".
  307. "DEF:d={$rrdfile}:idle_workers:AVERAGE ".
  308. 'CDEF:a=aa,60,* '.
  309. 'CDEF:err=aa,UN,INF,UNKN,IF '.
  310. 'AREA:err#FFD0D0 '.
  311. 'AREA:c#FF0000:"Busy Workers" GPRINT:c:LAST:"Current\:%8.2lf %s" GPRINT:c:AVERAGE:"Average\:%8.2lf %s" GPRINT:c:MAX:"Maximum\:%8.2lf %s\n" '.
  312. 'STACK:d#00CF00:"Idle Workers" GPRINT:d:LAST:"Current\:%8.2lf %s" GPRINT:d:AVERAGE:"Average\:%8.2lf %s" GPRINT:d:MAX:"Maximum\:%8.2lf %s\n" '.
  313. 'LINE2:a#0000FF:"Accesses " GPRINT:a:LAST:"Current\:%8.2lf %s" GPRINT:a:AVERAGE:"Average\:%8.2lf %s" GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" '.
  314. '';
  315. break;
  316. case 'cpu':
  317. $height *= 2;
  318. $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"percent\" ".
  319. "DEF:a={$rrdfile}:user:AVERAGE ".
  320. "DEF:b={$rrdfile}:nice:AVERAGE ".
  321. "DEF:c={$rrdfile}:system:AVERAGE ".
  322. "DEF:e={$rrdfile}:iowait:AVERAGE ".
  323. "DEF:f={$rrdfile}:irq:AVERAGE ".
  324. "DEF:g={$rrdfile}:softirq:AVERAGE ".
  325. "DEF:h={$rrdfile}:steal:AVERAGE ".
  326. "DEF:amax={$rrdfile}:user:MAX ".
  327. "DEF:bmax={$rrdfile}:nice:MAX ".
  328. "DEF:cmax={$rrdfile}:system:MAX ".
  329. "DEF:emax={$rrdfile}:iowait:MAX ".
  330. "DEF:fmax={$rrdfile}:irq:MAX ".
  331. "DEF:gmax={$rrdfile}:softirq:MAX ".
  332. "DEF:hmax={$rrdfile}:steal:MAX ".
  333. "CDEF:allmax=amax,bmax,cmax,emax,fmax,gmax,hmax,+,+,+,+,+,+ ".
  334. 'CDEF:err=allmax,UN,INF,UNKN,IF '.
  335. 'AREA:err#FFD0D0 '.
  336. 'AREA:allmax#C0C0C0 LINE1:allmax#808080 '.
  337. 'AREA:c#FF0000:"System " GPRINT:c:LAST:"Current\:%8.2lf %s" GPRINT:c:AVERAGE:"Average\:%8.2lf %s" GPRINT:c:MAX:"Maximum\:%8.2lf %s\n" '.
  338. 'STACK:f#EA8F00:"IRQ " GPRINT:f:LAST:"Current\:%8.2lf %s" GPRINT:f:AVERAGE:"Average\:%8.2lf %s" GPRINT:f:MAX:"Maximum\:%8.2lf %s\n" '.
  339. 'STACK:g#FFFF00:"Soft-IRQ" GPRINT:g:LAST:"Current\:%8.2lf %s" GPRINT:g:AVERAGE:"Average\:%8.2lf %s" GPRINT:g:MAX:"Maximum\:%8.2lf %s\n" '.
  340. 'STACK:h#0040FF:"IO-Wait " GPRINT:e:LAST:"Current\:%8.2lf %s" GPRINT:e:AVERAGE:"Average\:%8.2lf %s" GPRINT:e:MAX:"Maximum\:%8.2lf %s\n" '.
  341. 'STACK:a#00CFCF:"User " GPRINT:a:LAST:"Current\:%8.2lf %s" GPRINT:a:AVERAGE:"Average\:%8.2lf %s" GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" '.
  342. 'STACK:b#00CF00:"Nice " GPRINT:b:LAST:"Current\:%8.2lf %s" GPRINT:b:AVERAGE:"Average\:%8.2lf %s" GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" '.
  343. 'STACK:h#FF00FF:"Stolen " GPRINT:h:LAST:"Current\:%8.2lf %s" GPRINT:h:AVERAGE:"Average\:%8.2lf %s" GPRINT:h:MAX:"Maximum\:%8.2lf %s\n" ';
  344. break;
  345. case 'conntrack':
  346. $tmp3 = explode('.', $tmp1[1]);
  347. switch ($tmp3[0]) {
  348. case 'proto':
  349. $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --vertical-label=\"Connections\" ".
  350. "DEF:a={$rrdfile}:tcp:AVERAGE ".
  351. "DEF:b={$rrdfile}:udp:AVERAGE ".
  352. "DEF:c={$rrdfile}:unknown:AVERAGE ".
  353. 'CDEF:err=a,UN,INF,UNKN,IF '.
  354. 'AREA:err#FFD0D0 '.
  355. 'AREA:a#00CF00:"tcp " GPRINT:a:LAST:"Current\:%8.2lf %s" GPRINT:a:AVERAGE:"Average\:%8.2lf %s" GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" '.
  356. 'STACK:b#0000FF:"udp " GPRINT:b:LAST:"Current\:%8.2lf %s" GPRINT:b:AVERAGE:"Average\:%8.2lf %s" GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" '.
  357. 'STACK:c#FF0000:"unknown" GPRINT:c:LAST:"Current\:%8.2lf %s" GPRINT:c:AVERAGE:"Average\:%8.2lf %s" GPRINT:c:MAX:"Maximum\:%8.2lf %s\n" ';
  358. break;
  359. case 'tcp':
  360. $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --vertical-label=\"TCP Connections\" ".
  361. "DEF:a={$rrdfile}:none:AVERAGE ".
  362. "DEF:b={$rrdfile}:syn_sent:AVERAGE ".
  363. "DEF:c={$rrdfile}:syn_recv:AVERAGE ".
  364. "DEF:d={$rrdfile}:established:AVERAGE ".
  365. "DEF:e={$rrdfile}:fin_wait:AVERAGE ".
  366. "DEF:f={$rrdfile}:close_wait:AVERAGE ".
  367. "DEF:g={$rrdfile}:last_ack:AVERAGE ".
  368. "DEF:h={$rrdfile}:time_wait:AVERAGE ".
  369. "DEF:i={$rrdfile}:close:AVERAGE ".
  370. "DEF:j={$rrdfile}:listen:AVERAGE ".
  371. 'CDEF:err=a,UN,INF,UNKN,IF '.
  372. 'AREA:err#FFD0D0 '.
  373. 'AREA:b#FF0000:"SYN_SEND " GPRINT:b:LAST:"Current\:%8.2lf" GPRINT:b:AVERAGE:"Average\:%8.2lf" GPRINT:b:MAX:"Maximum\:%8.2lf\n" '.
  374. 'STACK:f#FF00FF:"CLOSE_WAIT " GPRINT:f:LAST:"Current\:%8.2lf" GPRINT:f:AVERAGE:"Average\:%8.2lf" GPRINT:f:MAX:"Maximum\:%8.2lf\n" '.
  375. 'STACK:g#0000FF:"LAST_ACK " GPRINT:g:LAST:"Current\:%8.2lf" GPRINT:g:AVERAGE:"Average\:%8.2lf" GPRINT:g:MAX:"Maximum\:%8.2lf\n" '.
  376. 'STACK:h#007FFF:"TIME_WAIT " GPRINT:h:LAST:"Current\:%8.2lf" GPRINT:h:AVERAGE:"Average\:%8.2lf" GPRINT:h:MAX:"Maximum\:%8.2lf\n" '.
  377. 'STACK:c#00FFFF:"SYN_RECV " GPRINT:c:LAST:"Current\:%8.2lf" GPRINT:c:AVERAGE:"Average\:%8.2lf" GPRINT:c:MAX:"Maximum\:%8.2lf\n" '.
  378. 'STACK:d#00FF00:"ESTABLISHED" GPRINT:d:LAST:"Current\:%8.2lf" GPRINT:d:AVERAGE:"Average\:%8.2lf" GPRINT:d:MAX:"Maximum\:%8.2lf\n" '.
  379. 'STACK:e#FFFF00:"FIN_WAIT " GPRINT:e:LAST:"Current\:%8.2lf" GPRINT:e:AVERAGE:"Average\:%8.2lf" GPRINT:e:MAX:"Maximum\:%8.2lf\n" '.
  380. 'STACK:i#FF7F00:"CLOSE " GPRINT:i:LAST:"Current\:%8.2lf" GPRINT:i:AVERAGE:"Average\:%8.2lf" GPRINT:i:MAX:"Maximum\:%8.2lf\n" ';
  381. break;
  382. default:
  383. $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --vertical-label=\"Connections\" ".
  384. "DEF:a={$rrdfile}:total:AVERAGE ".
  385. "DEF:b={$rrdfile}:local:AVERAGE ".
  386. "DEF:c={$rrdfile}:nated:AVERAGE ".
  387. "DEF:d={$rrdfile}:unreplied:AVERAGE ".
  388. 'CDEF:err=a,UN,INF,UNKN,IF '.
  389. 'AREA:err#FFD0D0 '.
  390. 'LINE1:a#000000:"Total " GPRINT:a:LAST:"Current\:%8.2lf %s" GPRINT:a:AVERAGE:"Average\:%8.2lf %s" GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" '.
  391. 'AREA:b#00CF00:"Local " GPRINT:b:LAST:"Current\:%8.2lf %s" GPRINT:b:AVERAGE:"Average\:%8.2lf %s" GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" '.
  392. 'STACK:c#0000FF:"NATed " GPRINT:c:LAST:"Current\:%8.2lf %s" GPRINT:c:AVERAGE:"Average\:%8.2lf %s" GPRINT:c:MAX:"Maximum\:%8.2lf %s\n" '.
  393. 'LINE1:d#FF0000:"Unreplied" GPRINT:d:LAST:"Current\:%8.2lf %s" GPRINT:d:AVERAGE:"Average\:%8.2lf %s" GPRINT:d:MAX:"Maximum\:%8.2lf %s\n" ';
  394. break;
  395. }
  396. break;
  397. case 'ctstat':
  398. $height *= 2;
  399. $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --vertical-label=\"calls\" ".
  400. "DEF:a={$rrdfile}:searched:AVERAGE ".
  401. "DEF:b={$rrdfile}:found:AVERAGE ".
  402. "DEF:c={$rrdfile}:new:AVERAGE ".
  403. "DEF:d={$rrdfile}:invalid:AVERAGE ".
  404. "DEF:e={$rrdfile}:ignore:AVERAGE ".
  405. "DEF:f={$rrdfile}:delete:AVERAGE ".
  406. "DEF:g={$rrdfile}:delete_list:AVERAGE ".
  407. "DEF:h={$rrdfile}:insert:AVERAGE ".
  408. "DEF:i={$rrdfile}:insert_failed:AVERAGE ".
  409. "DEF:j={$rrdfile}:drop:AVERAGE ".
  410. "DEF:k={$rrdfile}:early_drop:AVERAGE ".
  411. "DEF:l={$rrdfile}:icmp_error:AVERAGE ".
  412. "DEF:m={$rrdfile}:expect_new:AVERAGE ".
  413. "DEF:n={$rrdfile}:expect_create:AVERAGE ".
  414. "DEF:o={$rrdfile}:expect_delete:AVERAGE ".
  415. 'CDEF:ii=i,-1,* '.
  416. 'CDEF:jj=j,-1,* '.
  417. 'CDEF:kk=k,-1,* '.
  418. 'CDEF:ll=l,-1,* '.
  419. 'CDEF:mm=m,-1,* '.
  420. 'CDEF:nn=n,-1,* '.
  421. 'CDEF:oo=o,-1,* '.
  422. 'CDEF:err=a,UN,INF,UNKN,IF '.
  423. 'AREA:err#FFD0D0 '.
  424. 'LINE1:a#FF0000:"searched " GPRINT:a:LAST:"Current\:%8.0lf" GPRINT:a:AVERAGE:"Average\:%8.0lf" GPRINT:a:MAX:"Maximum\:%8.0lf\n" '.
  425. 'LINE1:b#FF00FF:"found " GPRINT:b:LAST:"Current\:%8.0lf" GPRINT:b:AVERAGE:"Average\:%8.0lf" GPRINT:b:MAX:"Maximum\:%8.0lf\n" '.
  426. 'LINE1:c#0000FF:"new " GPRINT:c:LAST:"Current\:%8.0lf" GPRINT:c:AVERAGE:"Average\:%8.0lf" GPRINT:c:MAX:"Maximum\:%8.0lf\n" '.
  427. 'LINE1:d#007FFF:"invalid " GPRINT:d:LAST:"Current\:%8.0lf" GPRINT:d:AVERAGE:"Average\:%8.0lf" GPRINT:d:MAX:"Maximum\:%8.0lf\n" '.
  428. 'LINE1:e#00FFFF:"ignore " GPRINT:e:LAST:"Current\:%8.0lf" GPRINT:e:AVERAGE:"Average\:%8.0lf" GPRINT:e:MAX:"Maximum\:%8.0lf\n" '.
  429. 'LINE1:f#00FF00:"delete " GPRINT:f:LAST:"Current\:%8.0lf" GPRINT:f:AVERAGE:"Average\:%8.0lf" GPRINT:f:MAX:"Maximum\:%8.0lf\n" '.
  430. 'LINE1:g#FFFF00:"delete_list " GPRINT:g:LAST:"Current\:%8.0lf" GPRINT:g:AVERAGE:"Average\:%8.0lf" GPRINT:g:MAX:"Maximum\:%8.0lf\n" '.
  431. 'LINE1:h#FF7F00:"insert " GPRINT:h:LAST:"Current\:%8.0lf" GPRINT:h:AVERAGE:"Average\:%8.0lf" GPRINT:h:MAX:"Maximum\:%8.0lf\n" '.
  432. 'HRULE:0#000000:"-\n" '.
  433. 'LINE1:ii#FF0000:"insert_failed " GPRINT:i:LAST:"Current\:%8.0lf" GPRINT:i:AVERAGE:"Average\:%8.0lf" GPRINT:i:MAX:"Maximum\:%8.0lf\n" '.
  434. 'LINE1:jj#FF00FF:"drop " GPRINT:j:LAST:"Current\:%8.0lf" GPRINT:j:AVERAGE:"Average\:%8.0lf" GPRINT:j:MAX:"Maximum\:%8.0lf\n" '.
  435. 'LINE1:kk#0000FF:"early_drop " GPRINT:k:LAST:"Current\:%8.0lf" GPRINT:k:AVERAGE:"Average\:%8.0lf" GPRINT:k:MAX:"Maximum\:%8.0lf\n" '.
  436. 'LINE1:ll#007FFF:"icmp_errore " GPRINT:l:LAST:"Current\:%8.0lf" GPRINT:l:AVERAGE:"Average\:%8.0lf" GPRINT:l:MAX:"Maximum\:%8.0lf\n" '.
  437. 'LINE1:mm#00FFFF:"expect_new " GPRINT:m:LAST:"Current\:%8.0lf" GPRINT:m:AVERAGE:"Average\:%8.0lf" GPRINT:m:MAX:"Maximum\:%8.0lf\n" '.
  438. 'LINE1:nn#00FF00:"expect_create " GPRINT:n:LAST:"Current\:%8.0lf" GPRINT:n:AVERAGE:"Average\:%8.0lf" GPRINT:n:MAX:"Maximum\:%8.0lf\n" '.
  439. 'LINE1:oo#FFFF00:"expect_delete " GPRINT:o:LAST:"Current\:%8.0lf" GPRINT:o:AVERAGE:"Average\:%8.0lf" GPRINT:o:MAX:"Maximum\:%8.0lf\n" ';
  440. break;
  441. case 'disk':
  442. $height *= 2;
  443. $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --vertical-label=\"sectors\" ".
  444. "DEF:a={$rrdfile}:read_cnt:AVERAGE ".
  445. "DEF:b={$rrdfile}:read_sec:AVERAGE ".
  446. "DEF:c={$rrdfile}:read_ms:AVERAGE ".
  447. "DEF:dd={$rrdfile}:write_cnt:AVERAGE ".
  448. "DEF:ee={$rrdfile}:write_cnt:AVERAGE ".
  449. "DEF:ff={$rrdfile}:write_ms:AVERAGE ".
  450. 'CDEF:d=dd,-1,* '.
  451. 'CDEF:e=ee,-1,* '.
  452. 'CDEF:f=ff,-1,* '.
  453. 'CDEF:oerr=a,UN,INF,UNKN,IF CDEF:ierr=dd,UN,-INF,UNKN,IF '.
  454. 'HRULE:0#FF0000 AREA:ierr#FFD0D0 AREA:oerr#FFD0D0 '.
  455. 'LINE1:a#FF0000:"read_count " GPRINT:a:LAST:"Current\:%8.0lf" GPRINT:a:AVERAGE:"Average\:%8.0lf" GPRINT:a:MAX:"Maximum\:%8.0lf\n" '.
  456. 'LINE1:b#FF00FF:"read_sectors " GPRINT:b:LAST:"Current\:%8.0lf" GPRINT:b:AVERAGE:"Average\:%8.0lf" GPRINT:b:MAX:"Maximum\:%8.0lf\n" '.
  457. 'LINE1:c#0000FF:"sectors / ms " GPRINT:c:LAST:"Current\:%8.0lf" GPRINT:c:AVERAGE:"Average\:%8.0lf" GPRINT:c:MAX:"Maximum\:%8.0lf\n" '.
  458. 'LINE1:d#FF0000:"write_count " GPRINT:dd:LAST:"Current\:%8.0lf" GPRINT:dd:AVERAGE:"Average\:%8.0lf" GPRINT:dd:MAX:"Maximum\:%8.0lf\n" '.
  459. 'LINE1:e#FF00FF:"write_sectors " GPRINT:ee:LAST:"Current\:%8.0lf" GPRINT:ee:AVERAGE:"Average\:%8.0lf" GPRINT:ee:MAX:"Maximum\:%8.0lf\n" '.
  460. 'LINE1:f#0000FF:"writes / ms " GPRINT:ff:LAST:"Current\:%8.0lf" GPRINT:ff:AVERAGE:"Average\:%8.0lf" GPRINT:ff:MAX:"Maximum\:%8.0lf\n" '.
  461. '';
  462. break;
  463. case 'diskstandby':
  464. $height /= 2;
  465. $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"Active\" ".
  466. "DEF:a={$rrdfile}:active:AVERAGE ".
  467. "CDEF:b=1,a,- ".
  468. 'CDEF:err=a,UN,INF,UNKN,IF '.
  469. 'AREA:err#FFD0D0 '.
  470. 'AREA:a#FF0000:"Active\n" '.
  471. 'STACK:b#00CF00:"Standby" ';
  472. break;
  473. case 'hddtemp':
  474. $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"Temperature\" ".
  475. "DEF:a={$rrdfile}:temperature:AVERAGE ".
  476. 'CDEF:err=a,UN,INF,UNKN,IF '.
  477. 'AREA:err#FFD0D0 '.
  478. 'AREA:a#00CF00:"Temperature" GPRINT:a:LAST:"Current\:%8.2lf %s" GPRINT:a:AVERAGE:"Average\:%8.2lf %s" GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" '.
  479. 'LINE1:a#404040 ';
  480. break;
  481. case 'hwmon':
  482. $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"Temperature\" ".
  483. "DEF:a={$rrdfile}:temp:AVERAGE ".
  484. "CDEF:aa=a,1000,/ ".
  485. 'CDEF:err=a,UN,INF,UNKN,IF '.
  486. 'AREA:err#FFD0D0 '.
  487. 'AREA:aa#00CF00:"Temperature" GPRINT:aa:LAST:"Current\:%8.2lf %s" GPRINT:aa:AVERAGE:"Average\:%8.2lf %s" GPRINT:aa:MAX:"Maximum\:%8.2lf %s\n" '.
  488. 'LINE1:aa#404040 ';
  489. break;
  490. case 'load':
  491. $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"load\" ".
  492. "DEF:a={$rrdfile}:1min:MAX ".
  493. "DEF:b={$rrdfile}:5min:MAX ".
  494. "DEF:c={$rrdfile}:15min:MAX ".
  495. 'CDEF:x=a,b,c,MAX,MAX '.
  496. 'CDEF:err=x,UN,INF,UNKN,IF '.
  497. 'AREA:err#FFD0D0 '.
  498. 'AREA:a#EACC00:" 1 Minute Maximum " GPRINT:a:LAST:"Current\:%8.2lf %s\n" '.
  499. 'AREA:b#EA8F00:" 5 Minute Maximum " GPRINT:b:LAST:"Current\:%8.2lf %s\n" '.
  500. 'AREA:c#FF0000:"15 Minute Maximum " GPRINT:c:LAST:"Current\:%8.2lf %s\n" '.
  501. 'LINE1:x#404040:"Total"';
  502. break;
  503. case 'memory':
  504. $cmd .= "--base=1024 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"kB\" ".
  505. "DEF:aa={$rrdfile}:total:AVERAGE ".
  506. "DEF:bb={$rrdfile}:free:AVERAGE ".
  507. "DEF:cc={$rrdfile}:buffers:AVERAGE ".
  508. "DEF:dd={$rrdfile}:cached:AVERAGE ".
  509. 'CDEF:a=aa,1024,* '.
  510. 'CDEF:b=bb,1024,* '.
  511. 'CDEF:c=cc,1024,* '.
  512. 'CDEF:d=dd,1024,* '.
  513. 'CDEF:x=aa,bb,cc,dd,+,+,-,1024,* '.
  514. 'CDEF:xc=x,c,+ '.
  515. 'CDEF:xcd=x,c,d,+,+ '.
  516. 'CDEF:err=xcd,UN,INF,UNKN,IF '.
  517. 'AREA:err#FFD0D0 '.
  518. 'LINE1:a#000000:"Total Memory " GPRINT:a:LAST:"Current\:%8.2lf %s\n" '.
  519. 'AREA:x#FF0000:"Used Memory " GPRINT:x:LAST:"Current\:%8.2lf %s" GPRINT:x:AVERAGE:"Average\:%8.2lf %s" GPRINT:x:MAX:"Maximum\:%8.2lf %s\n" '.
  520. 'STACK:c#FF7D00:"Buffer Memory " GPRINT:c:LAST:"Current\:%8.2lf %s" GPRINT:c:AVERAGE:"Average\:%8.2lf %s" GPRINT:c:MAX:"Maximum\:%8.2lf %s\n" '.
  521. 'STACK:d#FFC73B:"Cache Memory " GPRINT:d:LAST:"Current\:%8.2lf %s" GPRINT:d:AVERAGE:"Average\:%8.2lf %s" GPRINT:d:MAX:"Maximum\:%8.2lf %s\n" '.
  522. 'STACK:b#00CF00:"Free Memory " GPRINT:b:LAST:"Current\:%8.2lf %s" GPRINT:b:AVERAGE:"Average\:%8.2lf %s" GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" '.
  523. 'LINE1:x#404040 LINE1:xc#404040 LINE1:xcd#404040';
  524. break;
  525. case 'mount':
  526. $cmd .= "--base=1024 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"kB\" ".
  527. "DEF:aa={$rrdfile}:block_total:AVERAGE ".
  528. "DEF:cc={$rrdfile}:block_free:AVERAGE ".
  529. 'CDEF:a=aa,1024,* '.
  530. 'CDEF:b=aa,cc,-,1024,* '.
  531. 'CDEF:c=cc,1024,* '.
  532. 'CDEF:err=a,UN,INF,UNKN,IF '.
  533. 'AREA:err#FFD0D0 '.
  534. 'LINE1:a#000000:"Total " GPRINT:a:LAST:"Current\:%8.2lf %s\n" '.
  535. 'AREA:b#FF0000:"Used " GPRINT:b:LAST:"Current\:%8.2lf %s" GPRINT:b:AVERAGE:"Average\:%8.2lf %s" GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" '.
  536. 'STACK:c#00CF00:"Free " GPRINT:c:LAST:"Current\:%8.2lf %s" GPRINT:c:AVERAGE:"Average\:%8.2lf %s" GPRINT:c:MAX:"Maximum\:%8.2lf %s\n" '.
  537. 'LINE1:b#404040 ';
  538. break;
  539. case 'mysql':
  540. switch ($tmp1[1]) {
  541. case 'commands':
  542. $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"commands\" ".
  543. "DEF:aa={$rrdfile}:com_delete:AVERAGE ".
  544. "DEF:bb={$rrdfile}:com_insert:AVERAGE ".
  545. "DEF:cc={$rrdfile}:com_select:AVERAGE ".
  546. "DEF:dd={$rrdfile}:com_update:AVERAGE ".
  547. "DEF:ee={$rrdfile}:questions:AVERAGE ".
  548. 'CDEF:a=aa,60,* '.
  549. 'CDEF:b=bb,60,* '.
  550. 'CDEF:c=cc,60,* '.
  551. 'CDEF:d=dd,60,* '.
  552. 'CDEF:e=ee,60,* '.
  553. 'CDEF:err=a,UN,INF,UNKN,IF '.
  554. 'AREA:err#FFD0D0 '.
  555. 'AREA:e#0000FF:"All Commands " GPRINT:e:LAST:"Current\:%8.2lf %s" GPRINT:e:AVERAGE:"Average\:%8.2lf %s" GPRINT:e:MAX:"Maximum\:%8.2lf %s\n" '.
  556. 'AREA:a#FF0000:"DELETE ... " GPRINT:a:LAST:"Current\:%8.2lf %s" GPRINT:a:AVERAGE:"Average\:%8.2lf %s" GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" '.
  557. 'STACK:b#FF7D00:"INSERT ... " GPRINT:b:LAST:"Current\:%8.2lf %s" GPRINT:b:AVERAGE:"Average\:%8.2lf %s" GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" '.
  558. 'STACK:d#FFC73B:"UPDATE ... " GPRINT:d:LAST:"Current\:%8.2lf %s" GPRINT:d:AVERAGE:"Average\:%8.2lf %s" GPRINT:d:MAX:"Maximum\:%8.2lf %s\n" '.
  559. 'STACK:c#00CF00:"SELECT ... " GPRINT:c:LAST:"Current\:%8.2lf %s" GPRINT:c:AVERAGE:"Average\:%8.2lf %s" GPRINT:c:MAX:"Maximum\:%8.2lf %s\n" '.
  560. '';
  561. break;
  562. case 'qcache':
  563. $cmd .= "--base=1024 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"???\" ".
  564. "DEF:a={$rrdfile}:qc_free_blocks:AVERAGE ".
  565. "DEF:b={$rrdfile}:qc_free_memory:AVERAGE ".
  566. "DEF:cc={$rrdfile}:qc_hits:AVERAGE ".
  567. "DEF:dd={$rrdfile}:qc_inserts:AVERAGE ".
  568. "DEF:ee={$rrdfile}:qc_lowmem_prunes:AVERAGE ".
  569. "DEF:ff={$rrdfile}:qc_not_cached:AVERAGE ".
  570. "DEF:g={$rrdfile}:qc_queries_in_cache:AVERAGE ".
  571. "DEF:h={$rrdfile}:qc_total_blocks:AVERAGE ".
  572. 'CDEF:c=cc,60,* '.
  573. 'CDEF:d=dd,60,* '.
  574. 'CDEF:e=ee,60,* '.
  575. 'CDEF:f=ff,60,* '.
  576. 'CDEF:err=a,UN,INF,UNKN,IF '.
  577. 'AREA:err#FFD0D0 '.
  578. 'LINE1:a#FF0000:"qc_free_blocks " GPRINT:a:LAST:"Current\:%8.2lf %s" GPRINT:a:AVERAGE:"Average\:%8.2lf %s" GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" '.
  579. 'LINE1:b#FFFF00:"qc_free_memory " GPRINT:b:LAST:"Current\:%8.2lf %s" GPRINT:b:AVERAGE:"Average\:%8.2lf %s" GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" '.
  580. 'LINE1:c#00FF00:"qc_hits " GPRINT:c:LAST:"Current\:%8.2lf %s" GPRINT:c:AVERAGE:"Average\:%8.2lf %s" GPRINT:c:MAX:"Maximum\:%8.2lf %s\n" '.
  581. 'LINE1:d#00FFFF:"qc_inserts " GPRINT:d:LAST:"Current\:%8.2lf %s" GPRINT:d:AVERAGE:"Average\:%8.2lf %s" GPRINT:d:MAX:"Maximum\:%8.2lf %s\n" '.
  582. 'LINE1:e#0000FF:"qc_lowmemprunes " GPRINT:e:LAST:"Current\:%8.2lf %s" GPRINT:e:AVERAGE:"Average\:%8.2lf %s" GPRINT:e:MAX:"Maximum\:%8.2lf %s\n" '.
  583. 'LINE1:f#FF00FF:"qc_not_cached " GPRINT:f:LAST:"Current\:%8.2lf %s" GPRINT:f:AVERAGE:"Average\:%8.2lf %s" GPRINT:f:MAX:"Maximum\:%8.2lf %s\n" '.
  584. 'LINE1:g#FF00FF:"qc_queries_in_cache" GPRINT:g:LAST:"Current\:%8.2lf %s" GPRINT:g:AVERAGE:"Average\:%8.2lf %s" GPRINT:g:MAX:"Maximum\:%8.2lf %s\n" '.
  585. 'LINE1:h#000000:"qc_total_blocks " GPRINT:h:LAST:"Current\:%8.2lf %s" GPRINT:h:AVERAGE:"Average\:%8.2lf %s" GPRINT:h:MAX:"Maximum\:%8.2lf %s\n" '.
  586. '';
  587. break;
  588. case 'threads':
  589. $cmd .= "--base=1024 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"threads\" ".
  590. "DEF:a={$rrdfile}:threads_cached:AVERAGE ".
  591. "DEF:b={$rrdfile}:threads_connected:AVERAGE ".
  592. "DEF:cc={$rrdfile}:threads_created:AVERAGE ".
  593. "DEF:d={$rrdfile}:threads_running:AVERAGE ".
  594. 'CDEF:c=cc,60,* '.
  595. 'CDEF:err=a,UN,INF,UNKN,IF '.
  596. 'AREA:err#FFD0D0 '.
  597. 'LINE1:c#00CF00:"threads created " GPRINT:c:LAST:"Current\:%8.2lf %s" GPRINT:c:AVERAGE:"Average\:%8.2lf %s" GPRINT:c:MAX:"Maximum\:%8.2lf %s\n" '.
  598. 'LINE1:d#FF0000:"threads running " GPRINT:d:LAST:"Current\:%8.2lf %s" GPRINT:d:AVERAGE:"Average\:%8.2lf %s" GPRINT:d:MAX:"Maximum\:%8.2lf %s\n" '.
  599. 'LINE1:b#00FFFF:"threads connected" GPRINT:b:LAST:"Current\:%8.2lf %s" GPRINT:b:AVERAGE:"Average\:%8.2lf %s" GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" '.
  600. 'LINE1:a#0000FF:"threads cached " GPRINT:a:LAST:"Current\:%8.2lf %s" GPRINT:a:AVERAGE:"Average\:%8.2lf %s" GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" '.
  601. '';
  602. break;
  603. case 'traffic':
  604. $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --vertical-label=\"bytes per second\" ".
  605. "DEF:imax={$rrdfile}:bytes_received:MAX ".
  606. "DEF:iavg={$rrdfile}:bytes_received:AVERAGE ".
  607. "DEF:imin={$rrdfile}:bytes_received:MIN ".
  608. "DEF:omax={$rrdfile}:bytes_sent:MAX ".
  609. "DEF:oavg={$rrdfile}:bytes_sent:AVERAGE ".
  610. "DEF:omin={$rrdfile}:bytes_sent:MIN ".
  611. 'CDEF:omaxn=omax,-1,* CDEF:oavgn=oavg,-1,* CDEF:ominn=omin,-1,* '.
  612. 'CDEF:imid=imax,imin,- CDEF:omid=omaxn,ominn,- '.
  613. 'CDEF:oerr=oavg,UN,INF,UNKN,IF CDEF:ierr=iavg,UN,-INF,UNKN,IF '.
  614. 'HRULE:0#FF0000 AREA:ierr#FFD0D0 AREA:oerr#FFD0D0 '.
  615. 'AREA:imin STACK:imid#A0FFA0:"min/max Inbound " GPRINT:imin:MIN:"%6.2lf%s" GPRINT:imax:MAX:"%6.2lf%s" '.
  616. 'LINE1:imin#a0a0a0 LINE1:imax#a0a0a0 LINE1:iavg#008000:"avg Inbound " '.
  617. 'GPRINT:iavg:MIN:"min\: %6.2lf%s" GPRINT:iavg:AVERAGE:"avg\: %6.2lf%s" GPRINT:iavg:MAX:"max\: %6.2lf%s\n" '.
  618. 'AREA:ominn STACK:omid#C0C0FF:"min/max Outbound" GPRINT:omin:MIN:"%6.2lf%s" GPRINT:omax:MAX:"%6.2lf%s" '.
  619. 'LINE1:ominn#a0a0a0 LINE1:omaxn#a0a0a0 LINE1:oavgn#000080:"avg Outbound" '.
  620. 'GPRINT:oavg:MIN:"min\: %6.2lf%s" GPRINT:oavg:AVERAGE:"avg\: %6.2lf%s" GPRINT:oavg:MAX:"max\: %6.2lf%s\n" ';
  621. break;
  622. }
  623. break;
  624. case 'net':
  625. $height *= 2;
  626. $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --vertical-label=\"bytes per second\" ".
  627. "DEF:imax={$rrdfile}:byte_in:MAX ".
  628. "DEF:iavg={$rrdfile}:byte_in:AVERAGE ".
  629. "DEF:imin={$rrdfile}:byte_in:MIN ".
  630. "DEF:omax={$rrdfile}:byte_out:MAX ".
  631. "DEF:oavg={$rrdfile}:byte_out:AVERAGE ".
  632. "DEF:omin={$rrdfile}:byte_out:MIN ".
  633. 'CDEF:omaxn=omax,-1,* CDEF:oavgn=oavg,-1,* CDEF:ominn=omin,-1,* '.
  634. 'CDEF:imid=imax,imin,- CDEF:omid=omaxn,ominn,- '.
  635. 'CDEF:oerr=oavg,UN,INF,UNKN,IF CDEF:ierr=iavg,UN,-INF,UNKN,IF '.
  636. 'HRULE:0#FF0000 AREA:ierr#FFD0D0 AREA:oerr#FFD0D0 '.
  637. 'AREA:imin#E0FFE0 STACK:imid#A0FFA0:"min/max Inbound " GPRINT:imin:MIN:"%6.2lf%s" GPRINT:imax:MAX:"%6.2lf%s" '.
  638. 'LINE1:imin#a0a0a0 LINE1:imax#a0a0a0 LINE1:iavg#008000:"avg Inbound " '.
  639. 'GPRINT:iavg:MIN:"min\: %6.2lf%s" GPRINT:iavg:AVERAGE:"avg\: %6.2lf%s" GPRINT:iavg:MAX:"max\: %6.2lf%s\n" '.
  640. 'AREA:ominn#E0E0FF STACK:omid#C0C0FF:"min/max Outbound" GPRINT:omin:MIN:"%6.2lf%s" GPRINT:omax:MAX:"%6.2lf%s" '.
  641. 'LINE1:ominn#a0a0a0 LINE1:omaxn#a0a0a0 LINE1:oavgn#000080:"avg Outbound" '.
  642. 'GPRINT:oavg:MIN:"min\: %6.2lf%s" GPRINT:oavg:AVERAGE:"avg\: %6.2lf%s" GPRINT:oavg:MAX:"max\: %6.2lf%s\n" ';
  643. break;
  644. case 'proc':
  645. $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"per second\" ".
  646. "DEF:a={$rrdfile}:intr:AVERAGE ".
  647. "DEF:b={$rrdfile}:ctxt:AVERAGE ".
  648. "DEF:c={$rrdfile}:fork:AVERAGE ".
  649. 'CDEF:err=a,UN,INF,UNKN,IF '.
  650. 'AREA:err#FFD0D0 '.
  651. 'AREA:b#00AF00:"Context " GPRINT:b:LAST:"Current\:%8.2lf %s" GPRINT:b:AVERAGE:"Average\:%8.2lf %s" GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" '.
  652. 'LINE1:a#FF0000:"Interrupts" GPRINT:a:LAST:"Current\:%8.2lf %s" GPRINT:a:AVERAGE:"Average\:%8.2lf %s" GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" '.
  653. 'LINE1:c#0000FF:"Forks " GPRINT:c:LAST:"Current\:%8.2lf %s" GPRINT:c:AVERAGE:"Average\:%8.2lf %s" GPRINT:c:MAX:"Maximum\:%8.2lf %s\n" ';
  654. break;
  655. case 'random':
  656. $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --lower-limit 0 --vertical-label=\"bytes\" ".
  657. "DEF:a={$rrdfile}:entropy:AVERAGE ".
  658. 'CDEF:err=a,UN,INF,UNKN,IF '.
  659. 'AREA:err#FFD0D0 '.
  660. 'AREA:a#00CF00:"Available Entropy" GPRINT:a:LAST:"Current\:%8.2lf %s" GPRINT:a:AVERAGE:"Average\:%8.2lf %s" GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" '.
  661. 'LINE1:a#404040 ';
  662. break;
  663. case 'rtcache':
  664. $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --vertical-label=\"calls\" ".
  665. "DEF:a={$rrdfile}:entries:AVERAGE ".
  666. "DEF:b={$rrdfile}:gc_total:AVERAGE ".
  667. "DEF:c={$rrdfile}:gc_ignored:AVERAGE ".
  668. "DEF:d={$rrdfile}:gc_goal_miss:AVERAGE ".
  669. "DEF:e={$rrdfile}:gc_dst_overflow:AVERAGE ".
  670. 'CDEF:err=a,UN,INF,UNKN,IF '.
  671. 'AREA:err#FFD0D0 '.
  672. 'LINE1:a#FF0000:"entries " GPRINT:a:LAST:"Current\:%8.0lf" GPRINT:a:AVERAGE:"Average\:%8.0lf" GPRINT:a:MAX:"Maximum\:%8.0lf\n" '.
  673. 'LINE1:b#FF00FF:"gc_total " GPRINT:b:LAST:"Current\:%8.0lf" GPRINT:b:AVERAGE:"Average\:%8.0lf" GPRINT:b:MAX:"Maximum\:%8.0lf\n" '.
  674. 'LINE1:c#0000FF:"gc_ignored " GPRINT:c:LAST:"Current\:%8.0lf" GPRINT:c:AVERAGE:"Average\:%8.0lf" GPRINT:c:MAX:"Maximum\:%8.0lf\n" '.
  675. 'LINE1:d#007FFF:"gc_goal_miss " GPRINT:d:LAST:"Current\:%8.0lf" GPRINT:d:AVERAGE:"Average\:%8.0lf" GPRINT:d:MAX:"Maximum\:%8.0lf\n" '.
  676. 'LINE1:e#00FFFF:"gc_dst_overflow " GPRINT:e:LAST:"Current\:%8.0lf" GPRINT:e:AVERAGE:"Average\:%8.0lf" GPRINT:e:MAX:"Maximum\:%8.0lf\n" ';
  677. break;
  678. case 'rtstat':
  679. $height *= 2;
  680. $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --vertical-label=\"calls\" ".
  681. "DEF:a={$rrdfile}:in_hit:AVERAGE ".
  682. "DEF:b={$rrdfile}:in_slow_tot:AVERAGE ".
  683. "DEF:c={$rrdfile}:in_slow_mc:AVERAGE ".
  684. "DEF:d={$rrdfile}:in_no_route:AVERAGE ".
  685. "DEF:e={$rrdfile}:in_brd:AVERAGE ".
  686. "DEF:f={$rrdfile}:in_martian_dst:AVERAGE ".
  687. "DEF:g={$rrdfile}:in_martian_src:AVERAGE ".
  688. "DEF:h={$rrdfile}:in_hlist_search:AVERAGE ".
  689. "DEF:i={$rrdfile}:out_hit:AVERAGE ".
  690. "DEF:j={$rrdfile}:out_slow_tot:AVERAGE ".
  691. "DEF:k={$rrdfile}:out_slow_mc:AVERAGE ".
  692. "DEF:l={$rrdfile}:out_hlist_search:AVERAGE ".
  693. 'CDEF:ii=i,-1,* '.
  694. 'CDEF:jj=j,-1,* '.
  695. 'CDEF:kk=k,-1,* '.
  696. 'CDEF:ll=l,-1,* '.
  697. 'CDEF:oerr=a,UN,INF,UNKN,IF CDEF:ierr=i,UN,-INF,UNKN,IF '.
  698. 'AREA:ierr#FFD0D0 AREA:oerr#FFD0D0 '.
  699. 'LINE1:a#FF0000:"in_hit " GPRINT:a:LAST:"Current\:%8.0lf" GPRINT:a:AVERAGE:"Average\:%8.0lf" GPRINT:a:MAX:"Maximum\:%8.0lf\n" '.
  700. 'LINE1:b#FF00FF:"in_slow_tot " GPRINT:b:LAST:"Current\:%8.0lf" GPRINT:b:AVERAGE:"Average\:%8.0lf" GPRINT:b:MAX:"Maximum\:%8.0lf\n" '.
  701. 'LINE1:c#0000FF:"in_slow_mc " GPRINT:c:LAST:"Current\:%8.0lf" GPRINT:c:AVERAGE:"Average\:%8.0lf" GPRINT:c:MAX:"Maximum\:%8.0lf\n" '.
  702. 'LINE1:d#007FFF:"in_no_route " GPRINT:d:LAST:"Current\:%8.0lf" GPRINT:d:AVERAGE:"Average\:%8.0lf" GPRINT:d:MAX:"Maximum\:%8.0lf\n" '.
  703. 'LINE1:e#00FFFF:"in_brd " GPRINT:e:LAST:"Current\:%8.0lf" GPRINT:e:AVERAGE:"Average\:%8.0lf" GPRINT:e:MAX:"Maximum\:%8.0lf\n" '.
  704. 'LINE1:f#00FF00:"in_martian_dst " GPRINT:f:LAST:"Current\:%8.0lf" GPRINT:f:AVERAGE:"Average\:%8.0lf" GPRINT:f:MAX:"Maximum\:%8.0lf\n" '.
  705. 'LINE1:g#FFFF00:"in_martian_src " GPRINT:g:LAST:"Current\:%8.0lf" GPRINT:g:AVERAGE:"Average\:%8.0lf" GPRINT:g:MAX:"Maximum\:%8.0lf\n" '.
  706. 'LINE1:h#FF7F00:"in_hlist_search " GPRINT:h:LAST:"Current\:%8.0lf" GPRINT:h:AVERAGE:"Average\:%8.0lf" GPRINT:h:MAX:"Maximum\:%8.0lf\n" '.
  707. 'HRULE:0#FF0000:"-\n" '.
  708. 'LINE1:ii#FF0000:"out_hit " GPRINT:i:LAST:"Current\:%8.0lf" GPRINT:i:AVERAGE:"Average\:%8.0lf" GPRINT:i:MAX:"Maximum\:%8.0lf\n" '.
  709. 'LINE1:jj#FF00FF:"out_slow_tot " GPRINT:j:LAST:"Current\:%8.0lf" GPRINT:j:AVERAGE:"Average\:%8.0lf" GPRINT:j:MAX:"Maximum\:%8.0lf\n" '.
  710. 'LINE1:kk#0000FF:"out_slow_mc " GPRINT:k:LAST:"Current\:%8.0lf" GPRINT:k:AVERAGE:"Average\:%8.0lf" GPRINT:k:MAX:"Maximum\:%8.0lf\n" '.
  711. 'LINE1:ll#FF7F00:"out_hlist_search " GPRINT:l:LAST:"Current\:%8.0lf" GPRINT:l:AVERAGE:"Average\:%8.0lf" GPRINT:l:MAX:"Maximum\:%8.0lf\n" ';
  712. break;
  713. case 'swap':
  714. $cmd .= "--base=1024 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"kB\" ".
  715. "DEF:aa={$rrdfile}:total:AVERAGE ".
  716. "DEF:bb={$rrdfile}:free:AVERAGE ".
  717. 'CDEF:a=aa,1024,* '.
  718. 'CDEF:b=bb,1024,* '.
  719. 'CDEF:x=aa,bb,-,1024,* '.
  720. 'CDEF:err=a,UN,INF,UNKN,IF '.
  721. 'AREA:err#FFD0D0 '.
  722. 'LINE1:a#000000:"Total Swap " GPRINT:a:LAST:"Current\:%8.2lf %s\n" '.
  723. 'AREA:x#FF0000:"Used Swap " GPRINT:x:LAST:"Current\:%8.2lf %s" GPRINT:x:AVERAGE:"Average\:%8.2lf %s" GPRINT:x:MAX:"Maximum\:%8.2lf %s\n" '.
  724. 'STACK:b#00CF00:"Free Swap " GPRINT:b:LAST:"Current\:%8.2lf %s" GPRINT:b:AVERAGE:"Average\:%8.2lf %s" GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" ';
  725. break;
  726. case 'ts2':
  727. $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --lower-limit 0 --vertical-label=\"users/chans\" ".
  728. "DEF:users={$rrdfile}:users:AVERAGE ".
  729. "DEF:chans={$rrdfile}:channels:AVERAGE ".
  730. 'CDEF:err=users,UN,INF,UNKN,IF '.
  731. 'AREA:err#FFD0D0 '.
  732. 'AREA:chans#00CF00:"Channels \n" '.
  733. 'LINE1:users#002A97:"Users "';
  734. break;
  735. case 'uptime':
  736. $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --lower-limit 0 --vertical-label=\"days\" ".
  737. "DEF:ups={$rrdfile}:uptime:AVERAGE ".
  738. "DEF:idles={$rrdfile}:idletime:AVERAGE ".
  739. 'CDEF:up=ups,86400,/ '.
  740. 'CDEF:idle=idles,86400,/ '.
  741. 'CDEF:err=ups,UN,INF,UNKN,IF '.
  742. 'AREA:err#FFD0D0 '.
  743. 'AREA:up#00CF00:"Uptime \n" '.
  744. 'LINE1:idle#002A97:"Idletime "';
  745. break;
  746. case 'vmstat':
  747. $height *= 2;
  748. $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --vertical-label=\"allocs\" ".
  749. "DEF:a={$rrdfile}:pgalloc_high:AVERAGE ".
  750. "DEF:b={$rrdfile}:pgalloc_normal:AVERAGE ".
  751. "DEF:c={$rrdfile}:pgalloc_dma:AVERAGE ".
  752. "DEF:d={$rrdfile}:pgfree:AVERAGE ".
  753. "DEF:e={$rrdfile}:pgfault:AVERAGE ".
  754. "CDEF:ee=e,-1,* ".
  755. 'CDEF:oerr=a,UN,INF,UNKN,IF CDEF:ierr=e,UN,-INF,UNKN,IF '.
  756. 'AREA:ierr#FFD0D0 AREA:oerr#FFD0D0 '.
  757. 'HRULE:0#FF0000: '.
  758. 'AREA:c#FF0000:"pgalloc_dma " GPRINT:c:LAST:"Current\:%8.2lf %s" GPRINT:c:AVERAGE:"Average\:%8.2lf %s" GPRINT:c:MAX:"Maximum\:%8.2lf %s\n" '.
  759. 'STACK:b#00CF00:"pgalloc_normal " GPRINT:b:LAST:"Current\:%8.2lf %s" GPRINT:b:AVERAGE:"Average\:%8.2lf %s" GPRINT:b:MAX:"Maximum\:%8.2lf %s\n" '.
  760. 'STACK:a#00CFCF:"pgalloc_high " GPRINT:a:LAST:"Current\:%8.2lf %s" GPRINT:a:AVERAGE:"Average\:%8.2lf %s" GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" '.
  761. 'LINE1:d#FF7D00:"pgfree " GPRINT:d:LAST:"Current\:%8.2lf %s" GPRINT:d:AVERAGE:"Average\:%8.2lf %s" GPRINT:d:MAX:"Maximum\:%8.2lf %s\n" '.
  762. 'AREA:ee#0040FF:"pgfault " GPRINT:e:LAST:"Current\:%8.2lf %s" GPRINT:e:AVERAGE:"Average\:%8.2lf %s" GPRINT:e:MAX:"Maximum\:%8.2lf %s\n" '.
  763. 'LINE1:ee#002A97 ';
  764. break;
  765. }
  766. header('Content-type: image/x-png');
  767. passthru($cmd);
  768. die();
  769. }
  770. $action = $_GET['action'];
  771. switch ($action) {
  772. case 'init':
  773. $conf = create_config();
  774. write_config(CONFIG, $conf);
  775. header("Location: {$_SERVER['SCRIPT_NAME']}?action=setup");
  776. break;
  777. case 'setup':
  778. $conf = read_config(CONFIG);
  779. $conf = setup($conf);
  780. if (isset($conf)) {
  781. write_config(CONFIG, $conf);
  782. header("Location: {$_SERVER['SCRIPT_NAME']}?action=setup");
  783. }
  784. break;
  785. case 'rrd':
  786. $conf = read_config(CONFIG);
  787. show_rrd($conf);
  788. break;
  789. default:
  790. case 'show':
  791. $conf = read_config(CONFIG);
  792. show_html($conf);
  793. break;
  794. }
  795. ?>