mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Merge branch 'master' of https://github.com/librenms/librenms into rrdtune
This commit is contained in:
@ -69,4 +69,5 @@ Contributors to LibreNMS:
|
||||
- Rob Gormley <robert@gormley.me> (rgormley)
|
||||
- Richard Kojedzinszky <krichy@nmdps.net> (rkojedzinszky)
|
||||
- Tony Murray <murraytony@gmail.com> (murrant)
|
||||
- Peter Lamperud <peter.lamperud@gmail.com> (vizay)
|
||||
[1]: http://observium.org/ "Observium web site"
|
||||
|
@ -35,6 +35,7 @@ function authenticate($username, $password) {
|
||||
if (isset($config['auth_ad_groups'][$group_cn]['level'])) {
|
||||
// user is in one of the defined groups
|
||||
$user_authenticated = 1;
|
||||
adduser($username);
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,6 +44,7 @@ function authenticate($username, $password) {
|
||||
}
|
||||
else {
|
||||
// group membership is not required and user is valid
|
||||
adduser($username);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -81,11 +83,20 @@ function auth_usermanagement() {
|
||||
}
|
||||
|
||||
|
||||
function adduser() {
|
||||
// not supported so return 0
|
||||
return 0;
|
||||
function adduser($username) {
|
||||
// Check to see if user is already added in the database
|
||||
if (!user_exists_in_db($username)) {
|
||||
return dbInsert(array('username' => $username, 'user_id' => get_userid($username), 'level' => "0", 'can_modify_passwd' => 0, 'twofactor' => 0), 'users');
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function user_exists_in_db($username) {
|
||||
$return = dbFetchCell('SELECT COUNT(*) FROM users WHERE username = ?', array($username), true);
|
||||
return $return;
|
||||
}
|
||||
|
||||
function user_exists($username) {
|
||||
global $config, $ds;
|
||||
|
@ -1178,6 +1178,9 @@ function dynamic_override_config($type, $name, $device) {
|
||||
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.'>';
|
||||
}
|
||||
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()
|
||||
|
||||
function generate_dynamic_config_panel($title,$end_panel=true,$config_groups,$items=array(),$transport='') {
|
||||
|
@ -218,7 +218,7 @@ echo $edges;
|
||||
var network = new vis.Network(container, data, options);
|
||||
network.on('click', function (properties) {
|
||||
if (properties.nodes > 0) {
|
||||
window.location.href = "/device/device="+properties.nodes+"/tab=map/"
|
||||
window.location.href = "device/device="+properties.nodes+"/tab=map/"
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
@ -29,7 +29,7 @@ if (isset($searchPhrase) && !empty($searchPhrase)) {
|
||||
$sql .= " AND (`D`.`hostname` LIKE '%$searchPhrase%' OR `E`.`datetime` LIKE '%$searchPhrase%' OR `E`.`message` LIKE '%$searchPhrase%' OR `E`.`type` LIKE '%$searchPhrase%')";
|
||||
}
|
||||
|
||||
$count_sql = "SELECT COUNT(datetime) $sql";
|
||||
$count_sql = "SELECT COUNT(event_id) $sql";
|
||||
$total = dbFetchCell($count_sql, $param);
|
||||
if (empty($total)) {
|
||||
$total = 0;
|
||||
|
@ -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
|
||||
$("[name='global-config-check']").bootstrapSwitch('offColor','danger');
|
||||
$('input[name="global-config-check"]').on('switchChange.bootstrapSwitch', function(event, state) {
|
||||
|
@ -36,7 +36,7 @@ if ($_POST['device']) {
|
||||
|
||||
foreach ($enabled as $app) {
|
||||
if (!in_array($app, $app_in_db)) {
|
||||
$updated += dbInsert(array('device_id' => $device['device_id'], 'app_type' => $app), 'applications');
|
||||
$updated += dbInsert(array('device_id' => $device['device_id'], 'app_type' => $app, 'app_status' => '', 'app_instance' => ''), 'applications');
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,4 +99,4 @@ echo '<div class="row">
|
||||
';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
@ -14,6 +14,12 @@ echo '
|
||||
'.dynamic_override_config('checkbox','override_Oxidized_disable', $device).'
|
||||
</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>
|
||||
';
|
||||
|
||||
|
@ -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 '
|
||||
<div class="panel-group" id="accordion">
|
||||
<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('Unix-agent integration',true,$config_groups,$unixagent_conf);
|
||||
|
||||
echo '
|
||||
</form>
|
||||
|
@ -3,14 +3,22 @@
|
||||
if ($device['os_group'] == 'unix') {
|
||||
echo $config['project_name'].' UNIX Agent: ';
|
||||
|
||||
// FIXME - this should be in config and overridable in database
|
||||
$agent_port = '6556';
|
||||
$agent_port = get_dev_attrib($device,'override_Unixagent_port');
|
||||
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 = 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
|
||||
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);
|
||||
|
||||
if (!$agent) {
|
||||
@ -108,7 +116,7 @@ if ($device['os_group'] == 'unix') {
|
||||
if (in_array($key, array('apache', 'mysql', 'nginx', 'proxmox', 'ceph'))) {
|
||||
if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ?', array($device['device_id'], $key)) == '0') {
|
||||
echo "Found new application '$key'\n";
|
||||
dbInsert(array('device_id' => $device['device_id'], 'app_type' => $key), 'applications');
|
||||
dbInsert(array('device_id' => $device['device_id'], 'app_type' => $key, 'app_status' => '', 'app_instance' => ''), 'applications');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -120,7 +128,7 @@ if ($device['os_group'] == 'unix') {
|
||||
foreach ($agent_data['app']['memcached'] as $memcached_host => $memcached_data) {
|
||||
if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ? AND `app_instance` = ?', array($device['device_id'], 'memcached', $memcached_host)) == '0') {
|
||||
echo "Found new application 'Memcached' $memcached_host\n";
|
||||
dbInsert(array('device_id' => $device['device_id'], 'app_type' => 'memcached', 'app_instance' => $memcached_host), 'applications');
|
||||
dbInsert(array('device_id' => $device['device_id'], 'app_type' => 'memcached', 'app_status' => '', 'app_instance' => $memcached_host), 'applications');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -134,7 +142,7 @@ if ($device['os_group'] == 'unix') {
|
||||
$agent_data['app']['drbd'][$drbd_dev] = $drbd_data;
|
||||
if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ? AND `app_instance` = ?', array($device['device_id'], 'drbd', $drbd_dev)) == '0') {
|
||||
echo "Found new application 'DRBd' $drbd_dev\n";
|
||||
dbInsert(array('device_id' => $device['device_id'], 'app_type' => 'drbd', 'app_instance' => $drbd_dev), 'applications');
|
||||
dbInsert(array('device_id' => $device['device_id'], 'app_type' => 'drbd', 'app_status' => '', 'app_instance' => $drbd_dev), 'applications');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
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