This commit is contained in:
Neil Lathwood
2016-10-03 18:26:00 +01:00
15 changed files with 412 additions and 110 deletions
+1
View File
@@ -136,6 +136,7 @@ LibreNMS contributors:
- Bartosz Radwan <b.radwan@citypartner.pl> (bartoszradwan)
- Kate Gerry <kate@fansubber.com> (kate66)
- Johan Zaxmy <johan@zaxmy.com> (Zaxmy)
- Ryan Gibbons <rtgibbons23@gmail.com> (rtgibbons)
[1]: http://observium.org/ "Observium web site"
Observium was written by:
+10
View File
@@ -130,6 +130,16 @@ extend memcached /etc/snmp/memcached
The MySQL script requires PHP-CLI and the PHP MySQL extension, so please verify those are installed.
CentOS
```
yum install php-cli php-mysql
```
Debian
```
apt-get install php5-cli php5-mysql
```
Unlike most other scripts, the MySQL script requires a configuration file `/usr/lib/check_mk_agent/local/mysql.cnf` with following content:
```php
+1 -1
View File
@@ -86,7 +86,7 @@ It's designed to scan through all of the subnets in your config or what you have
to automatically add devices. An example of it's usage is:
```bash
./snmp-scan.php r 192.168.0.0/24
./snmp-scan.php -r 192.168.0.0/24
```
#### Discovering devices by IP
+147
View File
@@ -1,4 +1,151 @@
source: General/Changelog.md
## Release: 201609
*September 2016*
#### Features
* Added alerts output to capture system ([#4574](https://github.com/librenms/librenms/issues/4574))
* Add support for ups-apcups via snmp
* Add snmpsim to Travis automated testing. Update to check new setting for true and isset
* use snmpsim for testing fallback feature so we don't have to run snmpsim on devel computers, should be adequate for now ./scripts/pre-commit.php -u -snmpsim will start an snmpsimd.py process automatically
* Improved readability for snmp debug output
* Add last changed, connected, and mtu to all ports data
* Add temp & state sensors to Riverbed
* Added support for all OS tests
* Added Runtime support for APC ups
* Capture device troubleshooting info (discovery, poller, snmpwalk)
* Add temp & state sensors to Riverbed
* Add more state sensors to Dell iDrac
* Allow scripts to be run from any working directory ([#4437](https://github.com/librenms/librenms/issues/4437))
* New app: ups-nut ([#4386](https://github.com/librenms/librenms/issues/4386))
* Added new discovery-wrapper.py script to replicate poller-wrapper.py ([#4351](https://github.com/librenms/librenms/issues/4351))
* Extended graphing for sla - icmp-jitter [#4341](https://github.com/librenms/librenms/issues/4341)
* Added Cisco Stackwise Support [#4301](https://github.com/librenms/librenms/issues/4301)
* Add Cisco WAAS Optimized TCP Connections Graph ([#4645](https://github.com/librenms/librenms/issues/4645))
#### Bugfixes
* Toner nrg os capacity ([#4177](https://github.com/librenms/librenms/issues/4177))
* Fixed swos detection [#4533](https://github.com/librenms/librenms/issues/4533)
* Updated edit snmp to set default poller_group ([#4694](https://github.com/librenms/librenms/issues/4694))
* Fixed SQL query for bgpPeers check to remove stale sessions ([#4697](https://github.com/librenms/librenms/issues/4697))
* Netonix version display ([#4672](https://github.com/librenms/librenms/issues/4672))
* FreeBSD variants ([#4661](https://github.com/librenms/librenms/issues/4661))
* unix-agent handling of reported time values from check_mk [#4652](https://github.com/librenms/librenms/issues/4652)
* Add checks for devices with no uptime over snmp [#4587](https://github.com/librenms/librenms/issues/4587)
* stop qnap discovery from running for every device
* Fixed the old port rrd migration code to work with new rrdtool functions ([#4616](https://github.com/librenms/librenms/issues/4616))
* Run cleanup for ipmi sensor discovery ([#4582](https://github.com/librenms/librenms/issues/4582))
* Numerous availability-map bug fixes
* AD auth stop alerts being generated
* Possible additional fix for non-terminating rrdtool processes.
* AD auth stop alerts being generated
* APC runtime graph missing in device>health>overview
* LibreNMS/Proc improvements Should fix sending rrdtool the quit command without a newline at the end. (not sure if this is an issue)
* Port ifLastChange polling now usable ([#4541](https://github.com/librenms/librenms/issues/4541))
* brother toner levels ([#4526](https://github.com/librenms/librenms/issues/4526))
* poweralert ups divisor
* Update Fortinet Logo
* Change CiscoSB devices to use ifEntry
* Disable refreshing on window resize when $no_refresh is set.
* Fix quota bills showing 0/0 for in/out ([#4462](https://github.com/librenms/librenms/issues/4462))
* This removes stale entries in the mac_ipv4 table ([#4444](https://github.com/librenms/librenms/issues/4444))
* Swos os discovery fixes [#3593](https://github.com/librenms/librenms/issues/3593)
* Vyos discovery fix [#4486](https://github.com/librenms/librenms/issues/4486)
* Toner descr that contain invalid characters [#4464](https://github.com/librenms/librenms/issues/4464)
* Alert statics not showing data
* Ubnt bad edgeswitch uptime [#4470](https://github.com/librenms/librenms/issues/4470)
* New installs would have multiple entries in dbSchema table ([#4460](https://github.com/librenms/librenms/issues/4460))
* Force add now ignores all snmp queries
* Clean up errors in the webui ([#4438](https://github.com/librenms/librenms/issues/4438))
* Reduce mib graph queries ([#4439](https://github.com/librenms/librenms/issues/4439))
* Ports page includes disabled, ignored, and deleted ports ([#4419](https://github.com/librenms/librenms/issues/4419))
* RRDTool call was always being done to check for local files ([#4427](https://github.com/librenms/librenms/issues/4427))
* MikroTik OS detection [#3593](https://github.com/librenms/librenms/issues/3593)
* Added cisco886Va to bad_ifXEntry for cisco os ([#4374](https://github.com/librenms/librenms/issues/4374))
* Stop irc bot crashing on .reload [#4353](https://github.com/librenms/librenms/issues/4353)
* Quanta blade switches are now being correctly detected as Quanta switches ([#4358](https://github.com/librenms/librenms/issues/4358))
* Added options to make temperature graphs display y-axis correctly [#4350](https://github.com/librenms/librenms/issues/4350)
* Added options to make voltage graphs display y-axis correctly [#4326](https://github.com/librenms/librenms/issues/4326)
* Calling rrdtool_pipe_open() instead of rrdtool_initialize(); ([#4343](https://github.com/librenms/librenms/issues/4343))
* Enterasys use ifname for port names [#3263](https://github.com/librenms/librenms/issues/3263)
* Ricoh/nrg toner levels [#4177](https://github.com/librenms/librenms/issues/4177)
* Availability map device box reverted to original size, fixes for device groups ([#4334](https://github.com/librenms/librenms/issues/4334))
* Remove Cisco remote access stats graph transparency ([#4331](https://github.com/librenms/librenms/issues/4331))
* Cisco remote access stats bugfix [#4293](https://github.com/librenms/librenms/issues/4293) ([#4309](https://github.com/librenms/librenms/issues/4309))
* Added ability to force devices to use ifEntry instead of ifXEntry ([#4100](https://github.com/librenms/librenms/issues/4100))
* Dont add Cisco VSS sensors if VSS is not running [#4111](https://github.com/librenms/librenms/issues/4111)
* Always validate the default dashboard_id to make sure it still exists
* NRG Toner detection [#4250](https://github.com/librenms/librenms/issues/4250)
* Missing variable in services api call
* Added influxdb options to check-services.php
#### Documentation
* Include PHP Install instructions for MySQL app
* Added FAQ for why interfaces are missing from overall traffic graphs ([#4696](https://github.com/librenms/librenms/issues/4696))
* Updated Applications to clarify apache setup
* Update apache applications to detail testing and additional requirements.md
* Updated release doc with more information on stable / dev branches
* Corrected the rsyslog documentation to be compatible with logrotate
* Fixed centos snmp path
* Updated to include info on how to use git hook to validate code ([#4484](https://github.com/librenms/librenms/issues/4484))
* Added info on how to perform unit testing
* Added faq to explain why devices show as warning ([#4449](https://github.com/librenms/librenms/issues/4449))
* Standardize snmp extend script location to /etc/snmp/ ([#4418](https://github.com/librenms/librenms/issues/4418))
* Added NFSen docs + update general config docs ([#4412](https://github.com/librenms/librenms/issues/4412))
* Clarify install docs to run validate as root [#4286](https://github.com/librenms/librenms/issues/4286)
* Added example to alerting doc for using variables of similar name [#4264](https://github.com/librenms/librenms/issues/4264)
* Added docs + file changes to support creating new releases/changelog
* Update snmpd setup in Installation-Ubuntu-1604 docs [#4243](https://github.com/librenms/librenms/issues/4243)
#### Refactoring
* Centralize MIB include directory specification ([#4603](https://github.com/librenms/librenms/issues/4603))
* OS discovery files (a-z)
* F5 device discovery cleanup + test unit
* Remove external uses of GenGroupSQL()
* consolidate snmpcmd generation
* consolidate snmpcmd generation I needed to generate an snmpcmd for an upcoming PR, so I figured I'd save a little code duplication.
* Refactored new helper functions for case sensitivity [#4283](https://github.com/librenms/librenms/issues/4283)
* Final PSR2 cleanup
* Moved IRCBot class to LibreNMS namespace [#4246](https://github.com/librenms/librenms/issues/4246)
* Update code in /includes to be psr2 compliant [#4220](https://github.com/librenms/librenms/issues/4220)
#### Devices
* Samsung Printer Discovery [#4251](https://github.com/librenms/librenms/issues/4251) ([#4258](https://github.com/librenms/librenms/issues/4258))
* HP 1820 Discovery [#3933](https://github.com/librenms/librenms/issues/3933) ([#4259](https://github.com/librenms/librenms/issues/4259))
* Added support for Cisco Callmanager
* Edge Core ES3528M - base support
* Added support for Cisco IPS ([#4561](https://github.com/librenms/librenms/issues/4561))
* Added MGE detection
* Netonix switch data collection update
* Eaton PowerXpert
* Added Datacom Dbm Support
* Updated Edgerouter lite detection
* Added support for Cisco Callmanager
* Procurve 5400R series [#4375](https://github.com/librenms/librenms/issues/4375)
* hp online admin cpu and mem [#4327](https://github.com/librenms/librenms/issues/4327)
* Added support for Foundry Networks [#4311](https://github.com/librenms/librenms/issues/4311)
* Added Cisco Stackwise Support [#4301](https://github.com/librenms/librenms/issues/4301)
* Added support for PLANET Networking & Communication switches ([#4308](https://github.com/librenms/librenms/issues/4308))
* Added support for Fujitsu Primergy switches [#4277](https://github.com/librenms/librenms/issues/4277) ([#4280](https://github.com/librenms/librenms/issues/4280))
* Added support for Lanier printers [#4267](https://github.com/librenms/librenms/issues/4267)
* Added Temp and State support for EdgeSwitch OS [#4265](https://github.com/librenms/librenms/issues/4265)
* Added support for DDN Storage [#2737](https://github.com/librenms/librenms/issues/2737) ([#4261](https://github.com/librenms/librenms/issues/4261))
* Improved support for UBNT EdgeSwitch OS [#4249](https://github.com/librenms/librenms/issues/4249)
* Improved support for Avaya VSP [#4237](https://github.com/librenms/librenms/issues/4237)
* Added support for macOS Sierra ([#4557](https://github.com/librenms/librenms/issues/4557))
* Improve BDCOM detection ([#4329](https://github.com/librenms/librenms/issues/4329))
#### WebUI
* top devices enhancement [#4447](https://github.com/librenms/librenms/issues/4447)
* Individual devices now use bootgrid syslog ([#4584](https://github.com/librenms/librenms/issues/4584))
* added amazon server icon
* Update all glyphicon to font awesome
* Relocate Alerts menu
* Updated force add option for addhost.php to be present in all instances ([#4428](https://github.com/librenms/librenms/issues/4428))
* Add check to display make bill on port page only if billing is enabled ([#4361](https://github.com/librenms/librenms/issues/4361))
* Added Pagination and server side search via Ajax to NTP ([#4330](https://github.com/librenms/librenms/issues/4330))
---
### August 2016
#### Bug fixes
+36
View File
@@ -20,6 +20,7 @@ source: Support/FAQ.md
- [Things aren't working correctly?](#faq18)
- [What do the values mean in my graphs?](#faq21)
- [Why does a device show as a warning?](#faq22)
- [Why do I not see all interfaces in the Overall traffic graph for a device?](#faq23)
### Developing
- [How do I add support for a new OS?](#faq8)
@@ -43,6 +44,8 @@ You have two options for adding a new device into LibreNMS.
./addhost.php [community] [v1|v2c] [port] [udp|udp6|tcp|tcp6]
```
> Please note that if the community contains special characters such as `$` then you will need to wrap it in `'`. I.e: `'Pa$$w0rd'`.
2. Using the web interface, go to Devices and then Add Device. Enter the details required for the device that you want to add and then click 'Add Host'.
#### <a name="faq3"> How do I get help?</a>
@@ -169,6 +172,39 @@ here are those values:
This is indicating that the device has rebooted within the last 24 hours (by default). If you want to adjust this
threshold then you can do so by setting `$config['uptime_warning']` in config.php. The value must be in seconds.
#### <a name="faq23"> Why do I not see all interfaces in the Overall traffic graph for a device?</a>
By default numerous interface types and interface descriptions are excluded from this graph. The excluded defailts are:
```php
$config['device_traffic_iftype'][] = '/loopback/';
$config['device_traffic_iftype'][] = '/tunnel/';
$config['device_traffic_iftype'][] = '/virtual/';
$config['device_traffic_iftype'][] = '/mpls/';
$config['device_traffic_iftype'][] = '/ieee8023adLag/';
$config['device_traffic_iftype'][] = '/l2vlan/';
$config['device_traffic_iftype'][] = '/ppp/';
$config['device_traffic_descr'][] = '/loopback/';
$config['device_traffic_descr'][] = '/vlan/';
$config['device_traffic_descr'][] = '/tunnel/';
$config['device_traffic_descr'][] = '/bond/';
$config['device_traffic_descr'][] = '/null/';
$config['device_traffic_descr'][] = '/dummy/';
```
If you would like to re-include l2vlan interfaces for instance, you first need to `unset` the config array and set your options:
```php
unset($config['device_traffic_iftype']);
$config['device_traffic_iftype'][] = '/loopback/';
$config['device_traffic_iftype'][] = '/tunnel/';
$config['device_traffic_iftype'][] = '/virtual/';
$config['device_traffic_iftype'][] = '/mpls/';
$config['device_traffic_iftype'][] = '/ieee8023adLag/';
$config['device_traffic_iftype'][] = '/ppp/';
```
#### <a name="faq8"> How do I add support for a new OS?</a>
The easiest way to show you how to do that is to link to an existing pull request that has been merged in on [GitHub](https://github.com/librenms/librenms/pull/352/files)
@@ -0,0 +1,16 @@
<?php
$rrd_filename = rrd_name($device['hostname'], 'panos-activetunnels');
$ds = 'activetunnels';
$colour_area = '9999cc';
$colour_line = '0000cc';
$colour_area_max = '9999cc';
$graph_max = 1;
$unit_text = 'Active Tunnels';
require 'includes/graphs/generic_simplex.inc.php';
+1 -1
View File
@@ -8,7 +8,7 @@ if ($_POST['editing']) {
$port = $_POST['port'] ? mres($_POST['port']) : $config['snmp']['port'];
$timeout = mres($_POST['timeout']);
$retries = mres($_POST['retries']);
$poller_group = mres($_POST['poller_group']);
$poller_group = isset($_POST['poller_group']) ? mres($_POST['poller_group']) : 0;
$port_assoc_mode = mres($_POST['port_assoc_mode']);
$max_repeaters = mres($_POST['max_repeaters']);
$v3 = array(
+1 -1
View File
@@ -1118,7 +1118,7 @@ function version_info($remote = true)
$output['php_ver'] = phpversion();
$output['mysql_ver'] = dbFetchCell('SELECT version()');
$output['rrdtool_ver'] = implode(' ', array_slice(explode(' ', shell_exec($config['rrdtool'].' --version |head -n1')), 1, 1));
$output['netsnmp_ver'] = shell_exec($config['snmpget'].' --version 2>&1');
$output['netsnmp_ver'] = str_replace('version: ', '', rtrim(shell_exec($config['snmpget'].' --version 2>&1')));
return $output;
}//end version_info()
+5
View File
@@ -2454,9 +2454,14 @@ $config['graph_types']['device']['fortigate_cpu']['descr'] = 'CPU';
$config['graph_types']['device']['screenos_sessions']['section'] = 'firewall';
$config['graph_types']['device']['screenos_sessions']['order'] = '0';
$config['graph_types']['device']['screenos_sessions']['descr'] = 'Active Sessions';
//PAN OS Graphs
$config['graph_types']['device']['panos_sessions']['section'] = 'firewall';
$config['graph_types']['device']['panos_sessions']['order'] = '0';
$config['graph_types']['device']['panos_sessions']['descr'] = 'Active Sessions';
$config['graph_types']['device']['panos_activetunnels']['section'] = 'firewall';
$config['graph_types']['device']['panos_activetunnels']['order'] = '1';
$config['graph_types']['device']['panos_activetunnels']['descr'] = 'Active GlobalProtect Tunnels';
//Pulse Secure Graphs
$config['graph_types']['device']['pulse_users']['section'] = 'firewall';
+1 -1
View File
@@ -214,7 +214,7 @@ if ($config['enable_bgp']) {
}
// Delete removed peers
$sql = "SELECT * FROM bgpPeers WHERE device_id = '".$device['device_id']."' AND context_name = '".$device['context_name']."'";
$sql = "SELECT * FROM bgpPeers WHERE device_id = '".$device['device_id']."' AND (context_name = '".$device['context_name']."' OR context_name IS NULL)";
foreach (dbFetchRows($sql) as $entry) {
unset($exists);
+65
View File
@@ -891,3 +891,68 @@ function get_device_divisor($device, $serial, $sensor)
}
return $divisor;
}
/**
* @param $device
* @param $capacity_oid
* @return int
*/
function get_toner_capacity($device, $capacity_oid)
{
if ($device['os'] == 'ricoh' || $device['os'] == 'nrg' || $device['os'] == 'lanier') {
$capacity = 100;
} else {
$capacity = snmp_get($device, $capacity_oid, '-Oqv');
}
return $capacity;
}
/**
* @param $device
* @param $oid_value
* @param $oid_capacity
* @return float|int
*/
function get_toner_levels($device, $oid_value, $oid_capacity)
{
if ($device['os'] == 'ricoh' || $device['os'] == 'nrg' || $device['os'] == 'lanier') {
if ($oid_value == '-3') {
$current = 50;
} elseif ($oid_value == '-100') {
$current = 0;
} else {
$current = ($oid_value / $oid_capacity * 100);
}
} elseif ($device['os'] == 'brother') {
if (str_contains($device['hardware'], 'NC-8600h')) {
switch ($oid_value) {
case '0':
$current = 0;
break;
case '-3':
$current = 50;
break;
}
} else {
switch ($oid_value) {
case '0':
$current = 100;
break;
case '1':
$current = 5;
break;
case '2':
$current = 0;
break;
case '3':
$current = 1;
break;
}
}
} else {
$current = ($oid_value / $oid_capacity * 100);
}
return $current;
}
+16 -47
View File
@@ -8,7 +8,7 @@ if ($device['os_group'] == 'printer') {
$oids = trim(snmp_walk($device, 'SNMPv2-SMI::mib-2.43.11.1.1.2.1 ', '-OsqnU'));
}
d_echo($oids."\n");
d_echo($oids . "\n");
if ($oids) {
echo 'Jetdirect ';
@@ -17,60 +17,29 @@ if ($device['os_group'] == 'printer') {
foreach (explode("\n", $oids) as $data) {
$data = trim($data);
if ($data) {
list($oid,$role) = explode(' ', $data);
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 1)];
list($oid, $role) = explode(' ', $data);
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 1)];
if (is_numeric($role)) {
//ricoh using private oids to expose toner levels
if ($os == 'ricoh' || $os == 'nrg' || $os == 'lanier') {
$toner_oid = ".1.3.6.1.4.1.367.3.2.1.2.24.1.1.5.$index";
$descr_oid = ".1.3.6.1.4.1.367.3.2.1.2.24.1.1.3.$index";
$capacity_oid = '';
} else {
$toner_oid = ".1.3.6.1.2.1.43.11.1.1.9.1.$index";
$descr_oid = ".1.3.6.1.2.1.43.11.1.1.6.1.$index";
$toner_oid = ".1.3.6.1.2.1.43.11.1.1.9.1.$index";
$descr_oid = ".1.3.6.1.2.1.43.11.1.1.6.1.$index";
$capacity_oid = ".1.3.6.1.2.1.43.11.1.1.8.1.$index";
}
$descr = trim(str_replace("\n", '', preg_replace('/[^ \w]+/', '', snmp_get($device, $descr_oid, '-Oqv'))));
if ($descr != '') {
$current = snmp_get($device, $toner_oid, '-Oqv');
$oid_toner = snmp_get($device, $toner_oid, '-Oqv');
$oid_capacity = snmp_get($device, $capacity_oid, '-Oqv');
//ricoh private mibs returns values as percent, no capacity is disclosed as it is not needed
if ($os == 'ricoh' || $os == 'nrg' || $os == 'lanier') {
$capacity = 100;
} else {
$capacity = snmp_get($device, $capacity_oid, '-Oqv');
}
//fix for ricoh devices returning garbage and devices returning percentage
if ($os == 'ricoh' || $os == 'nrg' || $os == 'lanier') {
if ($current == '-3') {
$current = 50;
} elseif ($current == '-100') {
$current = 0;
} else {
$current = ($current / $capacity * 100);
}
} elseif ($os == 'brother') {
switch ($current) {
case '0':
$current = 100;
break;
case '1':
$current = 5;
break;
case '2':
$current = 0;
break;
case '3':
$current = 1;
break;
}
} else {
//normal devices returning toner values
$current = ($current / $capacity * 100);
}
$capacity = get_toner_capacity($device, $oid_capacity);
$current = get_toner_levels($device, $oid_toner, $oid_capacity);
$type = 'jetdirect';
if (isHexString($descr)) {
@@ -80,18 +49,18 @@ if ($device['os_group'] == 'printer') {
discover_toner($valid_toner, $device, $toner_oid, $index, $type, $descr, $capacity_oid, $capacity, $current);
}
}
}//end if
}//end foreach
}//end if
}
}
}
// Delete removed toners
d_echo("\n Checking ... \n");
d_echo($valid_toner);
$sql = "SELECT * FROM toner WHERE device_id = '".$device['device_id']."'";
$sql = "SELECT * FROM toner WHERE device_id = '" . $device['device_id'] . "'";
foreach (dbFetchRows($sql) as $test_toner) {
$toner_index = $test_toner['toner_index'];
$toner_type = $test_toner['toner_type'];
$toner_type = $test_toner['toner_type'];
if (!$valid_toner[$toner_type][$toner_index]) {
echo '-';
dbDelete('toner', '`toner_id` = ?', array($test_toner['toner_id']));
+15
View File
@@ -19,3 +19,18 @@ if (is_numeric($sessions)) {
$graphs['panos_sessions'] = true;
}
$activetunnels = snmp_get($device, '1.3.6.1.4.1.25461.2.1.2.5.1.3.0', '-Ovq');
if (is_numeric($activetunnels)) {
$rrd_def = 'DS:activetunnels:GAUGE:600:0:3000000';
$fields = array(
'activetunnels' => $activetunnels,
);
$tags = compact('rrd_def');
data_update($device, 'panos-activetunnels', $tags, $fields);
$graphs['panos_activetunnels'] = true;
}
+1
View File
@@ -0,0 +1 @@
INSERT INTO `graph_types`(`graph_type`, `graph_subtype`, `graph_section`, `graph_descr`, `graph_order`) VALUES ('device', 'panos_activetunnels', 'firewall', 'Active GlobalProtect Tunnels', '');
+96 -59
View File
@@ -15,6 +15,9 @@
chdir(__DIR__); // cwd to the directory containing this script
require_once 'includes/defaults.inc.php';
require_once 'includes/common.php';
$options = getopt('m:h::');
if (isset($options['h'])) {
@@ -35,20 +38,62 @@ if (isset($options['h'])) {
exit;
}
if (strstr(`php -ln config.php`, 'No syntax errors detected')) {
$first_line = `head -n1 config.php`;
$last_lines = explode(PHP_EOL, `tail -n2 config.php`);
if (substr($first_line, 0, 5) !== '<?php') {
print_fail("config.php doesn't start with a <?php - please fix this ($first_line)");
} elseif ($last_lines[0] == '?>' && $last_lines[1] == '') {
print_fail('config.php contains a new line at the end, please remove any whitespace at the end of the file and also remove ?>');
} elseif ($last_lines[1] == '?>') {
print_warn("It looks like you have ?> at the end of config.php, it is suggested you remove this");
}
} else {
print_fail('Syntax error in config.php');
$console_color = new Console_Color2();
// critical config.php checks
if (!file_exists('config.php')) {
print_fail('config.php does not exist, please copy config.php.default to config.php');
exit;
}
$config_failed = false;
$syntax_check = `php -ln config.php`;
if (!str_contains($syntax_check, 'No syntax errors detected')) {
print_fail('Syntax error in config.php');
echo $syntax_check;
$config_failed = true;
}
$first_line = rtrim(`head -n1 config.php`);
if (!starts_with($first_line, '<?php')) {
print_fail("config.php doesn't start with a <?php - please fix this ($first_line)");
$config_failed = true;
}
if (str_contains(`tail config.php`, '?>')) {
print_fail("Remove the ?> at the end of config.php");
$config_failed = true;
}
if ($config_failed) {
exit;
}
// load config.php now
require_once 'config.php';
// make sure install_dir is set correctly, or the next includes will fail
if (!file_exists($config['install_dir'].'/config.php')) {
print_fail('$config[\'install_dir\'] is not set correctly. It should probably be set to: ' . getcwd());
exit;
}
// continue loading includes
require_once 'includes/definitions.inc.php';
require_once 'includes/functions.php';
require_once 'includes/alerts.inc.php';
$versions = version_info();
$cur_sha = $versions['local_sha'];
echo "==========================================================\n";
echo "LibreNMS Version: $cur_sha\n";
echo "DB Schema: ".$versions['db_schema']."\n";
echo "PHP: ".$versions['php_ver']."\n";
echo "MySQL: ".$versions['mysql_ver']."\n";
echo "RRDTool: ".$versions['rrdtool_ver']."\n";
echo "SNMP: ".$versions['netsnmp_ver']."\n";
echo "==========================================================\n\n";
// Check we are running this as the root user
if (function_exists('posix_getpwuid')) {
$userinfo = posix_getpwuid(posix_geteuid());
@@ -60,53 +105,10 @@ if ($username !== 'root') {
print_fail("You need to run this script as root");
}
// load config.php now
require_once 'includes/defaults.inc.php';
require_once 'config.php';
// make sure install_dir is set correctly, or the next includes will fail
if (!file_exists($config['install_dir'].'/config.php')) {
print_fail('$config[\'install_dir\'] is not set correctly. It should probably be set to: ' . getcwd());
exit;
}
// continue loading includes
require_once 'includes/definitions.inc.php';
require_once 'includes/functions.php';
require_once 'includes/common.php';
require_once $config['install_dir'].'/includes/alerts.inc.php';
$versions = version_info();
echo "====================================\n";
echo "Version info:\n";
$cur_sha = $versions['local_sha'];
if ($config['update_channel'] == 'master' && $cur_sha != $versions['github']['sha']) {
$commit_date = new DateTime('@'.$versions['local_date'], new DateTimeZone(date_default_timezone_get()));
print_warn("Your install is out of date: $cur_sha " . $commit_date->format('(r)'));
} else {
echo "Commit SHA: $cur_sha\n";
print_warn("Your install is out of date, last update: " . $commit_date->format('r'));
}
if ($versions['local_branch'] != 'master') {
print_warn("Your local git branch is not master, this will prevent automatic updates.");
}
// check for modified files
$modifiedcmd = 'git diff --name-only --exit-code';
if ($username === 'root') {
$modifiedcmd = 'su '.$config['user'].' -c "'.$modifiedcmd.'"';
}
exec($modifiedcmd, $cmdoutput, $code);
if ($code !== 0 && !empty($cmdoutput)) {
print_warn("Your local git contains modified files, this could prevent automatic updates.\nModified files:");
echo(' ' . implode("\n ", $cmdoutput) . "\n");
}
echo "DB Schema: ".$versions['db_schema']."\n";
echo "PHP: ".$versions['php_ver']."\n";
echo "MySQL: ".$versions['mysql_ver']."\n";
echo "RRDTool: ".$versions['rrdtool_ver']."\n";
echo "SNMP: ".$versions['netsnmp_ver']."\n";
echo "====================================\n";
// Check php modules we use to make sure they are loaded
$extensions = array('pcre','curl','session','snmp','mcrypt');
@@ -226,6 +228,41 @@ if (!function_exists('openssl_random_pseudo_bytes')) {
}
}
// check discovery last run
if (dbFetchCell('SELECT COUNT(`device_id`) FROM `devices` WHERE `last_discovered` IS NOT NULL') == 0) {
print_fail('Discovery has never run, check the cron job');
} elseif (dbFetchCell("SELECT COUNT(`device_id`) FROM `devices` WHERE `last_discovered` <= DATE_ADD(NOW(), INTERVAL - 24 hours) AND `ignore` = 0 AND `disabled` = 0 AND `status` = 1") > 0) {
print_fail("Discovery has not run in the last 24 hours, check the cron job");
}
// check poller
if (dbFetchCell('SELECT COUNT(`device_id`) FROM `devices` WHERE `last_polled` IS NOT NULL') == 0) {
print_fail('The poller has never run, check the cron job');
} elseif (dbFetchCell("SELECT COUNT(`device_id`) FROM `devices` WHERE `last_polled` <= DATE_ADD(NOW(), INTERVAL - 5 minute) AND `ignore` = 0 AND `disabled` = 0 AND `status` = 1") > 0) {
print_fail("The poller has not run in the last 5 minutes, check the cron job");
} elseif (dbFetchCell("SELECT COUNT(`device_id`) FROM `devices` WHERE (`last_polled` <= DATE_ADD(NOW(), INTERVAL - 5 minute) OR `last_polled` IS NULL) AND `ignore` = 0 AND `disabled` = 0 AND `status` = 1") > 0) {
print_warn("Some devices have not been polled in the last 5 minutes, check your poll log");
}
if (dbFetchCell('SELECT COUNT(`device_id`) FROM `devices` WHERE last_polled_timetaken > 300 AND `ignore` = 0 AND `disabled` = 0 AND `status` = 1') > 0) {
print_fail("Some devices have not completed their polling run in 5 minutes, this will create gaps in data.\n Check your poll log and refer to http://docs.librenms.org/Support/Performance/");
}
if ($versions['local_branch'] != 'master') {
print_warn("Your local git branch is not master, this will prevent automatic updates.");
}
// check for modified files
$modifiedcmd = 'git diff --name-only --exit-code';
if ($username === 'root') {
$modifiedcmd = 'su '.$config['user'].' -c "'.$modifiedcmd.'"';
}
exec($modifiedcmd, $cmdoutput, $code);
if ($code !== 0 && !empty($cmdoutput)) {
print_warn("Your local git contains modified files, this could prevent automatic updates.\nModified files:");
echo(' ' . implode("\n ", $cmdoutput) . "\n");
}
// Modules test
$modules = explode(',', $options['m']);
foreach ($modules as $module) {
@@ -339,19 +376,19 @@ foreach ($modules as $module) {
function print_ok($msg)
{
echo "[OK] $msg\n";
c_echo("[%gOK%n] $msg\n");
}//end print_ok()
function print_fail($msg)
{
echo "[FAIL] $msg\n";
c_echo("[%RFAIL%n] $msg\n");
}//end print_fail()
function print_warn($msg)
{
echo "[WARN] $msg\n";
c_echo("[%YWARN%n] $msg\n");
}//end print_warn()
function check_rrdcached()