piechart.check_naf.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <?php
  2. #
  3. # Copyright (c) 2006-2010 Joerg Linge (http://www.pnp4nagios.org)
  4. # Copyright (c) 2011 Sven Velt <sv@teamix.net>
  5. # Copyright (c) 2011 Sebastian Harl <sh@teamix.net>
  6. #
  7. # Default Template used if no other template is found.
  8. #
  9. ### Helper functions
  10. #
  11. require_once("check_naf_helper.php");
  12. #
  13. ### Main loop
  14. #
  15. $graphs = 0;
  16. ##foreach ($this->DS as $KEY=>$VAL) {
  17. while( count($this->DS) > 0 ) {
  18. $VAL = array_shift($this->DS);
  19. if ($VAL['NAME'] == 'nacache_usage') {
  20. $opt[$graphs]['title'] = "PAM cache usage on " . $this->MACRO['DISP_HOSTNAME'];
  21. $opt[$graphs]['labels'] = array("PAM cache usage");
  22. $ds_name[$graphs] = "PAM cache usage";
  23. # this is an percentage
  24. $def[$graphs] = array($VAL['ACT'], 100.0 - $VAL['ACT']);
  25. } elseif (substr($VAL['NAME'], 0, 8) == 'nacache_') {
  26. $o_hits = $VAL;
  27. $o_miss = array_shift($this->DS);
  28. $o_evict = array_shift($this->DS);
  29. $o_inval = array_shift($this->DS);
  30. $o_insert = array_shift($this->DS);
  31. $opt[$graphs]['title'] = "PAM ops/s on " . $this->MACRO['DISP_HOSTNAME'];
  32. $opt[$graphs]['labels'] = array("hits", "miss", "evict", "inval", "insert");
  33. $ds_name[$graphs] = "PAM ops/s";
  34. $def[$graphs] = array($o_hits['ACT'], $o_miss['ACT'], $o_evict['ACT'], $o_inval['ACT'], $o_insert['ACT']);
  35. # } elseif ($VAL['NAME'] == 'nacpu') {
  36. # $opt[$graphs] = "--vertical-label % -l 0 -r --title \"CPU usage on ";
  37. # $opt[$graphs] .= $this->MACRO['DISP_HOSTNAME'] . "\"";
  38. #
  39. # $ds_name[$graphs] = $VAL['LABEL'];
  40. #
  41. # $def[$graphs] = "";
  42. # $def[$graphs] .= rrd::def ("cpu_avg", $VAL['RRDFILE'], $VAL['DS'], "AVERAGE");
  43. # $def[$graphs] .= rrd::def ("cpu_min", $VAL['RRDFILE'], $VAL['DS'], "MIN");
  44. # $def[$graphs] .= rrd::def ("cpu_max", $VAL['RRDFILE'], $VAL['DS'], "MAX");
  45. #
  46. # $def[$graphs] .= rrd::area ("cpu_max", "#6666FFCC");
  47. # $def[$graphs] .= rrd::area ("cpu_min", "#FFFFFF");
  48. # $def[$graphs] .= rrd::line1 ("cpu_avg", "#0000FF", "CPU usage:");
  49. #
  50. # $def[$graphs] .= wc($VAL);
  51. # $def[$graphs] .= rrd::gprint ("cpu_avg", array("LAST","MAX","AVERAGE"), "%3.4lf %S".$VAL['UNIT']);
  52. #
  53. #
  54. # } elseif ($VAL['NAME'] == 'nacs') {
  55. # $opt[$graphs] = "--vertical-label \"Context Switches\" -l 0 -r --title \"Context switches on ";
  56. # $opt[$graphs] .= $this->MACRO['DISP_HOSTNAME'] . "\"";
  57. #
  58. # $ds_name[$graphs] = $VAL['LABEL'];
  59. #
  60. # $def[$graphs] = "";
  61. # $def[$graphs] .= rrd::def ("cs_avg", $VAL['RRDFILE'], $VAL['DS'], "AVERAGE");
  62. # $def[$graphs] .= rrd::def ("cs_min", $VAL['RRDFILE'], $VAL['DS'], "MIN");
  63. # $def[$graphs] .= rrd::def ("cs_max", $VAL['RRDFILE'], $VAL['DS'], "MAX");
  64. #
  65. # $def[$graphs] .= rrd::area ("cs_max", "#FF6666CC");
  66. # $def[$graphs] .= rrd::area ("cs_min", "#FFFFFF");
  67. # $def[$graphs] .= rrd::line1 ("cs_avg", "#FF0000", "Context switches:");
  68. #
  69. # $def[$graphs] .= wc($VAL);
  70. # $def[$graphs] .= rrd::gprint ("cs_avg", array("LAST","MAX","AVERAGE"), "%3.4lf %S".$VAL['UNIT']);
  71. #
  72. #
  73. # } elseif ($VAL['NAME'] == 'nadisk_total') {
  74. # $d_t = $VAL;
  75. # $d_a = array_shift($this->DS);
  76. # $d_s = array_shift($this->DS);
  77. # $d_f = array_shift($this->DS);
  78. #
  79. # $opt[$graphs] = "--vertical-label \"Disks\" -l 0 -r --title \"Disks on ";
  80. # $opt[$graphs] .= $this->MACRO['DISP_HOSTNAME'] . "\"";
  81. #
  82. # $ds_name[$graphs] = "Disks";
  83. #
  84. # $def[$graphs] = "";
  85. # $def[$graphs] .= rrd::def ("total", $d_t['RRDFILE'], $d_t['DS'], "MAX");
  86. # $def[$graphs] .= rrd::def ("active", $d_a['RRDFILE'], $d_a['DS'], "MIN");
  87. # $def[$graphs] .= rrd::def ("spare", $d_s['RRDFILE'], $d_s['DS'], "MIN");
  88. # $def[$graphs] .= rrd::def ("failed", $d_f['RRDFILE'], $d_f['DS'], "MAX");
  89. #
  90. # $def[$graphs] .= rrd::line1 ("total", "#000000", "Disks total\: ");
  91. # $def[$graphs] .= rrd::gprint ("total", "LAST", "%3.0lf %S\\n".$d_t['UNIT']);
  92. #
  93. # $def[$graphs] .= rrd::area ("active", "#0000FFEE", "Disks active\:");
  94. # $def[$graphs] .= rrd::gprint ("active", "LAST", "%3.0lf %S\\n".$d_a['UNIT']);
  95. #
  96. # $def[$graphs] .= rrd::area ("spare", "#77FF77CC", "Disks spare\: ", "STACK");
  97. # $def[$graphs] .= rrd::gprint ("spare", "LAST", "%3.0lf %S\\n".$d_s['UNIT']);
  98. #
  99. # $def[$graphs] .= rrd::area ("failed", "#FF3333", "Disks failed\:", "STACK");
  100. # $def[$graphs] .= rrd::gprint ("failed", "LAST", "%3.0lf %S\\n".$d_s['UNIT']);
  101. #
  102. #
  103. # } elseif (substr($VAL['NAME'], 0, 5) == 'naio_') {
  104. # $io1 = $VAL;
  105. # $io2 = array_shift($this->DS);
  106. #
  107. # $type = substr($io1['NAME'], 5, 3);
  108. # $name = 'UNKN';
  109. # $desc_r = 'Read ';
  110. # $desc_w = 'Write';
  111. # if ($type == 'net') {
  112. # $name = 'Net';
  113. # $desc_r = 'In ';
  114. # $desc_w = 'Out';
  115. # } elseif ($type == 'dis') {
  116. # $name = 'Disk';
  117. # } elseif ($type == 'tap') {
  118. # $name = 'Tape';
  119. # } elseif ($type == 'fcp') {
  120. # $name = 'Fibre channel';
  121. # } elseif ($type == 'isc') {
  122. # $name = 'iSCSI';
  123. # }
  124. #
  125. # $opt[$graphs] = "--vertical-label \"Bytes/s\" --title \"" . $name . " I/O on ";
  126. # $opt[$graphs] .= $this->MACRO['DISP_HOSTNAME'] . "\"";
  127. #
  128. # $ds_name[$graphs] = $io1['NAME'] . " + " . $io2['NAME'];
  129. #
  130. # $def[$graphs] = "";
  131. # $def[$graphs] .= rrd::def ("ior", $io1['RRDFILE'], $io1['DS'], "AVERAGE");
  132. # $def[$graphs] .= rrd::def ("iow", $io2['RRDFILE'], $io2['DS'], "AVERAGE");
  133. #
  134. # $def[$graphs] .= rrd::area ("ior", "#00FF00", $desc_r . "\: ");
  135. # $def[$graphs] .= rrd::gprint ("ior", array("LAST","MAX","AVERAGE"), "%7.2lf %SB/s");
  136. #
  137. # $def[$graphs] .= rrd::line2 ("iow", "#0000FF", $desc_w . "\: ");
  138. # $def[$graphs] .= rrd::gprint ("iow", array("LAST","MAX","AVERAGE"), "%7.2lf %SB/s");
  139. #
  140. #
  141. # } elseif (substr($VAL['NAME'], 0, 6) == 'naops_') {
  142. # $o_nfs = $VAL;
  143. # $o_cifs = array_shift($this->DS);
  144. # $o_http = array_shift($this->DS);
  145. # $o_fcp = array_shift($this->DS);
  146. # $o_iscsi = array_shift($this->DS);
  147. #
  148. # $opt[$graphs] = "--vertical-label \"Ops/s\" -l 0 -r --title \"Ops/s on ";
  149. # $opt[$graphs] .= $this->MACRO['DISP_HOSTNAME'] . "\"";
  150. #
  151. # $ds_name[$graphs] = "Ops/s";
  152. #
  153. # $def[$graphs] = "";
  154. # $def[$graphs] .= rrd::def ("nfs", $o_nfs['RRDFILE'], $o_nfs['DS'], "AVERAGE");
  155. # $def[$graphs] .= rrd::def ("cifs", $o_cifs['RRDFILE'], $o_cifs['DS'], "AVERAGE");
  156. # $def[$graphs] .= rrd::def ("http", $o_http['RRDFILE'], $o_http['DS'], "AVERAGE");
  157. # $def[$graphs] .= rrd::def ("fcp", $o_fcp['RRDFILE'], $o_fcp['DS'], "AVERAGE");
  158. # $def[$graphs] .= rrd::def ("iscsi", $o_iscsi['RRDFILE'], $o_iscsi['DS'], "AVERAGE");
  159. #
  160. # $def[$graphs] .= rrd::line1 ("nfs", "#000000", "NFS ops/s\: ");
  161. # $def[$graphs] .= rrd::gprint ("nfs", array("LAST","MAX","AVERAGE"), "%7.2lf%Sops/s");
  162. #
  163. # $def[$graphs] .= rrd::line1 ("cifs", "#00FFFF", "CIFS ops/s\: ");
  164. # $def[$graphs] .= rrd::gprint ("cifs", array("LAST","MAX","AVERAGE"), "%7.2lf%Sops/s");
  165. #
  166. # $def[$graphs] .= rrd::line1 ("http", "#7F0000", "HTTP ops/s\: ");
  167. # $def[$graphs] .= rrd::gprint ("http", array("LAST","MAX","AVERAGE"), "%7.2lf%Sops/s");
  168. #
  169. # $def[$graphs] .= rrd::line1 ("fcp", "#00FF00", "FCP ops/s\: ");
  170. # $def[$graphs] .= rrd::gprint ("fcp", array("LAST","MAX","AVERAGE"), "%7.2lf%Sops/s");
  171. #
  172. # $def[$graphs] .= rrd::line1 ("iscsi", "#0000FF", "iSCSI ops/s\: ");
  173. # $def[$graphs] .= rrd::gprint ("iscsi", array("LAST","MAX","AVERAGE"), "%7.2lf%Sops/s");
  174. } elseif (substr($VAL['NAME'], 0, 6) == 'navdu_') {
  175. $v_du = $VAL;
  176. $v_dt = array_shift($this->DS);
  177. $v_su = array_shift($this->DS);
  178. $v_st = array_shift($this->DS);
  179. $opt[$graphs]['title'] = substr($VAL['NAME'], 6) . " on " . $this->MACRO['DISP_HOSTNAME'];
  180. $opt[$graphs]['labels'] = array("used", "free", "over resv.", "free snap", "used snap");
  181. $opt[$graphs]['colors'] = array("#AAAAAA", "#00FF00", "#AA0000", "#00FFFF", "#0000CC");
  182. $ds_name[$graphs] = "Volume " . substr($VAL['NAME'], 6);
  183. $du = $v_du['ACT'];
  184. $dt = $v_dt['ACT'];
  185. $supo = $v_su['ACT'];
  186. $st = $v_st['ACT'];
  187. $sf = ($supo <= $st) ? $st - $supo : 0;
  188. $su = ($supo > $st) ? $st : $supo;
  189. $so = ($supo > $st) ? $supo - $st : 0;
  190. $df = $dt - $du - $so;
  191. $def[$graphs] = array($du, $df, $so, $sf, $su);
  192. } elseif (substr($VAL['NAME'], 0, 6) == 'naviu_') {
  193. $v_iu = $VAL;
  194. $v_it = array_shift($this->DS);
  195. $opt[$graphs]['title'] = "INode usage on " . $this->MACRO['DISP_HOSTNAME'];
  196. $opt[$graphs]['labels'] = array("used", "");
  197. $ds_name[$graphs] = "INode usage on " . substr($VAL['NAME'], 6);
  198. $def[$graphs] = array($v_iu['ACT'], $v_it['ACT'] - $v_iu['ACT']);
  199. } else {
  200. $values = array();
  201. $labels = array();
  202. $value = -1;
  203. if ($VAL['MIN'] != "") {
  204. $value = $VAL['ACT'] - $VAL['MIN'];
  205. }
  206. else {
  207. $value - $VAL['ACT'];
  208. }
  209. array_push($values, $value);
  210. array_push($labels, $VAL['LABEL']);
  211. if ($VAL['MAX'] != "") {
  212. $value = $VAL['MAX'] - $VAL['ACT'];
  213. array_push($values, $value);
  214. array_push($labels, "");
  215. }
  216. elseif ($VAL['UNIT'] == "%%") {
  217. $value = 100.0 - $VAL['ACT'];
  218. array_push($values, $value);
  219. array_push($labels, "");
  220. }
  221. $def[$KEY] = $values;
  222. $opt[$KEY]['title'] = $this->MACRO['DISP_HOSTNAME'] . ' / ' . $this->MACRO['DISP_SERVICEDESC'];
  223. $opt[$KEY]['labels'] = $labels;
  224. $ds_name[$graphs] = $VAL['LABEL'];
  225. } // default
  226. $graphs++;
  227. }
  228. ?>