Merge branch 'master' into issue-1650

This commit is contained in:
Aaron Daniels 2016-01-15 17:52:40 +10:00
commit ad751983dc
38 changed files with 811 additions and 222 deletions

32
.gitignore vendored
View File

@ -1,21 +1,21 @@
# Ignore all dotfiles #
#######################
.*
!/.gitignore
!/.editorconfig
!/.scrutinizer.yml
# Others #
##########
*.swp
Thumbs.db
config.php
.index
junk
logs
patches
rrd
html/plugins/*
!html/plugins/Test/
junk
logs
nbproject
.alerts.lock
.ircbot.alert
.metadata_never_index
*.swp
patches
rrd
# OS generated files #
######################
.DS_Store
.DS_Store?
.Spotlight-V100
.Trashes
Thumbs.db

View File

@ -78,6 +78,7 @@ LibreNMS contributors:
- D. Britz <github@wrind.de> (flatterlight)
- Tobias Herrmann <tobias@fiveninedigital.ch> (Mightea)
- Nicolas Guillaumin <nicolas+github@guillaumin.me> (nguillaumin)
- Jurrian van Iersel <jurrian@vaniersel.net> (jviersel)
[1]: http://observium.org/ "Observium web site"
Observium was written by:

View File

@ -81,6 +81,12 @@ Alert when:
- Any port changes: `%ports.ifOperStatus != 'up'`
- Root-directory gets too full: `%storage.storage_descr = '/' && %storage.storage_perc >= '75'`
- Any storage gets fuller than the 'warning': `%storage.storage_perc >= %storage_perc_warn`
- If device is a server and the used storage is above the warning level, but ignore /boot partitions: `%storage.storage_perc > %storage.storage_perc_warn && %devices.type = "server" && %storage.storage_descr !~ "/boot"`
- VMware LAG is not using "Source ip address hash" load balancing: `%devices.os = "vmware" && %ports.ifType = "ieee8023adLag" && %ports.ifDescr !~ "Link Aggregation @, load balancing algorithm: Source ip address hash"`
- Syslog, authentication failure during the last 5m: `%syslog.timestamp >= %macros.past_5m && %syslog.msg ~ "@authentication failure@"`
- High memory usage: `%macros.device_up = "1" && %mempools.mempool_perc >= "90" && %mempools.mempool_descr = "Virtual@"`
- High CPU usage(per core usage, not overall): `%macros.device_up = "1" && %processors.processor_usage >= "90"`
- High port usage, where description is not client & ifType is not softwareLoopback: `%macros.port_usage_perc >= "80" && %port.port_descr_type != "client" && %ports.ifType != "softwareLoopback"`
# <a name="templates">Templates</a>

View File

@ -69,8 +69,9 @@ The components involved in MIB-based polling are:
- During discovery, relevant MIBs are parsed using `snmptranslate`, and the
data returned is used to populate a database which guides the poller in
what to store. At the moment, only OIDs with Unsigned32 and Counter64
data types are parsed.
what to store. At the moment, only OIDs of INTEGER, Integer32, Gauge32,
Unsigned32, Counter32, and Counter64 data types are parsed, and negative
values are untested.
- Devices may be excluded from MIB polling by changing the setting in the
device edit screen:

View File

@ -31,14 +31,6 @@ You can set a default group that devices will fall back to with:
$config['oxidized']['default_group'] = 'default';
```
To return a group to Oxidized you can do this by matching a regex for either hostname or location. The order is hostname is matched first, if nothing is found then location is attempted.
The first match found will be used. To match on the device hostnames that contain 'lon-sw' or if the location contains 'London' then you would place the following within config.php:
```php
$config['oxidized']['group']['hostname'][] = array('regex' => '/^lon-sw/', 'group' => 'london-switches');
$config['oxidized']['group']['location'][] = array('regex' => '/london/', 'group' => 'london-switches');
```
### Feeding Oxidized
Oxidized has support for feeding devices into it via an API call, support for Oxidized has been added to the LibreNMS API. A sample config for Oxidized is provided below.
@ -56,10 +48,40 @@ You will need to configure default credentials for your devices, LibreNMS doesn'
map:
name: hostname
model: os
group: group
headers:
X-Auth-Token: '01582bf94c03104ecb7953dsadsadwed'
```
LibreNMS is able to reload the Oxidized list of nodes, each time a device is added to LibreNMS.
To do so, edit the option in Global Settings>External Settings>Oxidized Integration or add the following to your config.php.
```php
$config['oxidized']['reload_nodes'] = TRUE;
```
### Using Groups
To return a group to Oxidized you can do this by matching a regex for either hostname or location. The order is hostname is matched first, if nothing is found then location is attempted.
The first match found will be used. To match on the device hostnames that contain 'lon-sw' or if the location contains 'London' then you would place the following within config.php:
```php
$config['oxidized']['group']['hostname'][] = array('regex' => '/^lon-sw/', 'group' => 'london-switches');
$config['oxidized']['group']['location'][] = array('regex' => '/london/', 'group' => 'london-switches');
```
If you need to, you can specify credentials for groups by using the following in your Oxidized config:
```bash
groups:
<groupname>:
username: <user>
password: <password>
```
### Miscellaneous
If you have devices which you do not wish to appear in Oxidized then you can edit those devices in Device -> Edit -> Misc and enable "Exclude from Oxidized?"
It's also possible to exclude certain device types and OS' from being output via the API. This is currently only possible via config.php:

View File

@ -488,6 +488,7 @@ This array can be used to filter out syslog messages that you don't want to be s
```php
$config['enable_libvirt'] = 1;
$config['libvirt_protocols'] = array("qemu+ssh","xen+ssh");
$config['libvirt_username'] = 'root';
```
Enable this to switch on support for libvirt along with `libvirt_protocols`
to indicate how you connect to libvirt. You also need to:

View File

@ -39,7 +39,6 @@ disable it for one device then you can do this within the WebUI -> Settings -> M
```php
$config['poller_modules']['unix-agent'] = 0;
$config['poller_modules']['system'] = 1;
$config['poller_modules']['os'] = 1;
$config['poller_modules']['ipmi'] = 1;
$config['poller_modules']['sensors'] = 1;

View File

@ -76,3 +76,4 @@ foreach ($periods as $period) {
echo "</div>";
}
}
unset($graph_array);

View File

@ -25,6 +25,10 @@ $oxidized_conf = array(
'descr' => 'Set the default group returned',
'type' => 'text',
),
array('name' => 'oxidized.reload_nodes',
'descr' => 'Reload Oxidized nodes list, each time a device is added',
'type' => 'checkbox',
),
);
$unixagent_conf = array(

View File

@ -473,6 +473,7 @@ $config['rancid_ignorecomments'] = 0;
$config['smokeping']['pings'] = 20;
// $config['oxidized']['enabled'] = FALSE;//Set to TRUE
// $config['oxidized']['url'] = 'http://127.0.0.1:8888';// Set the Oxidized rest URL
// $config['oxidized']['reload_nodes'] = FALSE;//Set to TRUE, check documentation
// NFSen RRD dir.
$config['nfsen_enable'] = 0;
// $config['nfsen_split_char'] = "_";
@ -675,7 +676,6 @@ $config['warn']['ifdown'] = true;
// List of poller modules. Need to be in the array to be
// considered for execution.
$config['poller_modules']['unix-agent'] = 0;
$config['poller_modules']['system'] = 1;
$config['poller_modules']['os'] = 1;
$config['poller_modules']['ipmi'] = 1;
$config['poller_modules']['sensors'] = 1;

View File

@ -1,6 +1,5 @@
<?php
// Observium Includes
require_once $config['install_dir'].'/includes/dbFacile.php';
require_once $config['install_dir'].'/includes/mergecnf.inc.php';
@ -164,10 +163,16 @@ $config['os'][$os]['over'][2]['graph'] = 'device_storage';
$config['os'][$os]['over'][2]['text'] = 'Storage Usage';
$os = 'qnap';
$config['os'][$os]['type'] = 'storage';
$config['os'][$os]['group'] = 'unix';
$config['os'][$os]['text'] = 'QNAP TurboNAS';
$config['os'][$os]['ifXmcbc'] = 1;
$config['os'][$os]['type'] = 'storage';
$config['os'][$os]['group'] = 'unix';
$config['os'][$os]['text'] = 'QNAP TurboNAS';
$config['os'][$os]['ifXmcbc'] = 1;
$config['os'][$os]['over'][0]['graph'] = 'device_processor';
$config['os'][$os]['over'][0]['text'] = 'Processor Usage';
$config['os'][$os]['over'][1]['graph'] = 'device_mempool';
$config['os'][$os]['over'][1]['text'] = 'Memory Usage';
$config['os'][$os]['over'][2]['graph'] = 'device_storage';
$config['os'][$os]['over'][2]['text'] = 'Storage Usage';
$os = 'netapp';
$config['os'][$os]['type'] = 'storage';
@ -772,11 +777,11 @@ $config['os'][$os]['over'][0]['graph'] = 'device_bits';
$config['os'][$os]['over'][0]['text'] = 'Device Traffic';
$config['os'][$os]['over'][1]['graph'] = 'device_processor';
$config['os'][$os]['over'][1]['text'] = 'CPU Usage';
// $config['os'][$os]['over'][2]['graph'] = "device_mempool";
// $config['os'][$os]['over'][2]['text'] = "Memory Usage";
$os = 'powervault';
$config['os'][$os]['text'] = 'Dell PowerVault';
$config['os'][$os]['icon'] = 'dell';
$config['os'][$os]['text'] = 'Dell PowerVault';
$config['os'][$os]['icon'] = 'dell';
$config['os'][$os]['type'] = 'storage';
$os = 'equallogic';
$config['os'][$os]['text'] = 'Dell EqualLogic';

View File

@ -9,18 +9,23 @@ if ($config['enable_libvirt'] == '1' && $device['os'] == 'linux') {
$ssh_ok = 0;
$userHostname = $device['hostname'];
if (isset($config['libvirt_username'])) {
$userHostname = $config['libvirt_username'].'@'.$userHostname;
}
foreach ($config['libvirt_protocols'] as $method) {
if (strstr($method, 'qemu')) {
$uri = $method.'://'.$device['hostname'].'/system';
$uri = $method.'://'.$userHostname.'/system';
}
else {
$uri = $method.'://'.$device['hostname'];
$uri = $method.'://'.$userHostname;
}
if (strstr($method, 'ssh') && !$ssh_ok) {
// Check if we are using SSH if we can log in without password - without blocking the discovery
// Also automatically add the host key so discovery doesn't block on the yes/no question, and run echo so we don't get stuck in a remote shell ;-)
exec('ssh -o "StrictHostKeyChecking no" -o "PreferredAuthentications publickey" -o "IdentitiesOnly yes" '.$device['hostname'].' echo -e', $out, $ret);
exec('ssh -o "StrictHostKeyChecking no" -o "PreferredAuthentications publickey" -o "IdentitiesOnly yes" '.$userHostname.' echo -e', $out, $ret);
if ($ret != 255) {
$ssh_ok = 1;
}

View File

@ -21,6 +21,11 @@ if (empty($os)) {
if (strstr($sysDescr, 'IOS XR')) {
$os = 'iosxr';
}
$extra_mibs = array(
"ciscoAAASessionMIB" => "CISCO-AAA-SESSION-MIB",
);
register_mibs($device, $extra_mibs, "includes/discovery/os/ios.inc.php");
}
// Fallback case

View File

@ -18,4 +18,10 @@ if (!$os) {
if ($sysDescr == 'RB260GS') {
$os = 'routeros';
}
// poll Cisco AAA MIB
$extra_mibs = array(
"ciscoAAASessionMIB" => "CISCO-AAA-SESSION-MIB",
);
register_mibs($device, $extra_mibs, "includes/discovery/os/routeros.inc.php");
}

View File

@ -1,31 +1,22 @@
<?php
/*
* LibreNMS
*
* Copyright (c) 2016 Søren Friis Rosiak <sorenrosiak@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.
*/
// FIXME - dbFacile and fewer SNMP_GETs
if (dbFetchCell("SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ? AND `sensor_class` = 'temperature' AND (`sensor_type` = 'cisco-entity-sensor' OR `sensor_type` = 'entity-sensor')", array($device['device_id'])) == '0' && ($device['os_group'] == 'cisco')) {
echo 'CISCO-ENVMON-MIB: ';
$oids = snmp_walk($device, '.1.3.6.1.4.1.9.9.13.1.3.1.2', '-Osqn', 'CISCO-ENVMON-MIB');
$oids = str_replace('.1.3.6.1.4.1.9.9.13.1.3.1.2.', '', $oids);
$oids = trim($oids);
foreach (explode("\n", $oids) as $data) {
$data = trim($data);
if ($data) {
list($index) = explode(' ', $data);
$oid = ".1.3.6.1.4.1.9.9.13.1.3.1.3.$index";
$descr_oid = ".1.3.6.1.4.1.9.9.13.1.3.1.2.$index";
$descr = snmp_get($device, $descr_oid, '-Oqv', 'CISCO-ENVMON-MIB');
$temperature = snmp_get($device, $oid, '-Oqv', 'CISCO-ENVMON-MIB');
if (!strstr($descr, 'No') && !strstr($temperature, 'No') && $temperature != '' && $descr != '') {
$descr = str_replace('"', '', $descr);
$descr = str_replace('temperature', '', $descr);
$descr = str_replace('temperature', '', $descr);
$descr = trim($descr);
if (!is_numeric($temperature)) {
$temperature = stristr($temperature, ' degrees', true);
}
discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, 'cisco', $descr, '1', '1', null, null, null, null, $temperature);
}
if ($device['os_group'] == 'cisco') {
$temp = snmpwalk_cache_multi_oid($device, 'ciscoEnvMonTemperatureStatusTable', array(), 'CISCO-ENVMON-MIB');
if (is_array($temp)) {
$cur_oid = '.1.3.6.1.4.1.9.9.13.1.3.1.3.';
foreach ($temp as $index => $entry) {
$descr = ucwords($temp[$index]['ciscoEnvMonTemperatureStatusDescr']);
discover_sensor($valid['sensor'], 'temperature', $device, $cur_oid.$index, $index, 'cisco', $descr, '1', '1', null, null, $temp[$index]['ciscoEnvMonTemperatureThreshold'], null, $temp[$index]['ciscoEnvMonTemperatureStatusValue'], 'snmp', $index);
}
}//end foreach
}//end if
}
}

