Guest User

Untitled

a guest
Dec 12th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. <?php
  2. $Hosts = $XML->hosts;
  3. $Services = $XML->services;
  4. //Loop XML Records for non-zero current status
  5. //current_states:
  6. //1 - WARNING
  7. //2 - CRITICAL
  8. //3 - UNKNOWN
  9. foreach($Hosts->host as $host){
  10. if($host->current_state > 0 ){
  11. switch($host->current_state){
  12. case 1:
  13. $HostOutages['' . $host->host_name . '']['status']='WARNING';
  14. break;
  15. case 2:
  16. $HostOutages['' . $host->host_name . '']['status']='CRITICAL';
  17. break;
  18. default:
  19. $HostOutages['' . $host->host_name . '']['status']='UNKOWN';
  20. break;
  21. }
  22. $HostOutages['' . $host->host_name . '']['details']= $host->plugin_output;
  23. $HostOutages['' . $host->host_name . '']['attempts']= $host->current_attempt . "/" . $host->max_attempts;
  24. $HostOutages['' . $host->host_name . '']['duration']= duration($host->last_state_change);
  25. }
  26. }
  27. print_r($HostOutages);exit;
Add Comment
Please, Sign In to add comment