From e886d1957eb28ade078050498c43ab7eaa84f78f Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Thu, 9 Oct 2014 18:54:19 +0000 Subject: [PATCH] Updated edit snmp device section to show relevant v1,v2c or v3 options --- html/pages/device/edit/snmp.inc.php | 216 +++++++++++++++------------- 1 file changed, 119 insertions(+), 97 deletions(-) diff --git a/html/pages/device/edit/snmp.inc.php b/html/pages/device/edit/snmp.inc.php index eb193458e3..ad43492b87 100644 --- a/html/pages/device/edit/snmp.inc.php +++ b/html/pages/device/edit/snmp.inc.php @@ -6,8 +6,8 @@ if ($_POST['editing']) { $community = mres($_POST['community']); $snmpver = mres($_POST['snmpver']); - $transport = mres($_POST['transport']); - $port = mres($_POST['port']); + if ($_POST['port']) { $port = mres($_POST['port']); } else { $port = $config['snmp']['port']; } + if ($_POST['transport']) { $transport = mres($_POST['transport']); } else { $transport = "udp"; } $timeout = mres($_POST['timeout']); $retries = mres($_POST['retries']); $v3 = array ( @@ -34,18 +34,24 @@ if ($_POST['editing']) $update = array_merge($update, $v3); - $rows_updated = dbUpdate($update, 'devices', '`device_id` = ?',array($device['device_id'])); + $device_tmp = deviceArray($device['hostname'], $community, $snmpver, $port, $transport, $v3); + if (isSNMPable($device_tmp)) { + $rows_updated = dbUpdate($update, 'devices', '`device_id` = ?',array($device['device_id'])); - if ($rows_updated > 0) - { - $update_message = $rows_updated . " Device record updated."; - $updated = 1; - } elseif ($rows_updated = '-1') { - $update_message = "Device record unchanged. No update necessary."; - $updated = -1; + if ($rows_updated > 0) + { + $update_message = $rows_updated . " Device record updated."; + $updated = 1; + } elseif ($rows_updated = '-1') { + $update_message = "Device record unchanged. No update necessary."; + $updated = -1; + } else { + $update_message = "Device record update error."; + $updated = 0; + } } else { - $update_message = "Device record update error."; - $updated = 0; + $update_message = "We couldn't connect to this device with new SNMP details"; + $updated = 0; } } } @@ -53,125 +59,141 @@ if ($_POST['editing']) $device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id'])); $descr = $device['purpose']; +echo('
+
'); if ($updated && $update_message) { print_message($update_message); } elseif ($update_message) { print_error($update_message); } +echo('
+
'); echo("
- -
-
-
-
- -
-
- -
- +
+ +
+
+
- +
+
+
+ +
+
+ +
-
- -
- +
+
+
+
+
+ +
+
+ +
+ + +
-
-
- -
- +
+ +
+ +
-
-
- -
- +
+ +
+ +
-
-
- -
- +
+ +
+ +
-
-
- -
- +
+ +
+ +
-
-
- -
- -
-
-
- -
-
- -
- -
-
-
- -
- -
-
-
- -
- seconds -
-
-
- -
- +
+ +
+ +
"); echo(' - '); ?> +