View File

@ -580,6 +580,7 @@ function createHost($host, $community = NULL, $snmpver, $port = 161, $transport
if (host_exists($host) === false) {
$device_id = dbInsert($device, 'devices');
if ($device_id) {
oxidized_reload_nodes();
return($device_id);
}
else {
@ -1302,3 +1303,20 @@ function warn_innodb_buffer($innodb_buffer) {
$output .= 'Config proposal: "innodb_buffer_pool_size = '.pow(2,ceil(log(($innodb_buffer['used'] / 1024 / 1024),2))).'M"'.PHP_EOL;
return $output;
}
function oxidized_reload_nodes() {
global $config;
if ($config['oxidized']['enabled'] === TRUE && $config['oxidized']['reload_nodes'] === TRUE && isset($config['oxidized']['url'])) {
$oxidized_reload_url = $config['oxidized']['url'] . '/reload';
$ch = curl_init($oxidized_reload_url);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_exec($ch);
curl_close($ch);
}
}

View File

@ -0,0 +1,131 @@
<?php
/*
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2011, Observium Developers - http://www.observium.org
*
* 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.
*
* See COPYING for more details.
*/
unset($poll_device);
$snmpdata = snmp_get_multi($device, 'sysUpTime.0 sysLocation.0 sysContact.0 sysName.0 sysDescr.0 sysObjectID.0', '-OQnUs', 'SNMPv2-MIB:HOST-RESOURCES-MIB:SNMP-FRAMEWORK-MIB');
$poll_device = $snmpdata[0];
$poll_device['sysName'] = strtolower($poll_device['sysName']);
if (!empty($agent_data['uptime'])) {
list($uptime) = explode(' ', $agent_data['uptime']);
$uptime = round($uptime);
echo "Using UNIX Agent Uptime ($uptime)\n";
}
if (empty($uptime)) {
$snmp_data = snmp_get_multi($device, 'snmpEngineTime.0 hrSystemUptime.0', '-OQnUs', 'HOST-RESOURCES-MIB:SNMP-FRAMEWORK-MIB');
$uptime_data = $snmp_data[0];
$snmp_uptime = (integer) $uptime_data['snmpEngineTime'];
$hrSystemUptime = $uptime_data['hrSystemUptime'];
if (!empty($hrSystemUptime) && !strpos($hrSystemUptime, 'No') && ($device['os'] != 'windows')) {
echo 'Using hrSystemUptime ('.$hrSystemUptime.")\n";
$agent_uptime = $uptime;
// Move uptime into agent_uptime
// HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (63050465) 7 days, 7:08:24.65
$hrSystemUptime = str_replace('(', '', $hrSystemUptime);
$hrSystemUptime = str_replace(')', '', $hrSystemUptime);
list($days,$hours, $mins, $secs) = explode(':', $hrSystemUptime);
list($secs, $microsecs) = explode('.', $secs);
$hours = ($hours + ($days * 24));
$mins = ($mins + ($hours * 60));
$secs = ($secs + ($mins * 60));
$uptime = $secs;
}
else {
echo 'Using SNMP Agent Uptime ('.$poll_device['sysUpTime'].")\n";
// SNMPv2-MIB::sysUpTime.0 = Timeticks: (2542831) 7:03:48.31
$poll_device['sysUpTime'] = str_replace('(', '', $poll_device['sysUpTime']);
$poll_device['sysUpTime'] = str_replace(')', '', $poll_device['sysUpTime']);
list($days, $hours, $mins, $secs) = explode(':', $poll_device['sysUpTime']);
list($secs, $microsecs) = explode('.', $secs);
$hours = ($hours + ($days * 24));
$mins = ($mins + ($hours * 60));
$secs = ($secs + ($mins * 60));
$uptime = $secs;
}//end if
}//end if
if ($snmp_uptime > $uptime && is_numeric($snmp_uptime)) {
$uptime = $snmp_uptime;
d_echo('hrSystemUptime or sysUpTime looks like to have rolled, using snmpEngineTime instead');
}
if (is_numeric($uptime)) {
if ($uptime < $device['uptime']) {
log_event('Device rebooted after '.formatUptime($device['uptime']), $device, 'reboot', $device['uptime']);
}
$uptime_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/uptime.rrd';
if (!is_file($uptime_rrd)) {
rrdtool_create($uptime_rrd, 'DS:uptime:GAUGE:600:0:U '.$config['rrd_rra']);
}
$fields = array(
'uptime' => $uptime,
);
rrdtool_update($uptime_rrd, $fields);
$measurement = 'uptime';
$tags = array();
influx_update($device,$measurement,$tags,$fields);
$graphs['uptime'] = true;
echo 'Uptime: '.formatUptime($uptime)."\n";
$update_array['uptime'] = $uptime;
}//end if
$poll_device['sysLocation'] = str_replace('"', '', $poll_device['sysLocation']);
// Remove leading & trailing backslashes added by VyOS/Vyatta/EdgeOS
$poll_device['sysLocation'] = trim($poll_device['sysLocation'], '\\');
// Rewrite sysLocation if there is a mapping array (database too?)
if (!empty($poll_device['sysLocation']) && is_array($config['location_map'])) {
$poll_device['sysLocation'] = rewrite_location($poll_device['sysLocation']);
}
$poll_device['sysContact'] = str_replace('"', '', $poll_device['sysContact']);
// Remove leading & trailing backslashes added by VyOS/Vyatta/EdgeOS
$poll_device['sysContact'] = trim($poll_device['sysContact'], '\\');
foreach (array('sysLocation', 'sysContact') as $elem) {
if ($poll_device[$elem] == 'not set') {
$poll_device[$elem] = '';
}
}
// Save results of various polled values to the database
foreach (array('sysContact', 'sysObjectID', 'sysName', 'sysDescr') as $elem) {
if ($poll_device[$elem] && $poll_device[$elem] != $device[$elem]) {
$update_array[$elem] = $poll_device[$elem];
log_event("$elem -> ".$poll_device[$elem], $device, 'system');
}
}
if ($poll_device['sysLocation'] && $device['location'] != $poll_device['sysLocation'] && $device['override_sysLocation'] == 0) {
$update_array['location'] = $poll_device['sysLocation'];
log_event('Location -> '.$poll_device['sysLocation'], $device, 'system');
}
if ($config['geoloc']['latlng'] === true) {
location_to_latlng($device);
}

View File

@ -204,6 +204,9 @@ function poll_device($device, $options) {
$graphs = array();
$oldgraphs = array();
// we always want the core module to be included
include 'includes/polling/core.inc.php';
if ($options['m']) {
foreach (explode(',', $options['m']) as $module) {
if (is_file('includes/polling/'.$module.'.inc.php')) {

View File

@ -2,7 +2,7 @@
echo 'Doing Nortel/Avaya ERS ';
$sysObjectID = snmp_get($device, 'sysObjectID.0', '-Oqvn');
$sysObjectID = $poll_device['sysObjectID'];
// Try multiple ways of getting firmware version
$version = snmp_get($device, 'SNMPv2-SMI::enterprises.2272.1.1.7.0', '-Oqvn');
@ -17,7 +17,7 @@ if ($version == '') {
}
// Get hardware details
$sysDescr = snmp_get($device, 'SNMPv2-MIB::sysDescr.0', '-Oqvn');
$sysDescr = $poll_device['sysDescr'];
$details = explode(' ', $sysDescr);
$details = str_replace('ERS-', 'Ethernet Routing Switch ', $details);

View File

@ -1,5 +1,5 @@
<?php
$hardware = 'Datacom '.str_replace('dmSwitch', 'DM', snmp_get($device, 'swChassisModel.0', '-Ovq', 'DMswitch-MIB'));
$version = snmp_get($device, 'swFirmwareVer.1', '-Ovq', 'DMswitch-MIB');
$features = snmp_get($device, 'sysDescr.0', '-Oqv', 'SNMPv2-MIB');
$features = $poll_device['sysDescr'];
$serial = snmp_get($device, 'DMswitch-MIB::swSerialNumber.1', '-Ovq', 'DMswitch-MIB');

View File

@ -1,6 +1,6 @@
<?php
$Descr_string = snmp_get($device, 'sysDescr.0', '-Oqv', 'SNMPv2-MIB');
$Descr_string = $poll_device['sysDescr'];
$Descr_chopper = preg_split('/[ ]+/', "$Descr_string");
$version = 'Firmware '.$Descr_chopper[1];

View File

@ -14,10 +14,10 @@ $serial = trim(snmp_get($device, "1.3.6.1.4.1.14125.100.1.7.0", "-OQv"),'" ');
# There doesn't seem to be a real hardware identification.. sysName will have to do?
$hw_response = snmp_get($device, "1.3.6.1.4.1.14125.100.1.6.0", "-OQv");
if(!empty($hw_response)) {
$hardware = str_replace("EnGenius ","",snmp_get($device,"sysName.0", "-OQv")) . " v" . trim(snmp_get($device, "1.3.6.1.4.1.14125.100.1.6.0", "-OQv"),'" .');
$hardware = str_replace("EnGenius ","",$poll_device['sysName']) . " v" . trim(snmp_get($device, "1.3.6.1.4.1.14125.100.1.6.0", "-OQv"),'" .');
}
else {
$hardware = snmp_get($device,"sysName.0", "-OQv") . trim(snmp_get($device, "1.3.6.1.4.1.14125.3.1.1.5.0", "-OQv"),'" .');
$hardware = $poll_device['sysName'] . trim(snmp_get($device, "1.3.6.1.4.1.14125.3.1.1.5.0", "-OQv"),'" .');
}
$mode = snmp_get($device, "1.3.6.1.4.1.14125.100.1.4.0", "-OQv");

View File

@ -0,0 +1,16 @@
<?php
/*
* LibreNMS HP MSM OS information module
*
* Copyright (c) 2016 Mike Rostermund <mike@kollegienet.dk>
* 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.
*/
preg_match_all('/^(MSM\d{3})|Serial number ([\S]+)|Firmware version (\d+\.\d+\.\d+\.\d+-\d+)/', $poll_device['sysDescr'], $matches);
$hardware = $matches[1][0];
$serial = $matches[2][1];
$version = $matches[3][2];

View File

@ -9,7 +9,7 @@
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*/
$sysdescr_value = snmp_get($device, 'sysDescr.0', '-Ovq');
$sysdescr_value = $poll_device['sysDescr'];
if (strpos($sysdescr_value, 'IBM Networking Operating System') !== false) {
$hardware = str_replace('IBM Networking Operating System', '', $sysdescr_value);
if (strpos($sysdescr_value, 'G8052') !== false) {

View File

@ -10,6 +10,6 @@
* the source code distribution for details.
*/
$version = snmp_get($device, 'SNMPv2-MIB::sysDescr.0', '-Ovq');
$version = $poll_device['sysDescr'];
$version = explode(' ', $version)[2];
$hardware = snmp_get($device, 'IEEE802dot11-MIB::dot11manufacturerProductName.5', '-Ovq');

View File

@ -11,5 +11,5 @@
*/
if (empty($hardware)) {
$hardware = snmp_get($device, 'sysDescr.0', '-Osqv', 'SNMPv2-MIB');
$hardware = $poll_device['sysDescr'];
}

View File

@ -11,5 +11,5 @@
*/
if (empty($hardware)) {
$hardware = snmp_get($device, 'sysDescr.0', '-Osqv', 'SNMPv2-MIB');
$hardware = $poll_device['sysDescr'];
}

View File

@ -11,5 +11,5 @@
*/
if (empty($hardware)) {
$hardware = snmp_get($device, 'sysDescr.0', '-Osqv', 'SNMPv2-MIB');
$hardware = $poll_device['sysDescr'];
}

View File

@ -6,7 +6,7 @@ if (preg_match('/^Pacific Broadband Networks .+\n.+ Version ([^,]+), .+\n.+\n.+\
// for PBN CPE 120/121
}
else if (strstr(snmp_get($device, 'SNMPv2-MIB::sysObjectID.0', '-Ovqn'), '.1.3.6.1.4.1.11606.24.1.1.10')) {
else if (strstr($poll_device['sysObjectID'], '.1.3.6.1.4.1.11606.24.1.1.10')) {
$version = str_replace(array('"'), '', snmp_get($device, '1.3.6.1.4.1.11606.24.1.1.6.0', '-Ovq'));
$hardware = str_replace(array('"'), '', snmp_get($device, '1.3.6.1.4.1.11606.24.1.1.7.0', '-Ovq'));
$features = str_replace(array('"'), '', snmp_get($device, '1.3.6.1.4.1.11606.24.1.1.10.0', '-Ovq'));

View File

@ -12,7 +12,7 @@
$version = trim(snmp_get($device, "productVersion.0", "-OQv", "PULSESECURE-PSG-MIB"),'"');
$hardware = "Juniper " . trim(snmp_get($device, "productName.0", "-OQv", "PULSESECURE-PSG-MIB"),'"');
$hostname = trim(snmp_get($device, "sysName.0", "-OQv", "SNMPv2-MIB"),'"');
$hostname = trim($poll_device['sysName'],'"');
$usersrrd = $config['rrd_dir'].'/'.$device['hostname'].'/pulse_users.rrd';
$users = snmp_get($device, 'PULSESECURE-PSG-MIB::iveConcurrentUsers.0', '-OQv');

View File

@ -1,3 +1,3 @@
<?php
list($features, $version) = explode('-', trim(str_replace('Vyatta', '', snmp_get($device, 'SNMPv2-MIB::sysDescr.0', '-Oqv', 'SNMPv2-MIB'))), 2);
list($features, $version) = explode('-', trim(str_replace('Vyatta', '', $poll_device['sysDescr'])), 2);

View File

@ -1,5 +1,5 @@
<?php
$sysObjectId = snmp_get($device, 'SNMPv2-MIB::sysObjectID.0', '-Ovqn');
$sysObjectId = $poll_device['sysObjectID'];
switch ($sysObjectId) {
case '.1.3.6.1.4.1.674.10895.3031':
/*

View File

@ -1,132 +1,2 @@
<?php
/*
* Observium Network Management and Monitoring System
* Copyright (C) 2006-2011, Observium Developers - http://www.observium.org
*
* 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.
*
* See COPYING for more details.
*/
unset($poll_device);
$snmpdata = snmp_get_multi($device, 'sysUpTime.0 sysLocation.0 sysContact.0 sysName.0', '-OQUs', 'SNMPv2-MIB');
$poll_device = $snmpdata[0];
$poll_device['sysDescr'] = snmp_get($device, 'sysDescr.0', '-Oqv', 'SNMPv2-MIB');
$poll_device['sysObjectID'] = snmp_get($device, 'sysObjectID.0', '-Oqvn', 'SNMPv2-MIB');
$poll_device['sysName'] = strtolower($poll_device['sysName']);
if (!empty($agent_data['uptime'])) {
list($uptime) = explode(' ', $agent_data['uptime']);
$uptime = round($uptime);
echo "Using UNIX Agent Uptime ($uptime)\n";
}
if (empty($uptime)) {
$snmp_uptime = (integer) snmp_get($device, 'snmpEngineTime.0', '-OUqv', 'SNMP-FRAMEWORK-MIB');
$hrSystemUptime = snmp_get($device, 'hrSystemUptime.0', '-Oqv', 'HOST-RESOURCES-MIB');
if (!empty($hrSystemUptime) && !strpos($hrSystemUptime, 'No') && ($device['os'] != 'windows')) {
echo 'Using hrSystemUptime ('.$hrSystemUptime.")\n";
$agent_uptime = $uptime;
// Move uptime into agent_uptime
// HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (63050465) 7 days, 7:08:24.65
$hrSystemUptime = str_replace('(', '', $hrSystemUptime);
$hrSystemUptime = str_replace(')', '', $hrSystemUptime);
list($days,$hours, $mins, $secs) = explode(':', $hrSystemUptime);
list($secs, $microsecs) = explode('.', $secs);
$hours = ($hours + ($days * 24));
$mins = ($mins + ($hours * 60));
$secs = ($secs + ($mins * 60));
$uptime = $secs;
}
else {
echo 'Using SNMP Agent Uptime ('.$poll_device['sysUpTime'].")\n";
// SNMPv2-MIB::sysUpTime.0 = Timeticks: (2542831) 7:03:48.31
$poll_device['sysUpTime'] = str_replace('(', '', $poll_device['sysUpTime']);
$poll_device['sysUpTime'] = str_replace(')', '', $poll_device['sysUpTime']);
list($days, $hours, $mins, $secs) = explode(':', $poll_device['sysUpTime']);
list($secs, $microsecs) = explode('.', $secs);
$hours = ($hours + ($days * 24));
$mins = ($mins + ($hours * 60));
$secs = ($secs + ($mins * 60));
$uptime = $secs;
}//end if
}//end if
if ($snmp_uptime > $uptime && is_numeric($snmp_uptime)) {
$uptime = $snmp_uptime;
d_echo('hrSystemUptime or sysUpTime looks like to have rolled, using snmpEngineTime instead');
}
if (is_numeric($uptime)) {
if ($uptime < $device['uptime']) {
log_event('Device rebooted after '.formatUptime($device['uptime']), $device, 'reboot', $device['uptime']);
}
$uptime_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/uptime.rrd';
if (!is_file($uptime_rrd)) {
rrdtool_create($uptime_rrd, 'DS:uptime:GAUGE:600:0:U '.$config['rrd_rra']);
}
$fields = array(
'uptime' => $uptime,
);
rrdtool_update($uptime_rrd, $fields);
$measurement = 'uptime';
$tags = array();
influx_update($device,$measurement,$tags,$fields);
$graphs['uptime'] = true;
echo 'Uptime: '.formatUptime($uptime)."\n";
$update_array['uptime'] = $uptime;
}//end if
$poll_device['sysLocation'] = str_replace('"', '', $poll_device['sysLocation']);
// Remove leading & trailing backslashes added by VyOS/Vyatta/EdgeOS
$poll_device['sysLocation'] = trim($poll_device['sysLocation'], '\\');
// Rewrite sysLocation if there is a mapping array (database too?)
if (!empty($poll_device['sysLocation']) && is_array($config['location_map'])) {
$poll_device['sysLocation'] = rewrite_location($poll_device['sysLocation']);
}
$poll_device['sysContact'] = str_replace('"', '', $poll_device['sysContact']);
// Remove leading & trailing backslashes added by VyOS/Vyatta/EdgeOS
$poll_device['sysContact'] = trim($poll_device['sysContact'], '\\');
foreach (array('sysLocation', 'sysContact') as $elem) {
if ($poll_device[$elem] == 'not set') {
$poll_device[$elem] = '';
}
}
// Save results of various polled values to the database
foreach (array('sysContact', 'sysObjectID', 'sysName', 'sysDescr') as $elem) {
if ($poll_device[$elem] && $poll_device[$elem] != $device[$elem]) {
$update_array[$elem] = $poll_device[$elem];
log_event("$elem -> ".$poll_device[$elem], $device, 'system');
}
}
if ($poll_device['sysLocation'] && $device['location'] != $poll_device['sysLocation'] && $device['override_sysLocation'] == 0) {
$update_array['location'] = $poll_device['sysLocation'];
log_event('Location -> '.$poll_device['sysLocation'], $device, 'system');
}
if ($config['geoloc']['latlng'] === true) {
location_to_latlng($device);
}

View File

@ -43,6 +43,12 @@ if ($device['type'] == 'network' || $device['type'] == 'firewall' || $device['ty
echo (($wificlients1 + 0).' clients on dot11Radio0, '.($wificlients2 + 0)." clients on dot11Radio1\n");
}
if ($device['os'] == 'hpmsm') {
echo 'Checking HP MSM Wireless clients... ';
$wificlients1 = snmp_get($device, '.1.3.6.1.4.1.8744.5.25.1.7.2.0', '-OUqnv');
echo $wificlients1." clients\n";
}
// MikroTik RouterOS
if ($device['os'] == 'routeros') {
// Check inventory for wireless card in device. Valid types be here:

View File

@ -1040,22 +1040,19 @@ function oid_rrd_type($oid, $mibdef)
case 'INTEGER':
case 'Integer32':
// FIXME
return false;
return 'GAUGE:600:U:U';
case 'Counter32':
// FIXME
return false;
case 'Counter64':
return 'COUNTER:600:0:U';
case 'Gauge32':
case 'Unsigned32':
return 'GAUGE:600:U:U';
return 'GAUGE:600:0:U';
}
return false;
} // oid_rrd_type
@ -1124,7 +1121,7 @@ function save_mibs($device, $mibname, $oids, $mibdef, &$graphs)
foreach ($oids as $index => $array) {
foreach ($array as $obj => $val) {
// build up the device_oid row for saving into the database
$numvalue = preg_match('/^\d+$/', $val) ? $val : null;
$numvalue = is_numeric($val) ? $val + 0 : 0;
$deviceoids[] = array(
'device_id' => $device['device_id'],
'oid' => $mibdef[$obj]['oid'].".".$index,
@ -1190,7 +1187,12 @@ function load_mibdefs($module, $name)
// add shortname to each element
$prefix = longest_matching_prefix($name, $object_types);
foreach ($result as $mib => $m) {
$result[$mib]['shortname'] = str_replace($prefix, '', $m['object_type']);
if (strlen($prefix) > 2) {
$result[$mib]['shortname'] = preg_replace("/^$prefix/", '', $m['object_type'], 1);
}
else {
$result[$mib]['shortname'] = $m['object_type'];
}
}
d_print_r($result);

494
mibs/CISCO-AAA-SESSION-MIB Normal file
View File

@ -0,0 +1,494 @@
-- *****************************************************************
-- CISCO-AAA-SESSION-MIB.my: Cisco AAA Session MIB
--
-- November 1999, Ed Richardson
--
-- Copyright (c) 1999, 2000, 2002, 2006 by cisco Systems, Inc.
-- All rights reserved.
-- *****************************************************************
--
CISCO-AAA-SESSION-MIB DEFINITIONS ::= BEGIN
IMPORTS
MODULE-IDENTITY,
OBJECT-TYPE,
Counter32,
Gauge32,
IpAddress,
Unsigned32
FROM SNMPv2-SMI
MODULE-COMPLIANCE,
OBJECT-GROUP
FROM SNMPv2-CONF
DisplayString,
TruthValue,
TEXTUAL-CONVENTION,
RowPointer
FROM SNMPv2-TC
InterfaceIndexOrZero
FROM IF-MIB
ciscoMgmt
FROM CISCO-SMI;
ciscoAAASessionMIB MODULE-IDENTITY
LAST-UPDATED "200603210000Z"
ORGANIZATION "Cisco Systems, Inc."
CONTACT-INFO
" Cisco Systems
Customer Service
Postal: 170 W. Tasman Drive
San Jose, CA 95134
USA
Tel: +1 800 553-NETS
E-mail: cs-aaa@cisco.com"
DESCRIPTION
"This MIB module provides data for accounting sessions
based on Authentication, Authorization, Accounting
(AAA) protocols.
References:
RFC 2139 RADIUS Accounting
The TACACS+ Protocol Version 1.78, Internet Draft
"
REVISION "200603210000Z"
DESCRIPTION
"Added the casnNasPort and casnVaiIfIndex objects to the
casnActiveTable.
"
REVISION "200204110000Z"
DESCRIPTION
"Imported Unsigned32 from SNMPv2-SMI instead of CISCO-TC
"
REVISION "9911160000Z"
DESCRIPTION
"Initial version
"
::= { ciscoMgmt 150 }
--
-- Textual Conventions
--
--
-- Call Identifier textual convention
--
CctCallId ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION
"Represents a Call Identifier.
The call identifier is used as an unique identifier for an
call within the system.
A zero value indicates no call ID.
"
SYNTAX Unsigned32
--
-- Session Identifier textual convention
--
CasnSessionId ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION
"Represents an Accounting Session Identifier.
The session identifier is used as an unique identifier for
a session within the system.
"
SYNTAX Unsigned32 (1..4294967295)
-- AAA Session MIB objects definitions
casnMIBObjects OBJECT IDENTIFIER ::= { ciscoAAASessionMIB 1 }
-- The AAA Session MIB consists of the following groups
-- [1] AAA Session Active Group (casnActive)
-- [2] AAA Session General Group (casnGeneral)
casnActive OBJECT IDENTIFIER ::= { casnMIBObjects 1 }
casnGeneral OBJECT IDENTIFIER ::= { casnMIBObjects 2 }
--**********************************************************************
-- AAA Session Active Group
--**********************************************************************
--
--
--
-- Active Table
--
casnActiveTableEntries OBJECT-TYPE
SYNTAX Gauge32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Number of entries currently in casnActiveTable
"
::= { casnActive 1 }
casnActiveTableHighWaterMark OBJECT-TYPE
SYNTAX Gauge32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Maximum number of entries present in casnActiveTable
since last system re-initialization.
This corresponds to the maximum value reported by
casnActiveTableEntries.
"
::= { casnActive 2 }
casnActiveTable OBJECT-TYPE
SYNTAX SEQUENCE OF CasnActiveEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"This table contains entries for active AAA accounting
sessions in the system.
"
::= { casnActive 3 }
casnActiveEntry OBJECT-TYPE
SYNTAX CasnActiveEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"The information regarding a single accounting session.
Entries are created when a new accounting session
is begun.
Entries are removed when the accounting session
is ended.
Initiating termination of a session with the object
casnDisconnect will cause removal of the entry when
the session completes termination.
"
INDEX { casnSessionId }
::= { casnActiveTable 1 }
CasnActiveEntry ::=
SEQUENCE {
casnSessionId CasnSessionId,
casnUserId DisplayString,
casnIpAddr IpAddress,
casnIdleTime Gauge32,
casnDisconnect TruthValue,
casnCallTrackerId CctCallId,
casnNasPort RowPointer,
casnVaiIfIndex InterfaceIndexOrZero
}
casnSessionId OBJECT-TYPE
SYNTAX CasnSessionId
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"This is the session identification used by the
accounting protocol.
This value is unique to a session within the system,
even if multiple accounting protocols are in use.
The value of this object corresponds to these
accounting protocol attributes.
RADIUS: attribute 44, Acct-Session-Id
TACACS+: attribute 'task_id'
"
::= { casnActiveEntry 1 }
casnUserId OBJECT-TYPE
SYNTAX DisplayString(SIZE(0..255))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The User login ID or zero length string if unavailable.
The value of this object corresponds to these
accounting protocol attributes.
RADIUS: attribute 1, User-Name
TACACS+: attribute 'user'
"
::= { casnActiveEntry 2 }
casnIpAddr OBJECT-TYPE
SYNTAX IpAddress
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The IP address of the session or 0.0.0.0 if not
applicable or unavailable.
RADIUS: attribute 8, Framed-IP-Address
TACACS+: attribute 'addr'
"
::= { casnActiveEntry 3 }
casnIdleTime OBJECT-TYPE
SYNTAX Gauge32
UNITS "seconds"
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The elapsed time that this session has been idle.
This is the time since the last user-level data has been
received or transmitted. Protocol level handshaking
associated with the call is considered to be idle for
this object.
"
::= { casnActiveEntry 4 }
casnDisconnect OBJECT-TYPE
SYNTAX TruthValue
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"This object is used to terminate this session.
Setting the value to true(1) will initiate termination
of this session.
The entry will be removed once the session has completed
termination.
Once this object has been set to true(1), the session
termination process can not be cancelled by setting the
value false(2).
"
::= { casnActiveEntry 5 }
casnCallTrackerId OBJECT-TYPE
SYNTAX CctCallId
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The value of this object is the entry index in the
CISCO-CALL-TRACKER-MIB cctActiveTable of the call
corresponding to this accounting session.
Using the value of this object to query the
cctActiveTable will provide more detailed data regarding
the session represented by this casnActiveEntry.
"
::= { casnActiveEntry 6 }
casnNasPort OBJECT-TYPE
SYNTAX RowPointer
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The value of this object identifies a particular
conceptual row associated with the session identified by
casnSessionId. The conceptual row that this object points
to represents a port that is used to transport a session.
If the port transporting the session cannot be determined,
the value of this object will be zeroDotZero.
For example, suppose a session is established using an ATM
PVC. If the ifIndex of the ATM interface is 7, and the
VPI/VCI values of the PVC are 1, 100 respectively, then
the value of this object might be as follows:
casnNasPort.15 = atmVclAdminStatus.7.1.100
^ ^ ^ ^
| | | |
casnSessionId --+ | | |
ifIndex -------------------------+ | |
atmVclVpi ---------------------------+ |
atmVclVci ------------------------------+
where atmVclAdminStatus is the first accessible object
of the atmVclTable of the ATM-MIB.
"
::= { casnActiveEntry 7 }
casnVaiIfIndex OBJECT-TYPE
SYNTAX InterfaceIndexOrZero
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The ifIndex of the Virtual Access Interface (VAI)
that is associated with the PPP session.
This interface may not be represented in the IF-MIB in
which case the value of this object will be zero.
"
::= { casnActiveEntry 8 }
--**********************************************************************
-- AAA Session General Group
--**********************************************************************
--
--
casnTotalSessions OBJECT-TYPE
SYNTAX Counter32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Total number of sessions since last system
re-initialization.
This value includes all sessions currently in the
casnActiveTable and all previous sessions whether
terminated via casnDisconnect or via other
mechanisms.
"
::= { casnGeneral 1 }
casnDisconnectedSessions OBJECT-TYPE
SYNTAX Counter32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Total number of sessions which have been disconnected using
casnDisconnect since last system re-initialization.
This value includes any sessions still in the
casnActiveTable with a casnDisconnect value of true(1) and
all previous sessions which terminated as a result of
setting casnDisconnect.
"
::= { casnGeneral 2 }
--**********************************************************************
-- Notifications
--**********************************************************************
casnMIBNotificationPrefix OBJECT IDENTIFIER ::=
{ ciscoAAASessionMIB 2 }
casnMIBNotifications OBJECT IDENTIFIER ::=
{ casnMIBNotificationPrefix 1 }
casnMIBConformance OBJECT IDENTIFIER ::=
{ ciscoAAASessionMIB 3 }
casnMIBCompliances OBJECT IDENTIFIER ::=
{ casnMIBConformance 1 }
casnMIBGroups OBJECT IDENTIFIER ::=
{ casnMIBConformance 2 }
-- compliance statements
casnMIBCompliance MODULE-COMPLIANCE
STATUS deprecated
DESCRIPTION
"The compliance statement for entities which
implement the CISCO AAA Session MIB"
MODULE -- this module
MANDATORY-GROUPS
{ casnActiveGroup,
casnGeneralGroup
}
OBJECT casnDisconnect
MIN-ACCESS read-only
DESCRIPTION
"Write access is not required."
::= { casnMIBCompliances 1 }
casnMIBComplianceRev1 MODULE-COMPLIANCE
STATUS current
DESCRIPTION
"The compliance statement for entities which
implement the CISCO AAA Session MIB"
MODULE -- this module
MANDATORY-GROUPS
{ casnActiveGroup,
casnGeneralGroup,
casnActiveGroupSup1
}
OBJECT casnDisconnect
MIN-ACCESS read-only
DESCRIPTION
"Write access is not required."
::= { casnMIBCompliances 2 }
-- units of conformance
casnActiveGroup OBJECT-GROUP
OBJECTS {
casnActiveTableEntries,
casnActiveTableHighWaterMark,
casnUserId,
casnIpAddr,
casnIdleTime,
casnDisconnect,
casnCallTrackerId
}
STATUS current
DESCRIPTION
"A collection of objects providing the
AAA session information.
"
::= { casnMIBGroups 1 }
casnGeneralGroup OBJECT-GROUP
OBJECTS {
casnTotalSessions,
casnDisconnectedSessions
}
STATUS current
DESCRIPTION
"A collection of objects providing the
AAA session information.
"
::= { casnMIBGroups 2 }
casnActiveGroupSup1 OBJECT-GROUP
OBJECTS {
casnNasPort,
casnVaiIfIndex
}
STATUS current
DESCRIPTION
"A collection of objects that supplements
the casnActiveGroup.
"
::= { casnMIBGroups 3 }
END

1
sql-schema/089.sql Normal file
View File

@ -0,0 +1 @@
ALTER TABLE `perf_times` ADD `poller` VARCHAR( 255 ) NOT NULL ;

1
sql-schema/090.sql Normal file
View 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 ('oxidized.reload_nodes','false','false','Reload Oxidized nodes list, each time a device is added','external',0,'oxidized',0,'0','0');