mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Added support for per device unix-agent port
This commit is contained in:
@@ -1178,6 +1178,9 @@ function dynamic_override_config($type, $name, $device) {
|
|||||||
if ($type == 'checkbox') {
|
if ($type == 'checkbox') {
|
||||||
return '<input type="checkbox" id="override_config" name="override_config" data-attrib="'.$name.'" data-device_id="'.$device['device_id'].'" data-size="small" '.$checked.'>';
|
return '<input type="checkbox" id="override_config" name="override_config" data-attrib="'.$name.'" data-device_id="'.$device['device_id'].'" data-size="small" '.$checked.'>';
|
||||||
}
|
}
|
||||||
|
elseif ($type == 'text') {
|
||||||
|
return '<input type="text" id="override_config_text" name="override_config_text" data-attrib="'.$name.'" data-device_id="'.$device['device_id'].'" value="'.$attrib_val.'">';
|
||||||
|
}
|
||||||
}//end dynamic_override_config()
|
}//end dynamic_override_config()
|
||||||
|
|
||||||
function generate_dynamic_config_panel($title,$end_panel=true,$config_groups,$items=array(),$transport='') {
|
function generate_dynamic_config_panel($title,$end_panel=true,$config_groups,$items=array(),$transport='') {
|
||||||
|
@@ -25,6 +25,32 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Device override for text inputs
|
||||||
|
$(document).on('blur', 'input[name="override_config_text"]', function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
var $this = $(this);
|
||||||
|
var attrib = $this.data('attrib');
|
||||||
|
var device_id = $this.data('device_id');
|
||||||
|
var value = $this.val();
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: 'ajax_form.php',
|
||||||
|
data: { type: 'override-config', device_id: device_id, attrib: attrib, state: value },
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(data) {
|
||||||
|
if (data.status == 'ok') {
|
||||||
|
toastr.success(data.message);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
toastr.error(data.message);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
toastr.error('Could not set this override');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Checkbox config ajax calls
|
// Checkbox config ajax calls
|
||||||
$("[name='global-config-check']").bootstrapSwitch('offColor','danger');
|
$("[name='global-config-check']").bootstrapSwitch('offColor','danger');
|
||||||
$('input[name="global-config-check"]').on('switchChange.bootstrapSwitch', function(event, state) {
|
$('input[name="global-config-check"]').on('switchChange.bootstrapSwitch', function(event, state) {
|
||||||
|
@@ -14,6 +14,12 @@ echo '
|
|||||||
'.dynamic_override_config('checkbox','override_Oxidized_disable', $device).'
|
'.dynamic_override_config('checkbox','override_Oxidized_disable', $device).'
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="unixagent" class="col-sm-2 control-label">Unix agent port</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
'.dynamic_override_config('text','override_Unixagent_port', $device).'
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
';
|
';
|
||||||
|
|
||||||
|
@@ -19,12 +19,28 @@ $oxidized_conf = array(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$unixagent_conf = array(
|
||||||
|
array('name' => 'unix-agent.port',
|
||||||
|
'descr' => 'Default unix-agent port',
|
||||||
|
'type' => 'text',
|
||||||
|
),
|
||||||
|
array('name' => 'unix-agent.connection-timeout',
|
||||||
|
'descr' => 'Connection timeout',
|
||||||
|
'type' => 'text',
|
||||||
|
),
|
||||||
|
array('name' => 'unix-agent.read-timeout',
|
||||||
|
'descr' => 'Read timeout',
|
||||||
|
'type' => 'text',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<div class="panel-group" id="accordion">
|
<div class="panel-group" id="accordion">
|
||||||
<form class="form-horizontal" role="form" action="" method="post">
|
<form class="form-horizontal" role="form" action="" method="post">
|
||||||
';
|
';
|
||||||
|
|
||||||
echo generate_dynamic_config_panel('Oxidized integration',true,$config_groups,$oxidized_conf);
|
echo generate_dynamic_config_panel('Oxidized integration',true,$config_groups,$oxidized_conf);
|
||||||
|
echo generate_dynamic_config_panel('Unix-agent integration',true,$config_groups,$unixagent_conf);
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
</form>
|
</form>
|
||||||
|
@@ -3,14 +3,22 @@
|
|||||||
if ($device['os_group'] == 'unix') {
|
if ($device['os_group'] == 'unix') {
|
||||||
echo $config['project_name'].' UNIX Agent: ';
|
echo $config['project_name'].' UNIX Agent: ';
|
||||||
|
|
||||||
// FIXME - this should be in config and overridable in database
|
$agent_port = get_dev_attrib($device,'override_Unixagent_port');
|
||||||
$agent_port = '6556';
|
if (empty($agent_port)) {
|
||||||
|
$agent_port = $config['unix-agent']['port'];
|
||||||
|
}
|
||||||
|
if (empty($config['unix-agent']['connection-timeout'])) {
|
||||||
|
$config['unix-agent']['connection-timeout'] = $config['unix-agent-connection-time-out'];
|
||||||
|
}
|
||||||
|
if (empty($config['unix-agent']['read-timeout'])) {
|
||||||
|
$config['unix-agent']['read-timeout'] = $config['unix-agent-read-time-out'];
|
||||||
|
}
|
||||||
|
|
||||||
$agent_start = utime();
|
$agent_start = utime();
|
||||||
$agent = fsockopen($device['hostname'], $agent_port, $errno, $errstr, $config['unix-agent-connection-time-out']);
|
$agent = fsockopen($device['hostname'], $agent_port, $errno, $errstr, $config['unix-agent']['connection-timeout']);
|
||||||
|
|
||||||
// Set stream timeout (for timeouts during agent fetch
|
// Set stream timeout (for timeouts during agent fetch
|
||||||
stream_set_timeout($agent, $config['unix-agent-read-time-out']);
|
stream_set_timeout($agent, $config['unix-agent']['read-timeout']);
|
||||||
$agentinfo = stream_get_meta_data($agent);
|
$agentinfo = stream_get_meta_data($agent);
|
||||||
|
|
||||||
if (!$agent) {
|
if (!$agent) {
|
||||||
|
1
sql-schema/076.sql
Normal file
1
sql-schema/076.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
INSERT INTO config (config_name,config_value,config_default,config_descr,config_group,config_group_order,config_sub_group,config_sub_group_order,config_hidden,config_disabled) values ('unix-agent.port','6556','6556','Default port for the Unix-agent (check_mk)','external',0,'unix-agent',0,'0','0'),('unix-agent.connection-timeout','10','10','Unix-agent connection timeout','external',0,'unix-agent',0,'0','0'),('unix-agent.read-timeout','10','10','Unix-agent read timeout','external',0,'unix-agent',0,'0','0');
|
Reference in New Issue
Block a user