Переглянути джерело

web: add detect down host for walk snmp

Roman Dmitriev 2 роки тому
батько
коміт
2062a1551e
1 змінених файлів з 5 додано та 1 видалено
  1. 5 1
      html/inc/common.php

+ 5 - 1
html/inc/common.php

@@ -1873,8 +1873,12 @@ function check_snmp_access($ip, $community, $version)
     if (! isset($version)) {
         $version = '2';
     }
+    #check host up
+    $status = exec(escapeshellcmd("ping -W 1 -i 1 -c 3 ".$ip));
+    if (empty($status)) { return; }
+    #check snmp
     $result = get_snmp($ip, $community, $version, SYS_DESCR_MIB);
-    if (!isset($result)) { return; }
+    if (empty($result)) { return; }
     return 1;
 }