Browse Source

Add hooks to the pinger.

Joe Clarke 10 months ago
parent
commit
1b46d2163e
2 changed files with 7 additions and 0 deletions
  1. 3 0
      www/swreg/pinger.php
  2. 4 0
      www/swreg/swreg.inc.php

+ 3 - 0
www/swreg/pinger.php

@@ -27,6 +27,7 @@
 
 include_once '../db.inc.php';
 include_once 'swreg.inc.php';
+require_once '../functions.php';
 require_once 'Log.php';
 
 $dsn = "$db_driver:host=$db_host;dbname=$db_name";
@@ -70,9 +71,11 @@ while ($sth !== null && $row = $sth->fetch()) {
     exec("$FPING -q -C 1 {$row['ip_address']} 2>/dev/null", $output, $result);
     if ($result == 0) {
         $status = REACHABILITY_REACHABLE;
+        call_hook("PINGER:REACHABLE", array($row['serial_number'], $row['ip_address']));
     } else {
         if ($row['status'] == REACHABILITY_REACHABLE || $row['status'] == REACHABILITY_NOW_UNREACHABLE) {
             $status = REACHABILITY_NOW_UNREACHABLE;
+            call_hook("PINGER:UNREACHABLE", array($row['serial_number'], $row['ip_address']));
         }
     }
 

+ 4 - 0
www/swreg/swreg.inc.php

@@ -233,4 +233,8 @@ $HOOKS = array(
         'UNKNOWN' => '',
         'ERROR' => '',
     ),
+    'PINGER' => array(
+        'REACHABLE' => '',
+        'UNREACHABLE' => '',
+    ),
 );