A very simple monitoring daemon written in PHP without the bloat
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.

Config.php 960B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace PhpMonitor;
  3. class Config
  4. {
  5. protected static $configfile = 'monitor.json';
  6. protected static $data = null;
  7. public static function load($file = null)
  8. {
  9. if($file === null)
  10. $file = self::$configfile;
  11. if(!file_exists($file) || !is_readable($file))
  12. trigger_error(E_USER_ERROR, "Config file ".$file." not found!");
  13. $content = file_get_contents($file);
  14. if(!$content)
  15. return false;
  16. self::$data = json_decode($content, true);
  17. return true;
  18. }
  19. public static function get($property, $defaultvalue = null)
  20. {
  21. if(self::$data === null)
  22. self::load();
  23. if(!isset(self::$data['config'][$property]))
  24. return $defaultvalue;
  25. return self::$data['config'][$property];
  26. }
  27. public static function getChecks()
  28. {
  29. if(self::$data === null)
  30. self::load();
  31. return self::$data['checks'];
  32. }
  33. }