Merge branch 'master' of https://github.com/librenms/librenms into docs-ubuntu1604

This commit is contained in:
laf
2016-06-16 10:31:56 +01:00
140 changed files with 30811 additions and 543 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ Please replace the relevant information in these commands.
```bash
./discovery.php -h HOSTNAME -d -m os
./poller.php -h HOSTNAME -r -f -d -m os
snmpbulkwalk -v2c -c COMMUNITY HOSTNAME .
snmpbulkwalk -On -v2c -c COMMUNITY HOSTNAME .
```
If possible please also provide what the OS name should be if it doesn't exist already.
+5 -2
View File
@@ -102,11 +102,14 @@ LibreNMS contributors:
- Jussi Sorjonen <mieleton@mieleton.net> (mieleton)
- Jens Langhammer <jens@beryju.org> (BeryJu)
- Robert Verspuy <robert@exa.nl> (exarv)
- Peter Tkatchenko <peter@flytrace.com> (Peter2121)
- Marc Runkel <marc@runkel.org> (mrunkel)
- Josh Driver <keeperofdakeys@gmail.com> (keeperofdakeys)
- Felix Eckhofer <felix@eckhofer.com> (tribut)
- Vikram Adukia <adukia@dropbox.com> (justmedude)
[1]: http://observium.org/ "Observium web site"
Observium was written by:
- Adam Armstrong
- Tom Laermans
- various others as indicated in the file contents and commit logs
+8 -3
View File
@@ -204,9 +204,13 @@ if (!empty($argv[1])) {
echo 'Added device '.$device['hostname'].' ('.$device_id.")\n";
exit;
}
}//end if
else {
print $console_color->convert("%rWe couldn't add this device, please check the snmp details%n\n");
}
}
else {
print $console_color->convert(
print $console_color->convert(
"\n".$config['project_name_version'].' Add Host Tool
Usage (SNMPv1/2c): ./addhost.php [-g <poller group>] [-f] [-p <port assoc mode>] <%Whostname%n> [community] [v1|v2c] [port] ['.implode('|', $config['snmp']['transports']).']
@@ -224,4 +228,5 @@ print $console_color->convert(
%rRemember to run discovery for the host afterwards.%n
'
);
);
}
+2 -1
View File
@@ -455,11 +455,12 @@ function FormatAlertTpl($obj) {
function DescribeAlert($alert) {
$obj = array();
$i = 0;
$device = dbFetchRow('SELECT hostname, sysName FROM devices WHERE device_id = ?', array($alert['device_id']));
$device = dbFetchRow('SELECT hostname, sysName, location FROM devices WHERE device_id = ?', array($alert['device_id']));
$tpl = dbFetchRow('SELECT `template`,`title`,`title_rec` FROM `alert_templates` JOIN `alert_template_map` ON `alert_template_map`.`alert_templates_id`=`alert_templates`.`id` WHERE `alert_template_map`.`alert_rule_id`=?', array($alert['rule_id']));
$default_tpl = "%title\r\nSeverity: %severity\r\n{if %state == 0}Time elapsed: %elapsed\r\n{/if}Timestamp: %timestamp\r\nUnique-ID: %uid\r\nRule: {if %name}%name{else}%rule{/if}\r\n{if %faults}Faults:\r\n{foreach %faults} #%key: %value.string\r\n{/foreach}{/if}Alert sent to: {foreach %contacts}%value <%key> {/foreach}";
$obj['hostname'] = $device['hostname'];
$obj['sysName'] = $device['sysName'];
$obj['location'] = $device['location'];
$obj['device_id'] = $alert['device_id'];
$extra = $alert['details'];
if (!isset($tpl['template'])) {
+13 -1
View File
@@ -4,6 +4,7 @@ Table of Content:
- [Rules](#rules)
- [Syntax](#rules-syntax)
- [Examples](#rules-examples)
- [Procedure](#rules-procedure)
- [Templates](#templates)
- [Syntax](#templates-syntax)
- [Examples](#templates-examples)
@@ -89,6 +90,9 @@ Alert when:
- 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="rules-procedure">Procedure</a>
You can associate a rule to a procedure by giving the URL of the procedure when creating the rule. Only links like "http://" are supported, otherwise an error will be returned. Once configured, procedure can be opened from the Alert widget through the "Open" button, which can be shown/hidden from the widget configuration box.
# <a name="templates">Templates</a>
Templates can be assigned to a single or a group of rules.
@@ -107,6 +111,8 @@ Controls:
Placeholders:
- Hostname of the Device: `%hostname`
- sysName of the Device: `%sysName`
- location of the Device: `%location`
- Title for the Alert: `%title`
- Time Elapsed, Only available on recovery (`%state == 0`): `%elapsed`
- Alert-ID: `%id`
@@ -564,6 +570,12 @@ All macros that are not unary should return Boolean.
You can only apply _Equal_ or _Not-Equal_ Operations on Boolean-macros where `True` is represented by `"1"` and `False` by `"0"`.
Note, if using a /, spaces must be inserted around it.
Example
```php
((%ports.ifInOctets_rate*8) / %ports.ifSpeed)*100
```
## <a name="macros-device">Device</a> (Boolean)
@@ -627,7 +639,7 @@ Entity: `%macros.port_usage_perc`
Description: Return port-usage in percent.
Source: `((%ports.ifInOctets_rate*8)/%ports.ifSpeed)*100`
Source: `((%ports.ifInOctets_rate*8) / %ports.ifSpeed)*100`
## <a name="macros-time">Time</a>
+24
View File
@@ -168,3 +168,27 @@ $config['radius']['timeout'] = 3;
$config['radius']['users_purge'] = 14;//Purge users who haven't logged in for 14 days.
$config['radius']['default_level'] = 1;//Set the default user level when automatically creating a user.
```
#### HTTP Authentication / AD Authorization
Config option: `ad-authorization`
This module is a combination of ___http-auth___ and ___active_directory___
LibreNMS will expect the user to have authenticated via your webservice already (e.g. using Kerberos Authentication in Apache) but will use Active Directory lookups to determine and assign the userlevel of a user.
The userlevel will be calculated by using AD group membership information as the ___active_directory___ module does.
The configuration is the same as for the ___active_directory___ module with two extra, optional options: auth_ad_binduser and auth_ad_bindpassword.
These should be set to a AD user with read capabilities in your AD Domain in order to be able to perform searches.
If these options are omitted, the module will attempt an anonymous bind (which then of course must be allowed by your Active Directory server(s)).
There is also one extra option for controlling user information caching: auth_ldap_cache_ttl.
This option allows to control how long user information (user_exists, userid, userlevel) are cached within the PHP Session.
The default value is 300 seconds.
To disable this caching (highly discourage) set this option to 0.
```php
$config['auth_ad_binduser'] = "ad_binduser";
$config['auth_ad_bindpassword'] = "ad_bindpassword";
$config['auth_ldap_cache_ttl'] = 300;
```
+59
View File
@@ -0,0 +1,59 @@
# Auto discovery support
LibreNMS provides the ability to automatically add devices on your network, we can do this with via
a few methods which will be explained below and also indicate if they are enabled by default.
All discovery methods run when discovery.php runs (every 6 hours by default and within 5 minutes for new devices).
### Discovery methods
#### ARP
Disabled by default.
To enable, switch on globally the `$config['discovery_modules']['discovery-arp'] = 1;` or per device within the Modules section.
#### XDP
Enabled by default.
`$config['autodiscovery']['xdp'] = false;` to disable.
This includes FDP, CDP and LLDP support based on the device type.
#### OSPF
Enabled by default.
`$config['autodiscovery']['ospf'] = false;` to disable.
#### BGP
Enabled by default.
`$config['autodiscovery']['bgp'] = false;` to disable.
This module is invoked from bgp-peers discovery module.
### Including / Excluding subnets to scan
By default the following config is in place to exclude loopback, multicast, etc ranges. You can expand this out by adding more
ranges to config.php
```php
$config['autodiscovery']['nets-exclude'][] = '0.0.0.0/8';
$config['autodiscovery']['nets-exclude'][] = '127.0.0.0/8';
$config['autodiscovery']['nets-exclude'][] = '169.254.0.0/16';
$config['autodiscovery']['nets-exclude'][] = '224.0.0.0/4';
$config['autodiscovery']['nets-exclude'][] = '240.0.0.0/4';
```
You will need to specify your own subnets that you would like to scan for which can be done with:
`$config['nets'][] = '8.8.8.0/24';`
#### Discovering devices by IP
By default we don't add devices by IP address, we look for a reverse dns name to be found and add with that. If this fails
and you would like to still add devices automatically then you will need to set `$config['discovery_by_ip'] = true;`
#### Short hostnames
If your devices only return a short hostname such as lax-fa0-dc01 but the full name should be lax-fa0-dc01.example.com then you can
set `$config['mydomain'] = 'example.com';`
+29
View File
@@ -0,0 +1,29 @@
# SNMP Proxy
If you have machines that you want to monitor but are not reachable directly, you can use [SNMPD Proxy](http://www.net-snmp.org/wiki/index.php/Snmpd_proxy). This will use the reachable SNMPD to proxy requests to the unreachable SNMPD.
## Example configuration
We want to poll ```unreachable.example.com``` via ```hereweare.example.com```. Use the following config:
On ```hereweare.example.com```:
```
view all included .1
com2sec -Cn ctx_unreachable readonly <poller-ip> unreachable
access MyROGroup ctx_unreachable any noauth prefix all none none
proxy -Cn ctx_unreachable -v 2c -c private unreachable.example.com .1.3
```
On ```unreachable.example.com```:
```
view all included .1 80
com2sec readonly <hereweare.example.com ip address> private
group MyROGroup v1 readonly
group MyROGroup v2c readonly
group MyROGroup usm readonly
access MyROGroup "" any noauth exact all none none
```
You can now poll community ```private``` on ```unreachable.example.com``` via community ```unreachable``` on host ```hereweare.example.com```. Please note that requests on ```unreachable.example.com``` will be coming from ```hereweare.example.com```, not your poller.
+85
View File
@@ -1,3 +1,88 @@
### June 2016
#### Bug fixes
- WebUI:
- Rename $ds to $ldap_connection for auth modules (PR3596)
- Misc:
- Fix smokeping path in gen_smokeping (PR3577)
- Fix full include path in includes/polling/functions.inc.php (PR3614)
#### Improvements
- Added / improved detection for:
- HPE 3Par (PR3578)
- Buffalo TeraStation (PR3587)
- Samsung C printers (PR3598)
- Roomalert3e (PR3599)
- Avtech Switches (PR3611)
- IBM Bladecenter switches (PR3623)
- HWg support (PR3624)
- IBM IMM (PR3625)
- Polling / Discovery:
- Use lsb_release in distro script (PR3580)
- Allow lmsensors fanspeeds of 0 to be discovered (PR3616)
- Added support for rrdcached application monitoring (PR3627)
- WebUI:
- Resolve some reported security issues (PR3586) With thanks to https://twitter.com/wireghoul
- Order apps list alphabetically (PR3600)
- Network map improvements (PR3602)
- Added support for varying hostname formats in Oxidized integration (PR3617)
- Added device hw/location on hover in alerts table (PR3621)
- Misc:
- Added pivot table for device groups ready for V2 (PR3589)
### May 2016
#### Bug fixes
- WebUI:
- Fixed broken performance charts using VisJS (PR3479)
- Fixed include path to file in create alert item (PR3480)
- Updated services box on front page to utilise the new services (PR3481)
- Potential fix for intermittent logouts (PR3372)
- Updated sensors hostname to use correct variable (PR3485)
- Polling / Discovery:
- Only poll AirMAX if device supports the MIB (PR3486)
- Alerting:
- Don't alert unless the sensor value surpasses the threshold (PR3507)
#### Improvements
- Added / improved detection for:
- Microsemo timing devices (PR3453)
- Bintec smart routers (PR3454)
- PoweWalker support (PR3456)
- BDCom support (PR3459)
- Cisco WAPs (PR3460)
- EMC Data domain (PR3461)
- Xerox support (PR3462)
- Calix support (PR3463)
- Isilon OneFS (PR3482)
- Ricoh printers (PR3483)
- HP Virtual Connect (PR3487)
- Equallogic arrays + Dell servers (PR3519)
- Alcatel-Lucent SR + SAR (PR3535, PR3553)
- Xirrus Wireless Access Points (PR3543)
- Polling / Discovery:
- Add config option to stop devices with duplicate sysName's being added (PR3473)
- Enable discovery support of CDP neighbours by IP (PR3561)
- Alerting:
- Added ability to use sysName in templates (PR3470)
- Send Slack alerts as pure JSON (PR3522)
- Apply colour to HipChat messages (PR3539)
- WebUI:
- Added ability to filter alerts by state (PR3471)
- Added support for using local openstreet map tiles (PR3472)
- Added ability to show services on availability map (PR3496)
- Added combined auth module for http auth and AD auth (PR3531)
- List services alphabetically (PR3538)
- Added support for scrollable widgets (PR3565)
- Graphs:
- Added Hit/Misses for memcached graphs (PR3499)
- API:
- Update get_graph_generic_by_hostname to use device_id as well (PR3494)
- Docs:
- Added configuration for SNMP Proxy support (PR3528)
- Misc:
- Added purge for alert log (PR3469)
### April 2016
#### Bug fixes
+8 -4
View File
@@ -46,17 +46,21 @@ Any issues with these images should be reported via [Github](https://github.com/
#### Credentials
> Please note the second character of the SSH password is a CAPITAL EYE
- SSH
- username: librenms
- password: CIne3fwdfds
- password: `CIne3fwdfds`
> Please note the second character of the SSH password is a CAPITAL EYE
- MySQL/MariaDB
- username: root
- password: NIfceu3fqfd
- password: `NIfceu3fqfd`
- username: librenms
- password: D42nf23rewD
- password: `D42nf23rewD`
- WebUI
- username: librenms
- password: D32fwefwef
- password: `D32fwefwef`
+14 -10
View File
@@ -33,31 +33,35 @@ Any issues with these images should be reported via [Github](https://github.com/
#### Download
[OVA Image](http://www.lathwood.co.uk/librenms/librenms_ubuntu_1604.ova) - 1.2G
[OVA Image](http://www.lathwood.co.uk/librenms/librenms_ubuntu_1604.ova) - 1.3G
- md5sum: 00fe34b925d09aa24ef05038d813e095
- md5sum: 944fcd73e918eabec7509569c2d98cf0
- sha256sum: 10c82dc30962f319bcea04838b1a46fb8dec225648c38e9aff26f9812f14d176
- sha256sum: 2a792e1d39813f0bdd510445aa04bc88e226311e825dddeb3780cf5d58bef43c
[VMDK Image](http://www.lathwood.co.uk/librenms/librenms_ubuntu_1604.vmdk) - 3.2G
[VMDK Image](http://www.lathwood.co.uk/librenms/librenms_ubuntu_1604.vmdk) - 3.3G
- md5sum: 063fbbdd506d78fa1de801d04ad0db99
- md5sum: e84e31e437e946a9a01d0c87059bfe04
- sha256sum: deccef6e62462ce905b7c423ad5da753d49d9eb5173ca2faeef27d92e970a5d2
- sha256sum: 4f687608291161ffd8f5e1aee38be1d6b9e0c2a13d15252da62fe783578f5708
#### Credentials
> Please note the second character of the SSH password is a CAPITAL EYE
- SSH
- username: librenms
- password: CIne3fwdfds
- password: `CIne3fwdfds`
> Please note the second character of the SSH password is a CAPITAL EYE
- MySQL/MariaDB
- username: root
- password: NIfceu3fqfd
- password: `NIfceu3fqfd`
- username: librenms
- password: D42nf23rewD
- password: `D42nf23rewD`
- WebUI
- username: librenms
- password: D32fwefwef
- password: `D32fwefwef`
+7 -1
View File
@@ -210,7 +210,7 @@ Disable the footer of the WebUI by setting `enable_footer` to 0.
You can enable the old style network map (only available for individual devices with links discovered via xDP) by setting:
```php
$config['gui']['network-map']['style'] = 'old';
````
```
#### Add host settings
The following setting controls how hosts are added. If a host is added as an ip address it is checked to ensure the ip is not already present. If the ip is present the host is not added.
@@ -220,6 +220,12 @@ $config['addhost_alwayscheckip'] = FALSE; #TRUE - check for duplicate ips even
#FALSE- only check when adding host by ip.
```
By default we allow hosts to be added with duplicate sysName's, you can disable this with the following config:
```php
$config['allow_duplicate_sysName'] = false;
```
#### SNMP Settings
```php
+1 -1
View File
@@ -164,7 +164,7 @@ If you see `nothing to commit, working directory clean` then let's go for it :)
Let's say that you want to test a users (f0o) new development branch (issue-1337) then you can do the following:
```bash
git remote add f0o https://github.com/librenms/librenms.git
git remote add f0o https://github.com/f0o/librenms.git
git remote update f0o
git checkout issue-1337
```
+8 -1
View File
@@ -1863,4 +1863,11 @@ label {
padding: 5px;
border-radius: 4px;
box-shadow: 0 5px 15px rgba(0,0,0,.5);
}
}
.edit-widget, .close-widget { cursor: pointer; }
.widget_body {
overflow-y: auto;
width: 100%;
height: calc(100% - 35px);
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 764 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

+1 -1
View File
@@ -1271,7 +1271,7 @@ function get_devices_by_group() {
}
else {
$group_id = dbFetchCell("SELECT `id` FROM `device_groups` WHERE `name`=?",array($name));
$devices = GetDevicesFromGroup($group_id);
$devices = GetDevicesFromGroup($group_id, true);
$count = count($devices);
if (empty($devices)) {
$message = 'No devices found in group ' . $name;
@@ -8,25 +8,25 @@ if (isset($config['auth_ad_check_certificates']) &&
putenv('LDAPTLS_REQCERT=never');
};
$ds = @ldap_connect($config['auth_ad_url']);
$ldap_connection = @ldap_connect($config['auth_ad_url']);
// disable referrals and force ldap version to 3
ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, 0);
ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3);
function authenticate($username, $password) {
global $config, $ds;
global $config, $ldap_connection;
if ($ds) {
if ($ldap_connection) {
// bind with sAMAccountName instead of full LDAP DN
if ($username && ldap_bind($ds, "{$username}@{$config['auth_ad_domain']}", $password)) {
if ($username && ldap_bind($ldap_connection, "{$username}@{$config['auth_ad_domain']}", $password)) {
// group membership in one of the configured groups is required
if (isset($config['auth_ad_require_groupmembership']) &&
$config['auth_ad_require_groupmembership'] > 0) {
$search = ldap_search($ds, $config['auth_ad_base_dn'],
$search = ldap_search($ldap_connection, $config['auth_ad_base_dn'],
"(samaccountname={$username})", array('memberOf'));
$entries = ldap_get_entries($ds, $search);
$entries = ldap_get_entries($ldap_connection, $search);
$user_authenticated = 0;
@@ -53,7 +53,7 @@ function authenticate($username, $password) {
}
}
else {
echo ldap_error($ds);
echo ldap_error($ldap_connection);
}
return 0;
@@ -108,11 +108,11 @@ function user_exists_in_db($username) {
}
function user_exists($username) {
global $config, $ds;
global $config, $ldap_connection;
$search = ldap_search($ds, $config['auth_ad_base_dn'],
$search = ldap_search($ldap_connection, $config['auth_ad_base_dn'],
"(samaccountname={$username})",array('samaccountname'));
$entries = ldap_get_entries($ds, $search);
$entries = ldap_get_entries($ldap_connection, $search);
if ($entries['count']) {
@@ -124,14 +124,14 @@ function user_exists($username) {
function get_userlevel($username) {
global $config, $ds;
global $config, $ldap_connection;
$userlevel = 0;
// Find all defined groups $username is in
$search = ldap_search($ds, $config['auth_ad_base_dn'],
$search = ldap_search($ldap_connection, $config['auth_ad_base_dn'],
"(samaccountname={$username})", array('memberOf'));
$entries = ldap_get_entries($ds, $search);
$entries = ldap_get_entries($ldap_connection, $search);
// Loop the list and find the highest level
foreach ($entries[0]['memberof'] as $entry) {
@@ -146,12 +146,12 @@ function get_userlevel($username) {
function get_userid($username) {
global $config, $ds;
global $config, $ldap_connection;
$attributes = array('objectsid');
$search = ldap_search($ds, $config['auth_ad_base_dn'],
$search = ldap_search($ldap_connection, $config['auth_ad_base_dn'],
"(samaccountname={$username})", $attributes);
$entries = ldap_get_entries($ds, $search);
$entries = ldap_get_entries($ldap_connection, $search);
if ($entries['count']) {
return preg_replace('/.*-(\d+)$/','$1',sid_from_ldap($entries[0]['objectsid'][0]));
@@ -172,7 +172,7 @@ function deluser($username) {
function get_userlist() {
global $config, $ds;
global $config, $ldap_connection;
$userlist = array();
$userhash = array();
@@ -180,14 +180,14 @@ function get_userlist() {
foreach($ldap_groups as $ldap_group) {
$group_cn = get_cn($ldap_group);
$search = ldap_search($ds, $config['auth_ad_base_dn'], "(cn={$group_cn})", array('member'));
$entries = ldap_get_entries($ds, $search);
$search = ldap_search($ldap_connection, $config['auth_ad_base_dn'], "(cn={$group_cn})", array('member'));
$entries = ldap_get_entries($ldap_connection, $search);
foreach($entries[0]['member'] as $member) {
$member_cn = get_cn($member);
$search = ldap_search($ds, $config['auth_ad_base_dn'], "(cn={$member_cn})",
$search = ldap_search($ldap_connection, $config['auth_ad_base_dn'], "(cn={$member_cn})",
array('sAMAccountname', 'displayName', 'objectSID', 'mail'));
$results = ldap_get_entries($ds, $search);
$results = ldap_get_entries($ldap_connection, $search);
foreach($results as $result) {
if(isset($result['samaccountname'][0])) {
$userid = preg_replace('/.*-(\d+)$/','$1',
@@ -235,12 +235,12 @@ function update_user($user_id, $realname, $level, $can_modify_passwd, $email) {
function get_fullname($username) {
global $config, $ds;
global $config, $ldap_connection;
$attributes = array('name');
$result = ldap_search($ds, $config['auth_ad_base_dn'],
$result = ldap_search($ldap_connection, $config['auth_ad_base_dn'],
"(samaccountname={$username})", $attributes);
$entries = ldap_get_entries($ds, $result);
$entries = ldap_get_entries($ldap_connection, $result);
if ($entries['count'] > 0) {
$membername = $entries[0]['name'][0];
}
@@ -279,13 +279,13 @@ function get_group_list() {
}
function get_dn($samaccountname) {
global $config, $ds;
global $config, $ldap_connection;
$attributes = array('dn');
$result = ldap_search($ds, $config['auth_ad_base_dn'],
$result = ldap_search($ldap_connection, $config['auth_ad_base_dn'],
"(samaccountname={$samaccountname})", $attributes);
$entries = ldap_get_entries($ds, $result);
$entries = ldap_get_entries($ldap_connection, $result);
if ($entries['count'] > 0) {
return $entries[0]['dn'];
}
@@ -0,0 +1,359 @@
<?php
if (! isset ($_SESSION['username'])) {
$_SESSION['username'] = '';
}
// Disable certificate checking before connect if required
if (isset($config['auth_ad_check_certificates']) &&
$config['auth_ad_check_certificates'] == 0) {
putenv('LDAPTLS_REQCERT=never');
};
// Set up connection to LDAP server
$ldap_connection = @ldap_connect($config['auth_ad_url']);
if (! $ldap_connection) {
echo '<h2>Fatal error while connecting to AD url ' . $config['auth_ad_url'] . ': ' . ldap_error($ldap_connection) . '</h2>';
exit;
}
// disable referrals and force ldap version to 3
ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, 0);
ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3);
// Bind to AD
if (isset($config['auth_ad_binduser']) && isset($config['auth_ad_bindpassword'])) {
// With specified bind user
if (! ldap_bind($ldap_connection, "${config['auth_ad_binduser']}@${config['auth_ad_domain']}", "${config['auth_ad_bindpassword']}")) {
echo ldap_error($ldap_connection);
}
}
else {
// Anonymous
if (! ldap_bind($ldap_connection)) {
echo ldap_error($ldap_connection);
}
}
function authenticate ($username, $password) {
global $config;
if (isset ($_SERVER['REMOTE_USER'])) {
$_SESSION['username'] = mres ($_SERVER['REMOTE_USER']);
if (user_exists ($_SESSION['username'])) {
adduser($username);
return 1;
}
$_SESSION['username'] = $config['http_auth_guest'];
return 1;
}
return 0;
}
function reauthenticate() {
// not supported so return 0
return 0;
}
function passwordscanchange() {
// not supported so return 0
return 0;
}
function changepassword() {
// not supported so return 0
return 0;
}
function auth_usermanagement() {
// not supported so return 0
return 0;
}
function adduser($username, $level=0, $email='', $realname='', $can_modify_passwd=0, $description='', $twofactor=0) {
// Check to see if user is already added in the database
if (!user_exists_in_db($username)) {
$userid = dbInsert(array('username' => $username, 'realname' => $realname, 'email' => $email, 'descr' => $description, 'level' => $level, 'can_modify_passwd' => $can_modify_passwd, 'twofactor' => $twofactor, 'user_id' => get_userid($username)), 'users');
if ($userid == false) {
return false;
}
else {
foreach (dbFetchRows('select notifications.* from notifications where not exists( select 1 from notifications_attribs where notifications.notifications_id = notifications_attribs.notifications_id and notifications_attribs.user_id = ?) order by notifications.notifications_id desc',array($userid)) as $notif) {
dbInsert(array('notifications_id'=>$notif['notifications_id'],'user_id'=>$userid,'key'=>'read','value'=>1),'notifications_attribs');
}
}
return $userid;
}
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, $ldap_connection;
if (auth_ldap_session_cache_get ('user_exists'))
return 1;
$search = ldap_search($ldap_connection, $config['auth_ad_base_dn'],
"(samaccountname=${username})",array('samaccountname'));
$entries = ldap_get_entries($ldap_connection, $search);
if ($entries['count']) {
/*
* Cache positiv result as this will result in more queries which we
* want to speed up.
*/
auth_ldap_session_cache_set ('user_exists', 1);
return 1;
}
return 0;
}
function get_userlevel($username) {
global $config, $ldap_connection;
$userlevel = auth_ldap_session_cache_get ('userlevel');
if ($userlevel) {
return $userlevel;
}
else {
$userlevel = 0;
}
// Find all defined groups $username is in
$search = ldap_search($ldap_connection, $config['auth_ad_base_dn'],
"(samaccountname={$username})", array('memberOf'));
$entries = ldap_get_entries($ldap_connection, $search);
// Loop the list and find the highest level
foreach ($entries[0]['memberof'] as $entry) {
$group_cn = get_cn($entry);
if ($config['auth_ad_groups'][$group_cn]['level'] > $userlevel) {
$userlevel = $config['auth_ad_groups'][$group_cn]['level'];
}
}
auth_ldap_session_cache_set ('userlevel', $userlevel);
return $userlevel;
}
function get_userid($username) {
global $config, $ldap_connection;
$user_id = auth_ldap_session_cache_get ('userid');
if (isset ($user_id)) {
return $user_id;
}
else {
$user_id = -1;
}
$attributes = array('objectsid');
$search = ldap_search($ldap_connection, $config['auth_ad_base_dn'],
"(samaccountname={$username})", $attributes);
$entries = ldap_get_entries($ldap_connection, $search);
if ($entries['count']) {
$user_id = preg_replace('/.*-(\d+)$/','$1',sid_from_ldap($entries[0]['objectsid'][0]));
}
auth_ldap_session_cache_set ('userid', $user_id);
return $user_id;
}
function deluser($username) {
dbDelete('bill_perms', '`user_name` = ?', array($username));
dbDelete('devices_perms', '`user_name` = ?', array($username));
dbDelete('ports_perms', '`user_name` = ?', array($username));
dbDelete('users_prefs', '`user_name` = ?', array($username));
dbDelete('users', '`user_name` = ?', array($username));
return dbDelete('users', '`username` = ?', array($username));
}
function get_userlist() {
global $config, $ldap_connection;
$userlist = array();
$userhash = array();
$ldap_groups = get_group_list();
foreach($ldap_groups as $ldap_group) {
$group_cn = get_cn($ldap_group);
$search = ldap_search($ldap_connection, $config['auth_ad_base_dn'], "(cn={$group_cn})", array('member'));
$entries = ldap_get_entries($ldap_connection, $search);
foreach($entries[0]['member'] as $member) {
$member_cn = get_cn($member);
$search = ldap_search($ldap_connection, $config['auth_ad_base_dn'], "(cn={$member_cn})",
array('sAMAccountname', 'displayName', 'objectSID', 'mail'));
$results = ldap_get_entries($ldap_connection, $search);
foreach($results as $result) {
if(isset($result['samaccountname'][0])) {
$userid = preg_replace('/.*-(\d+)$/','$1',
sid_from_ldap($result['objectsid'][0]));
// don't make duplicates, user may be member of more than one group
$userhash[$result['samaccountname'][0]] = array(
'realname' => $result['displayName'][0],
'user_id' => $userid,
'email' => $result['mail'][0]
);
}
}
}
}
foreach(array_keys($userhash) as $key) {
$userlist[] = array(
'username' => $key,
'realname' => $userhash[$key]['realname'],
'user_id' => $userhash[$key]['user_id'],
'email' => $userhash[$key]['email']
);
}
return $userlist;
}
function can_update_users() {
// not supported so return 0
return 0;
}
function get_user($user_id) {
// not supported so return 0
return dbFetchRow('SELECT * FROM `users` WHERE `user_id` = ?', array($user_id), true);
}
function update_user($user_id, $realname, $level, $can_modify_passwd, $email) {
dbUpdate(array('realname' => $realname, 'can_modify_passwd' => $can_modify_passwd, 'email' => $email), 'users', '`user_id` = ?', array($user_id));
}
function get_fullname($username) {
global $config, $ldap_connection;
$attributes = array('name');
$result = ldap_search($ldap_connection, $config['auth_ad_base_dn'],
"(samaccountname={$username})", $attributes);
$entries = ldap_get_entries($ldap_connection, $result);
if ($entries['count'] > 0) {
$membername = $entries[0]['name'][0];
}
else {
$membername = $username;
}
return $membername;
}
function get_group_list() {
global $config;
$ldap_groups = array();
// show all Active Directory Users by default
$default_group = 'Users';
if (isset($config['auth_ad_group'])) {
if ($config['auth_ad_group'] !== $default_group) {
$ldap_groups[] = $config['auth_ad_group'];
}
}
if (!isset($config['auth_ad_groups']) && !isset($config['auth_ad_group'])) {
$ldap_groups[] = get_dn($default_group);
}
foreach ($config['auth_ad_groups'] as $key => $value) {
$ldap_groups[] = get_dn($key);
}
return $ldap_groups;
}
function get_dn($samaccountname) {
global $config, $ldap_connection;
$attributes = array('dn');
$result = ldap_search($ldap_connection, $config['auth_ad_base_dn'],
"(samaccountname={$samaccountname})", $attributes);
$entries = ldap_get_entries($ldap_connection, $result);
if ($entries['count'] > 0) {
return $entries[0]['dn'];
}
else {
return '';
}
}
function get_cn($dn) {
preg_match('/[^,]*/', $dn, $matches, PREG_OFFSET_CAPTURE, 3);
return $matches[0][0];
}
function sid_from_ldap($sid)
{
$sidHex = unpack('H*hex', $sid);
$subAuths = unpack('H2/H2/n/N/V*', $sid);
$revLevel = hexdec(substr($sidHex, 0, 2));
$authIdent = hexdec(substr($sidHex, 4, 12));
return 'S-'.$revLevel.'-'.$authIdent.'-'.implode('-', $subAuths);
}
function auth_ldap_session_cache_get ($attr) {
global $config;
$ttl = 300;
if ($config['auth_ldap_cache_ttl'])
$ttl = $config['auth_ldap_cache_ttl'];
// auth_ldap cache present in this session?
if (! isset ($_SESSION['auth_ldap']))
return Null;
$cache = $_SESSION['auth_ldap'];
// $attr present in cache?
if (! isset ($cache[$attr]))
return Null;
// Value still valid?
if (time () - $cache[$attr]['last_updated'] >= $ttl)
return Null;
return $cache[$attr]['value'];
}
function auth_ldap_session_cache_set ($attr, $value) {
$_SESSION['auth_ldap'][$attr]['value'] = $value;
$_SESSION['auth_ldap'][$attr]['last_updated'] = time ();
}
@@ -45,19 +45,19 @@ if (! isset ($_SESSION['username'])) {
/**
* Set up connection to LDAP server
*/
$ds = @ldap_connect ($config['auth_ldap_server'], $config['auth_ldap_port']);
if (! $ds) {
echo '<h2>Fatal error while connecting to LDAP server ' . $config['auth_ldap_server'] . ':' . $config['auth_ldap_port'] . ': ' . ldap_error($ds) . '</h2>';
$ldap_connection = @ldap_connect ($config['auth_ldap_server'], $config['auth_ldap_port']);
if (! $ldap_connection) {
echo '<h2>Fatal error while connecting to LDAP server ' . $config['auth_ldap_server'] . ':' . $config['auth_ldap_port'] . ': ' . ldap_error($ldap_connection) . '</h2>';
exit;
}
if ($config['auth_ldap_version']) {
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $config['auth_ldap_version']);
ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, $config['auth_ldap_version']);
}
if ($config['auth_ldap_starttls'] && ($config['auth_ldap_starttls'] == 'optional' || $config['auth_ldap_starttls'] == 'require')) {
$tls = ldap_start_tls($ds);
$tls = ldap_start_tls($ldap_connection);
if ($config['auth_ldap_starttls'] == 'require' && $tls === false) {
echo '<h2>Fatal error: LDAP TLS required but not successfully negotiated:' . ldap_error($ds) . '</h2>';
echo '<h2>Fatal error: LDAP TLS required but not successfully negotiated:' . ldap_error($ldap_connection) . '</h2>';
exit;
}
}
@@ -112,14 +112,14 @@ function adduser ($username, $password, $level, $email = '', $realname = '', $ca
function user_exists ($username) {
global $config, $ds;
global $config, $ldap_connection;
if (auth_ldap_session_cache_get ('user_exists'))
return 1;
$filter = '(' . $config['auth_ldap_prefix'] . $username . ')';
$search = ldap_search ($ds, trim ($config['auth_ldap_suffix'], ','), $filter);
$entries = ldap_get_entries ($ds, $search);
$search = ldap_search ($ldap_connection, trim ($config['auth_ldap_suffix'], ','), $filter);
$entries = ldap_get_entries ($ldap_connection, $search);
if ($entries['count']) {
/*
* Cache positiv result as this will result in more queries which we
@@ -139,7 +139,7 @@ function user_exists ($username) {
function get_userlevel ($username) {
global $config, $ds;
global $config, $ldap_connection;
$userlevel = auth_ldap_session_cache_get ('userlevel');
if ($userlevel) {
@@ -150,8 +150,8 @@ function get_userlevel ($username) {
// Find all defined groups $username is in
$filter = '(&(|(cn=' . join (')(cn=', array_keys ($config['auth_ldap_groups'])) . '))(' . $config['auth_ldap_groupmemberattr'] .'=' . get_membername ($username) . '))';
$search = ldap_search ($ds, $config['auth_ldap_groupbase'], $filter);
$entries = ldap_get_entries($ds, $search);
$search = ldap_search ($ldap_connection, $config['auth_ldap_groupbase'], $filter);
$entries = ldap_get_entries($ldap_connection, $search);
// Loop the list and find the highest level
foreach ($entries as $entry) {
@@ -168,7 +168,7 @@ function get_userlevel ($username) {
function get_userid ($username) {
global $config, $ds;
global $config, $ldap_connection;
$user_id = auth_ldap_session_cache_get ('userid');
if (isset ($user_id)) {
@@ -178,8 +178,8 @@ function get_userid ($username) {
}
$filter = '(' . $config['auth_ldap_prefix'] . $username . ')';
$search = ldap_search ($ds, trim ($config['auth_ldap_suffix'], ','), $filter);
$entries = ldap_get_entries ($ds, $search);
$search = ldap_search ($ldap_connection, trim ($config['auth_ldap_suffix'], ','), $filter);
$entries = ldap_get_entries ($ldap_connection, $search);
if ($entries['count']) {
$user_id = $entries[0]['uidnumber'][0];
@@ -197,13 +197,13 @@ function deluser ($username) {
function get_userlist () {
global $config, $ds;
global $config, $ldap_connection;
$userlist = array ();
$filter = '(' . $config['auth_ldap_prefix'] . '*)';
$search = ldap_search ($ds, trim ($config['auth_ldap_suffix'], ','), $filter);
$entries = ldap_get_entries ($ds, $search);
$search = ldap_search ($ldap_connection, trim ($config['auth_ldap_suffix'], ','), $filter);
$entries = ldap_get_entries ($ldap_connection, $search);
if ($entries['count']) {
foreach ($entries as $entry) {
@@ -214,7 +214,7 @@ function get_userlist () {
$ldap_groups = get_group_list ();
foreach ($ldap_groups as $ldap_group) {
$ldap_comparison = ldap_compare(
$ds,
$ldap_connection,
$ldap_group,
$config['auth_ldap_groupmemberattr'],
get_membername($username)
@@ -256,14 +256,14 @@ function update_user ($user_id, $realname, $level, $can_modify_passwd, $email) {
function get_membername ($username) {
global $config, $ds;
global $config, $ldap_connection;
if ($config['auth_ldap_groupmembertype'] == 'fulldn') {
$membername = $config['auth_ldap_prefix'] . $username . $config['auth_ldap_suffix'];
}
elseif ($config['auth_ldap_groupmembertype'] == 'puredn') {
$filter = '(' . $config['auth_ldap_attr']['uid'] . '=' . $username . ')';
$search = ldap_search($ds, $config['auth_ldap_groupbase'], $filter);
$entries = ldap_get_entries($ds, $search);
$search = ldap_search($ldap_connection, $config['auth_ldap_groupbase'], $filter);
$entries = ldap_get_entries($ldap_connection, $search);
$membername = $entries[0]['dn'];
}
else {
+25 -25
View File
@@ -1,25 +1,25 @@
<?php
$ds = @ldap_connect($config['auth_ldap_server'], $config['auth_ldap_port']);
$ldap_connection = @ldap_connect($config['auth_ldap_server'], $config['auth_ldap_port']);
if ($config['auth_ldap_starttls'] && ($config['auth_ldap_starttls'] == 'optional' || $config['auth_ldap_starttls'] == 'require')) {
$tls = ldap_start_tls($ds);
$tls = ldap_start_tls($ldap_connection);
if ($config['auth_ldap_starttls'] == 'require' && $tls === false) {
echo '<h2>Fatal error: LDAP TLS required but not successfully negotiated:'.ldap_error($ds).'</h2>';
echo '<h2>Fatal error: LDAP TLS required but not successfully negotiated:'.ldap_error($ldap_connection).'</h2>';
exit;
}
}
function authenticate($username, $password) {
global $config, $ds;
global $config, $ldap_connection;
if ($username && $ds) {
if ($username && $ldap_connection) {
if ($config['auth_ldap_version']) {
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $config['auth_ldap_version']);
ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, $config['auth_ldap_version']);
}
if (ldap_bind($ds, $config['auth_ldap_prefix'].$username.$config['auth_ldap_suffix'], $password)) {
if (ldap_bind($ldap_connection, $config['auth_ldap_prefix'].$username.$config['auth_ldap_suffix'], $password)) {
if (!$config['auth_ldap_group']) {
return 1;
}
@@ -27,7 +27,7 @@ function authenticate($username, $password) {
$ldap_groups = get_group_list();
foreach ($ldap_groups as $ldap_group) {
$ldap_comparison = ldap_compare(
$ds,
$ldap_connection,
$ldap_group,
$config['auth_ldap_groupmemberattr'],
get_membername($username)
@@ -39,7 +39,7 @@ function authenticate($username, $password) {
}
}
else {
echo ldap_error($ds);
echo ldap_error($ldap_connection);
}
}
else {
@@ -83,11 +83,11 @@ function adduser($username, $password, $level, $email='', $realname='', $can_mod
function user_exists($username) {
global $config, $ds;
global $config, $ldap_connection;
$filter = '('.$config['auth_ldap_prefix'].$username.')';
$search = ldap_search($ds, trim($config['auth_ldap_suffix'], ','), $filter);
$entries = ldap_get_entries($ds, $search);
$search = ldap_search($ldap_connection, trim($config['auth_ldap_suffix'], ','), $filter);
$entries = ldap_get_entries($ldap_connection, $search);
if ($entries['count']) {
return 1;
}
@@ -98,14 +98,14 @@ function user_exists($username) {
function get_userlevel($username) {
global $config, $ds;
global $config, $ldap_connection;
$userlevel = 0;
// Find all defined groups $username is in
$filter = '(&(|(cn='.join(')(cn=', array_keys($config['auth_ldap_groups'])).'))('.$config['auth_ldap_groupmemberattr'].'='.get_membername($username).'))';
$search = ldap_search($ds, $config['auth_ldap_groupbase'], $filter);
$entries = ldap_get_entries($ds, $search);
$search = ldap_search($ldap_connection, $config['auth_ldap_groupbase'], $filter);
$entries = ldap_get_entries($ldap_connection, $search);
// Loop the list and find the highest level
foreach ($entries as $entry) {
@@ -121,11 +121,11 @@ function get_userlevel($username) {
function get_userid($username) {
global $config, $ds;
global $config, $ldap_connection;
$filter = '('.$config['auth_ldap_prefix'].$username.')';
$search = ldap_search($ds, trim($config['auth_ldap_suffix'], ','), $filter);
$entries = ldap_get_entries($ds, $search);
$search = ldap_search($ldap_connection, trim($config['auth_ldap_suffix'], ','), $filter);
$entries = ldap_get_entries($ldap_connection, $search);
if ($entries['count']) {
return $entries[0]['uidnumber'][0];
@@ -144,13 +144,13 @@ function deluser($username) {
function get_userlist() {
global $config, $ds;
global $config, $ldap_connection;
$userlist = array();
$filter = '('.$config['auth_ldap_prefix'].'*)';
$search = ldap_search($ds, trim($config['auth_ldap_suffix'], ','), $filter);
$entries = ldap_get_entries($ds, $search);
$search = ldap_search($ldap_connection, trim($config['auth_ldap_suffix'], ','), $filter);
$entries = ldap_get_entries($ldap_connection, $search);
if ($entries['count']) {
foreach ($entries as $entry) {
@@ -161,7 +161,7 @@ function get_userlist() {
$ldap_groups = get_group_list();
foreach ($ldap_groups as $ldap_group) {
$ldap_comparison = ldap_compare(
$ds,
$ldap_connection,
$ldap_group,
$config['auth_ldap_groupmemberattr'],
get_membername($username)
@@ -205,14 +205,14 @@ function update_user($user_id, $realname, $level, $can_modify_passwd, $email) {
function get_membername($username) {
global $config, $ds;
global $config, $ldap_connection;
if ($config['auth_ldap_groupmembertype'] == 'fulldn') {
$membername = $config['auth_ldap_prefix'].$username.$config['auth_ldap_suffix'];
}
elseif ($config['auth_ldap_groupmembertype'] == 'puredn') {
$filter = '('.$config['auth_ldap_attr']['uid'].'='.$username.')';
$search = ldap_search($ds, $config['auth_ldap_groupbase'], $filter);
$entries = ldap_get_entries($ds, $search);
$search = ldap_search($ldap_connection, $config['auth_ldap_groupbase'], $filter);
$entries = ldap_get_entries($ldap_connection, $search);
$membername = $entries[0]['dn'];
}
else {
+44 -1
View File
@@ -26,6 +26,7 @@ if(defined('show_settings')) {
$current_severity = isset($widget_settings['severity']) ? $widget_settings['severity'] : '';
$current_state = isset($widget_settings['state']) ? $widget_settings['state'] : '';
$current_group = isset($widget_settings['group']) ? $widget_settings['group'] : '';
$current_proc = isset($widget_settings['proc']) ? $widget_settings['proc'] : '';
$common_output[] = '
<form class="form" onsubmit="widget_settings(this); return false;">
@@ -94,6 +95,20 @@ if(defined('show_settings')) {
</select>
</div>
</div>
<div class="form-group row">
<div class="col-sm-4">
<label for="proc" class="control-label">Show Procedure field: </label>
</div>
<div class="col-sm-8">
<select class="form-control" name="proc">';
$common_output[] = '<option value="1"'.($current_proc == '1' ? ' selected' : ' ').'>show</option>';
$common_output[] = '<option value="0"'.($current_proc == '0' ? ' selected' : ' ').'>hide</option>';
$common_output[] = '
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
@@ -109,6 +124,7 @@ else {
$state = $widget_settings['state'];
$min_severity = $widget_settings['min_severity'];
$group = $widget_settings['group'];
$proc = $widget_settings['proc'];
$title = "Alerts";
@@ -165,7 +181,12 @@ else {
<th data-column-id="hostname">Hostname</th>
<th data-column-id="timestamp">Timestamp</th>
<th data-column-id="severity">Severity</th>
<th data-column-id="ack" data-formatter="ack" data-sortable="false">Acknowledge</th>
<th data-column-id="ack" data-formatter="ack" data-sortable="false">Acknowledge</th>';
if (is_numeric($proc)) {
if ($proc) { $common_output[] = '<th data-column-id="proc" data-formatter="proc" data-sortable="false">Procedure</th>'; }
}
else { $common_output[] = '<th data-column-id="proc" data-formatter="proc" data-sortable="false">Procedure</th>'; }
$common_output[] = '
</tr>
</thead>
</table>
@@ -192,6 +213,9 @@ var alerts_grid = $("#alerts_'.$unique_id.'").bootgrid({
if (is_numeric($group)) {
$common_output[]="group: '$group',\n";
}
if (is_numeric($proc)) {
$common_output[]="proc: '$proc',\n";
}
$common_output[]='
device_id: \'' . $device['device_id'] .'\'
@@ -204,6 +228,9 @@ var alerts_grid = $("#alerts_'.$unique_id.'").bootgrid({
},
"ack": function(column,row) {
return "<button type=\'button\' class=\'btn btn-"+row.ack_col+" btn-sm command-ack-alert\' data-target=\'#ack-alert\' data-state=\'"+row.state+"\' data-alert_id=\'"+row.alert_id+"\' name=\'ack-alert\' id=\'ack-alert\' data-extra=\'"+row.extra+"\'><span class=\'glyphicon glyphicon-"+row.ack_ico+"\'aria-hidden=\'true\'></span></button>";
},
"proc": function(column,row) {
return "<button type=\'button\' class=\'btn command-open-proc\' data-alert_id=\'"+row.alert_id+"\' name=\'open-proc\' id=\'open-proc\'>Open</button>";
}
},
templates: {
@@ -230,6 +257,22 @@ var alerts_grid = $("#alerts_'.$unique_id.'").bootgrid({
}
});
});
alerts_grid.find(".command-open-proc").on("click", function(e) {
e.preventDefault();
var alert_id = $(this).data("alert_id");
$.ajax({
type: "POST",
url: "ajax_form.php",
data: { type: "open-proc", alert_id: alert_id },
success: function(msg){
if (msg != "ERROR") { window.open(msg); }
else { $("#message").html(\'<div class="alert alert-info">Procedure link does not seem to be valid, please check the rule.</div>\'); }
},
error: function(){
$("#message").html(\'<div class="alert alert-info">An error occurred opening procedure for this alert. Does the procedure link was configured ?</div>\');
}
});
});
alerts_grid.find(".command-ack-alert").on("click", function(e) {
e.preventDefault();
var alert_id = $(this).data("alert_id");
@@ -15,7 +15,7 @@ if (defined('show_settings')) {
$current_mode = isset($widget_settings['mode']) ? $widget_settings['mode'] : 0;
$current_width = isset($widget_settings['tile_width']) ? $widget_settings['tile_width'] : 10;
$common_output[] = '
<form class="form-horizontal" onsubmit="widget_settings(this); return false;">
<form class="form-horizontal" onsubmit="return widget_settings(this)">
<div class="form-group">
<label for="tile_width" class="col-sm-4 control-label">Tile width</label>
<div class="col-sm-6">
+1 -1
View File
@@ -58,5 +58,5 @@ if( defined('show_settings') || empty($widget_settings) ) {
}
else {
$widget_settings['title'] = $widget_settings['image_title'];
$common_output[] = '<a target="_blank" href="'.$widget_settings['target_url'].'"><img class="minigraph-image" width="'.$widget_dimensions['x'].'" height="'.$widget_dimensions['y'].'" src="'.$widget_settings['image_url'].'"/></a>';
$common_output[] = '<a target="_blank" href="'.$widget_settings['target_url'].'"><img class="minigraph-image" style="max-width: '.$widget_dimensions['x'].'px; max-height:'.$widget_dimensions['y'].'px;" src="'.$widget_settings['image_url'].'"/></a>';
}
+1 -1
View File
@@ -116,7 +116,7 @@ $tmp_output .= '
range: "' . mres($_POST['range']) . '"
};
},
url: "/ajax_table.php",
url: "ajax_table.php",
});
</script>
+5 -3
View File
@@ -19,19 +19,21 @@ if (!is_numeric($alert_id)) {
echo 'ERROR: No alert selected';
exit;
}
else if (!is_numeric($state)) {
elseif (!is_numeric($state)) {
echo 'ERROR: No state passed';
exit;
}
else {
if ($state == 2) {
$state = dbFetchCell('SELECT alerted FROM alerts WHERE id = ?', array($alert_id));
$open = 1;
}
else if ($state >= 1) {
elseif ($state >= 1) {
$state = 2;
$open = 1;
}
if (dbUpdate(array('state' => $state), 'alerts', 'id=?', array($alert_id)) >= 0) {
if (dbUpdate(array('state' => $state, 'open' => $open), 'alerts', 'id=?', array($alert_id)) >= 0) {
echo 'Alert acknowledged status changed.';
exit;
}
@@ -26,6 +26,8 @@ $interval = mres($_POST['interval']);
$mute = mres($_POST['mute']);
$invert = mres($_POST['invert']);
$name = mres($_POST['name']);
if ($_POST['proc'] != "") { $proc = $_POST['proc']; }
else { $proc = ""; }
if (empty($rule)) {
$update_message = 'ERROR: No rule was generated - did you forget to click and / or?';
@@ -61,7 +63,7 @@ else if (validate_device_id($_POST['device_id']) || $_POST['device_id'] == '-1'
);
$extra_json = json_encode($extra);
if (is_numeric($alert_id) && $alert_id > 0) {
if (dbUpdate(array('rule' => $rule, 'severity' => mres($_POST['severity']), 'extra' => $extra_json, 'name' => $name), 'alert_rules', 'id=?', array($alert_id)) >= 0) {
if (dbUpdate(array('rule' => $rule, 'severity' => mres($_POST['severity']), 'extra' => $extra_json, 'name' => $name, 'proc' => $proc), 'alert_rules', 'id=?', array($alert_id)) >= 0) {
$update_message = "Edited Rule: <i>$name: $rule</i>";
}
else {
@@ -73,7 +75,7 @@ else if (validate_device_id($_POST['device_id']) || $_POST['device_id'] == '-1'
$device_id = ':'.$device_id;
}
if (dbInsert(array('device_id' => $device_id, 'rule' => $rule, 'severity' => mres($_POST['severity']), 'extra' => $extra_json, 'disabled' => 0, 'name' => $name), 'alert_rules')) {
if (dbInsert(array('device_id' => $device_id, 'rule' => $rule, 'severity' => mres($_POST['severity']), 'extra' => $extra_json, 'disabled' => 0, 'name' => $name, 'proc' => $proc), 'alert_rules')) {
$update_message = "Added Rule: <i>$name: $rule</i>";
if (is_array($_POST['maps'])) {
foreach ($_POST['maps'] as $target) {
@@ -16,6 +16,8 @@ if (is_admin() === false) {
die('ERROR: You need to be admin');
}
require_once '../includes/device-groups.inc.php';
$pattern = $_POST['patterns'];
$group_id = $_POST['group_id'];
$name = mres($_POST['name']);
@@ -38,7 +40,7 @@ if (empty($pattern)) {
$update_message = 'ERROR: No group was generated';
}
else if (is_numeric($group_id) && $group_id > 0) {
if (dbUpdate(array('pattern' => $pattern, 'name' => $name, 'desc' => $desc), 'device_groups', 'id=?', array($group_id)) >= 0) {
if (EditDeviceGroup($group_id, $name, $desc, $pattern)) {
$update_message = "Edited Group: <i>$name: $pattern</i>";
}
else {
@@ -46,7 +48,7 @@ else if (is_numeric($group_id) && $group_id > 0) {
}
}
else {
if (dbInsert(array('pattern' => $pattern, 'name' => $name, 'desc' => $desc), 'device_groups')) {
if (AddDeviceGroup($name, $desc, $pattern)) {
$update_message = "Added Group: <i>$name: $pattern</i>";
}
else {
+27
View File
@@ -0,0 +1,27 @@
<?php
/*
* LibreNMS
*
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk/fa>
*
* 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.
*/
# header('Content-type: text/plain');
$alert_id = $_POST['alert_id'];
if (!is_numeric($alert_id)) {
echo 'ERROR: No alert selected';
exit;
}
else {
$proc = dbFetchCell('SELECT proc FROM alerts,alert_rules WHERE alert_rules.id = alerts.rule_id AND alerts.id = ?', array($alert_id));
if (($proc == "") || ($proc == "NULL")) { echo header("HTTP/1.0 404 Not Found"); }
else if (! preg_match ('/^http:\/\//', $proc)) { echo "ERROR"; }
else { echo $proc; }
exit;
}
@@ -28,6 +28,7 @@ if (is_numeric($alert_id) && $alert_id > 0) {
'severity' => $rule['severity'],
'extra' => $rule['extra'],
'name' => $rule['name'],
'proc' => $rule['proc'],
'rules' => $rule_split,
);
header('Content-type: application/json');
+1 -1
View File
@@ -37,7 +37,7 @@ else {
$widget_settings = array();
}
if (dbFetchCell('select 1 from users_widgets inner join dashboards on users_widgets.dashboard_id = dashboards.dashboard_id where user_widget_id = ? && (users_widgets.user_id = ? || dashboards.access = 2)',array($widget_id,$_SESSION['user_id'])) == 1) {
if (dbUpdate(array('settings'=>json_encode($widget_settings)),'users_widgets','user_widget_id=?',array($widget_id))) {
if (dbUpdate(array('settings'=>json_encode($widget_settings)),'users_widgets','user_widget_id=?',array($widget_id)) >= 0) {
$status = 'ok';
$message = 'Updated';
}
@@ -0,0 +1,29 @@
<?php
/**
* rrdcached.inc.php
*
* Generate the rrd file and verify it is valid
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
$rrd = rrd_name($device['hostname'], array('app', 'rrdcached', $app['app_id']));
if (is_file($rrd)) {
$rrd_filename = $rrd;
}
@@ -0,0 +1,54 @@
<?php
/**
* rrdcached_events.inc.php
*
* Generates a combined graph of events for rrdcached
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
include 'rrdcached.inc.php';
$nototal = 1;
$colours = 'mixed';
$rrd_list = array(
array (
'ds' => 'updates_written',
'filename' => $rrd_filename,
'descr' => 'Updates Written',
),
array (
'ds' => 'data_sets_written',
'filename' => $rrd_filename,
'descr' => 'Data Sets Written',
),
array(
'ds' => 'updates_received',
'filename' => $rrd_filename,
'descr' => 'Updates Received',
),
array (
'ds' => 'flushes_received',
'filename' => $rrd_filename,
'descr' => 'Flushes Received',
),
);
require 'includes/graphs/generic_multi_line.inc.php';
@@ -0,0 +1,43 @@
<?php
/**
* rrdcached_journal.inc.php
*
* Generates a graph of journal stats for rrdcached
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
include 'rrdcached.inc.php';
$colours = 'pinks';
$rrd_list = array(
array(
'ds' => 'journal_rotate',
'filename' => $rrd_filename,
'descr' => 'Journal Rotated',
),
array(
'ds' => 'journal_bytes',
'filename' => $rrd_filename,
'descr' => 'Journal Bytes Written',
)
);
require 'includes/graphs/generic_multi.inc.php';
@@ -0,0 +1,37 @@
<?php
/**
* rrdcached_queue_length.inc.php
*
* Generates a graph of the queue length for rrdcached
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
require 'rrdcached.inc.php';
require 'includes/graphs/common.inc.php';
$ds = 'queue_length';
$colour_area = 'F37900';
$colour_line = 'FFA700';
$colour_area_max = 'F78800';
$unit_text = 'Queue Length';
require 'includes/graphs/generic_simplex.inc.php';
@@ -0,0 +1,43 @@
<?php
/**
* rrdcached_tree.inc.php
*
* Generates a graph of the tree stats for rrdcached
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
include 'rrdcached.inc.php';
$colours = 'blues';
$rrd_list = array(
array(
'ds' => 'tree_depth',
'filename' => $rrd_filename,
'descr' => 'Tree Depth',
),
array(
'ds' => 'tree_nodes_number',
'filename' => $rrd_filename,
'descr' => 'Tree Nodes',
)
);
require 'includes/graphs/generic_multi.inc.php';
@@ -0,0 +1,44 @@
<?php
require 'includes/graphs/common.inc.php';
$pallette = array(
1 => 'FF0000',
2 => '0000FF',
3 => '00FF00',
4 => 'FF00FF',
5 => '000000',
6 => 'FFFF00',
7 => 'C0C0C0',
8 => '800000',
9 => '808000',
10 => '008000',
11 => '00FFFF',
12 => '008080',
13 => '000080',
14 => '800080',
15 => 'FF69B4',
16 => '006400'
);
$rrd_options .= ' -l 0 -E ';
$rrd_options .= " COMMENT:'Average Data Rate Cur Min Max\\n'";
$radioId=1;
foreach(glob($config['rrd_dir'].'/'.$device['hostname'].'/xirrus_stats-*.rrd') as $rrd) {
// get radio name
preg_match("/xirrus_stats-iap([0-9]{1,2}).rrd/", $rrd, $out);
list(,$radioId)=$out;
// build graph
$color=$pallette[$radioId];
$descr = "iap$radioId ";
$rrd_options .= " DEF:rate$radioId=$rrd:dataRate:AVERAGE";
$rrd_options .= " LINE2:rate$radioId#".$color.":'".$descr."'";
$rrd_options .= " GPRINT:rate$radioId:LAST:'%5.0lf'";
$rrd_options .= " GPRINT:rate$radioId:MIN:'%5.0lf'";
$rrd_options .= " GPRINT:rate$radioId:MAX:'%5.0lf'\\l";
$radioId++;
}//end foreach
@@ -0,0 +1,44 @@
<?php
require 'includes/graphs/common.inc.php';
$pallette = array(
1 => 'FF0000',
2 => '0000FF',
3 => '00FF00',
4 => 'FF00FF',
5 => '000000',
6 => 'FFFF00',
7 => 'C0C0C0',
8 => '800000',
9 => '808000',
10 => '008000',
11 => '00FFFF',
12 => '008080',
13 => '000080',
14 => '800080',
15 => 'FF69B4',
16 => '006400'
);
$rrd_options .= ' -E ';
$rrd_options .= " COMMENT:'Noisefloor Cur Min Max\\n'";
$radioId=1;
foreach(glob($config['rrd_dir'].'/'.$device['hostname'].'/xirrus_stats-*.rrd') as $rrd) {
// get radio name
preg_match("/xirrus_stats-iap([0-9]{1,2}).rrd/", $rrd, $out);
list(,$radioId)=$out;
// build graph
$color=$pallette[$radioId];
$descr = "iap$radioId ";
$rrd_options .= " DEF:noise$radioId=$rrd:noiseFloor:AVERAGE";
$rrd_options .= " LINE2:noise$radioId#".$color.":'".$descr."'";
$rrd_options .= " GPRINT:noise$radioId:LAST:'%5.0lf'";
$rrd_options .= " GPRINT:noise$radioId:MIN:'%5.0lf'";
$rrd_options .= " GPRINT:noise$radioId:MAX:'%5.0lf'\\l";
$radioId++;
}//end foreach
@@ -0,0 +1,44 @@
<?php
require 'includes/graphs/common.inc.php';
$pallette = array(
1 => 'FF0000',
2 => '0000FF',
3 => '00FF00',
4 => 'FF00FF',
5 => '000000',
6 => 'FFFF00',
7 => 'C0C0C0',
8 => '800000',
9 => '808000',
10 => '008000',
11 => '00FFFF',
12 => '008080',
13 => '000080',
14 => '800080',
15 => 'FF69B4',
16 => '006400'
);
$rrd_options .= ' -E ';
$rrd_options .= " COMMENT:'Signal RSSI Cur Min Max\\n'";
$radioId=1;
foreach(glob($config['rrd_dir'].'/'.$device['hostname'].'/xirrus_stats-*.rrd') as $rrd) {
// get radio name
preg_match("/xirrus_stats-iap([0-9]{1,2}).rrd/", $rrd, $out);
list(,$radioId)=$out;
// build graph
$color=$pallette[$radioId];
$descr = "iap$radioId ";
$rrd_options .= " DEF:rssi$radioId=$rrd:rssi:AVERAGE";
$rrd_options .= " LINE2:rssi$radioId#".$color.":'".$descr."'";
$rrd_options .= " GPRINT:rssi$radioId:LAST:'%5.0lf'";
$rrd_options .= " GPRINT:rssi$radioId:MIN:'%5.0lf'";
$rrd_options .= " GPRINT:rssi$radioId:MAX:'%5.0lf'\\l";
$radioId++;
}//end foreach
@@ -0,0 +1,44 @@
<?php
require 'includes/graphs/common.inc.php';
$pallette = array(
1 => '001080',
2 => '043D85',
3 => '096C8A',
4 => '0F8F84',
5 => '159461',
6 => '1B9A3E',
7 => '279F22',
8 => '56A429',
9 => '83A930',
10 => 'AEAE38',
11 => 'B48E40',
12 => 'B97049',
13 => 'BE5552',
14 => 'C35B79',
15 => 'C864A1',
16 => 'CE6FC7'
);
$rrd_options .= ' -l 0 -E ';
$rrd_options .= " COMMENT:'Associated Stations Cur Min Max\\n'";
$radioId=1;
foreach(glob($config['rrd_dir'].'/'.$device['hostname'].'/xirrus_users-*.rrd') as $rrd) {
// get radio name
preg_match("/xirrus_users-iap([0-9]{1,2}).rrd/", $rrd, $out);
list(,$radioId)=$out;
// build graph
$color=$pallette[$radioId];
$descr = "iap$radioId ";
$rrd_options .= " DEF:stations$radioId=$rrd:stations:AVERAGE";
$rrd_options .= " AREA:stations$radioId#".$color.":'".$descr."':STACK";
$rrd_options .= " GPRINT:stations$radioId:LAST:'%5.0lf'";
$rrd_options .= " GPRINT:stations$radioId:MIN:'%5.0lf'";
$rrd_options .= " GPRINT:stations$radioId:MAX:'%5.0lf'\\l";
$radioId++;
}//end foreach
@@ -87,14 +87,14 @@ if ($i) {
// $rrd_options .= " LINE1.25:dout".$format."#".$colour_line_out.":";
}
else {
$rrd_options .= ' AREA:in'.$format.'#'.$colour_area_in.':';
$rrd_options .= " COMMENT:'bps Now Ave Max 95th %\\n'";
$rrd_options .= ' AREA:in'.$format.'#'.$colour_area_in.':In ';
// $rrd_options .= " LINE1.25:in".$format."#".$colour_line_in.":In\ ";
$rrd_options .= ' GPRINT:in'.$format.':LAST:%6.2lf%s';
$rrd_options .= ' GPRINT:in'.$format.':AVERAGE:%6.2lf%s';
$rrd_options .= ' GPRINT:in'.$format.':MAX:%6.2lf%s';
$rrd_options .= " GPRINT:95thin:%6.2lf%s\\\\n";
$rrd_options .= ' AREA:dout'.$format.'#'.$colour_area_out.':';
$rrd_options .= ' AREA:dout'.$format.'#'.$colour_area_out.':Out';
// $rrd_options .= " LINE1.25:dout".$format."#".$colour_line_out.":Out";
$rrd_options .= ' GPRINT:out'.$format.':LAST:%6.2lf%s';
$rrd_options .= ' GPRINT:out'.$format.':AVERAGE:%6.2lf%s';
+6 -2
View File
@@ -69,7 +69,7 @@ if(is_admin() === false) {
</span><br /><br />
<span><strong>Placeholders:</strong><br />
<?php
$placeholders = array('hostname','title','elapsed','id','uid','faults','state','severity','rule','timestamp','contacts','key','value','new line');
$placeholders = array('hostname', 'sysName', 'location', 'title','elapsed','id','uid','faults','state','severity','rule','timestamp','contacts','key','value','new line');
foreach ($placeholders as $placeholder) {
echo ' <button type="button" class="btn btn-success btn-sm" data-target="#placeholder-add" id="placeholder-add" name="placeholder-add" data-type="placeholder" data-value="'.$placeholder.'">'.$placeholder.'</button>';
}
@@ -102,9 +102,10 @@ $('#alert-template').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
var template_id = button.data('template_id');
var action = button.data('template_action');
$('#template').val();
$('#template').val('');
$('#line').val('');
$('#value').val('');
$('#name').val('');
if(action == 'edit') {
$('#template_id').val(template_id);
$.ajax({
@@ -121,6 +122,9 @@ $('#alert-template').on('show.bs.modal', function (event) {
});
}
});
$('#alert-template').on('hide.bs.modal', function(event) {
$('#template_id').val('');
});
$('#create-template').click('', function(e) {
e.preventDefault();
@@ -134,6 +134,12 @@ if(is_admin() !== false) {
</div>
</div>
</div>
<div class='form-group'>
<label for='proc' class='col-sm-3 control-label'>Procedure URL: </label>
<div class='col-sm-9'>
<input type='text' id='proc' name='proc' class='form-control' maxlength='30'>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-3">
<button class="btn btn-success btn-sm" type="submit" name="rule-submit" id="rule-submit" value="save">Save Rule</button>
@@ -219,6 +225,7 @@ $('#create-alert').on('show.bs.modal', function (event) {
$("[name='mute']").bootstrapSwitch('state',extra['mute']);
$("[name='invert']").bootstrapSwitch('state',extra['invert']);
$('#name').val(output['name']);
$('#proc').val(output['proc']);
}
});
});
+38 -21
View File
@@ -32,10 +32,10 @@ if (is_admin() === false && is_read() === false) {
$sql_array[] = $_SESSION['user_id'];
}
$tmp_devices = array();
$tmp_ids = array();
$tmp_links = array();
$tmp_link_ids = array();
$devices_by_id = array();
$links = array();
$link_assoc_seen = array();
$device_assoc_seen = array();
$ports = array();
$devices = array();
@@ -74,12 +74,15 @@ if (in_array('mac',$config['network_map_items'])) {
`P2`.`ifOperStatus` AS `remote_ifoperstatus`,
`P2`.`ifAdminStatus` AS `remote_ifadminstatus`,
`P2`.`ifInOctets_rate` AS `remote_ifinoctets_rate`,
`P2`.`ifOutOctets_rate` AS `remote_ifoutoctets_rate`
`P2`.`ifOutOctets_rate` AS `remote_ifoutoctets_rate`,
SUM(IF(`P2_ip`.`ipv4_address` = `M`.`ipv4_address`, 1, 0))
AS `remote_matching_ips`
FROM `ipv4_mac` AS `M`
LEFT JOIN `ports` AS `P1` ON `P1`.`port_id`=`M`.`port_id`
LEFT JOIN `ports` AS `P2` ON `P2`.`ifPhysAddress`=`M`.`mac_address`
LEFT JOIN `devices` AS `D1` ON `P1`.`device_id`=`D1`.`device_id`
LEFT JOIN `devices` AS `D2` ON `P2`.`device_id`=`D2`.`device_id`
LEFT JOIN `ipv4_addresses` AS `P2_ip` ON `P2_ip`.`port_id` = `P2`.`port_id`
$join_sql
WHERE
`M`.`mac_address` NOT IN ('000000000000','ffffffffffff') AND
@@ -89,6 +92,7 @@ if (in_array('mac',$config['network_map_items'])) {
$where
$sql
GROUP BY `P1`.`port_id`,`P2`.`port_id`
ORDER BY `remote_matching_ips` DESC, `local_ifname`, `remote_ifname`
", $sql_array);
}
@@ -131,11 +135,14 @@ if (in_array('xdp', $config['network_map_items'])) {
$where
$sql
GROUP BY `P1`.`port_id`,`P2`.`port_id`
ORDER BY `local_ifname`, `remote_ifname`
", $sql_array);
}
$list = array_merge($ports,$devices);
// Iterate though ports and links, generating a set of devices (nodes)
// and links (edges) that make up the topology graph.
foreach ($list as $items) {
$local_device = array('device_id'=>$items['local_device_id'], 'os'=>$items['local_os'], 'hostname'=>$items['local_hostname']);
$remote_device = array('device_id'=>$items['remote_device_id'], 'os'=>$items['remote_os'], 'hostname'=>$items['remote_hostname']);
@@ -143,14 +150,16 @@ foreach ($list as $items) {
$local_port = array('port_id'=>$items['local_port_id'],'device_id'=>$items['local_port_device_id'],'ifName'=>$items['local_ifname'],'ifSpeed'=>$items['local_ifspeed'],'ifOperStatus'=>$items['local_ifoperstatus'],'ifAdminStatus'=>$items['local_adminstatus']);
$remote_port = array('port_id'=>$items['remote_port_id'],'device_id'=>$items['remote_port_device_id'],'ifName'=>$items['remote_ifname'],'ifSpeed'=>$items['remote_ifspeed'],'ifOperStatus'=>$items['remote_ifoperstatus'],'ifAdminStatus'=>$items['remote_adminstatus']);
if (!in_array($items['local_device_id'],$tmp_ids)) {
$tmp_devices[] = array('id'=>$items['local_device_id'],'label'=>$items['local_hostname'],'title'=>generate_device_link($local_device,'',array(),'','','',0),'shape'=>'box');
$local_device_id = $items['local_device_id'];
if (!array_key_exists($local_device_id, $devices_by_id)) {
$devices_by_id[$local_device_id] = array('id'=>$local_device_id,'label'=>$items['local_hostname'],'title'=>generate_device_link($local_device,'',array(),'','','',0),'shape'=>'box');
}
array_push($tmp_ids,$items['local_device_id']);
if (!in_array($items['remote_device_id'],$tmp_ids)) {
$tmp_devices[] = array('id'=>$items['remote_device_id'],'label'=>$items['remote_hostname'],'title'=>generate_device_link($remote_device,'',array(),'','','',0),'shape'=>'box');
$remote_device_id = $items['remote_device_id'];
if (!array_key_exists($remote_device_id, $devices_by_id)) {
$devices_by_id[$remote_device_id] = array('id'=>$remote_device_id,'label'=>$items['remote_hostname'],'title'=>generate_device_link($remote_device,'',array(),'','','',0),'shape'=>'box');
}
array_push($tmp_ids,$items['remote_device_id']);
$speed = $items['local_ifspeed']/1000/1000;
if ($speed == 100) {
$width = 3;
@@ -183,22 +192,30 @@ foreach ($list as $items) {
$link_used = 100;
}
$link_color = $config['network_map_legend'][$link_used];
$id1 = $items['local_port_id'].':'.$items['remote_port_id'];
$id2 = $items['remote_port_id'].':'.$items['local_port_id'];
if (!in_array($id1,$tmp_link_ids) || !in_array($id2,$tmp_link_ids)) {
$link_id1 = $items['local_port_id'].':'.$items['remote_port_id'];
$link_id2 = $items['remote_port_id'].':'.$items['local_port_id'];
$device_id1 = $items['local_device_id'].':'.$items['remote_device_id'];
$device_id2 = $items['remote_device_id'].':'.$items['local_device_id'];
// Ensure only one link exists between any two ports, or any two devices.
if (!array_key_exists($link_id1, $link_assoc_seen) &&
!array_key_exists($link_id2, $link_assoc_seen) &&
!array_key_exists($device_id1, $device_assoc_seen) &&
!array_key_exists($device_id2, $device_assoc_seen)) {
$local_port = ifNameDescr($local_port);
$remote_port = ifNameDescr($remote_port);
$tmp_links[] = array('from'=>$items['local_device_id'],'to'=>$items['remote_device_id'],'label'=>shorten_interface_type($local_port['ifName']) . ' > ' . shorten_interface_type($remote_port['ifName']),'title'=>generate_port_link($local_port, "<img src='graph.php?type=port_bits&amp;id=".$items['local_port_id']."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=100&amp;height=20&amp;legend=no&amp;bg=".str_replace("#","", $row_colour)."'>\n",'',0,1),'width'=>$width,'color'=>$link_color);
$links[] = array('from'=>$items['local_device_id'],'to'=>$items['remote_device_id'],'label'=>shorten_interface_type($local_port['ifName']) . ' > ' . shorten_interface_type($remote_port['ifName']),'title'=>generate_port_link($local_port, "<img src='graph.php?type=port_bits&amp;id=".$items['local_port_id']."&amp;from=".$config['time']['day']."&amp;to=".$config['time']['now']."&amp;width=100&amp;height=20&amp;legend=no&amp;bg=".str_replace("#","", $row_colour)."'>\n",'',0,1),'width'=>$width,'color'=>$link_color);
}
array_push($tmp_link_ids,$id1);
array_push($tmp_link_ids,$id2);
$link_assoc_seen[$link_id1] = 1;
$link_assoc_seen[$link_id2] = 1;
$device_assoc_seen[$device_id1] = 1;
$device_assoc_seen[$device_id2] = 1;
}
$node_devices = $tmp_devices;
$nodes = json_encode($node_devices);
$edges = json_encode($tmp_links);
$nodes = json_encode(array_values($devices_by_id));
$edges = json_encode($links);
if (count($node_devices) > 1 && count($tmp_links) > 0) {
if (count($devices_by_id) > 1 && count($links) > 0) {
?>
+1 -1
View File
@@ -100,7 +100,7 @@ if ($rowCount != -1) {
$sql .= " LIMIT $limit_low,$limit_high";
}
$sql = "SELECT `alerts`.*, `devices`.`hostname` AS `hostname`, `devices`.`sysName` AS `sysName`,`alert_rules`.`rule` AS `rule`, `alert_rules`.`name` AS `name`, `alert_rules`.`severity` AS `severity` $sql";
$sql = "SELECT `alerts`.*, `devices`.`hostname`, `devices`.`sysName`, `devices`.`hardware`, `devices`.`location`, `alert_rules`.`rule`, `alert_rules`.`name`, `alert_rules`.`severity` $sql";
$rulei = 0;
$format = $_POST['format'];
+1 -1
View File
@@ -87,7 +87,7 @@ if (!empty($_POST['group'])) {
$sql .= ' AND ( ';
foreach (GetDevicesFromGroup($_POST['group']) as $dev) {
$sql .= '`devices`.`device_id` = ? OR ';
$param[] = $dev['device_id'];
$param[] = $dev;
}
$sql = substr($sql, 0, (strlen($sql) - 3));
+3 -3
View File
@@ -13,11 +13,11 @@
*/
if (empty($_SERVER['PATH_INFO'])) {
if( strstr($_SERVER['SERVER_SOFTWARE'],"nginx") ) {
$_SERVER['PATH_INFO'] = str_replace($_SERVER['PATH_TRANSLATED'].$_SERVER['PHP_SELF'],"",$_SERVER['ORIG_SCRIPT_FILENAME']);
if( strstr($_SERVER['SERVER_SOFTWARE'],"nginx") && isset($_SERVER['PATH_TRANSLATED']) && isset($_SERVER['ORIG_SCRIPT_FILENAME']) ) {
$_SERVER['PATH_INFO'] = str_replace($_SERVER['PATH_TRANSLATED'] . $_SERVER['PHP_SELF'], "", $_SERVER['ORIG_SCRIPT_FILENAME']);
}
else {
$_SERVER['PATH_INFO'] = !empty($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : '';
$_SERVER['PATH_INFO'] = isset($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : '';
}
}
+2 -2
View File
@@ -36,7 +36,7 @@ if (!$_SESSION['authenticated']) {
$output = '';
if ($_GET['query'] && $_GET['cmd']) {
$host = $_GET['query'];
if (Net_IPv6::checkIPv6($host) || Net_IPv4::validateip($host) || preg_match('/^[a-zA-Z0-9.-]*$/', $host)) {
if (Net_IPv6::checkIPv6($host) || Net_IPv4::validateip($host) || filter_var('http://'.$host, FILTER_VALIDATE_URL)) {
switch ($_GET['cmd']) {
case 'whois':
$cmd = $config['whois']." $host | grep -v \%";
@@ -66,5 +66,5 @@ if ($_GET['query'] && $_GET['cmd']) {
}//end if
}//end if
$output = trim($output);
$output = htmlentities(trim($output), ENT_QUOTES);
echo "<pre>$output</pre>";
+1 -1
View File
@@ -44,7 +44,7 @@ if (is_array($config['branding'])) {
}
}
if (isset($_GET['device'])) {
if (is_numeric($_GET['device']) && isset($_GET['device'])) {
$where = 'WHERE device_id = '.mres($_GET['device']);
}
else {
+4 -8
View File
@@ -16,15 +16,11 @@ else {
}
}
if ($handle = opendir($config['nagios_plugins'])) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..' && !strstr($file, '.') && strstr($file, 'check_')) {
list(,$check_name) = explode('_',$file,2);
$servicesform .= "<option value='$check_name'>$check_name</option>";
}
foreach (scandir($config['nagios_plugins']) as $file) {
if (substr($file, 0, 6) === 'check_') {
$check_name = substr($file, 6);
$servicesform .= "<option value='$check_name'>$check_name</option>";
}
closedir($handle);
}
foreach (dbFetchRows('SELECT * FROM `devices` ORDER BY `hostname`') as $device) {
+7
View File
@@ -33,6 +33,13 @@ $graphs['nginx'] = array(
'req',
);
$graphs['rrdcached'] = array(
'queue_length',
'events',
'tree',
'journal'
);
$graphs['bind'] = array('queries');
$graphs['tinydns'] = array(
+1 -1
View File
@@ -29,6 +29,6 @@ $pagetitle[] = 'Customers';
id: "customers",
};
},
url: "/ajax_table.php"
url: "ajax_table.php"
});
</script>
+52
View File
@@ -0,0 +1,52 @@
<?php
/**
* rrdcached.inc.php
*
* Shows the graphs for rrdcached apps
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
global $config;
$graphs = array(
'rrdcached_queue_length' => 'Queue Length',
'rrdcached_events' => 'Events',
'rrdcached_tree' => 'Tree',
'rrdcached_journal' => 'Journal',
);
foreach ($graphs as $key => $text) {
$graph_array['height'] = '100';
$graph_array['width'] = '215';
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = 'application_'.$key;
echo '<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">'.$text.'</h3>
</div>
<div class="panel-body">
<div class="row">';
include 'includes/print-graphrow.inc.php';
echo '</div>';
echo '</div>';
echo '</div>';
}
+3 -7
View File
@@ -2,14 +2,10 @@
<?php
// Load our list of available applications
if ($handle = opendir($config['install_dir'].'/includes/polling/applications/')) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..' && strstr($file, '.inc.php')) {
$applications[] = str_replace('.inc.php', '', $file);
}
foreach (scandir($config['install_dir'].'/includes/polling/applications/') as $file) {
if (substr($file, -8) == '.inc.php') {
$applications[] = substr($file, 0, -8);
}
closedir($handle);
}
// Check if the form was POSTed
+2 -2
View File
@@ -67,7 +67,7 @@
event.preventDefault();
$.ajax({
type: "POST",
url: "/ajax_form.php",
url: "ajax_form.php",
data: $('form#components').serialize(),
dataType: "json",
success: function(data){
@@ -97,6 +97,6 @@
device_id: "<?php echo $device['device_id']; ?>"
};
},
url: "/ajax_table.php"
url: "ajax_table.php"
});
</script>
+6 -2
View File
@@ -18,7 +18,9 @@
</tr>
<?php
foreach ($config['poller_modules'] as $module => $module_status) {
$poller_modules = $config['poller_modules'];
ksort($poller_modules);
foreach ($poller_modules as $module => $module_status) {
echo('
<tr>
<td><strong>'.$module.'</strong></td>
@@ -86,7 +88,9 @@ foreach ($config['poller_modules'] as $module => $module_status) {
<?php
foreach ($config['discovery_modules'] as $module => $module_status) {
$discovery_modules = $config['discovery_modules'];
ksort($discovery_modules);
foreach ($discovery_modules as $module => $module_status) {
echo('
<tr>
<td>
+4 -7
View File
@@ -14,14 +14,11 @@ if (is_admin() === true || is_read() === true) {
}
// Build the types list.
if ($handle = opendir($config['nagios_plugins'])) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..' && !strstr($file, '.') && strstr($file, 'check_')) {
list(,$check_name) = explode('_',$file,2);
$servicesform .= "<option value='$check_name'>$check_name</option>";
}
foreach (scandir($config['nagios_plugins']) as $file) {
if (substr($file, 0, 6) === 'check_') {
$check_name = substr($file, 6);
$servicesform .= "<option value='$check_name'>$check_name</option>";
}
closedir($handle);
}
$dev = device_by_id_cache($device['device_id']);
+1 -1
View File
@@ -92,7 +92,7 @@ echo "
</select>
</div>
<div class='col-sm-2'>
<input type='text' name='port' placeholder='port' class='form-control input-sm'>
<input type='text' name='port' placeholder='port' class='form-control input-sm' value='".($device['port'] == $config['snmp']['port'] ? "" : $device['port'])."'>
</div>
<div class='col-sm-1'>
<select name='transport' id='transport' class='form-control input-sm'>";
+2 -2
View File
@@ -40,7 +40,7 @@
device_id: <?php echo $device['device_id']; ?>,
};
},
url: "/ajax_table.php",
url: "ajax_table.php",
formatters: {
"perc_update": function(column,row) {
return "<div class='form-group'><input type='text' class='form-control input-sm storage' data-device_id='<?php echo $device['device_id']; ?>' data-storage_id='"+row.storage_id+"' value='"+row.storage_perc_warn+"'></div>";
@@ -58,7 +58,7 @@
var $this = $(this);
$.ajax({
type: 'POST',
url: '/ajax_form.php',
url: 'ajax_form.php',
data: {type: "storage-update", device_id: device_id, data: data, storage_id: storage_id},
dataType: "json",
success: function (data) {
+2 -2
View File
@@ -61,7 +61,7 @@ if (is_module_enabled('poller', 'mib')) {
device_id: '<?php echo htmlspecialchars($device['device_id']); ?>',
};
},
url: "/ajax_table.php",
url: "ajax_table.php",
formatters: {
},
templates: {
@@ -80,7 +80,7 @@ if (is_module_enabled('poller', 'mib')) {
device_id: '<?php echo htmlspecialchars($device['device_id']); ?>',
};
},
url: "/ajax_table.php",
url: "ajax_table.php",
formatters: {
},
templates: {
+25 -5
View File
@@ -103,10 +103,30 @@ if (is_admin()) {
}
}
else if ($config['oxidized']['enabled'] === true && isset($config['oxidized']['url'])) {
// Try with hostname as set in librenms first
$oxidized_hostname = $device['hostname'];
// fetch info about the node and then a list of versions for that node
$node_info = json_decode(file_get_contents($config['oxidized']['url'].'/node/show/'.$device['hostname'].'?format=json'), true);
$node_info = json_decode(file_get_contents($config['oxidized']['url'].'/node/show/'.$oxidized_hostname.'?format=json'), true);
// Try other hostname format if Oxidized request failed
if (! $node_info) {
// Adjust hostname based on whether domain was already in it or not
if (strpos($oxidized_hostname, '.') !== false) {
// Use short name
$oxidized_hostname = strtok($device['hostname'], '.');
}
elseif($config['mydomain']) {
$oxidized_hostname = $device['hostname'].'.'.$config['mydomain'];
}
// Try Oxidized again with new hostname, if it has changed
if ($oxidized_hostname != $device['hostname']) {
$node_info = json_decode(file_get_contents($config['oxidized']['url'].'/node/show/'.$oxidized_hostname.'?format=json'), true);
}
}
if ($config['oxidized']['features']['versioning'] === true) { // fetch a list of versions
$config_versions = json_decode(file_get_contents($config['oxidized']['url'].'/node/version?node_full='.(isset($node_info['full_name']) ? $node_info['full_name'] : $device['hostname']).'&format=json'), true);
$config_versions = json_decode(file_get_contents($config['oxidized']['url'].'/node/version?node_full='.(isset($node_info['full_name']) ? $node_info['full_name'] : $oxidized_hostname).'&format=json'), true);
}
$config_total = 1;
@@ -147,7 +167,7 @@ if (is_admin()) {
}
if (isset($previous_config)) {
$url = $config['oxidized']['url'].'/node/version/diffs?node='.$device['hostname'].'&group=';
$url = $config['oxidized']['url'].'/node/version/diffs?node='.$oxidized_hostname.'&group=';
if (!empty($node_info['group'])) {
$url .= $node_info['group'];
}
@@ -156,11 +176,11 @@ if (is_admin()) {
$text = file_get_contents($url); // fetch diff
} else {
// fetch current_version
$text = file_get_contents($config['oxidized']['url'].'/node/version/view?node='.$device['hostname'].'&group='.(!empty($node_info['group']) ? $node_info['group'] : '').'&oid='.$current_config['oid'].'&date='.urlencode($current_config['date']).'&num='.$current_config['version'].'&format=text');
$text = file_get_contents($config['oxidized']['url'].'/node/version/view?node='.$oxidized_hostname.'&group='.(!empty($node_info['group']) ? $node_info['group'] : '').'&oid='.$current_config['oid'].'&date='.urlencode($current_config['date']).'&num='.$current_config['version'].'&format=text');
}
}
else { // just fetch the only version
$text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.(!empty($node_info['group']) ? $node_info['group'].'/' : '').$device['hostname']);
$text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.(!empty($node_info['group']) ? $node_info['group'].'/' : '').$oxidized_hostname);
}
+1 -1
View File
@@ -200,7 +200,7 @@ if($format == "graph") {
$where .= " AND ( ";
foreach( GetDevicesFromGroup($vars['group']) as $dev ) {
$where .= "device_id = ? OR ";
$sql_param[] = $dev['device_id'];
$sql_param[] = $dev;
}
$where = substr($where, 0, strlen($where)-3);
$where .= " )";
+6 -5
View File
@@ -169,7 +169,7 @@ foreach (array('Private','Shared (Read)','Shared') as $k=>$v) {
<ul class="dropdown-menu">
<?php
foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widgets) {
echo ' <li><a href="javascript:return false;" name="place_widget" data-widget_id="'.$widgets['widget_id'] .'">'. $widgets['widget_title'] .'</a></li>';
echo ' <li><a href="#" onsubmit="return false;" class="place_widget" data-widget_id="'.$widgets['widget_id'] .'">'. $widgets['widget_title'] .'</a></li>';
}
?>
</ul>
@@ -316,7 +316,7 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg
});
});
$('a[name="place_widget"]').on('click', function(event, state) {
$('.place_widget').on('click', function(event, state) {
var widget_id = $(this).data('widget_id');
$.ajax({
type: 'POST',
@@ -458,11 +458,11 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg
'<header class="widget_header"><span id="widget_title_'+data.user_widget_id+'">'+data.title+
'</span>'+
'<span class="fade-edit pull-right">'+
'<a href="javascript:return false;" class="fa fa-pencil-square-o edit-widget" data-widget-id="'+data.user_widget_id+'" aria-label="Settings" data-toggle="tooltip" data-placement="top" title="Settings">&nbsp;</a>&nbsp;'+
'<a href="javascript:return false;" class="text-danger fa fa-times close-widget" data-widget-id="'+data.user_widget_id+'" aria-label="Close" data-toggle="tooltip" data-placement="top" title="Remove">&nbsp;</a>&nbsp;'+
'<i class="fa fa-pencil-square-o edit-widget" data-widget-id="'+data.user_widget_id+'" aria-label="Settings" data-toggle="tooltip" data-placement="top" title="Settings">&nbsp;</i>&nbsp;'+
'<i class="text-danger fa fa-times close-widget" data-widget-id="'+data.user_widget_id+'" aria-label="Close" data-toggle="tooltip" data-placement="top" title="Remove">&nbsp;</i>&nbsp;'+
'</span>'+
'</header>'+
'<div class="widget_body" id="widget_body_'+data.user_widget_id+'" style="height: 100%; width:100%;">'+data.widget+'</div>'+
'<div class="widget_body" id="widget_body_'+data.user_widget_id+'">'+data.widget+'</div>'+
'\<script\>var timeout'+data.user_widget_id+' = grab_data('+data.user_widget_id+','+data.refresh+',\''+data.widget+'\');\<\/script\>'+
'</li>';
if (data.hasOwnProperty('col') && data.hasOwnProperty('row')) {
@@ -506,6 +506,7 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg
}
});
}
return false;
}
function widget_reload(id,data_type) {
+1 -1
View File
@@ -41,7 +41,7 @@ if (is_module_enabled('poller', 'mib')) {
id: "device_mibs",
};
},
url: "/ajax_table.php",
url: "ajax_table.php",
formatters: {
},
templates: {
+1 -1
View File
@@ -47,7 +47,7 @@ if (is_module_enabled('poller', 'mib')) {
view: '<?php echo $vars['view']; ?>'
};
},
url: "/ajax_table.php",
url: "ajax_table.php",
formatters: {
},
templates: {
+12 -6
View File
@@ -21,6 +21,7 @@
* @subpackage Alerts
*/
// loop through each room
foreach($opts as $option) {
$url = $option['url'];
foreach($obj as $key=>$value) {
@@ -36,20 +37,25 @@ foreach($opts as $option) {
$option["message_format"] = 'text';
}
// Sane default of making the message color green if the message indicates
// that the alert recovered. If it rebooted, make it yellow.
if(stripos($obj["msg"], "recovered")) {
$color = "green";
} elseif(stripos($obj["msg"], "rebooted")) {
$color = "yellow";
} else {
$color = $option["color"];
}
$data[] = "message=".urlencode($obj["msg"]);
$data[] = "room_id=".urlencode($option["room_id"]);
$data[] = "from=".urlencode($option["from"]);
$data[] = "color=".urlencode($option["color"]);
$data[] = "color=".urlencode($color);
$data[] = "notify=".urlencode($option["notify"]);
$data[] = "message_format=".urlencode($option["message_format"]);
$data = implode('&', $data);
// Sane default of making the message color green if the message indicates
// that the alert recovered.
if(strstr($data["message"], "recovered")) {
$data["color"] = "green";
}
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, true);
+5 -4
View File
@@ -23,9 +23,6 @@
foreach( $opts as $tmp_api ) {
$host = $tmp_api['url'];
foreach( $obj as $k=>$v ) {
$api = str_replace("%".$k,$method == "get" ? urlencode($v) : $v, $api);
}
$curl = curl_init();
$data = array(
'text' => $obj['msg'],
@@ -34,11 +31,15 @@ foreach( $opts as $tmp_api ) {
'icon_url' => $tmp_api['icon_url'],
'icon_emoji' => $tmp_api['icon_emoji'],
);
$alert_message = "payload=" . json_encode($data);
$alert_message = json_encode($data);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json')
);
curl_setopt($curl, CURLOPT_URL, $host);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST,true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $alert_message );
$ret = curl_exec($curl);
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if( $code != 200 ) {
+7
View File
@@ -793,6 +793,10 @@ $config['dateformat']['mysql']['time'] = '%H:%i:%s';
$config['enable_clear_discovery'] = 1;
// Set this to 0 if you want to disable the web option to rediscover devices
$config['force_ip_to_sysname'] = false;// Set to true if you want to use sysName in place of IPs
// Allow duplicate devices by sysName
$config['allow_duplicate_sysName'] = true;// Set to false if you want to only allow unique sysName's
$config['enable_port_relationship'] = true;
// Set this to false to not display neighbour relationships for ports
$config['enable_footer'] = 1;
@@ -876,3 +880,6 @@ $config['ignore_unmapable_port'] = False;
$config['influxdb']['timeout'] = 0;
$config['influxdb']['verifySSL'] = false;
// Xirrus - Disable station/client polling if true as it may take a long time on larger/heavily used APs.
$config['xirrus_disable_stations'] = false;
+119 -3
View File
@@ -268,6 +268,13 @@ $config['os'][$os]['over'][1]['text'] = 'Processor Usage';
$config['os'][$os]['over'][2]['graph'] = 'device_mempool';
$config['os'][$os]['over'][2]['text'] = 'Memory Usage';
$os = 'buffalo';
$config['os'][$os]['text'] = 'Buffalo';
$config['os'][$os]['type'] = 'storage';
$config['os'][$os]['icon'] = 'buffalo';
$config['os'][$os]['over'][0]['graph'] = 'device_bits';
$config['os'][$os]['over'][0]['text'] = 'Device Traffic';
// Other Unix-based OSes here please.
$os = 'freebsd';
$config['os'][$os]['type'] = 'server';
@@ -358,6 +365,15 @@ $config['os'][$os]['icon'] = 'barracuda';
$config['os'][$os]['over'][0]['graph'] = 'device_bits';
$config['os'][$os]['over'][0]['text'] = 'Traffic';
$os = 'barracudangfirewall';
$config['os'][$os]['text'] = 'Barracuda NG Firewall';
$config['os'][$os]['type'] = 'firewall';
$config['os'][$os]['icon'] = 'barracuda';
$config['os'][$os]['over'][0]['graph'] = 'device_bits';
$config['os'][$os]['over'][0]['text'] = 'Traffic';
// Calix
$os = 'calix';
$config['os'][$os]['text'] = 'Calix E7';
@@ -726,6 +742,17 @@ $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 = 'swos';
$config['os'][$os]['text'] = 'Mikrotik SwOS';
$config['os'][$os]['type'] = 'network';
$config['os'][$os]['nobulk'] = 1;
$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 = 'bintec-smart';
$config['os'][$os]['text'] = 'Bintec Smart Router';
$config['os'][$os]['type'] = 'network';
@@ -922,6 +949,8 @@ $config['os'][$os]['text'] = 'Dell EqualLogic';
$config['os'][$os]['icon'] = 'dell';
$config['os'][$os]['over'][0]['graph'] = 'device_bits';
$config['os'][$os]['over'][0]['text'] = 'Device Traffic';
$config['os'][$os]['over'][1]['graph'] = 'device_storage';
$config['os'][$os]['over'][1]['text'] = 'Storage Usage';
$os = 'drac';
$config['os'][$os]['text'] = 'Dell DRAC';
@@ -1027,6 +1056,17 @@ $config['os'][$os]['text'] = 'Blade Network Technologies';
$config['os'][$os]['type'] = 'network';
$config['os'][$os]['icon'] = 'bnt';
$os = 'ibm-imm';
$config['os'][$os]['text'] = 'IBM IMM';
$config['os'][$os]['type'] = 'appliance';
$config['os'][$os]['icon'] = 'ibmnos';
$config['os'][$os]['over'][0]['graph'] = 'device_bits';
$config['os'][$os]['over'][0]['text'] = '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 = 'ibmnos';
$config['os'][$os]['text'] = 'IBM Networking Operating System';
$config['os'][$os]['type'] = 'network';
@@ -1041,6 +1081,13 @@ $config['os'][$os]['icon'] = 'generic';
$config['os'][$os]['over'][0]['graph'] = 'device_bits';
$config['os'][$os]['over'][0]['text'] = 'Traffic';
$os = 'informos';
$config['os'][$os]['text'] = 'HPE 3PAR';
$config['os'][$os]['type'] = 'storage';
$config['os'][$os]['icon'] = 'hp';
$config['os'][$os]['over'][0]['graph'] = 'device_bits';
$config['os'][$os]['over'][0]['text'] = 'Traffic';
$os = 'comware';
$config['os'][$os]['text'] = 'HP Comware';
$config['os'][$os]['type'] = 'network';
@@ -1365,6 +1412,13 @@ $config['os'][$os]['over'][0]['graph'] = 'device_current';
$config['os'][$os]['over'][0]['text'] = 'Current';
$config['os'][$os]['icon'] = 'servertech';
$os = 'sentry4';
$config['os'][$os]['text'] = 'ServerTech Sentry4';
$config['os'][$os]['type'] = 'power';
$config['os'][$os]['over'][0]['graph'] = 'device_current';
$config['os'][$os]['over'][0]['text'] = 'Current';
$config['os'][$os]['icon'] = 'servertech';
$os = 'raritan';
$config['os'][$os]['text'] = 'Raritan PDU';
$config['os'][$os]['type'] = 'power';
@@ -1583,6 +1637,18 @@ $config['os'][$os]['icon'] = 'generic';
$config['os'][$os]['over'][0]['graph'] = 'device_bits';
$config['os'][$os]['over'][0]['text'] = 'Traffic';
// HP Blade Management
$os = 'hpblmos';
$config['os'][$os]['text'] = 'HP Blade Management';
$config['os'][$os]['type'] = 'appliance';
$config['os'][$os]['icon'] = 'hp';
$config['os'][$os]['over'][0]['graph'] = 'device_bits';
$config['os'][$os]['over'][0]['text'] = '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';
// HP MSM
$os = 'hpmsm';
$config['os'][$os]['text'] = 'HP MSM';
@@ -1616,10 +1682,18 @@ $config['os'][$os]['over'][0]['graph'] = 'device_bits';
$config['os'][$os]['over'][0]['text'] = 'Traffic';
// HWGroup Poseidon
$os = 'poseidon';
$config['os'][$os]['text'] = 'Poseidon';
$os = 'hwg-poseidon';
$config['os'][$os]['text'] = 'HWg Poseidon';
$config['os'][$os]['type'] = 'environment';
$config['os'][$os]['icon'] = 'poseidon';
$config['os'][$os]['icon'] = 'hwg-poseidon';
$config['os'][$os]['over'][0]['graph'] = 'device_bits';
$config['os'][$os]['over'][0]['text'] = 'Traffic';
// HWGroup STE
$os = 'hwg-ste';
$config['os'][$os]['text'] = 'HWg STE';
$config['os'][$os]['type'] = 'environment';
$config['os'][$os]['icon'] = 'hwg';
$config['os'][$os]['over'][0]['graph'] = 'device_bits';
$config['os'][$os]['over'][0]['text'] = 'Traffic';
@@ -1648,6 +1722,18 @@ $config['os'][$os]['text'] = 'Infoblox';
$config['os'][$os]['type'] = 'appliance';
$config['os'][$os]['icon'] = 'infoblox';
// Oracle ILOM
$os = 'oracle-ilom';
$config['os'][$os]['text'] = 'Oracle ILOM';
$config['os'][$os]['type'] = 'appliance';
$config['os'][$os]['icon'] = 'oracle';
$config['os'][$os]['over'][0]['graph'] = 'device_bits';
$config['os'][$os]['over'][0]['text'] = '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';
// Lenovo EMC (NAS)
$os = 'lenovoemc';
$config['os'][$os]['type'] = 'storage';
@@ -1669,6 +1755,21 @@ $config['os'][$os]['icon'] = 'deliberant';
$config['os'][$os]['over'][0]['graph'] = 'device_bits';
$config['os'][$os]['over'][0]['text'] = 'Device Traffic';
// Xirrus AP
$os = 'xirrus_aos';
$config['os'][$os]['text'] = 'Xirrus ArrayOS';
$config['os'][$os]['type'] = 'wireless';
$config['os'][$os]['icon'] = 'xirrus';
$config['os'][$os]['over'][0]['graph'] = 'device_bits';
$config['os'][$os]['over'][0]['text'] = 'Device Traffic';
$config['os'][$os]['over'][1]['graph'] = 'device_xirrus_stations';
$config['os'][$os]['over'][1]['text'] = 'Wifi Clients';
$config['os'][$os]['over'][2]['graph'] = 'device_xirrus_rssi';
$config['os'][$os]['over'][2]['text'] = 'Signal RSSI';
// Graph Types
require_once $config['install_dir'].'/includes/load_db_graph_types.inc.php';
@@ -2142,6 +2243,21 @@ $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';
$config['graph_types']['device']['xirrus_rssi']['section'] = 'wireless';
$config['graph_types']['device']['xirrus_rssi']['order'] = '0';
$config['graph_types']['device']['xirrus_rssi']['descr'] = 'Signal Rssi';
$config['graph_types']['device']['xirrus_dataRates']['section'] = 'wireless';
$config['graph_types']['device']['xirrus_dataRates']['order'] = '0';
$config['graph_types']['device']['xirrus_dataRates']['descr'] = 'Average DataRates';
$config['graph_types']['device']['xirrus_noiseFloor']['section'] = 'wireless';
$config['graph_types']['device']['xirrus_noiseFloor']['order'] = '0';
$config['graph_types']['device']['xirrus_noiseFloor']['descr'] = 'Noise Floor';
$config['graph_types']['device']['xirrus_stations']['section'] = 'wireless';
$config['graph_types']['device']['xirrus_stations']['order'] = '0';
$config['graph_types']['device']['xirrus_stations']['descr'] = 'Associated Stations';
// Device Types
$i = 0;
+151 -11
View File
@@ -18,13 +18,59 @@
/**
* Device-Grouping
* @author Daniel Preussker <f0o@devilcode.org>
* @copyright 2015 f0o, LibreNMS
* @author Tony Murray <murrayotony@gmail.com>
* @copyright 2016 f0o, murrant, LibreNMS
* @license GPL
* @package LibreNMS
* @subpackage Devices
*/
/**
* Add a new device group
* @param $pattern
* @param $name
* @param $desc
* @return int|string
*/
function AddDeviceGroup($name, $desc, $pattern)
{
$group_id = dbInsert(array('name' => $name, 'desc' => $desc, 'pattern' => $pattern), 'device_groups');
if ($group_id) {
UpdateDeviceGroup($group_id);
}
return $group_id;
}
/**
* Update a device group
* @param $group_id
* @param $pattern
* @param $name
* @param $desc
* @return bool
*/
function EditDeviceGroup($group_id, $name = null, $desc = null, $pattern = null)
{
$vars = array();
if (!is_null($name)) {
$vars['name'] = $name;
}
if (!is_null($desc)) {
$vars['desc'] = $desc;
}
if (!is_null($pattern)) {
$vars['pattern'] = $pattern;
}
$success = dbUpdate($vars, 'device_groups', 'id=?', array($group_id)) >= 0;
if ($success) {
UpdateDeviceGroup($group_id);
}
return $success;
}
/**
* Generate SQL from Group-Pattern
* @param string $pattern Pattern to generate SQL for
@@ -77,22 +123,38 @@ function GenGroupSQL($pattern, $search='',$extra=0) {
/**
* Get all devices of Group
* Run the group queries again to get fresh list of devices for this group
* @param integer $group_id Group-ID
* @return string
*/
function GetDevicesFromGroup($group_id) {
$pattern = dbFetchCell('SELECT pattern FROM device_groups WHERE id = ?', array($group_id));
function QueryDevicesFromGroup($group_id)
{
$pattern = dbFetchCell('SELECT pattern FROM device_groups WHERE id = ?', array($group_id));
$pattern = rtrim($pattern, '&&');
$pattern = rtrim($pattern, '||');
if (!empty($pattern)) {
return dbFetchRows(GenGroupSQL($pattern));
return dbFetchColumn(GenGroupSQL($pattern));
}
return false;
}//end GetDevicesFromGroup()
}//end QueryDevicesFromGroup()
/**
* Get an array of all the device ids belonging to this group_id
* @param $group_id
* @param bool $nested Return an array of arrays containing 'device_id'. (for API compatibility)
* @return array
*/
function GetDevicesFromGroup($group_id, $nested = false)
{
$query = 'SELECT `device_id` FROM `device_group_device` WHERE `device_group_id`=?';
if ($nested) {
return dbFetchRows($query, array($group_id));
} else {
return dbFetchColumn($query, array($group_id));
}
}//end GetDevicesFromGroup()
/**
* Get all Device-Groups
@@ -104,14 +166,15 @@ function GetDeviceGroups() {
}//end GetDeviceGroups()
/**
* Get all groups of Device
* @param integer $device Device-ID
* Run the group queries again to get fresh list of groups for this device
* @param integer $device_id Device-ID
* @param int $extra Return extra info about the groups (name, desc, pattern)
* @return array
*/
function GetGroupsFromDevice($device,$extra=0) {
function QueryGroupsFromDevice($device_id,$extra=0) {
$ret = array();
foreach (GetDeviceGroups() as $group) {
if (dbFetchCell(GenGroupSQL($group['pattern'], 'device_id=?',$extra).' LIMIT 1', array($device)) == $device) {
if (dbFetchCell(GenGroupSQL($group['pattern'], 'device_id=?',$extra).' LIMIT 1', array($device_id)) == $device_id) {
if ($extra === 0) {
$ret[] = $group['id'];
}
@@ -123,7 +186,24 @@ function GetGroupsFromDevice($device,$extra=0) {
return $ret;
}//end GetGroupsFromDevice()
}//end QueryGroupsFromDevice()
/**
* Get the Device Group IDs of a Device from the database
* @param $device_id
* @param int $extra Return extra info about the groups (name, desc, pattern)
* @return array
*/
function GetGroupsFromDevice($device_id, $extra = 0)
{
$ret = array();
if ($extra === 0) {
$ret = dbFetchColumn('SELECT `device_group_id` FROM `device_group_device` WHERE `device_id`=?', array($device_id));
} else {
$ret = dbFetchRows('SELECT `device_groups`.* FROM `device_group_device` LEFT JOIN `device_groups` ON `device_group_device`.`device_group_id`=`device_groups`.`id` WHERE `device_group_device`.`device_id`=?', array($device_id));
}
return $ret;
}//end GetGroupsFromDeviceDB()
/**
* Process Macros
@@ -148,3 +228,63 @@ function RunGroupMacros($rule,$x=1) {
}
return $rule;
}//end RunGroupMacros()
/**
* Update device-group relationship for the given device id
* @param $device_id
*/
function UpdateGroupsForDevice($device_id)
{
global $debug;
$debug = true;
$queried_groups = QueryGroupsFromDevice($device_id);
$db_groups = GetGroupsFromDevice($device_id);
// compare the arrays to get the added and removed groups
$added_groups = array_diff($queried_groups, $db_groups);
$removed_groups = array_diff($db_groups, $queried_groups);
// insert new groups
$insert = array();
foreach ($added_groups as $group_id) {
$insert[] = array('device_id' => $device_id, 'device_group_id' => $group_id);
}
if (!empty($insert)) {
dbBulkInsert($insert, 'device_group_device');
}
// remove old groups
if (!empty($removed_groups)) {
dbDelete('device_group_device', '`device_id`=? AND `device_group_id` IN (?)', array($device_id, array(implode(',', $removed_groups))));
}
}
/**
* Update the device-group relationship for the given group id
* @param $group_id
*/
function UpdateDeviceGroup($group_id)
{
$queried_devices = QueryDevicesFromGroup($group_id);
$db_devices = GetDevicesFromGroup($group_id);
// compare the arrays to get the added and removed devices
$added_devices = array_diff($queried_devices, $db_devices);
$removed_devices = array_diff($db_devices, $queried_devices);
// insert new devices
$insert = array();
foreach ($added_devices as $device_id) {
$insert[] = array('device_id' => $device_id, 'device_group_id' => $group_id);
}
if (!empty($insert)) {
dbBulkInsert($insert, 'device_group_device');
}
// remove old devices
if (!empty($removed_devices)) {
dbDelete('device_group_device', '`device_group_id`=? AND `device_id` IN (?)', array($group_id, array(implode(',', $removed_devices))));
}
}
+208 -197
View File
@@ -1,234 +1,245 @@
<?php
if ($config['enable_bgp']) {
// Discover BGP peers
echo 'BGP Sessions : ';
if( key_exists('vrf_lite_cisco', $device) && (count($device['vrf_lite_cisco'])!=0) ){
$vrfs_lite_cisco = $device['vrf_lite_cisco'];
}
else{
$vrfs_lite_cisco = array(array('context_name'=>null));
}
$bgpLocalAs = trim(snmp_walk($device, '.1.3.6.1.2.1.15.2', '-Oqvn', 'BGP4-MIB', $config['mibdir']));
if (is_numeric($bgpLocalAs)) {
echo "AS$bgpLocalAs ";
if ($bgpLocalAs != $device['bgpLocalAs']) {
dbUpdate(array('bgpLocalAs' => $bgpLocalAs), 'devices', 'device_id=?', array($device['device_id']));
echo 'Updated AS ';
}
$peer2 = false;
$peers_data = snmp_walk($device, 'cbgpPeer2RemoteAs', '-Oq', 'CISCO-BGP4-MIB', $config['mibdir']);
if (empty($peers_data)) {
$peers_data = snmp_walk($device, 'BGP4-MIB::bgpPeerRemoteAs', '-Oq', 'BGP4-MIB', $config['mibdir']);
}
else {
$peer2 = true;
}
d_echo("Peers : $peers_data \n");
$peers = trim(str_replace('CISCO-BGP4-MIB::cbgpPeer2RemoteAs.', '', $peers_data));
$peers = trim(str_replace('BGP4-MIB::bgpPeerRemoteAs.', '', $peers));
foreach (explode("\n", $peers) as $peer) {
if ($peer2 === true) {
list($ver, $peer) = explode('.', $peer, 2);
}
list($peer_ip, $peer_as) = explode(' ', $peer);
if (strstr($peer_ip, ':')) {
$peer_ip_snmp = preg_replace('/:/', ' ', $peer_ip);
$peer_ip = preg_replace('/(\S+\s+\S+)\s/', '$1:', $peer_ip_snmp);
$peer_ip = str_replace('"', '', str_replace(' ', '', $peer_ip));
}
if ($peer && $peer_ip != '0.0.0.0') {
d_echo("Found peer $peer_ip (AS$peer_as)\n");
$peerlist[] = array(
'ip' => $peer_ip,
'as' => $peer_as,
'ver' => $ver,
);
}
}
if ($device['os'] == 'junos') {
// Juniper BGP4-V2 MIB
// FIXME: needs a big cleanup! also see below.
// FIXME: is .0.ipv6 the only possible value here?
$result = snmp_walk($device, 'jnxBgpM2PeerRemoteAs.0.ipv6', '-Onq', 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos');
$peers = trim(str_replace('.1.3.6.1.4.1.2636.5.1.1.2.1.1.1.13.0.', '', $result));
foreach (explode("\n", $peers) as $peer) {
list($peer_ip_snmp, $peer_as) = explode(' ', $peer);
// Magic! Basically, takes SNMP form and finds peer IPs from the walk OIDs.
$peer_ip = Net_IPv6::compress(snmp2ipv6(implode('.', array_slice(explode('.', $peer_ip_snmp), (count(explode('.', $peer_ip_snmp)) - 16)))));
if ($peer) {
d_echo("Found peer $peer_ip (AS$peer_as)\n");
$peerlist[] = array(
'ip' => $peer_ip,
'as' => $peer_as,
);
}
}
}
}
else {
echo 'No BGP on host';
if ($device['bgpLocalAs']) {
dbUpdate(array('bgpLocalAs' => 'NULL'), 'devices', 'device_id=?', array($device['device_id']));
echo ' (Removed ASN) ';
}
}
// Process disovered peers
if (isset($peerlist)) {
foreach ($peerlist as $peer) {
$astext = get_astext($peer['as']);
if (dbFetchCell('SELECT COUNT(*) from `bgpPeers` WHERE device_id = ? AND bgpPeerIdentifier = ?', array($device['device_id'], $peer['ip'])) < '1') {
$add = dbInsert(array('device_id' => $device['device_id'], 'bgpPeerIdentifier' => $peer['ip'], 'bgpPeerRemoteAs' => $peer['as']), 'bgpPeers');
if ($config['autodiscovery']['bgp'] === true) {
$name = gethostbyaddr($peer['ip']);
$remote_device_id = discover_new_device($name, $device, 'BGP');
foreach ($vrfs_lite_cisco as $vrf) {
$device['context_name'] = $vrf['context_name'];
if (is_numeric($bgpLocalAs)) {
echo "AS$bgpLocalAs ";
if ($bgpLocalAs != $device['bgpLocalAs']) {
dbUpdate(array('bgpLocalAs' => $bgpLocalAs), 'devices', 'device_id=?', array($device['device_id']));
echo 'Updated AS ';
}
echo '+';
}
else {
$update = dbUpdate(array('bgpPeerRemoteAs' => $peer['as'], 'astext' => mres($astext)), 'bgpPeers', 'device_id=? AND bgpPeerIdentifier=?', array($device['device_id'], $peer['ip']));
echo '.';
}
$peer2 = false;
$peers_data = snmp_walk($device, 'cbgpPeer2RemoteAs', '-Oq', 'CISCO-BGP4-MIB', $config['mibdir']);
if (empty($peers_data)) {
$peers_data = snmp_walk($device, 'BGP4-MIB::bgpPeerRemoteAs', '-Oq', 'BGP4-MIB', $config['mibdir']);
}
else {
$peer2 = true;
}
if ($device['os_group'] == 'cisco' || $device['os'] == 'junos') {
if ($device['os_group'] == 'cisco') {
// Get afi/safi and populate cbgp on cisco ios (xe/xr)
unset($af_list);
d_echo("Peers : $peers_data \n");
$peers = trim(str_replace('CISCO-BGP4-MIB::cbgpPeer2RemoteAs.', '', $peers_data));
$peers = trim(str_replace('BGP4-MIB::bgpPeerRemoteAs.', '', $peers));
foreach (explode("\n", $peers) as $peer) {
if ($peer2 === true) {
$af_data = snmpwalk_cache_oid($device, 'cbgpPeer2AddrFamilyEntry', $cbgp, 'CISCO-BGP4-MIB', $config['mibdir']);
}
else {
$af_data = snmpwalk_cache_oid($device, 'cbgpPeerAddrFamilyEntry', $cbgp, 'CISCO-BGP4-MIB', $config['mibdir']);
list($ver, $peer) = explode('.', $peer, 2);
}
d_echo('afi data :: ');
d_echo($af_data);
list($peer_ip, $peer_as) = explode(' ', $peer);
if (strstr($peer_ip, ':')) {
$peer_ip_snmp = preg_replace('/:/', ' ', $peer_ip);
$peer_ip = preg_replace('/(\S+\s+\S+)\s/', '$1:', $peer_ip_snmp);
$peer_ip = str_replace('"', '', str_replace(' ', '', $peer_ip));
}
foreach ($af_data as $k => $v) {
if ($peer2 === true) {
list(,$k) = explode('.', $k, 2);
}
if ($peer && $peer_ip != '0.0.0.0') {
d_echo("Found peer $peer_ip (AS$peer_as)\n");
d_echo("AFISAFI = $k\n");
$afisafi_tmp = explode('.', $k);
$safi = array_pop($afisafi_tmp);
$afi = array_pop($afisafi_tmp);
$bgp_ip = str_replace(".$afi.$safi", '', $k);
$bgp_ip = preg_replace('/:/', ' ', $bgp_ip);
$bgp_ip = preg_replace('/(\S+\s+\S+)\s/', '$1:', $bgp_ip);
$bgp_ip = str_replace('"', '', str_replace(' ', '', $bgp_ip));
if ($afi && $safi && $bgp_ip == $peer['ip']) {
$af_list[$bgp_ip][$afi][$safi] = 1;
if (dbFetchCell('SELECT COUNT(*) from `bgpPeers_cbgp` WHERE device_id = ? AND bgpPeerIdentifier = ?, AND afi=? AND safi=?', array($device['device_id'], $peer['ip'], $afi, $safi)) == 0) {
dbInsert(array('device_id' => $device['device_id'], 'bgpPeerIdentifier' => $peer['ip'], 'afi' => $afi, 'safi' => $safi), 'bgpPeers_cbgp');
}
}
$peerlist[] = array(
'ip' => $peer_ip,
'as' => $peer_as,
'ver' => $ver,
);
}
}
if ($device['os'] == 'junos') {
$safis[1] = 'unicast';
$safis[2] = 'multicast';
// Juniper BGP4-V2 MIB
// FIXME: needs a big cleanup! also see below.
// FIXME: is .0.ipv6 the only possible value here?
$result = snmp_walk($device, 'jnxBgpM2PeerRemoteAs.0.ipv6', '-Onq', 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos');
$peers = trim(str_replace('.1.3.6.1.4.1.2636.5.1.1.2.1.1.1.13.0.', '', $result));
foreach (explode("\n", $peers) as $peer) {
list($peer_ip_snmp, $peer_as) = explode(' ', $peer);
if (!isset($j_peerIndexes)) {
$j_bgp = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PeerTable', $jbgp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos');
// Magic! Basically, takes SNMP form and finds peer IPs from the walk OIDs.
$peer_ip = Net_IPv6::compress(snmp2ipv6(implode('.', array_slice(explode('.', $peer_ip_snmp), (count(explode('.', $peer_ip_snmp)) - 16)))));
foreach ($j_bgp as $index => $entry) {
switch ($entry['jnxBgpM2PeerRemoteAddrType']) {
case 'ipv4':
$ip = long2ip(hexdec($entry['jnxBgpM2PeerRemoteAddr']));
d_echo("peerindex for ipv4 $ip is ".$entry['jnxBgpM2PeerIndex']."\n");
if ($peer) {
d_echo("Found peer $peer_ip (AS$peer_as)\n");
$j_peerIndexes[$ip] = $entry['jnxBgpM2PeerIndex'];
break;
$peerlist[] = array(
'ip' => $peer_ip,
'as' => $peer_as,
);
}
}
}
}
else {
echo 'No BGP on host';
if ($device['bgpLocalAs']) {
dbUpdate(array('bgpLocalAs' => 'NULL'), 'devices', 'device_id=?', array($device['device_id']));
echo ' (Removed ASN) ';
}
}
case 'ipv6':
$ip6 = trim(str_replace(' ', '', $entry['jnxBgpM2PeerRemoteAddr']), '"');
$ip6 = substr($ip6, 0, 4).':'.substr($ip6, 4, 4).':'.substr($ip6, 8, 4).':'.substr($ip6, 12, 4).':'.substr($ip6, 16, 4).':'.substr($ip6, 20, 4).':'.substr($ip6, 24, 4).':'.substr($ip6, 28, 4);
$ip6 = Net_IPv6::compress($ip6);
d_echo("peerindex for ipv6 $ip6 is ".$entry['jnxBgpM2PeerIndex']."\n");
// Process disovered peers
if (isset($peerlist)) {
foreach ($peerlist as $peer) {
$astext = get_astext($peer['as']);
$j_peerIndexes[$ip6] = $entry['jnxBgpM2PeerIndex'];
break;
if (dbFetchCell('SELECT COUNT(*) from `bgpPeers` WHERE device_id = ? AND bgpPeerIdentifier = ?', array($device['device_id'], $peer['ip'])) < '1') {
$add = dbInsert(array('device_id' => $device['device_id'], 'bgpPeerIdentifier' => $peer['ip'], 'bgpPeerRemoteAs' => $peer['as'], 'context_name' => $device['context_name']), 'bgpPeers');
if ($config['autodiscovery']['bgp'] === true) {
$name = gethostbyaddr($peer['ip']);
$remote_device_id = discover_new_device($name, $device, 'BGP');
}
default:
echo "HALP? Don't know RemoteAddrType ".$entry['jnxBgpM2PeerRemoteAddrType']."!\n";
break;
echo '+';
}
else {
$update = dbUpdate(array('bgpPeerRemoteAs' => $peer['as'], 'astext' => mres($astext)), 'bgpPeers', 'device_id=? AND bgpPeerIdentifier=?', array($device['device_id'], $peer['ip']));
echo '.';
}
if ($device['os_group'] == 'cisco' || $device['os'] == 'junos') {
if ($device['os_group'] == 'cisco') {
// Get afi/safi and populate cbgp on cisco ios (xe/xr)
unset($af_list);
if ($peer2 === true) {
$af_data = snmpwalk_cache_oid($device, 'cbgpPeer2AddrFamilyEntry', $cbgp, 'CISCO-BGP4-MIB', $config['mibdir']);
}
else {
$af_data = snmpwalk_cache_oid($device, 'cbgpPeerAddrFamilyEntry', $cbgp, 'CISCO-BGP4-MIB', $config['mibdir']);
}
d_echo('afi data :: ');
d_echo($af_data);
foreach ($af_data as $k => $v) {
if ($peer2 === true) {
list(,$k) = explode('.', $k, 2);
}
d_echo("AFISAFI = $k\n");
$afisafi_tmp = explode('.', $k);
$safi = array_pop($afisafi_tmp);
$afi = array_pop($afisafi_tmp);
$bgp_ip = str_replace(".$afi.$safi", '', $k);
$bgp_ip = preg_replace('/:/', ' ', $bgp_ip);
$bgp_ip = preg_replace('/(\S+\s+\S+)\s/', '$1:', $bgp_ip);
$bgp_ip = str_replace('"', '', str_replace(' ', '', $bgp_ip));
if ($afi && $safi && $bgp_ip == $peer['ip']) {
$af_list[$bgp_ip][$afi][$safi] = 1;
if (dbFetchCell('SELECT COUNT(*) from `bgpPeers_cbgp` WHERE device_id = ? AND bgpPeerIdentifier = ?, AND afi=? AND safi=?', array($device['device_id'], $peer['ip'], $afi, $safi)) == 0) {
dbInsert(array('device_id' => $device['device_id'], 'bgpPeerIdentifier' => $peer['ip'], 'afi' => $afi, 'safi' => $safi, 'context_name' => $device['context_name']), 'bgpPeers_cbgp');
}
}
}
}
if ($device['os'] == 'junos') {
$safis[1] = 'unicast';
$safis[2] = 'multicast';
if (!isset($j_peerIndexes)) {
$j_bgp = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PeerTable', $jbgp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos');
foreach ($j_bgp as $index => $entry) {
switch ($entry['jnxBgpM2PeerRemoteAddrType']) {
case 'ipv4':
$ip = long2ip(hexdec($entry['jnxBgpM2PeerRemoteAddr']));
d_echo("peerindex for ipv4 $ip is ".$entry['jnxBgpM2PeerIndex']."\n");
$j_peerIndexes[$ip] = $entry['jnxBgpM2PeerIndex'];
break;
case 'ipv6':
$ip6 = trim(str_replace(' ', '', $entry['jnxBgpM2PeerRemoteAddr']), '"');
$ip6 = substr($ip6, 0, 4).':'.substr($ip6, 4, 4).':'.substr($ip6, 8, 4).':'.substr($ip6, 12, 4).':'.substr($ip6, 16, 4).':'.substr($ip6, 20, 4).':'.substr($ip6, 24, 4).':'.substr($ip6, 28, 4);
$ip6 = Net_IPv6::compress($ip6);
d_echo("peerindex for ipv6 $ip6 is ".$entry['jnxBgpM2PeerIndex']."\n");
$j_peerIndexes[$ip6] = $entry['jnxBgpM2PeerIndex'];
break;
default:
echo "HALP? Don't know RemoteAddrType ".$entry['jnxBgpM2PeerRemoteAddrType']."!\n";
break;
}
}
}
if (!isset($j_afisafi)) {
$j_prefixes = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PrefixCountersTable', $jbgp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos');
foreach (array_keys($j_prefixes) as $key) {
list($index,$afisafi) = explode('.', $key, 2);
$j_afisafi[$index][] = $afisafi;
}
}
foreach ($j_afisafi[$j_peerIndexes[$peer['ip']]] as $afisafi) {
list ($afi,$safi) = explode('.', $afisafi);
$safi = $safis[$safi];
$af_list[$afi][$safi] = 1;
if (dbFetchCell('SELECT COUNT(*) from `bgpPeers_cbgp` WHERE device_id = ? AND bgpPeerIdentifier = ?, AND afi=? AND safi=?', array($device['device_id'], $peer['ip'], $afi, $safi)) == 0) {
dbInsert(array('device_id' => $device['device_id'], 'bgpPeerIdentifier' => $peer['ip'], 'afi' => $afi, 'safi' => $safi), 'bgpPeers_cbgp');
}
}
}
$af_query = "SELECT * FROM bgpPeers_cbgp WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '".$peer['ip']."'";
foreach (dbFetchRows($af_query) as $entry) {
$afi = $entry['afi'];
$safi = $entry['safi'];
if (!$af_list[$afi][$safi] || !$af_list[$entry['bgpPeerIdentifier']][$afi][$safi]) {
dbDelete('bgpPeers_cbgp', '`device_id` = ? AND `bgpPeerIdentifier` = ?, afi=?, safi=?', array($device['device_id'], $peer['ip'], $afi, $safi));
}
}
}
if (!isset($j_afisafi)) {
$j_prefixes = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PrefixCountersTable', $jbgp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos');
foreach (array_keys($j_prefixes) as $key) {
list($index,$afisafi) = explode('.', $key, 2);
$j_afisafi[$index][] = $afisafi;
}
}
foreach ($j_afisafi[$j_peerIndexes[$peer['ip']]] as $afisafi) {
list ($afi,$safi) = explode('.', $afisafi);
$safi = $safis[$safi];
$af_list[$afi][$safi] = 1;
if (dbFetchCell('SELECT COUNT(*) from `bgpPeers_cbgp` WHERE device_id = ? AND bgpPeerIdentifier = ?, AND afi=? AND safi=?', array($device['device_id'], $peer['ip'], $afi, $safi)) == 0) {
dbInsert(array('device_id' => $device['device_id'], 'bgpPeerIdentifier' => $peer['ip'], 'afi' => $afi, 'safi' => $safi), 'bgpPeers_cbgp');
}
}
}
$af_query = "SELECT * FROM bgpPeers_cbgp WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '".$peer['ip']."'";
foreach (dbFetchRows($af_query) as $entry) {
$afi = $entry['afi'];
$safi = $entry['safi'];
if (!$af_list[$afi][$safi] || !$af_list[$entry['bgpPeerIdentifier']][$afi][$safi]) {
dbDelete('bgpPeers_cbgp', '`device_id` = ? AND `bgpPeerIdentifier` = ?, afi=?, safi=?', array($device['device_id'], $peer['ip'], $afi, $safi));
unset($j_afisafi);
unset($j_prefixes);
unset($j_bgp);
unset($j_peerIndexes);
}
// Delete removed peers
$sql = "SELECT * FROM bgpPeers WHERE device_id = '".$device['device_id']."' AND context_name = '".$device['context_name']."'";
foreach (dbFetchRows($sql) as $entry) {
unset($exists);
$i = 0;
while ($i < count($peerlist) && !isset($exists)) {
if ($peerlist[$i]['ip'] == $entry['bgpPeerIdentifier']) {
$exists = 1;
}
$i++;
}
if (!isset($exists)) {
dbDelete('bgpPeers', '`bgpPeer_id` = ?', array($entry['bgpPeer_id']));
dbDelete('bgpPeers_cbgp', '`bgpPeer_id` = ?', array($entry['bgpPeer_id']));
echo '-';
}
}
}
unset($j_afisafi);
unset($j_prefixes);
unset($j_bgp);
unset($j_peerIndexes);
unset($peerlist);
echo "\n";
unset($device['context_name']);
}
// Delete removed peers
$sql = "SELECT * FROM bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id AND D.device_id = '".$device['device_id']."'";
foreach (dbFetchRows($sql) as $entry) {
unset($exists);
$i = 0;
while ($i < count($peerlist) && !isset($exists)) {
if ($peerlist[$i]['ip'] == $entry['bgpPeerIdentifier']) {
$exists = 1;
}
$i++;
}
if (!isset($exists)) {
dbDelete('bgpPeers', '`bgpPeer_id` = ?', array($entry['bgpPeer_id']));
dbDelete('bgpPeers_cbgp', '`bgpPeer_id` = ?', array($entry['bgpPeer_id']));
echo '-';
}
}
unset($peerlist);
echo "\n";
unset($device['context_name']);
unset($vrfs_c);
}
echo "FIN BGP \n\n\n";
+15 -1
View File
@@ -55,7 +55,21 @@ if ($config['autodiscovery']['xdp'] === true) {
$remote_device_id = dbFetchCell('SELECT `device_id` FROM `devices` WHERE `sysName` = ? OR `hostname` = ?', array($cdp['cdpCacheDeviceId'], $cdp['cdpCacheDeviceId']));
if (!$remote_device_id) {
$remote_device_id = discover_new_device($cdp['cdpCacheDeviceId'], $device, 'CDP', $interface);
if($config['discovery_by_ip'] !== true) {
$remote_device_id = discover_new_device($cdp['cdpCacheDeviceId'], $device, 'CDP', $interface);
}
else {
$ip_arr = explode(" ", $cdp['cdpCacheAddress']);
$a = hexdec($ip_arr[0]);
$b = hexdec($ip_arr[1]);
$c = hexdec($ip_arr[2]);
$d = hexdec($ip_arr[3]);
$cdp_ip = "$a.$b.$c.$d";
$remote_device_id = discover_new_device($cdp_ip, $device, 'CDP', $interface);
}
}
if ($remote_device_id) {
+24 -1
View File
@@ -10,6 +10,11 @@ if ($config['enable_inventory']) {
echo ' jnxBoxAnatomy';
$entity_array = snmpwalk_cache_oid($device, 'jnxBoxAnatomy', $entity_array, 'JUNIPER-MIB');
}
elseif ($device['os'] == 'timos') {
$entity_array = array();
echo 'tmnxHwObjs';
$entity_array = snmpwalk_cache_multi_oid($device, 'tmnxHwObjs', $entity_array, 'TIMETRA-CHASSIS-MIB', '+'.$config['mib_dir'].'/aos:'.$config['mib_dir']);
}
else {
$entity_array = array();
echo ' entPhysicalEntry';
@@ -39,7 +44,25 @@ if ($config['enable_inventory']) {
$entPhysicalAssetID = $entry['entPhysicalAssetID'];
// fix for issue 1865, $entPhysicalIndex, as it contains a quad dotted number on newer Junipers
// using str_replace to remove all dots should fix this even if it changes in future
$entPhysicalIndex = str_replace('.','',$entPhysicalIndex);
$entPhysicalIndex = str_replace('.','',$entPhysicalIndex);
}
elseif ($device['os'] == 'timos') {
$entPhysicalDescr = $entry['tmnxCardTypeDescription'];
$entPhysicalContainedIn = $entry['tmnxHwContainedIn'];
$entPhysicalClass = $entry['tmnxHwClass'];
$entPhysicalName = $entry['tmnxCardTypeName'];
$entPhysicalSerialNum = $entry['tmnxHwSerialNumber'];
$entPhysicalModelName = $entry['tmnxHwMfgBoardNumber'];
$entPhysicalMfgName = $entry['tmnxHwMfgBoardNumber'];
$entPhysicalVendorType = $entry['tmnxCardTypeName'];
$entPhysicalParentRelPos = $entry['tmnxHwParentRelPos'];
$entPhysicalHardwareRev = '1.0';
$entPhysicalFirmwareRev = $entry['tmnxHwBootCodeVersion'];
$entPhysicalSoftwareRev = $entry['tmnxHwBootCodeVersion'];
$entPhysicalIsFRU = $entry['tmnxHwIsFRU'];
$entPhysicalAlias = $entry['tmnxHwAlias'];
$entPhysicalAssetID = $entry['tmnxHwAssetID'];
$entPhysicalIndex = str_replace('.','',$entPhysicalIndex);
}
else {
$entPhysicalDescr = $entry['entPhysicalDescr'];
+38 -4
View File
@@ -63,7 +63,7 @@ function discover_new_device($hostname, $device = '', $method = '', $interface =
$extra_log = ' (port ' . $int['label'] . ') ';
}
log_event('Device $' . $remote_device['hostname'] . " ($ip) $extra_log autodiscovered through $method on " . $device['hostname'], $remote_device_id, 'discovery');
log_event('Device ' . $remote_device['hostname'] . " ($ip) $extra_log autodiscovered through $method on " . $device['hostname'], $remote_device_id, 'discovery');
} else {
log_event("$method discovery of " . $remote_device['hostname'] . " ($ip) failed - check ping and SNMP access", $device['device_id'], 'discovery');
}
@@ -760,7 +760,8 @@ function avtech_add_sensor($device, $sensor) {
// get the sensor value
$value = snmp_get($device, $oid, '-OvQ');
// if the sensor doesn't exist abort
if ($value === false || $value == 0) { //issue unfortunately non-existant sensors return 0
if ($value === false || ($type == 'temperature' && $value == 0)) {
//issue unfortunately some non-existant sensors return 0
d_echo('Error: sensor returned no data, skipping' . "\n");
return false;
}
@@ -770,6 +771,31 @@ function avtech_add_sensor($device, $sensor) {
$type = $sensor['type'] ? $sensor['type'] : 'temperature';
d_echo('Sensor type: ' . $type . "\n");
$type_name = $device['os'];
if ($type == 'switch') {
// set up state sensor
$type_name .= ucfirst($type);
$type = 'state';
$state_index_id = create_state_index($type_name);
//Create State Translation
if (isset($state_index_id)) {
$states = array(
array($state_index_id,'Off',1,0,-1),
array($state_index_id,'On',1,1,0),
);
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');
}
}
}
// set the description
if ($sensor['descr_oid']) {
@@ -788,9 +814,12 @@ function avtech_add_sensor($device, $sensor) {
if ($sensor['divisor']) {
$divisor = $sensor['divisor'];
}
else {
elseif ($type == 'temperature') {
$divisor = 100;
}
else {
$divisor = 1;
}
d_echo('Sensor divisor: ' . $divisor . "\n");
@@ -813,7 +842,12 @@ function avtech_add_sensor($device, $sensor) {
d_echo('Sensor alarm max: ' . $max . "\n");
// add the sensor
discover_sensor($valid['sensor'], $type, $device, $oid, $id, $device['os'], $descr, $divisor, '1', $min, null, null, $max, $value/$divisor);
discover_sensor($valid['sensor'], $type, $device, $oid, $id, $type_name, $descr, $divisor, '1', $min, null, null, $max, $value/$divisor);
if ($type == 'state') {
create_sensor_to_state_index($device, $type_name, $id);
}
return true;
}
@@ -34,4 +34,20 @@ if (!$os) {
if (strpos($sysObjectId, '.1.3.6.1.4.1.6527.1.9.1') !== false) {
$os = 'timos';
}
// TiMOS-B-6.0.R2 both/hops ALCATEL-LUCENT SAR 7705
if (strpos($sysObjectId, '.1.3.6.1.4.1.6527.6.1.1.2.1') !== false) {
$os = 'timos';
}
// TiMOS-B-6.1.R7 both/hops ALCATEL-LUCENT SAR 7705
if (strpos($sysObjectId, '.1.3.6.1.4.1.6527.6.1.1.2.2') !== false) {
$os = 'timos';
}
// TiMOS-B-7.0.R5 both/hops ALCATEL SAR 7705
if (strpos($sysObjectId, '.1.3.6.1.4.1.6527.6.1.1.2.5') !== false) {
$os = 'timos';
}
// TiMOS-B-6.0.R2 both/hops ALCATEL-LUCENT SAR 7705
if (strpos($sysObjectId, '.1.3.6.1.4.1.6527.6.1.1.2.6') !== false) {
$os = 'timos';
}
}//end if
+4
View File
@@ -17,4 +17,8 @@ if (!$os) {
if (stristr($sysDescr, 'Barracuda Spam Firewall')) {
$os = 'barracudaspamfirewall';
}
if (stristr($sysDescr, 'Barracuda Firewall')) {
$os = 'barracudangfirewall';
}
}
+17
View File
@@ -0,0 +1,17 @@
<?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.
*/
if (!$os) {
if (strstr($sysDescr, 'BUFFALO TeraStation')) {
$os = 'buffalo';
}
}
+17
View File
@@ -0,0 +1,17 @@
<?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.
*/
if (!$os) {
if (strstr($sysObjectId, '.1.3.6.1.4.1.12925.1')) {
$os = 'informos';
}
}
+17
View File
@@ -0,0 +1,17 @@
<?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.
*/
if (!$os) {
if (strstr($sysObjectId, '.1.3.6.1.4.1.11.5.7.1.2')) {
$os = 'hpblmos';
}
}
@@ -12,6 +12,6 @@
if (!$os) {
if (strstr($sysObjectId, '.1.3.6.1.4.1.21796.3.3')) {
$os = 'poseidon';
$os = 'hwg-poseidon';
}
}
}
+17
View File
@@ -0,0 +1,17 @@
<?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.
*/
if (!$os) {
if (strstr($sysObjectId, '.1.3.6.1.4.1.21796.4.1')) {
$os = 'hwg-ste';
}
}
+17
View File
@@ -0,0 +1,17 @@
<?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.
*/
if (!$os) {
if (strstr($sysObjectId, '1.3.6.1.4.1.2.3.51.3')) {
$os = 'ibm-imm';
}
}
+1 -1
View File
@@ -11,7 +11,7 @@
*/
if (!$os) {
if (stristr($sysDescr, 'IBM Networking Operating System') || stristr($sysDescr, 'IBM Flex System Fabric')) {
if (stristr($sysDescr, 'IBM Networking Operating System') || stristr($sysDescr, 'IBM Flex System Fabric') || stristr($sysDescr, 'IBM Networking OS')) {
$os = 'ibmnos';
}
}
+2 -1
View File
@@ -4,7 +4,8 @@ if (!$os) {
$skip_oids = array(
'.1.3.6.1.4.1.674.10892.2',
'.1.3.6.1.4.1.17163.1.1',
'.1.3.6.1.4.1.17713.21'
'.1.3.6.1.4.1.17713.21',
'.1.3.6.1.4.1.2.3.51.3'
);
if (preg_match('/^Linux/', $sysDescr) && !in_array($sysObjectId, $skip_oids)) {
$os = 'linux';
+17
View File
@@ -0,0 +1,17 @@
<?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.
*/
if (!$os) {
if (strstr($sysObjectId, '.1.3.6.1.4.1.42.2.200.2.1.1')) {
$os = 'oracle-ilom';
}
}
-4
View File
@@ -15,10 +15,6 @@ if (!$os) {
$os = 'routeros';
}
if ($sysDescr == 'RB260GS') {
$os = 'routeros';
}
// poll Cisco AAA MIB
if (!empty($os)) {
$extra_mibs = array(
+4 -2
View File
@@ -1,6 +1,8 @@
<?php
if (!$os) {
if (strstr($sysDescr, 'Samsung CLX') || strstr($sysDescr, 'Samsung SCX')) {
$os = 'samsungprinter';
if (strstr($sysDescr, 'Samsung CLX') ||
strstr($sysDescr, 'Samsung SCX') ||
strstr($sysDescr, 'Samsun C')) {
$os = 'samsungprinter';
}
}
+13 -1
View File
@@ -2,6 +2,18 @@
if (!$os) {
if (preg_match('/^Sentry\ (Switched|Smart) /', $sysDescr)) {
$os = 'sentry3';
// ServerTech doesn't have a way to distinguish between sentry3 and sentry4 devices
// Hopefully, we can use the version string to figure it out
$version = trim(snmp_get($device, 'Sentry3-MIB::serverTech.4.1.1.1.3.0', '-Osqnv'));
$version = explode(" ", $version)[1];
$version = intval($version);
// It appears that version 8 and up is good for sentry4
if ($version >= 8) {
$os = 'sentry4';
} else {
$os = 'sentry3';
}
}
}
+7
View File
@@ -0,0 +1,7 @@
<?php
if (!$os) {
if (is_numeric(snmp_get($device, 'SNMPv2-SMI::enterprises.14988.2', '-Oqv', ''))) {
$os = 'swos';
}
}
+10
View File
@@ -0,0 +1,10 @@
<?php
if(!$os) {
if (strstr($sysDescr, 'Xirrus')) {
if (strstr($sysDescr, 'ArrayOS')) {
$os = 'xirrus_aos';
}
}
}
+3 -3
View File
@@ -21,7 +21,7 @@ if ($device['port_association_mode'])
$port_association_mode = get_port_assoc_mode_name ($device['port_association_mode']);
// Build array of ports in the database and an ifIndex/ifName -> port_id map
$ports_mapped = get_ports_mapped ($device['id']);
$ports_mapped = get_ports_mapped ($device['device_id']);
$ports_db = $ports_mapped['ports'];
//
@@ -62,7 +62,7 @@ foreach ($port_stats as $ifIndex => $port) {
// Port re-discovered after previous deletion?
else if ($ports_db[$port_id]['deleted'] == '1') {
dbUpdate(array('deleted' => '0'), 'ports', '`port_id` = ?', array($ports_db[$port_id]));
dbUpdate(array('deleted' => '0'), 'ports', '`port_id` = ?', array($port_id));
$ports_db[$port_id]['deleted'] = '0';
echo 'U';
}
@@ -78,7 +78,7 @@ foreach ($port_stats as $ifIndex => $port) {
else {
if (is_array($ports_db[$port_id])) {
if ($ports_db[$port_id]['deleted'] != '1') {
dbUpdate(array('deleted' => '1'), 'ports', '`port_id` = ?', array($ports_db[$port_id]));
dbUpdate(array('deleted' => '1'), 'ports', '`port_id` = ?', array($port_id));
$ports_db[$port_id]['deleted'] = '1';
echo '-';
}
@@ -1,5 +1,10 @@
<?php
$divisor = 10;
if ($device['os'] == 'poweralert') {
$divisor = 1;
}
// RFC1628 UPS
if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modules_compat']['rfc1628'][$device['os']]) {
echo 'RFC1628 ';
@@ -21,7 +26,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul
$type = 'rfc1628';
$index = (500 + $current_id);
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', null, null, null, null, $current);
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current);
}
}
@@ -41,7 +46,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul
$type = 'rfc1628';
$index = $i;
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', null, null, null, null, $current);
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current);
}
$oids = trim(snmp_walk($device, '1.3.6.1.2.1.33.1.3.2.0', '-OsqnU'));
@@ -60,7 +65,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul
$type = 'rfc1628';
$index = (100 + $i);
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', null, null, null, null, $current);
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current);
}
$oids = trim(snmp_walk($device, '1.3.6.1.2.1.33.1.5.2.0', '-OsqnU'));
@@ -79,6 +84,6 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul
$type = 'rfc1628';
$index = (200 + $i);
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', null, null, null, null, $current);
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current);
}
}//end if
@@ -19,7 +19,7 @@ if ($device['os'] == 'linux' || $device['os'] == 'pktj' || $device['os'] == 'cu
$oid = '1.3.6.1.4.1.2021.13.16.3.1.3.'.$index;
$current = snmp_get($device, $oid, '-Oqv', 'LM-SENSORS-MIB');
$descr = trim(str_ireplace('fan-', '', $descr));
if ($current > '0') {
if ($current !== false && $current >= 0) {
discover_sensor($valid['sensor'], 'fanspeed', $device, $oid, $index, 'lmsensors', $descr, '1', '1', null, null, null, null, $current);
}
}
@@ -20,7 +20,10 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul
$divisor = 10;
if ($device['os'] == 'huaweiups') {
$divisor = 100;
};
}
if ($device['os'] == 'poweralert') {
$divisor = 1;
}
$index = '3.2.0.'.$i;
discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current);
}
@@ -32,7 +35,10 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul
$divisor = 10;
if ($device['os'] == 'huaweiups') {
$divisor = 100;
};
}
if ($device['os'] == 'poweralert') {
$divisor = 1;
}
$index = '4.2.0';
discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current);
@@ -43,7 +49,10 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul
$divisor = 10;
if ($device['os'] == 'huaweiups') {
$divisor = 100;
};
}
if ($device['os'] == 'poweralert') {
$divisor = 1;
}
$index = '5.1.0';
discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current);
}//end if

Some files were not shown because too many files have changed in this diff Show More