2011-03-18 16:49:15 +00:00
<? php
2019-06-23 00:29:12 -05:00
use LibreNMS\Config ;
2018-04-07 15:55:28 -05:00
2015-07-13 20:10:26 +02:00
if ( $_POST [ 'editing' ]) {
2019-08-05 14:16:05 -05:00
if ( Auth :: user () -> hasGlobalAdmin ()) {
2020-01-26 09:04:00 -05:00
$force_save = ( $_POST [ 'force_save' ] == 'on' );
2020-06-08 14:16:40 +01:00
$poller_group = isset ( $_POST [ 'poller_group' ]) ? $_POST [ 'poller_group' ] : 0 ;
2017-10-28 05:59:25 +02:00
$snmp_enabled = ( $_POST [ 'snmp' ] == 'on' );
2020-01-26 09:04:00 -05:00
2017-10-28 05:59:25 +02:00
if ( $snmp_enabled ) {
2020-06-08 14:16:40 +01:00
$max_repeaters = $_POST [ 'max_repeaters' ];
$max_oid = $_POST [ 'max_oid' ];
$port = $_POST [ 'port' ] ? $_POST [ 'port' ] : Config :: get ( 'snmp.port' );
$port_assoc_mode = $_POST [ 'port_assoc_mode' ];
$retries = $_POST [ 'retries' ];
$snmpver = $_POST [ 'snmpver' ];
$transport = $_POST [ 'transport' ] ? $_POST [ 'transport' ] : $transport = 'udp' ;
$timeout = $_POST [ 'timeout' ];
2015-07-13 20:10:26 +02:00
2020-09-21 15:40:17 +02:00
$update = [
2017-10-28 05:59:25 +02:00
'poller_group' => $poller_group ,
2020-01-26 09:04:00 -05:00
'port' => $port ,
2017-10-28 05:59:25 +02:00
'port_association_mode' => $port_assoc_mode ,
'snmp_disable' => 0 ,
2020-01-26 09:04:00 -05:00
'snmpver' => $snmpver ,
'transport' => $transport ,
2020-09-21 15:40:17 +02:00
];
2015-07-13 20:10:26 +02:00
2020-01-26 09:04:00 -05:00
if ( $retries ) {
$update [ 'retries' ] = $retries ;
} else {
2020-09-21 15:40:17 +02:00
$update [ 'retries' ] = [ 'NULL' ];
2020-01-26 09:04:00 -05:00
}
2020-09-21 15:59:34 +02:00
if ( $snmpver != 'v3' ) {
2020-06-08 14:16:40 +01:00
$community = $_POST [ 'community' ];
2020-09-21 15:40:17 +02:00
$update [ 'community' ] = $community ;
2020-01-26 09:04:00 -05:00
}
2017-10-28 05:59:25 +02:00
if ( $timeout ) {
$update [ 'timeout' ] = $timeout ;
} else {
2020-09-21 15:40:17 +02:00
$update [ 'timeout' ] = [ 'NULL' ];
2017-10-28 05:59:25 +02:00
}
2015-07-13 20:10:26 +02:00
2020-09-21 15:40:17 +02:00
$v3 = [];
2020-09-21 15:59:34 +02:00
if ( $snmpver == 'v3' ) {
2020-01-26 09:04:00 -05:00
$community = '' ; // if v3 works, we don't need a community
2020-06-08 14:16:40 +01:00
$v3 [ 'authalgo' ] = $_POST [ 'authalgo' ];
$v3 [ 'authlevel' ] = $_POST [ 'authlevel' ];
$v3 [ 'authname' ] = $_POST [ 'authname' ];
$v3 [ 'authpass' ] = $_POST [ 'authpass' ];
$v3 [ 'cryptoalgo' ] = $_POST [ 'cryptoalgo' ];
$v3 [ 'cryptopass' ] = $_POST [ 'cryptopass' ];
2020-01-26 09:04:00 -05:00
$update = array_merge ( $update , $v3 );
2017-10-28 05:59:25 +02:00
}
2016-08-18 20:28:22 -05:00
} else {
2020-01-26 09:04:00 -05:00
// snmp is disabled
$update [ 'features' ] = null ;
2020-06-08 14:16:40 +01:00
$update [ 'hardware' ] = $_POST [ 'hardware' ];
2020-01-26 09:04:00 -05:00
$update [ 'icon' ] = null ;
2020-09-21 15:59:34 +02:00
$update [ 'os' ] = $_POST [ 'os' ] ? $_POST [ 'os_id' ] : 'ping' ;
2019-05-24 07:35:33 -05:00
$update [ 'poller_group' ] = $poller_group ;
2020-01-26 09:04:00 -05:00
$update [ 'snmp_disable' ] = 1 ;
2020-06-08 14:16:40 +01:00
$update [ 'sysName' ] = $_POST [ 'sysName' ] ? $_POST [ 'sysName' ] : null ;
2020-01-26 09:04:00 -05:00
$update [ 'version' ] = null ;
2014-10-09 18:54:19 +00:00
}
2011-03-18 16:49:15 +00:00
2020-01-26 09:04:00 -05:00
$device_is_snmpable = false ;
2020-09-21 15:40:17 +02:00
$rows_updated = 0 ;
2020-01-26 09:04:00 -05:00
if ( $force_save !== true && $snmp_enabled ) {
$device_snmp_details = deviceArray ( $device [ 'hostname' ], $community , $snmpver , $port , $transport , $v3 , $port_assoc_mode );
2020-09-21 15:40:17 +02:00
$device_issnmpable = isSNMPable ( $device_snmp_details );
2020-01-26 09:04:00 -05:00
}
2020-09-21 15:40:17 +02:00
if ( $force_save === true || ! $snmp_enabled || $device_issnmpable ) {
2020-01-26 09:04:00 -05:00
// update devices table
2020-09-21 15:40:17 +02:00
$rows_updated = dbUpdate ( $update , 'devices' , '`device_id` = ?' , [ $device [ 'device_id' ]]);
2020-01-26 09:04:00 -05:00
}
2018-02-07 06:35:00 +01:00
2020-01-26 09:04:00 -05:00
if ( $snmp_enabled && ( $force_save === true || $device_issnmpable )) {
// update devices_attribs table
2016-07-06 14:45:23 +01:00
2020-01-26 09:04:00 -05:00
// note:
// set_dev_attrib and del_dev_attrib *only* return (bool)
// setAttrib() returns true if it was set and false if it was not (e.g. it didn't change)
// forgetAttrib() returns true if it was deleted and false if it was not (e.g. it didn't exist)
// Symfony throws FatalThrowableError on error
2015-07-13 20:10:26 +02:00
2020-09-21 15:40:17 +02:00
$devices_attribs = [ 'snmp_max_repeaters' , 'snmp_max_oid' ];
2016-10-11 17:34:09 +01:00
2020-01-26 09:04:00 -05:00
foreach ( $devices_attribs as $devices_attrib ) {
// defaults
2020-09-21 15:40:17 +02:00
$feedback_prefix = $devices_attrib ;
$form_value = null ;
$form_value_is_numeric = false ; // does not need to be a number greater than zero
2020-01-26 09:04:00 -05:00
if ( $devices_attrib == 'snmp_max_repeaters' ) {
2020-09-21 15:59:34 +02:00
$feedback_prefix = 'SNMP Max Repeaters' ;
2020-09-21 15:40:17 +02:00
$form_value = $max_repeaters ;
$form_value_is_numeric = true ;
2020-01-26 09:04:00 -05:00
}
if ( $devices_attrib == 'snmp_max_oid' ) {
2020-09-21 15:59:34 +02:00
$feedback_prefix = 'SNMP Max OID' ;
2020-09-21 15:40:17 +02:00
$form_value = $max_oid ;
$form_value_is_numeric = true ;
2020-01-26 09:04:00 -05:00
}
$get_devices_attrib = get_dev_attrib ( $device , $devices_attrib );
$set_devices_attrib = false ; // testing $set_devices_attrib === false is not a true indicator of a failure
if ( $form_value != $get_devices_attrib && $form_value_is_numeric && is_numeric ( $form_value ) && $form_value != 0 ) {
2020-09-21 15:40:17 +02:00
$set_devices_attrib = set_dev_attrib ( $device , $devices_attrib , $form_value );
2020-01-26 09:04:00 -05:00
}
2020-09-21 15:40:17 +02:00
if ( $form_value != $get_devices_attrib && ! $form_value_is_numeric ) {
$set_devices_attrib = set_dev_attrib ( $device , $devices_attrib , $form_value );
2020-01-26 09:04:00 -05:00
}
2020-09-21 15:40:17 +02:00
if ( $form_value != $get_devices_attrib && $form_value_is_numeric && ! is_numeric ( $form_value )) {
$set_devices_attrib = del_dev_attrib ( $device , $devices_attrib );
2020-01-26 09:04:00 -05:00
}
2020-09-21 15:40:17 +02:00
if ( $form_value != $get_devices_attrib && ! $form_value_is_numeric && $form_value == '' ) {
$set_devices_attrib = del_dev_attrib ( $device , $devices_attrib );
2020-01-26 09:04:00 -05:00
}
if ( $form_value != $get_devices_attrib && $set_devices_attrib ) {
$set_devices_attrib = get_dev_attrib ( $device , $devices_attrib ); // re-check the db value
}
if ( $form_value != $get_devices_attrib && $form_value == $set_devices_attrib && ( is_null ( $set_devices_attrib ) || $set_devices_attrib == '' )) {
$update_message [] = " $feedback_prefix deleted" ;
}
2020-09-21 15:40:17 +02:00
if ( $form_value != $get_devices_attrib && $form_value == $set_devices_attrib && ( ! is_null ( $set_devices_attrib ) && $set_devices_attrib != '' )) {
2020-01-26 09:04:00 -05:00
$update_message [] = " $feedback_prefix updated to $set_devices_attrib " ;
}
if ( $form_value != $get_devices_attrib && $form_value != $set_devices_attrib ) {
$update_failed_message [] = " $feedback_prefix update failed." ;
}
unset ( $get_devices_attrib , $set_devices_attrib );
2015-07-13 20:10:26 +02:00
}
2020-01-26 09:04:00 -05:00
unset ( $devices_attrib );
2015-07-13 20:10:26 +02:00
}
2020-01-26 09:04:00 -05:00
if ( $rows_updated > 0 ) {
$update_message [] = 'Device record updated' ;
}
2020-09-21 15:40:17 +02:00
if ( $snmp_enabled && ( $force_save !== true && ! $device_issnmpable )) {
2020-09-21 15:59:34 +02:00
$update_failed_message [] = 'Could not connect to ' . htmlspecialchars ( $device [ 'hostname' ]) . ' with those SNMP settings. To save anyway, turn on Force Save.' ;
2020-01-26 09:04:00 -05:00
$update_message [] = 'SNMP settings reverted' ;
}
2020-09-21 15:40:17 +02:00
if ( $rows_updated == 0 && ! isset ( $update_message ) && ! isset ( $update_failed_message )) {
2020-01-26 09:04:00 -05:00
$update_message [] = 'SNMP settings did not change' ;
}
} //end if (Auth::user()->hasGlobalAdmin())
} //end if ($_POST['editing'])
// the following unsets are for security; the database is authoritative
// i.e. prevent unintentional artifacts from being saved or used (again), posting around the form, etc.
unset ( $_POST );
// these are only used for editing and should not be used as-is
unset ( $force_save , $poller_group , $snmp_enabled );
unset ( $community , $max_repeaters , $max_oid , $port , $port_assoc_mode , $retries , $snmpver , $transport , $timeout );
// get up-to-date database values for use on the form
2020-09-21 15:40:17 +02:00
$device = dbFetchRow ( 'SELECT * FROM `devices` WHERE `device_id` = ?' , [ $device [ 'device_id' ]]);
2020-01-26 09:04:00 -05:00
$max_oid = get_dev_attrib ( $device , 'snmp_max_oid' );
$max_repeaters = get_dev_attrib ( $device , 'snmp_max_repeaters' );
2020-09-21 15:59:34 +02:00
echo '<h3> SNMP Settings </h3>' ;
2011-03-18 16:49:15 +00:00
2020-01-26 09:04:00 -05:00
// use Toastr to print normal (success) messages, similar to Device Settings
2017-10-28 05:59:25 +02:00
if ( isset ( $update_message )) {
2020-09-21 15:40:17 +02:00
$toastr_options = [];
2020-01-26 09:04:00 -05:00
if ( is_array ( $update_message )) {
foreach ( $update_message as $message ) {
Toastr :: success ( $message , null , $toastr_options );
}
}
if ( is_string ( $update_message )) {
Toastr :: success ( $update_message , null , $toastr_options );
}
unset ( $message , $toastr_options , $update_message );
2017-10-28 05:59:25 +02:00
}
2020-01-26 09:04:00 -05:00
// use Toastr:error to call attention to the problem; don't let it time out
2017-10-28 05:59:25 +02:00
if ( isset ( $update_failed_message )) {
2020-09-21 15:40:17 +02:00
$toastr_options = [];
2020-09-21 15:59:34 +02:00
$toastr_options [ 'closeButton' ] = true ;
$toastr_options [ 'extendedTimeOut' ] = 0 ;
$toastr_options [ 'timeOut' ] = 0 ;
2020-01-26 09:04:00 -05:00
if ( is_array ( $update_failed_message )) {
foreach ( $update_failed_message as $error ) {
Toastr :: error ( $error , null , $toastr_options );
}
}
2011-03-18 16:49:15 +00:00
2020-01-26 09:04:00 -05:00
if ( is_string ( $update_failed_message )) {
Toastr :: error ( $update_failed_message , null , $toastr_options );
}
unset ( $error , $update_failed_message );
}
2016-07-06 14:45:23 +01:00
2015-07-13 20:10:26 +02:00
echo "
<form id='edit' name='edit' method='post' action='' role='form' class='form-horizontal'>
2019-07-17 07:20:26 -05:00
" . csrf_field () . "
2017-10-28 05:59:25 +02:00
<div class='form-group'>
<label for='hardware' class='col-sm-2 control-label'>SNMP</label>
<div class='col-sm-4'>
2020-09-21 15:59:34 +02:00
<input type='checkbox' id='snmp' name='snmp' data-size='small' onChange='disableSnmp(this);'" . ( $device [ 'snmp_disable' ] ? '' : ' checked' ) . ">
2017-10-28 05:59:25 +02:00
</div>
</div>
2020-09-21 15:59:34 +02:00
<div id='snmp_override' style='display: " . ( $device [ 'snmp_disable' ] ? 'block' : 'none' ) . ";'>
2017-10-28 05:59:25 +02:00
<div class='form-group'>
2018-02-07 06:35:00 +01:00
<label for='sysName' class='col-sm-2 control-label'>sysName (optional)</label>
<div class='col-sm-4'>
2020-09-21 15:40:17 +02:00
<input id='sysName' class='form-control' name='sysName' value='" . htmlspecialchars ( $device [ 'sysName' ]) . "'/>
2018-02-07 06:35:00 +01:00
</div>
</div>
<div class='form-group'>
2017-10-28 05:59:25 +02:00
<label for='hardware' class='col-sm-2 control-label'>Hardware (optional)</label>
<div class='col-sm-4'>
2020-09-21 15:40:17 +02:00
<input id='hardware' class='form-control' name='hardware' value='" . htmlspecialchars ( $device [ 'hardware' ]) . "'/>
2017-10-28 05:59:25 +02:00
</div>
</div>
<div class='form-group'>
<label for='os' class='col-sm-2 control-label'>OS (optional)</label>
<div class='col-sm-4'>
2020-06-08 14:16:40 +01:00
<input id='os' class='form-control' name='os' value='" . htmlspecialchars ( Config :: get ( "os. { $device [ 'os' ] } .text" )) . "'/>
2020-09-21 15:40:17 +02:00
<input type='hidden' id='os_id' class='form-control' name='os_id' value='" . $device [ 'os' ] . "'/>
2017-10-28 05:59:25 +02:00
</div>
</div>
</div>
2020-09-21 15:59:34 +02:00
<div id='snmp_conf' style='display: " . ( $device [ 'snmp_disable' ] ? 'none' : 'block' ) . ";'>
2015-07-13 20:10:26 +02:00
<input type=hidden name='editing' value='yes'>
<div class='form-group'>
2014-10-09 18:54:19 +00:00
<label for='snmpver' class='col-sm-2 control-label'>SNMP Details</label>
<div class='col-sm-1'>
2015-07-13 20:10:26 +02:00
<select id='snmpver' name='snmpver' class='form-control input-sm' onChange='changeForm();'>
<option value='v1'>v1</option>
2020-09-21 15:40:17 +02:00
<option value='v2c' " . ( $device [ 'snmpver' ] == 'v2c' ? 'selected' : '' ) . ">v2c</option>
<option value='v3' " . ( $device [ 'snmpver' ] == 'v3' ? 'selected' : '' ) . ">v3</option>
2015-07-13 20:10:26 +02:00
</select>
2014-06-16 23:06:04 +01:00
</div>
2014-10-09 18:54:19 +00:00
<div class='col-sm-2'>
2020-09-21 15:59:34 +02:00
<input type='number' name='port' placeholder='port' class='form-control input-sm' value='" . htmlspecialchars ( $device [ 'port' ] == Config :: get ( 'snmp.port' ) ? '' : $device [ 'port' ]) . "'>
2014-06-16 23:06:04 +01:00
</div>
2014-10-09 18:54:19 +00:00
<div class='col-sm-1'>
2015-07-13 20:10:26 +02:00
<select name='transport' id='transport' class='form-control input-sm'>" ;
2019-06-23 00:29:12 -05:00
foreach ( Config :: get ( 'snmp.transports' ) as $transport ) {
2020-09-21 15:40:17 +02:00
echo "<option value='" . $transport . "'" ;
2014-10-09 18:54:19 +00:00
if ( $transport == $device [ 'transport' ]) {
2015-07-13 20:10:26 +02:00
echo " selected='selected'" ;
2014-10-09 18:54:19 +00:00
}
2015-07-13 20:10:26 +02:00
2020-09-21 15:40:17 +02:00
echo '>' . $transport . '</option>' ;
2014-10-09 18:54:19 +00:00
}
2015-07-13 20:10:26 +02:00
echo " </select>
</div>
2014-06-16 23:06:04 +01:00
</div>
2015-07-13 20:10:26 +02:00
<div class='form-group'>
2014-10-09 18:54:19 +00:00
<div class='col-sm-2'>
2014-06-16 23:06:04 +01:00
</div>
2014-10-09 18:54:19 +00:00
<div class='col-sm-1'>
2020-09-21 15:40:17 +02:00
<input type='number' id='timeout' name='timeout' class='form-control input-sm' value='" . htmlspecialchars ( $device [ 'timeout' ] ? $device [ 'timeout' ] : '' ) . "' placeholder='seconds' />
2014-06-16 23:06:04 +01:00
</div>
2014-10-09 18:54:19 +00:00
<div class='col-sm-1'>
2020-09-21 15:40:17 +02:00
<input type='number' id='retries' name='retries' class='form-control input-sm' value='" . htmlspecialchars ( $device [ 'timeout' ] ? $device [ 'retries' ] : '' ) . "' placeholder='retries' />
2015-07-13 20:10:26 +02:00
</div>
2014-06-16 23:06:04 +01:00
</div>
2016-01-21 22:05:11 +01:00
<div class='form-group'>
<label for='port_assoc_mode' class='col-sm-2 control-label'>Port Association Mode</label>
<div class='col-sm-1'>
<select name='port_assoc_mode' id='port_assoc_mode' class='form-control input-sm'>
" ;
2018-08-05 03:50:13 -05:00
foreach ( get_port_assoc_modes () as $pam_id => $pam ) {
2016-01-21 22:05:11 +01:00
echo " <option value=' $pam_id '" ;
2016-08-18 20:28:22 -05:00
if ( $pam_id == $device [ 'port_association_mode' ]) {
2016-01-21 22:05:11 +01:00
echo " selected='selected'" ;
2016-08-18 20:28:22 -05:00
}
2016-01-21 22:05:11 +01:00
echo "> $pam </option> \n " ;
}
2020-10-29 20:02:26 +02:00
$snmpv3_sha2_capable = snmpv3_sha2_capable ();
2016-01-21 22:05:11 +01:00
echo " </select>
</div>
</div>
2016-07-06 14:45:23 +01:00
<div class='form-group'>
<label for='max_repeaters' class='col-sm-2 control-label'>Max Repeaters</label>
<div class='col-sm-1'>
2020-09-21 15:40:17 +02:00
<input type='number' id='max_repeaters' name='max_repeaters' class='form-control input-sm' value='" . htmlspecialchars ( $max_repeaters ) . "' placeholder='max repeaters' />
2016-07-06 14:45:23 +01:00
</div>
</div>
2016-10-11 17:34:09 +01:00
<div class='form-group'>
<label for='max_oid' class='col-sm-2 control-label'>Max OIDs</label>
<div class='col-sm-1'>
2020-09-21 15:40:17 +02:00
<input type='number' id='max_oid' name='max_oid' class='form-control input-sm' value='" . htmlspecialchars ( $max_oid ) . "' placeholder='max oids' />
2016-10-11 17:34:09 +01:00
</div>
</div>
2015-07-13 20:10:26 +02:00
<div id='snmpv1_2'>
2014-10-09 18:54:19 +00:00
<div class='form-group'>
2015-07-13 20:10:26 +02:00
<label class='col-sm-3 control-label text-left'><h4><strong>SNMPv1/v2c Configuration</strong></h4></label>
2014-06-16 23:06:04 +01:00
</div>
2014-10-09 18:54:19 +00:00
<div class='form-group'>
2015-07-13 20:10:26 +02:00
<label for='community' class='col-sm-2 control-label'>SNMP Community</label>
<div class='col-sm-4'>
2020-09-21 15:40:17 +02:00
<input id='community' class='form-control' name='community' value='" . htmlspecialchars ( $device [ 'community' ]) . "'/>
2015-07-13 20:10:26 +02:00
</div>
2014-06-16 23:06:04 +01:00
</div>
2015-07-13 20:10:26 +02:00
</div>
<div id='snmpv3'>
2014-10-09 18:54:19 +00:00
<div class='form-group'>
2015-07-13 20:10:26 +02:00
<label class='col-sm-3 control-label'><h4><strong>SNMPv3 Configuration</strong></h4></label>
2014-06-16 23:06:04 +01:00
</div>
2014-10-09 18:54:19 +00:00
<div class='form-group'>
2015-07-13 20:10:26 +02:00
<label for='authlevel' class='col-sm-2 control-label'>Auth Level</label>
<div class='col-sm-4'>
<select id='authlevel' name='authlevel' class='form-control'>
2015-08-20 17:06:11 +00:00
<option value='noAuthNoPriv'>noAuthNoPriv</option>
2020-09-21 15:40:17 +02:00
<option value='authNoPriv' " . ( $device [ 'authlevel' ] == 'authNoPriv' ? 'selected' : '' ) . ">authNoPriv</option>
<option value='authPriv' " . ( $device [ 'authlevel' ] == 'authPriv' ? 'selected' : '' ) . ">authPriv</option>
2015-07-13 20:10:26 +02:00
</select>
</div>
2014-06-16 23:06:04 +01:00
</div>
2014-10-09 18:54:19 +00:00
<div class='form-group'>
2015-07-13 20:10:26 +02:00
<label for='authname' class='col-sm-2 control-label'>Auth User Name</label>
<div class='col-sm-4'>
2020-09-21 15:40:17 +02:00
<input type='text' id='authname' name='authname' class='form-control' value='" . htmlspecialchars ( $device [ 'authname' ]) . "' autocomplete='off'>
2015-07-13 20:10:26 +02:00
</div>
2014-06-16 23:06:04 +01:00
</div>
2014-10-09 18:54:19 +00:00
<div class='form-group'>
2015-07-13 20:10:26 +02:00
<label for='authpass' class='col-sm-2 control-label'>Auth Password</label>
<div class='col-sm-4'>
2020-09-21 15:40:17 +02:00
<input type='password' id='authpass' name='authpass' class='form-control' value='" . htmlspecialchars ( $device [ 'authpass' ]) . "' autocomplete='off'>
2015-07-13 20:10:26 +02:00
</div>
2014-10-09 18:54:19 +00:00
</div>
<div class='form-group'>
2015-07-13 20:10:26 +02:00
<label for='authalgo' class='col-sm-2 control-label'>Auth Algorithm</label>
<div class='col-sm-4'>
<select id='authalgo' name='authalgo' class='form-control'>
<option value='MD5'>MD5</option>
2020-09-21 15:40:17 +02:00
<option value='SHA' " . ( $device [ 'authalgo' ] === 'SHA' ? 'selected' : '' ) . ">SHA</option>
2020-10-29 20:02:26 +02:00
<option value='SHA-224' " . ( $device [ 'authalgo' ] === 'SHA-224' ? 'selected' : '' ) . ( $snmpv3_sha2_capable ?: ' disabled' ) . ">SHA-224</option>
<option value='SHA-256' " . ( $device [ 'authalgo' ] === 'SHA-256' ? 'selected' : '' ) . ( $snmpv3_sha2_capable ?: ' disabled' ) . ">SHA-256</option>
<option value='SHA-384' " . ( $device [ 'authalgo' ] === 'SHA-384' ? 'selected' : '' ) . ( $snmpv3_sha2_capable ?: ' disabled' ) . ">SHA-384</option>
<option value='SHA-512' " . ( $device [ 'authalgo' ] === 'SHA-512' ? 'selected' : '' ) . ( $snmpv3_sha2_capable ?: ' disabled' ) . '>SHA-512</option>
2015-07-13 20:10:26 +02:00
</select>
2020-10-29 20:02:26 +02:00
' ;
if ( ! $snmpv3_sha2_capable ) {
echo '<label class="text-left"><small>Optional requirements not resolved so some options are disabled</small></label>' ;
}
echo "
2015-07-13 20:10:26 +02:00
</div>
2014-10-09 18:54:19 +00:00
</div>
<div class='form-group'>
2015-07-13 20:10:26 +02:00
<label for='cryptopass' class='col-sm-2 control-label'>Crypto Password</label>
<div class='col-sm-4'>
2020-09-21 15:40:17 +02:00
<input type='password' id='cryptopass' name='cryptopass' class='form-control' value='" . htmlspecialchars ( $device [ 'cryptopass' ]) . "' autocomplete='off'>
2015-07-13 20:10:26 +02:00
</div>
2014-10-09 18:54:19 +00:00
</div>
<div class='form-group'>
2015-07-13 20:10:26 +02:00
<label for='cryptoalgo' class='col-sm-2 control-label'>Crypto Algorithm</label>
<div class='col-sm-4'>
<select id='cryptoalgo' name='cryptoalgo' class='form-control'>
2020-10-29 20:02:26 +02:00
<option value='AES' " . ( $device [ 'cryptoalgo' ] === 'AES' ? 'selected' : '' ) . ">AES</option>
<option value='AES-192' " . ( $device [ 'cryptoalgo' ] === 'AES-192' ? 'selected' : '' ) . ( $snmpv3_sha2_capable ?: ' disabled' ) . ">AES-192</option>
<option value='AES-256' " . ( $device [ 'cryptoalgo' ] === 'AES-256' ? 'selected' : '' ) . ( $snmpv3_sha2_capable ?: ' disabled' ) . ">AES-256</option>
<option value='DES'>DES</option>
2015-07-13 20:10:26 +02:00
</select>
2020-10-29 20:02:26 +02:00
" ;
if ( ! $snmpv3_sha2_capable ) {
echo '<label class="text-left"><small>Optional requirements not resolved so some options are disabled</small></label>' ;
}
echo '
2014-06-16 23:06:04 +01:00
</div>
2015-07-13 20:10:26 +02:00
</div>
2020-09-21 15:59:34 +02:00
</div>' ;
2016-11-01 17:58:55 +00:00
?>
2019-11-05 00:02:49 +01:00
2017-10-28 05:59:25 +02:00
</div>
2016-11-01 17:58:55 +00:00
<?php
2019-06-23 00:29:12 -05:00
if (Config::get('distributed_poller') === true) {
2015-07-13 20:10:26 +02:00
echo '
<div class="form-group">
<label for="poller_group" class="col-sm-2 control-label">Poller Group</label>
<div class="col-sm-4">
<select name="poller_group" id="poller_group" class="form-control input-sm">
<option value="0"> Default poller group</option>
';
foreach (dbFetchRows('SELECT `id`,`group_name` FROM `poller_groups`') as $group) {
2020-09-21 15:40:17 +02:00
echo '<option value="' . $group['id'] . '"';
2015-03-19 12:00:03 +00:00
if ($device['poller_group'] == $group['id']) {
echo ' selected';
}
2015-07-13 20:10:26 +02:00
2020-09-21 15:40:17 +02:00
echo '>' . htmlspecialchars($group['group_name']) . '</option>';
2015-03-19 12:00:03 +00:00
}
2015-07-13 20:10:26 +02:00
echo '
</select>
</div>
</div>
';
}//end if
2020-01-26 09:04:00 -05:00
?>
2015-03-19 12:00:03 +00:00
2020-01-26 09:04:00 -05:00
<div class="form-group">
<label for="force_save" class="control-label col-sm-2">Force Save</label>
<div class="col-sm-9">
<input type="checkbox" name="force_save" id="force_save" data-size="small">
</div>
</div>
2015-03-19 12:00:03 +00:00
2020-01-26 09:04:00 -05:00
<div class="row">
<div class="col-md-1 col-md-offset-2">
<button type="submit" name="Submit" class="btn btn-success"><i class="fa fa-check"></i> Save</button>
2015-09-16 16:02:38 +05:30
</div>
2020-01-26 09:04:00 -05:00
</div>
</form>
2011-03-18 16:49:15 +00:00
2014-10-09 18:54:19 +00:00
<script>
2020-01-26 09:04:00 -05:00
$('[name="force_save"]').bootstrapSwitch();
2019-11-05 00:02:49 +01:00
2015-07-13 20:10:26 +02:00
function changeForm() {
snmpVersion = $("#snmpver").val();
if(snmpVersion == 'v1' || snmpVersion == 'v2c') {
$('#snmpv1_2').show();
$('#snmpv3').hide();
2014-10-09 18:54:19 +00:00
}
2015-07-13 20:10:26 +02:00
else if(snmpVersion == 'v3') {
$('#snmpv1_2').hide();
$('#snmpv3').show();
2014-10-09 18:54:19 +00:00
}
2015-07-13 20:10:26 +02:00
}
2017-10-28 05:59:25 +02:00
function disableSnmp(e) {
if(e.checked) {
$('#snmp_conf').show();
$('#snmp_override').hide();
} else {
$('#snmp_conf').hide();
$('#snmp_override').show();
}
}
var os_suggestions = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('text'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: "ajax_ossuggest.php?term=%QUERY",
filter: function (output) {
return $.map(output, function (item) {
return {
text: item.text,
os: item.os,
};
});
},
wildcard: "%QUERY"
}
});
os_suggestions.initialize();
$('#os').typeahead({
hint: true,
highlight: true,
minLength: 1,
classNames: {
menu: 'typeahead-left'
}
},
{
source: os_suggestions.ttAdapter(),
async: true,
displayKey: 'text',
valueKey: 'os',
templates: {
suggestion: Handlebars.compile('<p> {{text}}</p>')
},
limit: 20
});
$("#os").on("typeahead:selected typeahead:autocompleted", function(e,datum) {
$("#os_id").val(datum.os);
$("#os").html('<mark>' + datum.text + '</mark>');
});
$("[name='snmp']").bootstrapSwitch('offColor','danger');
2015-07-13 20:10:26 +02:00
<?php
2020-01-26 09:04:00 -05:00
if ($device['snmpver'] == 'v3') {
echo "$('#snmpv1_2').hide();";
echo "$('#snmpv3').show();";
2016-08-18 20:28:22 -05:00
} else {
2020-01-26 09:04:00 -05:00
echo "$('#snmpv1_2').show();";
echo "$('#snmpv3').hide();";
2015-07-13 20:10:26 +02:00
}
2014-10-09 18:54:19 +00:00
?>
</script>