hasGlobalAdmin()) { $poller_group = isset($_POST['poller_group']) ? clean($_POST['poller_group']) : 0; $snmp_enabled = ($_POST['snmp'] == 'on'); if ($snmp_enabled) { $no_checks = ($_POST['no_checks'] == 'on'); $community = clean($_POST['community']); $snmpver = clean($_POST['snmpver']); $transport = $_POST['transport'] ? clean($_POST['transport']) : $transport = 'udp'; $port = $_POST['port'] ? clean($_POST['port']) : Config::get('snmp.port'); $timeout = clean($_POST['timeout']); $retries = clean($_POST['retries']); $port_assoc_mode = clean($_POST['port_assoc_mode']); $max_repeaters = clean($_POST['max_repeaters']); $max_oid = clean($_POST['max_oid']); $v3 = array( 'authlevel' => clean($_POST['authlevel']), 'authname' => clean($_POST['authname']), 'authpass' => clean($_POST['authpass']), 'authalgo' => clean($_POST['authalgo']), 'cryptopass' => clean($_POST['cryptopass']), 'cryptoalgo' => clean($_POST['cryptoalgo']), ); // FIXME needs better feedback $update = array( 'community' => $community, 'snmpver' => $snmpver, 'port' => $port, 'transport' => $transport, 'poller_group' => $poller_group, 'port_association_mode' => $port_assoc_mode, 'snmp_disable' => 0, ); if ($timeout) { $update['timeout'] = $timeout; } else { $update['timeout'] = array('NULL'); } if ($retries) { $update['retries'] = $retries; } else { $update['retries'] = array('NULL'); } $update = array_merge($update, $v3); } else { $update['snmp_disable'] = 1; $update['os'] = $_POST['os'] ? clean($_POST['os_id']) : "ping"; $update['hardware'] = clean($_POST['hardware']); $update['features'] = null; $update['version'] = null; $update['icon'] = null; $update['sysName'] = $_POST['sysName'] ? clean($_POST['sysName']) : null; $update['poller_group'] = $poller_group; } $device_tmp = deviceArray($device['hostname'], $community, $snmpver, $port, $transport, $v3, $port_assoc_mode); if ($no_checks === true || !$snmp_enabled || isSNMPable($device_tmp)) { $rows_updated = dbUpdate($update, 'devices', '`device_id` = ?', array($device['device_id'])); $max_repeaters_set = 0; $max_oid_set = 0; if (is_numeric($max_repeaters) && $max_repeaters != 0) { $max_repeaters_set = set_dev_attrib($device, 'snmp_max_repeaters', $max_repeaters); } else { $max_repeaters_set = del_dev_attrib($device, 'snmp_max_repeaters'); } if (is_numeric($max_oid) && $max_oid != 0) { $max_oid_set = set_dev_attrib($device, 'snmp_max_oid', $max_oid); } else { $max_oid_set = del_dev_attrib($device, 'snmp_max_oid'); } if ($rows_updated > 0) { $update_message[] = $rows_updated.' Device record updated.'; } if ($max_repeaters_set) { $update_message[] = 'SNMP Max repeaters updated.'; } elseif ($max_repeaters_set === false) { $update_failed_message[] = 'SNMP Max repeaters update failed.'; } if ($max_oid_set) { $update_message[] = 'SNMP Max OID updated updated.'; } elseif ($max_oid_set === false) { $update_failed_message[] = 'SNMP Max OID updated failed.'; } if (!isset($update_message) && !isset($update_failed_message)) { $update_message[] = 'Device record unchanged. No update necessary.'; } } else { $update_failed_message[] = 'Could not connect to device with new SNMP details'; } }//end if }//end if $device = dbFetchRow('SELECT * FROM `devices` WHERE `device_id` = ?', array($device['device_id'])); $descr = $device['purpose']; if (isset($update_message)) { print_message(join("
", $update_message)); } if (isset($update_failed_message)) { print_error(join("
", $update_failed_message)); } $max_repeaters = get_dev_attrib($device, 'snmp_max_repeaters'); $max_oid = get_dev_attrib($device, 'snmp_max_oid'); echo "
" . csrf_field() . "
"; ?>
'; }//end if echo '
'; ?>