Conflicts:
	includes/services/check_dhcp.inc.php
This commit is contained in:
Rainer Schueler
2016-04-25 08:48:04 +02:00
70 changed files with 12698 additions and 162 deletions

View File

@@ -699,8 +699,8 @@ function get_smokeping_files($device) {
if ($handle = opendir($smokeping_dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..') {
if (eregi('.rrd', $file)) {
if (eregi('~', $file)) {
if (stripos($file, '.rrd') !== false) {
if (strpos($file, '~') !== false) {
list($target,$slave) = explode('~', str_replace('.rrd', '', $file));
$target = str_replace('_', '.', $target);
$smokeping_files['in'][$target][$slave] = $file;

View File

@@ -870,4 +870,4 @@ $config['ignore_unmapable_port'] = False;
// InfluxDB default configuration
$config['influxdb']['timeout'] = 0;
$config['influxdb']['verifySSL'] = false;
$config['influxdb']['verifySSL'] = false;

View File

@@ -2048,6 +2048,14 @@ $config['graph_types']['device']['cisco-iosxcode']['descr'] = 'Transcoder Uti
$config['graph_descr']['device_smokeping_in_all'] = 'This is an aggregate graph of the incoming smokeping tests to this host. The line corresponds to the average RTT. The shaded area around each line denotes the standard deviation.';
$config['graph_descr']['device_processor'] = 'This is an aggregate graph of all processors in the system.';
$config['graph_types']['device']['cisco_wwan_rssi']['section'] = 'wireless';
$config['graph_types']['device']['cisco_wwan_rssi']['order'] = '0';
$config['graph_types']['device']['cisco_wwan_rssi']['descr'] = 'Signal Rssi';
$config['graph_types']['device']['cisco_wwan_mnc']['section'] = 'wireless';
$config['graph_types']['device']['cisco_wwan_mnc']['order'] = '1';
$config['graph_types']['device']['cisco_wwan_mnc']['descr'] = 'MNC';
// Device Types
$i = 0;
$config['device_types'][$i]['text'] = 'Servers';

View File

@@ -0,0 +1,13 @@
<?php
// Code borrowed and modified from 'powerconnect-cpu.inc.php'
if ($device['os'] == 'dnos') {
echo 'DNOS-MEMORY-POOL: ';
$free = snmp_get($device, '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.1.1.4.1.0', '-OvQ');
if (is_numeric($free)) {
discover_mempool($valid_mempool, $device, 0, 'dnos-mem', 'Memory Utilization', '1', null, null);
}
}

View File

@@ -1,11 +1,45 @@
<?php
if ($device['os'] == 'ironware' || $device['os_type'] == 'ironware') {
echo 'Ironware Dynamic: ';
$percent = snmp_get($device, 'snAgGblDynMemUtil.0', '-OvQ', 'FOUNDRY-SN-AGENT-MIB');
$is_netiron = snmp_get($device, 'sysObjectID.0', '-OvQ', 'FOUNDRY-SN-AGENT-MIB');
if (strpos($is_netiron, 'NI') === false && strpos($is_netiron, 'MLX') === false && strpos($is_netiron, 'Cer') === false) {
echo 'Ironware Dynamic: ';
$percent = snmp_get($device, 'snAgGblDynMemUtil.0', '-OvQ', 'FOUNDRY-SN-AGENT-MIB');
if (is_numeric($percent)) {
discover_mempool($valid_mempool, $device, 0, 'ironware-dyn', 'Dynamic Memory', '1', null, null);
} //end_if
} //end_if
else {
echo 'NetIron: ';
d_echo('caching');
$ni_mempools_array = snmpwalk_cache_multi_oid($device, 'snAgentBrdMainBrdDescription', $ni_mempools_array, 'FOUNDRY-SN-AGENT-MIB', $config['install_dir'].'/mibs');
$ni_mempools_array = snmpwalk_cache_multi_oid($device, 'snAgentBrdMemoryUtil100thPercent', $ni_mempools_array, 'FOUNDRY-SN-AGENT-MIB', $config['install_dir'].'/mibs');
$ni_mempools_array = snmpwalk_cache_multi_oid($device, 'snAgentBrdMemoryAvailable', $ni_mempools_array, 'FOUNDRY-SN-AGENT-MIB', $config['install_dir'].'/mibs');
$ni_mempools_array = snmpwalk_cache_multi_oid($device, 'snAgentBrdMemoryTotal', $ni_mempools_array, 'FOUNDRY-SN-AGENT-MIB', $config['install_dir'].'/mibs');
d_echo($ni_mempool_array);
if (is_array($ni_mempools_array)) {
foreach ($ni_mempools_array as $index => $entry) {
d_echo($index.' '.$entry['snAgentBrdMainBrdDescription'].' -> '.$entry['snAgentBrdMemoryUtil100thPercent']."\n");
$usage_oid = '.1.3.6.1.4.1.1991.1.1.2.2.1.1.28.'.$index;
$descr = $entry['snAgentBrdMainBrdDescription'];
$usage = ($entry['snAgentBrdMemoryUtil100thPercent'] / 100);
if (!strstr($descr, 'No') && !strstr($usage, 'No') && $descr != '') {
discover_mempool($valid_mempool, $device, $index, 'ironware-dyn', $descr, '1', null, null);
} //end_if
} //end_foreach
} //end_if
} //end_else
} //end_if
if (is_numeric($percent)) {
discover_mempool($valid_mempool, $device, 0, 'ironware-dyn', 'Dynamic Memory', '1', null, null);
}
}

View File

@@ -4,16 +4,16 @@ echo 'OS: ';
$os = getHostOS($device);
if ($os != $device['os']) {
log_event('Device OS changed '.$device['os']." => $os", $device, 'system');
$device['os'] = $os;
$sql = dbUpdate(array('os' => $os), 'devices', 'device_id=?', array($device['device_id']));
echo "Changed OS! : $os\n";
log_event('Device OS changed '.$device['os']." => $os", $device, 'system');
}
$icon = getImageName($device, false);
if ($icon != $device['icon']) {
log_event('Device Icon changed '.$device['icon']." => $icon", $device, 'system');
$device['icon'] = $icon;
$sql = dbUpdate(array('icon' => $icon), 'devices', 'device_id=?', array($device['device_id']));
echo "Changed Icon! : $icon\n";
log_event('Device Icon changed '.$device['icon']." => $icon", $device, 'system');
}

View File

@@ -13,4 +13,17 @@ if (!$os) {
if (strstr($sysObjectId, '.1.3.6.1.4.1.674.10895.3054')) {
$os = 'dnos';
}
if (strstr($sysObjectId, '.1.3.6.1.4.1.674.10895.3055')) {
//Dell N2024P
$os = 'dnos';
}
if (strstr($sysObjectId, '.1.3.6.1.4.1.674.10895.3056')) {
//Dell N2048P
$os = 'dnos';
}
if (strstr($sysObjectId, '.1.3.6.1.4.1.674.10895.3046')) {
//Dell N4064F
$os = 'dnos';
}
}

View File

@@ -1,7 +1,7 @@
<?php
if (!$os) {
if (preg_match('/^POWERALERT/', $sysDescr)) {
if (preg_match('/^POWERALERT/i', $sysDescr)) {
$os = 'poweralert';
}
}

View File

@@ -0,0 +1,11 @@
<?php
if ($device['os'] == 'dnos') {
echo 'DNOS CPU: ';
$descr = 'CPU';
preg_match('/(\d*\.\d*)/', snmp_get($device, '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.1.1.4.9.0', '-OvQ'), $matches);
$usage = $matches[0];
discover_processor($valid['processor'], $device, '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.1.1.4.9.0', '0', 'dnos-cpu', $descr, '1', $usage, null, null);
}

View File

@@ -1,8 +1,8 @@
<?php
echo(" EXTREME-BASE-MIB ");
if ($device['os'] == 'xos') {
echo(" EXTREME-BASE-MIB ");
// Power Usage
$descr = "Power Usage";
$oid = "1.3.6.1.4.1.1916.1.1.1.40.1.0"; // extremeSystemPowerUsage

View File

@@ -0,0 +1,59 @@
<?php
/*
* LibreNMS
*
* Copyright (c) 2016 Tony Murray <murrayton@gmail.com>
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
if ($device['os'] == 'netonix') {
$temp = snmpwalk_cache_multi_oid($device, '.1.3.6.1.4.1.46242.5.1.2', array());
$cur_oid = '.1.3.6.1.4.1.';
if (is_array($temp)) {
//Create State Index
$state_name = 'netonixPoeStatus';
$state_index_id = create_state_index($state_name);
$states_ids = array(
'Off' => 1,
'24V' => 2,
'48V' => 3
);
//Create State Translation
if ($state_index_id !== null) {
$states = array(
array($state_index_id,'Off',0,1,-1) ,
array($state_index_id,'24V',0,2,0) ,
array($state_index_id,'48V',0,3,1) ,
);
foreach($states as $value){
$insert = array(
'state_index_id' => $value[0],
'state_descr' => $value[1],
'state_draw_graph' => $value[2],
'state_value' => $value[3],
'state_generic_value' => $value[4]
);
dbInsert($insert, 'state_translations');
}
}
foreach ($temp as $index => $entry) {
$id = substr($index, strrpos($index, '.')+1);
$descr = 'Port ' . $id . ' PoE';
$current = $states_ids[$entry['enterprises']];
//Discover Sensors
discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $id, $state_name, $descr, '1', '1', null, null, null, null, $current);
//Create Sensor To State Index
create_sensor_to_state_index($device, $state_name, $id);
}
}
}

View File

@@ -0,0 +1,22 @@
<?php
if ($device['os'] == 'dnos'){
$temps = snmp_walk($device, '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.8.1.5', '-Osqn');
//This will return at least 4 OIDs (multiplied by the number of switches if stacked) and associated values for various temperatures
$counter = 0;
foreach (explode("\n", $temps) as $i => $t) {
$t = explode(' ',$t);
$oid = $t[0];
$val = $t[1];
if (substr($oid, -1) == '1') {
// This code will only pull CPU temp for each stack member, but there is no reason why the additional values couldn't be graphed
$counter = $counter + 1;
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $counter, 'dnos',
'Unit '.$counter.' CPU temperature', '1', '1', null, null, null, null, $val);
}
}
}

View File

@@ -1252,10 +1252,30 @@ function function_check($function) {
return function_exists($function);
}
function force_influx_data($type,$data) {
if ($type == 'f' || $type == 'float') {
return(sprintf("%.1f",$data));
function force_influx_data($data) {
/*
* It is not trivial to detect if something is a float or an integer, and
* therefore may cause breakages on inserts.
* Just setting every number to a float gets around this, but may introduce
* inefficiencies.
* I've left the detection statement in there for a possible change in future,
* but currently everything just gets set to a float.
*/
if (is_numeric($data)) {
// If it is an Integer
if (ctype_digit($data)) {
return floatval($data);
// Else it is a float
}
else {
return floatval($data);
}
}
else {
return $data;
}
}// end force_influx_data
/**

View File

@@ -58,7 +58,10 @@ function influx_update($device,$measurement,$tags=array(),$fields) {
$tmp_tags[$k] = $v;
}
foreach ($fields as $k => $v) {
$tmp_fields[$k] = force_influx_data('f',$v);
$tmp_fields[$k] = force_influx_data($v);
if( $tmp_fields[$k] === null) {
unset($tmp_fields[$k]);
}
}
d_echo("\nInfluxDB data:\n");
@@ -76,7 +79,12 @@ function influx_update($device,$measurement,$tags=array(),$fields) {
$tmp_fields // optional additional fields
)
);
$result = $influxdb->writePoints($points);
try {
$result = $influxdb->writePoints($points);
} catch (Exception $e) {
d_echo("Caught exception: ", $e->getMessage(), "\n");
d_echo($e->getTrace());
}
}
else {
print $console_color->convert('[%gInfluxDB Disabled%n] ', false);

View File

@@ -44,6 +44,13 @@ function poll_sensor($device, $class, $unit) {
}
else if ($class == 'state') {
$sensor_value = trim(str_replace('"', '', snmp_walk($device, $sensor['sensor_oid'], '-Oevq', 'SNMPv2-MIB')));
if (!is_numeric($sensor_value)) {
$state_value = dbFetchCell('SELECT `state_value` FROM `state_translations` LEFT JOIN `sensors_to_state_indexes` ON `state_translations`.`state_index_id` = `sensors_to_state_indexes`.`state_index_id` WHERE `sensors_to_state_indexes`.`sensor_id` = ? AND `state_translations`.`state_descr` LIKE ?', array($sensor['sensor_id'], $sensor_value));
d_echo('State value of ' . $sensor_value . ' is ' . $state_value . "\n");
if (is_numeric($state_value)) {
$sensor_value = $state_value;
}
}
}
else if ($class == 'signal') {
$currentOS = $device['os'];

View File

@@ -0,0 +1,14 @@
<?php
// Code below was borrowed from 'powerconnect-cpu.inc.php'
//--------------------------------------------------------------------//
// Dell-Vendor-MIB::dellLanExtension.6132.1.1.1.1.4.1.0 = INTEGER: 23127
// Dell-Vendor-MIB::dellLanExtension.6132.1.1.1.1.4.2.0 = INTEGER: 262144
// Simple hard-coded poller for Dell Powerconnect (tested on 6248P)
// Yes, it really can be this simple.
// Pity there's no matching MIB to be found.
$mempool['total'] = snmp_get($device, '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.1.1.4.2.0', '-OvQ');
$mempool['free'] = snmp_get($device, '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.1.1.4.1.0', '-OvQ');
$mempool['used'] = ($mempool['total'] - $mempool['free']);

View File

@@ -1,7 +1,36 @@
<?php
// Simple hard-coded poller for Brocade Ironware Dynamic Memory (old style)
// Yes, it really can be this simple.
$mempool['total'] = snmp_get($device, 'snAgGblDynMemTotal.0', '-OvQ', 'FOUNDRY-SN-AGENT-MIB');
$mempool['free'] = snmp_get($device, 'snAgGblDynMemFree.0', '-OvQ', 'FOUNDRY-SN-AGENT-MIB');
$mempool['used'] = ($mempool['total'] - $mempool['free']);
$oid = $mempool['mempool_index'];
d_echo('Ironware Mempool'."\n");
$is_netiron = snmp_get($device, 'sysObjectID.0', '-OvQ', 'FOUNDRY-SN-AGENT-MIB');
if (strpos($is_netiron, 'NI') === false && strpos($is_netiron, 'MLX') === false && strpos($is_netiron, 'Cer') === false) {
$mempool['total'] = snmp_get($device, 'snAgGblDynMemTotal.0', '-OvQ', 'FOUNDRY-SN-AGENT-MIB');
$mempool['free'] = snmp_get($device, 'snAgGblDynMemFree.0', '-OvQ', 'FOUNDRY-SN-AGENT-MIB');
$mempool['used'] = ($mempool['total'] - $mempool['free']);
} //end_if
else {
d_echo('caching');
$mempool_cache['ironware-dyn'] = array();
$mempool_cache['ironware-dyn'] = snmpwalk_cache_multi_oid($device, 'snAgentBrdMemoryUtil100thPercent', $mempool_cache['ironware-dyn'], 'FOUNDRY-SN-AGENT-MIB', $config['install_dir'].'/mibs');
$mempool_cache['ironware-dyn'] = snmpwalk_cache_multi_oid($device, 'snAgentBrdMemoryAvailable', $mempool_cache['ironware-dyn'], 'FOUNDRY-SN-AGENT-MIB', $config['install_dir'].'/mibs');
$mempool_cache['ironware-dyn'] = snmpwalk_cache_multi_oid($device, 'snAgentBrdMemoryTotal', $mempool_cache['ironware-dyn'], 'FOUNDRY-SN-AGENT-MIB', $config['install_dir'].'/mibs');
d_echo($mempool_cache);
$entry = $mempool_cache['ironware-dyn'][$mempool[mempool_index]];
$perc = $entry['snAgentBrdMemoryUtil100thPercent'];
$memory_available = $entry['snAgentBrdMemoryTotal'];
$mempool['total'] = $memory_available;
$mempool['used'] = $memory_available / 10000 * $perc;
$mempool['free'] = $memory_available - $mempool['used'];
} //end_else

View File

@@ -48,16 +48,7 @@ if ($device['os'] != 'Snom') {
$data_array = snmpwalk_cache_oid($device, 'snmp', array(), 'SNMPv2-MIB');
$fields = array();
foreach ($oids as $oid) {
if (is_numeric($data_array[0][$oid])) {
$value = $data_array[0][$oid];
}
else {
$value = 'U';
}
$fields[$oid] = $value;
}
$fields = $data_array[0];
if (isset($data_array[0]['snmpInPkts']) && isset($data_array[0]['snmpOutPkts'])) {
if (!file_exists($rrd_file)) {

View File

@@ -41,3 +41,9 @@ if (empty($hardware)) {
// if(isset($cisco_hardware_oids[$poll_device['sysObjectID']])) { $hardware = $cisco_hardware_oids[$poll_device['sysObjectID']]; }
$serial = get_main_serial($device);
if (strstr($hardware, 'cisco819')) {
include 'includes/polling/wireless/cisco-wwan.inc.php';
}

View File

@@ -0,0 +1,8 @@
<?php
echo 'DNOS CPU Usage';
if ($device['os'] == 'dnos') {
preg_match('/(\d*\.\d*)/', snmp_get($device, '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.1.1.4.9.0', '-OvQ'), $matches);
$proc = $matches[0];
}

View File

@@ -97,7 +97,7 @@ if ($device['os_group'] == 'unix') {
dbDelete('processes', 'device_id = ?', array($device['device_id']));
$data=array();
foreach (explode("\n", $agent_data['ps']) as $process) {
$process = preg_replace('/\((.*),([0-9]*),([0-9]*),([0-9\:]*),([0-9]*)\)\ (.*)/', '\\1|\\2|\\3|\\4|\\5|\\6', $process);
$process = preg_replace('/\((.*),([0-9]*),([0-9]*),([0-9\:\.]*),([0-9]*)\)\ (.*)/', '\\1|\\2|\\3|\\4|\\5|\\6', $process);
list($user, $vsz, $rss, $cputime, $pid, $command) = explode('|', $process, 6);
if (!empty($command)) {
$data[]=array('device_id' => $device['device_id'], 'pid' => $pid, 'user' => $user, 'vsz' => $vsz, 'rss' => $rss, 'cputime' => $cputime, 'command' => $command);

View File

@@ -0,0 +1,41 @@
<?php
/*
* LibreNMS
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cisco-wwan-rssi.rrd";
$rssi = snmp_get($device, "CISCO-WAN-3G-MIB::c3gCurrentGsmRssi.13", "-Ovqn", "CISCO-WAN-3G-MIB");
if (is_numeric($rssi)) {
if (!is_file($rrd_filename)) {
rrdtool_create($rrd_filename, " --step 300 DS:rssi:GAUGE:600:-150:5000".$config['rrd_rra']);
}
$fields = array(
'rssi' => $rssi,
);
rrdtool_update($rrd_filename, $fields);
$graphs['cisco_wwan_rssi'] = TRUE;
unset($rrd_filename,$rssi);
}
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cisco-wwan-mnc.rrd";
$mnc = snmp_get($device, "CISCO-WAN-3G-MIB::c3gGsmMnc.13", "-Ovqn", "CISCO-WAN-3G-MIB");
if (is_numeric($mnc)) {
if (!is_file($rrd_filename)) {
rrdtool_create($rrd_filename, " --step 300 DS:mnc:GAUGE:600:0:U".$config['rrd_rra']);
}
$fields = array(
'mnc' => $mnc,
);
rrdtool_update($rrd_filename, $fields);
$graphs['cisco_wwan_mnc'] = TRUE;
unset($rrd_filename,$mnc);
}

View File

@@ -1,6 +1,2 @@
<?php
// provide some sane default
if ($service['service_ip']) { $dhcp = $service['service_ip']; } else { $dhcp = $service['hostname']; }
$check_cmd = $config['nagios_plugins'] . "/check_dhcp -s ".$dhcp;
$check_cmd = $config['nagios_plugins'] . "/check_dhcp ".$service['service_param'];

View File

@@ -1,2 +1,2 @@
<?php
$check_cmd = shell_exec($config['nagios_plugins'] . "/check_smtp -H ".$service['hostname']);
$check_cmd = $config['nagios_plugins'] . "/check_smtp -H ".$service['hostname'];