test_config.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <html>
  2. <head>
  3. <title>Symon2Web configuration test</title>
  4. </head>
  5. <body>
  6. <?php
  7. // $Id: test_config.php,v 1.3 2003/01/26 20:41:02 dijkstra Exp $
  8. //
  9. // Test configuration variables
  10. require_once('datasources.inc');
  11. require_once('class_cpu.inc');
  12. require_once('class_if.inc');
  13. require_once('class_io.inc');
  14. require_once('class_mem.inc');
  15. require_once('class_pf.inc');
  16. // Test to see if we can find rrdtool
  17. // Test to see if we can run rrdtool
  18. print "Trying to find rrdtool:<b>";
  19. $g = new CPU_Graph();
  20. $g->init(); $a = ""; $g->parseoptions($a);
  21. $rrdtool = substr($g->get("rrdtool"), 0, strpos($g->get("rrdtool"), " "));
  22. print $rrdtool . "<br>\n";
  23. if (!is_string($rrdtool)) {
  24. exit("Internal error, class_graph does not set a default rrdtool location!");
  25. } else {
  26. if (!is_file($rrdtool)) {
  27. exit("'$rrdtool' does not point to a file");
  28. }
  29. if (!is_executable($rrdtool)) {
  30. exit("'$rrdtool' is not executable");
  31. }
  32. }
  33. print "</b><br>rrdtool -v outputs:<hr><pre>";
  34. passthru($rrdtool.' -v');
  35. print "</pre><hr>";
  36. // Test to see if we can find rrd files
  37. print "Trying to find symon rrd files:<br>";
  38. $root_dir = dir($symon2web["tree"]);
  39. while ($machine = $root_dir->read()) {
  40. if ($machine != '.' &&
  41. $machine != '..' &&
  42. is_dir($symon2web["tree"]."/".$machine)) {
  43. $symon2web["machine"][$machine] = $symon2web["tree"]."/".$machine;
  44. }
  45. }
  46. reset($symon2web["machine"]);
  47. while (list($machine, $dir) = each($symon2web["machine"])) {
  48. $readable = TRUE;
  49. print '<b>machine('.$machine.')=</b><br>';
  50. $machine_dir = dir($dir);
  51. while ($filename = $machine_dir->read()) {
  52. $file = $dir."/".$filename;
  53. if (is_file($file) &&
  54. preg_match("/^(cpu|if|io|mem|pf)(_([a-z]+))?([0-9]?).rrd$/",
  55. $filename, $match)) {
  56. print "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$file";
  57. if (!is_readable($file)) {
  58. $readable = FALSE;
  59. print "!";
  60. }
  61. print "<br>";
  62. }
  63. }
  64. print "}<br>";
  65. if ($readable == FALSE) {
  66. print "Note that files tagged with an exclamation mark could not be read.<br><br>";
  67. } else {
  68. print "And all files accessable.<br><br>";
  69. }
  70. }
  71. // Test to see if we can load rrd files
  72. // Tie it all together
  73. ?>
  74. </body>
  75. </html>