From febdea231e12ee16611fb4863229089de8020a2e Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Fri, 18 Mar 2011 16:49:15 +0000 Subject: [PATCH] move snmp options to separate form on device edit, also hide services link when services disabled git-svn-id: http://www.observium.org/svn/observer/trunk@1928 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/images/icons/greyscale/snmp.png | Bin 0 -> 500 bytes html/images/icons/snmp.png | Bin 0 -> 566 bytes html/pages/device/edit.inc.php | 16 ++-- html/pages/device/edit/device.inc.php | 58 +------------- html/pages/device/edit/snmp.inc.php | 106 ++++++++++++++++++++++++++ 5 files changed, 120 insertions(+), 60 deletions(-) create mode 100644 html/images/icons/greyscale/snmp.png create mode 100755 html/images/icons/snmp.png create mode 100644 html/pages/device/edit/snmp.inc.php diff --git a/html/images/icons/greyscale/snmp.png b/html/images/icons/greyscale/snmp.png new file mode 100644 index 0000000000000000000000000000000000000000..dda417b12713bf875ac95e200eb4ef21da2ecb79 GIT binary patch literal 500 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6SkfJR9T^zbpD<_bdI{t+C3(BM zF#K=tKeHdm<1FxqEC$jZVC;4>+YTgHR^XTpq`_t}#2j0D7|40!>EaloalZAUt(SA4 zz|oKQe>1p7bF=bp3uAMfsPIDVPQwGUJMC+uH;9QQD|9d(6lFQ+q;uqu!@a%NAMKsN z;rL$U@}K8(W)^RL@;3_P`3aQ@Y z$E;pTe9w3EhkWH@G%s%W8`+?|z1QzL;}3&*41o{*7HYHGdag8O)hPK=BGtNUKZj{R zXHjjdT~SHujR|TFK{re{Fw5me9=h;o%~1yCl&16zR$CRWe@pp&UDWxfi{i~Md1qHE zWJ#KN9*JQ7F8(%aXO_~sv_-%6sQiAvdq1P|(n{^P72+#^{#GqyB~+6IPJ1_n|>A*)a{>q?GuNnCdgP^*Bj5V_b?dAq2Ppn9^MBB^YUM zad0N-T{Ujg*A6d~mYV4na=hT4Nz+_}SGTgW|Iir!%$ z;@OGkWI6+j0H}~K4RYR%!7y|zM`O@*K>rL{*&}x3lR**HrMXC1->#slU>X|w!U1xQ zqc 'Device Settings', - 'ports' => 'Port Settings', - 'apps' => 'Applications', - 'services' => 'Services', - 'ipmi' => 'IPMI'); + $panes['device'] = 'Device Settings'; + $panes['snmp'] = 'SNMP'; + $panes['ports'] = 'Port Settings'; + $panes['apps'] = 'Applications'; + + if ($config['enable_services']) + { + $panes['services'] = 'Services'; + } + + $panes['ipmi'] = 'IPMI'; print_optionbar_start(); diff --git a/html/pages/device/edit/device.inc.php b/html/pages/device/edit/device.inc.php index 7a3089e56..9cf455ccd 100644 --- a/html/pages/device/edit/device.inc.php +++ b/html/pages/device/edit/device.inc.php @@ -8,17 +8,10 @@ if ($_POST['editing']) $ignore = mres($_POST['ignore']); $type = mres($_POST['type']); $disabled = mres($_POST['disabled']); - $community = mres($_POST['community']); - $snmpver = mres($_POST['snmpver']); - $port = mres($_POST['port']); - $timeout = mres($_POST['timeout']); - $retries = mres($_POST['retries']); #FIXME needs more sanity checking! and better feedback - $sql = "UPDATE `devices` SET `purpose` = '" . $descr . "', `community` = '" . $community . "', `type` = '$type'"; - $sql .= ", `snmpver` = '" . $snmpver . "', `ignore` = '$ignore', `disabled` = '$disabled', `port` = '$port', "; - if ($timeout) { $sql .= "`timeout` = '$timeout', "; } else { $sql .= "`timeout` = NULL, "; } - if ($retries) { $sql .= "`retries` = '$retries'"; } else { $sql .= "`retries` = NULL"; } + $sql = "UPDATE `devices` SET `purpose` = '" . $descr . "', `type` = '$type'"; + $sql .= ", `ignore` = '$ignore', `disabled` = '$disabled'"; $sql .= " WHERE `device_id` = '".$device['device_id']."'"; $query = mysql_query($sql); @@ -38,7 +31,7 @@ if ($_POST['editing']) } } -$device = mysql_fetch_array(mysql_query("SELECT * FROM `devices` WHERE `device_id` = '".$device['device_id']."'")); +$device = mysql_fetch_assoc(mysql_query("SELECT * FROM `devices` WHERE `device_id` = '".$device['device_id']."'")); $descr = $device['purpose']; if ($updated && $update_message) @@ -64,51 +57,6 @@ echo(" - - - - - - - - - - - - - - - - - - - - - - - - -
Description
SNMP Community
-
SNMP Version
-
SNMP Port
-
SNMP Transport
- -
SNMP Timeout
  - seconds -
SNMP Retries
-
Type diff --git a/html/pages/device/edit/snmp.inc.php b/html/pages/device/edit/snmp.inc.php new file mode 100644 index 000000000..877b40508 --- /dev/null +++ b/html/pages/device/edit/snmp.inc.php @@ -0,0 +1,106 @@ + "7") + { + $community = mres($_POST['community']); + $snmpver = mres($_POST['snmpver']); + $port = mres($_POST['port']); + $timeout = mres($_POST['timeout']); + $retries = mres($_POST['retries']); + + #FIXME needs more sanity checking! and better feedback + $sql = "UPDATE `devices` SET `community` = '" . $community . "', `snmpver` = '" . $snmpver . "', `port` = '$port', "; + if ($timeout) { $sql .= "`timeout` = '$timeout', "; } else { $sql .= "`timeout` = NULL, "; } + if ($retries) { $sql .= "`retries` = '$retries'"; } else { $sql .= "`retries` = NULL"; } + $sql .= " WHERE `device_id` = '".$device['device_id']."'"; + $query = mysql_query($sql); + + $rows_updated = mysql_affected_rows(); + + if ($rows_updated > 0) + { + $update_message = mysql_affected_rows() . " 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; + } + } +} + +$device = mysql_fetch_assoc(mysql_query("SELECT * FROM `devices` WHERE `device_id` = '".$device['device_id']."'")); +$descr = $device['purpose']; + +if ($updated && $update_message) +{ + print_message($update_message); +} elseif ($update_message) { + print_error($update_message); +} + +echo(" +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + "); + +echo(' +
SNMP Community
+
SNMP Version
+
SNMP Port
+
SNMP Transport
+ +
SNMP Timeout
  + seconds +
SNMP Retries
+
+ + +
+ +
'); + +?> \ No newline at end of file