Browse Source

web: add detect down host for walk snmp

Roman Dmitriev 2 năm trước cách đây
mục cha
commit
2062a1551e
1 tập tin đã thay đổi với 5 bổ sung1 xóa
  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)) {
     if (! isset($version)) {
         $version = '2';
         $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);
     $result = get_snmp($ip, $community, $version, SYS_DESCR_MIB);
-    if (!isset($result)) { return; }
+    if (empty($result)) { return; }
     return 1;
     return 1;
 }
 }