From 6e845350314a831e654c5c30a0666a64cae71a99 Mon Sep 17 00:00:00 2001 From: laf Date: Thu, 22 Jan 2015 21:22:37 +0000 Subject: [PATCH 001/308] Dynamic config system --- html/form_new_config.php | 99 ++++++ html/forms/config-item-disable.inc.php | 48 +++ html/forms/config-item-update.inc.php | 37 +++ html/includes/functions.inc.php | 9 + html/pages/device/health/mempool.inc.php | 2 +- .../device/overview/generic/sensor.inc.php | 2 +- html/pages/device/overview/mempools.inc.php | 2 +- html/pages/device/port.inc.php | 2 +- html/pages/device/ports.inc.php | 2 +- html/pages/health/mempool.inc.php | 2 +- html/pages/health/sensors.inc.php | 2 +- html/pages/settings.inc.php | 282 +++++++++++++++--- includes/definitions.inc.php | 103 ++++++- includes/functions.php | 2 +- includes/polling/functions.inc.php | 2 +- includes/polling/mempools.inc.php | 2 +- includes/polling/ports.inc.php | 12 +- includes/polling/storage.inc.php | 2 +- 18 files changed, 544 insertions(+), 68 deletions(-) create mode 100644 html/form_new_config.php create mode 100644 html/forms/config-item-disable.inc.php create mode 100644 html/forms/config-item-update.inc.php diff --git a/html/form_new_config.php b/html/form_new_config.php new file mode 100644 index 000000000..6f45a3d6c --- /dev/null +++ b/html/form_new_config.php @@ -0,0 +1,99 @@ + + * + * 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. + */ + +enable_debug(); + +include_once("../includes/defaults.inc.php"); +include_once("../config.php"); +include_once("../includes/definitions.inc.php"); +include_once("includes/functions.inc.php"); +include_once("../includes/functions.php"); +include_once("includes/authenticate.inc.php"); + +if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; } + +$new_conf_type = $_POST['new_conf_type']; +$new_conf_name = $_POST['new_conf_name']; +$new_conf_desc = $_POST['new_conf_desc']; + +if(empty($new_conf_name)) +{ + echo("You haven't specified a config name"); + exit; +} +elseif(empty($new_conf_desc)) +{ + echo("You haven't specified a config description"); + exit; +} +elseif(empty($_POST['new_conf_single_value']) && empty($_POST['new_conf_multi_value'])) +{ + echo("You haven't specified a config value"); + exit; +} + +$db_inserted = '0'; + +if($new_conf_type == 'Single') +{ + $new_conf_type = 'single'; + $new_conf_value = $_POST['new_conf_single_value']; + $db_inserted = add_config_item($new_conf_name,$new_conf_value,$new_conf_type,$new_conf_desc); +} +elseif($new_conf_type == 'Single Array') +{ + $new_conf_type = 'single-array'; + $new_conf_value = $_POST['new_conf_single_value']; + $db_inserted = add_config_item($new_conf_name,$new_conf_value,$new_conf_type,$new_conf_desc); +} +elseif($new_conf_type == 'Standard Array' || $new_conf_type == 'Multi Array') +{ + if($new_conf_type == 'Standard Array') + { + $new_conf_type = 'array'; + } + elseif($new_conf_type == 'Multi Array') + { + $new_conf_type = 'multi-array'; + } + else + { + # $new_conf_type is invalid so clear values so we don't create any config + $new_conf_value = ''; + } + $new_conf_value = nl2br($_POST['new_conf_multi_value']); + $values = explode('
',$new_conf_value); + foreach ($values as $item) + { + $new_conf_value = trim($item); + $db_inserted = add_config_item($new_conf_name,$new_conf_value,$new_conf_type,$new_conf_desc); + } +} +else +{ + echo('Bad config type!'); + $db_inserted = 0; + exit; +} + +if($db_inserted == 1) +{ + echo('Your new config item has been added'); +} +else +{ + echo('An error occurred adding your config item to the database'); +} + +?> diff --git a/html/forms/config-item-disable.inc.php b/html/forms/config-item-disable.inc.php new file mode 100644 index 000000000..e44f6afdc --- /dev/null +++ b/html/forms/config-item-disable.inc.php @@ -0,0 +1,48 @@ + + * + * 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. + */ + +// FUA + +if(!is_numeric($_POST['config_id'])) +{ + echo('error with data'); + exit; +} +else +{ + if($_POST['state'] == 'true') + { + $state = 1; + } + elseif($_POST['state'] == 'false') + { + $state = 0; + } + else + { + $state = 0; + } + $update = dbUpdate(array('config_disabled' => $state), 'config', '`config_id` = ?', array($_POST['config_id'])); + if(!empty($update) || $update == '0') + { + echo('success'); + exit; + } + else + { + echo('error'); + exit; + } +} + diff --git a/html/forms/config-item-update.inc.php b/html/forms/config-item-update.inc.php new file mode 100644 index 000000000..9ba795786 --- /dev/null +++ b/html/forms/config-item-update.inc.php @@ -0,0 +1,37 @@ + + * + * 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. + */ + +// FUA + +if(!is_numeric($_POST['config_id']) || empty($_POST['data'])) +{ + echo('error with data'); + exit; +} +else +{ + $data = mres($_POST['data']); + $update = dbUpdate(array('config_value' => "$data"), 'config', '`config_id` = ?', array($_POST['config_id'])); + if(!empty($update) || $update == '0') + { + echo('success'); + exit; + } + else + { + echo('error'); + exit; + } +} + diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 7118facdb..9c37be97b 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -774,7 +774,16 @@ function clean_bootgrid($string) { $output = str_replace(array("\r","\n"), "", $string); $output = addslashes($output); return $output; +} +//Insert new config items +function add_config_item($new_conf_name,$new_conf_value,$new_conf_type,$new_conf_desc) { + if (dbInsert(array('config_name' => $new_conf_name, 'config_value' => $new_conf_value, 'config_default' => $new_conf_value, 'config_type' => $new_conf_type, 'config_desc' => $new_conf_desc, 'config_group' => '500_Custom Settings', 'config_sub_group' => '01_Custom settings', 'config_hidden' => '0', 'config_disabled' => '0'), 'config')) { + $db_inserted = 1; + } else { + $db_inserted = 0; + } + return($db_inserted); } ?> diff --git a/html/pages/device/health/mempool.inc.php b/html/pages/device/health/mempool.inc.php index 2b4e5fcc8..6630c3147 100644 --- a/html/pages/device/health/mempool.inc.php +++ b/html/pages/device/health/mempool.inc.php @@ -13,7 +13,7 @@ foreach (dbFetchRows("SELECT * FROM `mempools` WHERE device_id = ?", array($devi { if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - if ($config['memcached']['enable']) + if ($config['memcached']['enable'] === TRUE) { $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); if($debug) { print_r($state); } diff --git a/html/pages/device/overview/generic/sensor.inc.php b/html/pages/device/overview/generic/sensor.inc.php index bda3d04bd..6194c37c0 100644 --- a/html/pages/device/overview/generic/sensor.inc.php +++ b/html/pages/device/overview/generic/sensor.inc.php @@ -14,7 +14,7 @@ if (count($sensors)) '); foreach ($sensors as $sensor) { - if ($config['memcached']['enable']) + if ($config['memcached']['enable'] === TRUE) { $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); } diff --git a/html/pages/device/overview/mempools.inc.php b/html/pages/device/overview/mempools.inc.php index f11b6beaa..3d35a8d55 100644 --- a/html/pages/device/overview/mempools.inc.php +++ b/html/pages/device/overview/mempools.inc.php @@ -22,7 +22,7 @@ if (count($mempools)) foreach ($mempools as $mempool) { - if ($config['memcached']['enable']) + if ($config['memcached']['enable'] === TRUE) { $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); if($debug) { print_r($state); } diff --git a/html/pages/device/port.inc.php b/html/pages/device/port.inc.php index 944b10a55..ecb25cfd2 100644 --- a/html/pages/device/port.inc.php +++ b/html/pages/device/port.inc.php @@ -4,7 +4,7 @@ if (!isset($vars['view']) ) { $vars['view'] = "graphs"; } $port = dbFetchRow("SELECT * FROM `ports` WHERE `port_id` = ?", array($vars['port'])); -if ($config['memcached']['enable']) +if ($config['memcached']['enable'] === TRUE) { $state = $memcache->get('port-'.$port['port_id'].'-state'); if($debug) { print_r($state); } diff --git a/html/pages/device/ports.inc.php b/html/pages/device/ports.inc.php index df7c691d6..b254b376d 100644 --- a/html/pages/device/ports.inc.php +++ b/html/pages/device/ports.inc.php @@ -106,7 +106,7 @@ if ($vars['view'] == 'minigraphs') foreach ($ports as $port) { - if ($config['memcached']['enable']) + if ($config['memcached']['enable'] === TRUE) { $state = $memcache->get('port-'.$port['port_id'].'-state'); if($debug) { print_r($state); } diff --git a/html/pages/health/mempool.inc.php b/html/pages/health/mempool.inc.php index b348724e5..212a04709 100644 --- a/html/pages/health/mempool.inc.php +++ b/html/pages/health/mempool.inc.php @@ -19,7 +19,7 @@ foreach (dbFetchRows("SELECT * FROM `mempools` AS M, `devices` as D WHERE D.devi { $text_descr = $mempool['mempool_descr']; - if ($config['memcached']['enable']) + if ($config['memcached']['enable'] === TRUE) { $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); if($debug) { print_r($state); } diff --git a/html/pages/health/sensors.inc.php b/html/pages/health/sensors.inc.php index 82f9862ce..02224d485 100644 --- a/html/pages/health/sensors.inc.php +++ b/html/pages/health/sensors.inc.php @@ -26,7 +26,7 @@ echo(' foreach (dbFetchRows($sql, $param) as $sensor) { - if ($config['memcached']['enable']) + if ($config['memcached']['enable'] === TRUE) { $sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value'); if($debug) { echo("Memcached[".'sensor-'.$sensor['sensor_id'].'-value'."=".$sensor['sensor_current']."]"); } diff --git a/html/pages/settings.inc.php b/html/pages/settings.inc.php index 8885e131c..584d3d87f 100644 --- a/html/pages/settings.inc.php +++ b/html/pages/settings.inc.php @@ -1,46 +1,248 @@ - * 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 . */ -/** - * Global Settings - * @author f0o - * @copyright 2015 f0o, LibreNMS - * @license GPL - * @package LibreNMS - * @subpackage Page +/* + * LibreNMS + * + * Copyright (c) 2014 Neil Lathwood + * + * 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. */ -/** - * Array-To-Table - * @param array $a N-Dimensional, Associative Array - * @return string - */ -function a2t($a) { - $r = "
"; - foreach( $a as $k=>$v ) { - if( !empty($v) ) { - $r .= ""; - } - } - $r .= '
".$k."".(is_array($v)?a2t($v):"".wordwrap($v,75,"
")."
")."
'; - return $r; -} +if ($_SESSION['userlevel'] >= '10') { + +?> + + + + +
+ +
+ +
+
+

System Settings

+
+
+ +
+
+
+
+'); + + foreach (dbFetchRows("SELECT config_id,config_group FROM `config` WHERE config_hidden='0' GROUP BY config_group ORDER BY config_group ASC") as $group) + { + list($grp_num,$grp_title) = explode("_",$group['config_group']); + $found++; + echo(' +
+ +
+
+'); + foreach (dbFetchRows("SELECT * FROM `config` WHERE config_group='".$group['config_group']."' ORDER BY config_sub_group ASC, config_name ASC") as $cfg) + { + $cfg_ids[] = $cfg['config_id']; + $cfg_disabled = ''; + if($cfg['config_disabled'] == '1') + { + $cfg_disabled = 'checked'; + } + echo(' +
+ +
+ +
+
+
+ +
+
+ +
+
+'); + + } + + echo(' +
+
+
+'); + + } + + + echo(' + +'); + + if ($debug) + { + echo("
");
+    print_r($config);
+    echo("
"); + } + +?> + + + + += 10 ) { - echo "
".a2t($config)."
"; -} else { - include("includes/error-no-perm.inc.php"); -} ?> diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 78bd5a95f..3da03d78b 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -1,5 +1,96 @@ MySQL Error"); + echo(mysql_error()); + die; +} +$database_db = mysql_select_db($config['db_name'], $database_link); + +function create_array(&$arr,$string,$data,$type) +{ + // The original source of this code is from Stackoverflow (www.stackoverflow.com). + // http://stackoverflow.com/questions/9145902/create-variable-length-array-from-string + // Answer provided by stewe (http://stackoverflow.com/users/511300/stewe) + // This code is slightly adapted from the original posting. + + $a=explode(',',$string); + $last=count($a)-1; + $p=&$arr; + + foreach($a as $k=>$key) + { + if ($k==$last) + { + if($type == 'multi') + { + $p[$key]=explode(',',$data); + } + elseif($type == 'single') + { + $p[$key]=$data; + } + } + else if (is_array($p)) + { +// $p[$key]=array(); + } + $p=&$p[$key]; + } +} + +// We should be able to get config values from the DB now. +// Single field config values +$config_vars = get_defined_vars(); +$single_config = dbFetchRows("SELECT `config_name`, `config_value` FROM `config` WHERE `config_type` = 'single' AND `config_disabled` = '0'"); +foreach ($single_config as $config_data) +{ + $tmp_name = $config_data['config_name']; + if(!array_key_exists($config[$tmp_name], $config_vars)) + { + $config[$tmp_name] = $config_data['config_value']; + } +} +// Array config values +$config_vars = get_defined_vars(); +$array_config = dbFetchRows("SELECT `config_name`, GROUP_CONCAT( `config_value` ) AS `config_value` FROM `config` WHERE `config_type` = 'array' AND `config_disabled` = '0' GROUP BY config_name"); +foreach ($array_config as $config_data) +{ + $tmp_name = $config_data['config_name']; + if(!array_key_exists($config[$tmp_name], $config_vars)) + { + $config[$tmp_name] = explode(',',$config_data['config_value']); + } +} + +// Multi-array config values +$config_vars = get_defined_vars(); +$multi_array_config = dbFetchRows("SELECT `config_name`, GROUP_CONCAT( `config_value` ) AS `config_value` FROM `config` WHERE `config_type` = 'multi-array' AND `config_disabled` = '0' GROUP BY config_name"); +foreach ($multi_array_config as $config_data) +{ + create_array($config,$config_data['config_name'],$config_data['config_value'],'multi'); +} + +// Single-array config values +$config_vars = get_defined_vars(); +$single_array_config = dbFetchRows("SELECT `config_name`, GROUP_CONCAT( `config_value` ) AS `config_value` FROM `config` WHERE `config_type` = 'single-array' AND `config_disabled` = '0' GROUP BY config_name"); +foreach ($single_array_config as $config_data) +{ +// $tmp_name = explode(',',$config_data['config_name']); +// $new_name = implode('][',$tmp_name); +// if(!array_key_exists($config["{$tmp_name}"], $config_vars)) +// { +// $config["{$new_name}"] = $config_data['config_value']; +// } + create_array($config,$config_data['config_name'],$config_data['config_value'],'single'); +} + ///////////////////////////////////////////////////////// # NO CHANGES TO THIS FILE, IT IS NOT USER-EDITABLE # ///////////////////////////////////////////////////////// @@ -1726,17 +1817,7 @@ if (isset($_SERVER['HTTPS'])) $config['base_url'] = preg_replace('/^http:/','https:', $config['base_url']); } -// Connect to database -$database_link = mysql_pconnect($config['db_host'], $config['db_user'], $config['db_pass']); -if (!$database_link) -{ - echo("

MySQL Error

"); - echo(mysql_error()); - die; -} -$database_db = mysql_select_db($config['db_name'], $database_link); - -if ($config['memcached']['enable']) +if ($config['memcached']['enable'] === TRUE) { if (class_exists("Memcached")) { diff --git a/includes/functions.php b/includes/functions.php index c66dff623..d91259d0c 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -18,6 +18,7 @@ include_once("Net/IPv4.php"); include_once("Net/IPv6.php"); // Observium Includes +include_once($config['install_dir'] . "/includes/dbFacile.php"); include_once($config['install_dir'] . "/includes/common.php"); include_once($config['install_dir'] . "/includes/rrdtool.inc.php"); @@ -27,7 +28,6 @@ include_once($config['install_dir'] . "/includes/syslog.php"); include_once($config['install_dir'] . "/includes/rewrites.php"); include_once($config['install_dir'] . "/includes/snmp.inc.php"); include_once($config['install_dir'] . "/includes/services.inc.php"); -include_once($config['install_dir'] . "/includes/dbFacile.php"); include_once($config['install_dir'] . "/includes/console_colour.php"); $console_color = new Console_Color2(); diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index a85dfa4ab..33bd0cfe0 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -97,7 +97,7 @@ function poll_sensor($device, $class, $unit) log_event(ucfirst($class) . ' ' . $sensor['sensor_descr'] . " above threshold: " . $sensor_value . " $unit (> " . $sensor['sensor_limit'] . " $unit)", $device, $class, $sensor['sensor_id']); } - if ($config['memcached']['enable']) + if ($config['memcached']['enable'] === TRUE) { $memcache->set('sensor-'.$sensor['sensor_id'].'-value', $sensor_value); } else { diff --git a/includes/polling/mempools.inc.php b/includes/polling/mempools.inc.php index 2d065afe1..abc94a496 100644 --- a/includes/polling/mempools.inc.php +++ b/includes/polling/mempools.inc.php @@ -46,7 +46,7 @@ foreach (dbFetchRows("SELECT * FROM mempools WHERE device_id = ?", array($device $mempool['state']['mempool_lowestfree'] = $mempool['lowestfree']; } - if ($config['memcached']['enable']) + if ($config['memcached']['enable'] === TRUE) { if($debug) { print_r($mempool['state']); } $memcache->set('mempool-'.$mempool['mempool_id'].'-value', $mempool['state']); diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index 03896c69c..bad8e5cf0 100644 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -164,7 +164,7 @@ foreach ($ports as $port) if ($device['os'] == "vmware" && preg_match("/Device ([a-z0-9]+) at .*/", $this_port['ifDescr'], $matches)) { $this_port['ifDescr'] = $matches[1]; } - if ($config['memcached']['enable']) + if ($config['memcached']['enable'] === TRUE) { $state = $memcache->get('port-'.$port['port_id'].'-state'); if($debug) { print_r($state); } @@ -184,7 +184,7 @@ foreach ($ports as $port) $port['update']['poll_period'] = $polled_period; } - if ($config['memcached']['enable']) + if ($config['memcached']['enable'] === TRUE) { $port['state']['poll_time'] = $polled; $port['state']['poll_prev'] = $port['poll_time']; @@ -303,7 +303,7 @@ foreach ($ports as $port) $port['update'][$oid.'_prev'] = $port[$oid]; } - if ($config['memcached']['enable']) + if ($config['memcached']['enable'] === TRUE) { $port['state'][$oid] = $this_port[$oid]; $port['state'][$oid.'_prev'] = $port[$oid]; @@ -323,7 +323,7 @@ foreach ($ports as $port) $port['update'][$oid.'_delta'] = $oid_diff; } - if ($config['memcached']['enable']) + if ($config['memcached']['enable'] === TRUE) { $port['state'][$oid.'_rate'] = $oid_rate; $port['state'][$oid.'_delta'] = $oid_diff; @@ -356,7 +356,7 @@ foreach ($ports as $port) echo('pkts('.format_si($port['stats']['ifInUcastPkts_rate']).'pps/'.format_si($port['stats']['ifOutUcastPkts_rate']).'pps)'); // Store aggregate in/out state - if ($config['memcached']['enable']) + if ($config['memcached']['enable'] === TRUE) { $port['state']['ifOctets_rate'] = $port['stats']['ifOutOctets_rate'] + $port['stats']['ifInOctets_rate']; $port['state']['ifUcastPkts_rate'] = $port['stats']['ifOutUcastPkts_rate'] + $port['stats']['ifInUcastPkts_rate']; @@ -434,7 +434,7 @@ foreach ($ports as $port) if ($device['os'] == "aos") { include("port-alcatel.inc.php"); } // Update Memcached - if ($config['memcached']['enable']) + if ($config['memcached']['enable'] === TRUE) { if($debug) { print_r($port['state']); } $memcache->set('port-'.$port['port_id'].'-state', $port['state']); diff --git a/includes/polling/storage.inc.php b/includes/polling/storage.inc.php index 2485f822d..4c68d1752 100644 --- a/includes/polling/storage.inc.php +++ b/includes/polling/storage.inc.php @@ -36,7 +36,7 @@ foreach (dbFetchRows("SELECT * FROM storage WHERE device_id = ?", array($device[ rrdtool_update($storage_rrd,"N:".$storage['used'].":".$storage['free']); - if ($config['memcached']['enable']) + if ($config['memcached']['enable'] === TRUE) { $memcache->set('storage-'.$storage['storage_id'].'-used', $storage['used']); $memcache->set('storage-'.$storage['storage_id'].'-free', $storage['free']); From d315014c96fea93ed145af7db4735acfea30481c Mon Sep 17 00:00:00 2001 From: laf Date: Thu, 5 Mar 2015 15:52:01 +0000 Subject: [PATCH 002/308] Updated to use isset rather than array check for speed --- includes/definitions.inc.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 3da03d78b..28e66069f 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -30,11 +30,15 @@ function create_array(&$arr,$string,$data,$type) { if($type == 'multi') { - $p[$key]=explode(',',$data); + if (!isset($p[$key])) { + $p[$key]=explode(',',$data); + } } elseif($type == 'single') { - $p[$key]=$data; + if (!isset($p[$key])) { + $p[$key]=$data; + } } } else if (is_array($p)) @@ -52,7 +56,7 @@ $single_config = dbFetchRows("SELECT `config_name`, `config_value` FROM `config foreach ($single_config as $config_data) { $tmp_name = $config_data['config_name']; - if(!array_key_exists($config[$tmp_name], $config_vars)) + if(!isset($config[$tmp_name])) { $config[$tmp_name] = $config_data['config_value']; } @@ -63,7 +67,7 @@ $array_config = dbFetchRows("SELECT `config_name`, GROUP_CONCAT( `config_value` foreach ($array_config as $config_data) { $tmp_name = $config_data['config_name']; - if(!array_key_exists($config[$tmp_name], $config_vars)) + if(!isset($config[$tmp_name])) { $config[$tmp_name] = explode(',',$config_data['config_value']); } @@ -82,14 +86,9 @@ $config_vars = get_defined_vars(); $single_array_config = dbFetchRows("SELECT `config_name`, GROUP_CONCAT( `config_value` ) AS `config_value` FROM `config` WHERE `config_type` = 'single-array' AND `config_disabled` = '0' GROUP BY config_name"); foreach ($single_array_config as $config_data) { -// $tmp_name = explode(',',$config_data['config_name']); -// $new_name = implode('][',$tmp_name); -// if(!array_key_exists($config["{$tmp_name}"], $config_vars)) -// { -// $config["{$new_name}"] = $config_data['config_value']; -// } create_array($config,$config_data['config_name'],$config_data['config_value'],'single'); } +unset($config_vars); ///////////////////////////////////////////////////////// # NO CHANGES TO THIS FILE, IT IS NOT USER-EDITABLE # From 8327466d14e09b01e9d7540e4b85fbc8c8eb17f5 Mon Sep 17 00:00:00 2001 From: laf Date: Fri, 15 May 2015 14:19:45 +0100 Subject: [PATCH 003/308] Adding alerting config --- html/pages/settings.inc.php | 64 +++++++++++++++++++++++++++--------- includes/defaults.inc.php | 38 --------------------- includes/definitions.inc.php | 8 ++--- sql-schema/051.sql | 1 + 4 files changed, 54 insertions(+), 57 deletions(-) create mode 100644 sql-schema/051.sql diff --git a/html/pages/settings.inc.php b/html/pages/settings.inc.php index 584d3d87f..1b38e87cf 100644 --- a/html/pages/settings.inc.php +++ b/html/pages/settings.inc.php @@ -1,17 +1,50 @@ - * - * 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. +/* Copyright (C) 2015 Daniel Preussker + * 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 . */ + +/** + * Global Settings + * @author f0o + * @copyright 2015 f0o, LibreNMS + * @license GPL + * @package LibreNMS + * @subpackage Page */ +/** + * Array-To-Table + * @param array $a N-Dimensional, Associative Array + * @return string + */ + +function a2t($a) { + $r = ""; + foreach( $a as $k=>$v ) { + if( !empty($v) ) { + $r .= ""; + } + } + $r .= '
".$k."".(is_array($v)?a2t($v):"".wordwrap($v,75,"
")."
")."
'; + return $r; +} +if( $_SESSION['userlevel'] >= 10 ) { + echo "
".a2t($config)."
"; +} else { + include("includes/error-no-perm.inc.php"); +} + if ($_SESSION['userlevel'] >= '10') { ?> @@ -101,9 +134,10 @@ $('#multi_value').toggle();
'); - foreach (dbFetchRows("SELECT config_id,config_group FROM `config` WHERE config_hidden='0' GROUP BY config_group ORDER BY config_group ASC") as $group) + foreach (dbFetchRows("SELECT config_id,config_group FROM `config` WHERE config_hidden='0' GROUP BY config_group ORDER BY config_group ASC ,config_group_order DESC") as $group) { - list($grp_num,$grp_title) = explode("_",$group['config_group']); + $grp_num = $group['config_group_order']; + $grp_title = $group['config_group']; $found++; echo('
@@ -117,7 +151,7 @@ $('#multi_value').toggle();
'); - foreach (dbFetchRows("SELECT * FROM `config` WHERE config_group='".$group['config_group']."' ORDER BY config_sub_group ASC, config_name ASC") as $cfg) + foreach (dbFetchRows("SELECT * FROM `config` WHERE config_group='".$group['config_group']."' ORDER BY config_sub_group ASC, config_sub_group_order DESC, config_name ASC") as $cfg) { $cfg_ids[] = $cfg['config_id']; $cfg_disabled = ''; @@ -127,9 +161,9 @@ $('#multi_value').toggle(); } echo('
- +
- +
diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index b8943412f..62b67b5f4 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -201,44 +201,6 @@ $config['email_smtp_auth'] = FALSE; // Whether or not $config['email_smtp_username'] = NULL; // SMTP username. $config['email_smtp_password'] = NULL; // Password for SMTP authentication. -// Alerting Settings - -$config['alert'] = array( - 'macros' => array( //Macros: - 'rule' => array( // For Rules - //Time Macros - 'now' => 'NOW()', - 'past_5m' => 'DATE_SUB(NOW(),INTERVAL 5 MINUTE)', - 'past_10m' => 'DATE_SUB(NOW(),INTERVAL 10 MINUTE)', - 'past_15m' => 'DATE_SUB(NOW(),INTERVAL 15 MINUTE)', - 'past_30m' => 'DATE_SUB(NOW(),INTERVAL 30 MINUTE)', - 'past_60m' => 'DATE_SUB(NOW(),INTERVAL 60 MINUTE)', - - //Device Macros - 'device' => '(%devices.disabled = "0" && %devices.ignore = "0")', - 'device_up' => '(%devices.status = "1" && %macros.device)', - 'device_down' => '(%devices.status = "0" && %macros.device)', - - //Port Macros - 'port' => '(%ports.deleted = "0" && %ports.ignore = "0" && %ports.disabled = "0")', - 'port_up' => '(%ports.ifOperStatus = "up" && %ports.ifAdminStatus = "up" && %macros.port)', - 'port_down' => '(%ports.ifOperStatus = "down" && %ports.ifAdminStatus != "down" && %macros.port)', - 'port_usage_perc' => '((%ports.ifInOctets_rate*8)/%ports.ifSpeed)*100', - - //Misc Macros - ), - ), - 'transports' => array( //Transports: - 'dummy' => false, // Dummy alerting (debug) - 'mail' => false, // E-Mail alerting - 'irc' => false, // IRC Alerting - ), - 'globals' => false, //Issue to global-read users - 'admins' => false, //Issue to administrators - 'default_only' => false, //Only issue to default - 'default_mail' => '', //Default email -); - //Legacy options $config['alerts']['email']['default'] = NULL; // Default alert recipient diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 28e66069f..564697dfe 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -58,7 +58,7 @@ foreach ($single_config as $config_data) $tmp_name = $config_data['config_name']; if(!isset($config[$tmp_name])) { - $config[$tmp_name] = $config_data['config_value']; + $config[$tmp_name] = stripslashes($config_data['config_value']); } } // Array config values @@ -69,7 +69,7 @@ foreach ($array_config as $config_data) $tmp_name = $config_data['config_name']; if(!isset($config[$tmp_name])) { - $config[$tmp_name] = explode(',',$config_data['config_value']); + $config[$tmp_name] = explode(',',stripslashes($config_data['config_value'])); } } @@ -78,7 +78,7 @@ $config_vars = get_defined_vars(); $multi_array_config = dbFetchRows("SELECT `config_name`, GROUP_CONCAT( `config_value` ) AS `config_value` FROM `config` WHERE `config_type` = 'multi-array' AND `config_disabled` = '0' GROUP BY config_name"); foreach ($multi_array_config as $config_data) { - create_array($config,$config_data['config_name'],$config_data['config_value'],'multi'); + create_array($config,$config_data['config_name'],stripslashes($config_data['config_value']),'multi'); } // Single-array config values @@ -86,7 +86,7 @@ $config_vars = get_defined_vars(); $single_array_config = dbFetchRows("SELECT `config_name`, GROUP_CONCAT( `config_value` ) AS `config_value` FROM `config` WHERE `config_type` = 'single-array' AND `config_disabled` = '0' GROUP BY config_name"); foreach ($single_array_config as $config_data) { - create_array($config,$config_data['config_name'],$config_data['config_value'],'single'); + create_array($config,$config_data['config_name'],stripslashes($config_data['config_value']),'single'); } unset($config_vars); diff --git a/sql-schema/051.sql b/sql-schema/051.sql new file mode 100644 index 000000000..55ee4adfc --- /dev/null +++ b/sql-schema/051.sql @@ -0,0 +1 @@ +CREATE TABLE `config` ( `config_id` int(11) NOT NULL AUTO_INCREMENT, `config_name` varchar(255) NOT NULL, `config_value` varchar(255) NOT NULL, `config_default` varchar(255) NOT NULL, `config_type` enum('array','single','multi-array','single-array') NOT NULL DEFAULT 'single', `config_desc` varchar(100) NOT NULL, `config_group` varchar(50) NOT NULL, `config_sub_group` varchar(50) NOT NULL, `config_hidden` enum('0','1') NOT NULL DEFAULT '0', `config_disabled` enum('0','1') NOT NULL DEFAULT '0', PRIMARY KEY (`config_id`) ) ENGINE=InnoDB AUTO_INCREMENT=437 DEFAULT CHARSET=latin1; From d0a0df4e88beb1c6dc578d6b42b0169899cf476b Mon Sep 17 00:00:00 2001 From: laf Date: Sat, 16 May 2015 14:06:48 +0100 Subject: [PATCH 004/308] More updates to dynconfig + alert settings --- html/pages/settings.inc.php | 35 +++++++++++++++++++++++++--- html/pages/settings/alerting.inc.php | 21 +++++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 html/pages/settings/alerting.inc.php diff --git a/html/pages/settings.inc.php b/html/pages/settings.inc.php index 1b38e87cf..85c69e96e 100644 --- a/html/pages/settings.inc.php +++ b/html/pages/settings.inc.php @@ -23,6 +23,35 @@ * @subpackage Page */ +if (isset($vars['sub'])) { + + if (file_exists(mres($vars['sub']))) { + require_once "pages/settings/".mres($vars['sub']).".inc.php"; + } else { + print_error("This settings page doesn't exist, please go to the main settings page"); + } + +} else { + +?> + +
+
+ +
+ +
+ +
+
+ + diff --git a/html/pages/settings/alerting.inc.php b/html/pages/settings/alerting.inc.php new file mode 100644 index 000000000..06647581c --- /dev/null +++ b/html/pages/settings/alerting.inc.php @@ -0,0 +1,21 @@ + + * + * 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. + */ + +?> + + +
+
+'; + ?> -
-
-
'); + } else { + $("#message").html('
' + data.message + '
'); + } + }, + error: function () { + $("#message").html('
An error occurred.
'); + } + }); + }); + diff --git a/sql-schema/051.sql b/sql-schema/051.sql index 55ee4adfc..6538df71f 100644 --- a/sql-schema/051.sql +++ b/sql-schema/051.sql @@ -1 +1,2 @@ -CREATE TABLE `config` ( `config_id` int(11) NOT NULL AUTO_INCREMENT, `config_name` varchar(255) NOT NULL, `config_value` varchar(255) NOT NULL, `config_default` varchar(255) NOT NULL, `config_type` enum('array','single','multi-array','single-array') NOT NULL DEFAULT 'single', `config_desc` varchar(100) NOT NULL, `config_group` varchar(50) NOT NULL, `config_sub_group` varchar(50) NOT NULL, `config_hidden` enum('0','1') NOT NULL DEFAULT '0', `config_disabled` enum('0','1') NOT NULL DEFAULT '0', PRIMARY KEY (`config_id`) ) ENGINE=InnoDB AUTO_INCREMENT=437 DEFAULT CHARSET=latin1; +CREATE TABLE `config` ( `config_id` int(11) NOT NULL AUTO_INCREMENT, `config_name` varchar(255) NOT NULL, `config_value` varchar(512) NOT NULL, `config_default` varchar(512) NOT NULL, `config_type` enum('array','single','multi-array','single-array') NOT NULL DEFAULT 'single', `config_desc` varchar(100) NOT NULL, `config_form` text NOT NULL, `config_group` varchar(50) NOT NULL, `config_group_order` int(11) NOT NULL, `config_sub_group` varchar(50) NOT NULL, `config_sub_group_order` int(11) NOT NULL, `config_hidden` enum('0','1') NOT NULL DEFAULT '0', `config_disabled` enum('0','1') NOT NULL DEFAULT '0', PRIMARY KEY (`config_id`) ENGINE=InnoDB AUTO_INCREMENT=428 DEFAULT CHARSET=latin1; +INSERT INTO `config` VALUES (405,'alert,macros,rule,now','NOW()','NOW()','single-array','Time macro','text:','alerting',100,'macros',10,'0','0'),(406,'alert,macros,rule,past_5m','DATE_SUB(NOW(),INTERVAL 5 MINUTE)','DATE_SUB(NOW(),INTERVAL 5 MINUTE)','single-array','Time macro','text:','alerting',100,'macros',10,'0','0'),(407,'alert,macros,rule,past_10m','DATE_SUB(NOW(),INTERVAL 10 MINUTE)','DATE_SUB(NOW(),INTERVAL 10 MINUTE)','single-array','Time macro','text:','alerting',100,'macros',10,'0','0'),(408,'alert,macros,rule,past_15m','DATE_SUB(NOW(),INTERVAL 15 MINUTE)','DATE_SUB(NOW(),INTERVAL 10 MINUTE)','single-array','Time macro','text:','alerting',100,'macros',10,'0','0'),(409,'alert,macros,rule,past_30m','DATE_SUB(NOW(),INTERVAL 30 MINUTE)','DATE_SUB(NOW(),INTERVAL 10 MINUTE)','single-array','Time macro','text:','alerting',100,'macros',10,'0','0'),(410,'alert,macros,rule,past_60m','DATE_SUB(NOW(),INTERVAL 60 MINUTE)','DATE_SUB(NOW(),INTERVAL 10 MINUTE)','single-array','Time macro','text:','alerting',100,'macros',10,'0','0'),(411,'alert,macros,rule,device','(%devices.disabled = \"0\" && %devices.ignore = \"0\")','(%devices.disabled = \"0\" && %devices.ignore = \"0\")','single-array','Device macro','text:','alerting',100,'macros',10,'0','0'),(412,'alert,macros,rule,device_up','(%devices.status = \"1\" && %macros.device)','(%devices.status = \"1\" && %macros.device)','single-array','Device macro','text:','alerting',100,'macros',10,'0','0'),(413,'alert,macros,rule,device_down','(%devices.status = \"0\" && %macros.device)','(%devices.status = \"0\" && %macros.device)','single-array','Device macro','text:','alerting',100,'macros',10,'0','0'),(414,'alert,macros,rule,port','(%ports.deleted = \\\"0\\\" && %ports.ignore = \\\"0\\\" && %ports.disabled = \\\"0\\\")','(%ports.deleted = \"0\" && %ports.ignore = \"0\" && %ports.disabled = \"0\")','single-array','Port macro','text:','alerting',100,'macros',10,'0','0'),(415,'alert,macros,rule,port_up','(%ports.ifOperStatus = \"up\" && %ports.ifAdminStatus = \"up\" && %macros.port)','(%ports.ifOperStatus = \"up\" && %ports.ifAdminStatus = \"up\" && %macros.port)','single-array','Port macro','text:','alerting',100,'macros',10,'0','0'),(416,'alert,macros,rule,port_down','(%ports.ifOperStatus = \\\"down\\\" && %ports.ifAdminStatus != \\\"down\\\" && %macros.port)','(%ports.ifOperStatus = \"down\" && %ports.ifAdminStatus != \"down\" && %macros.port)','single-array','Port macro','text:','alerting',100,'macros',10,'0','0'),(417,'alert,macros,rule,port_usage_perc','((%ports.ifInOctets_rate*8)/%ports.ifSpeed)*100','((%ports.ifInOctets_rate*8)/%ports.ifSpeed)*100','single-array','Port macro','text:','alerting',100,'macros',10,'0','0'),(418,'alert,transports,dummy','false','false','single-array','Transports','radio:false,true','alerting',100,'transports',8,'0','0'),(419,'alert,transports,mail','false','false','single-array','Transports','radio:false,true','alerting',100,'transports',8,'0','0'),(420,'alert,transports,irc','false','false','single-array','Transports','radio:false,true','alerting',100,'transports',8,'0','0'),(421,'alert,globals','false','false','single-array','Issue alerts to global-read users','radio:false,true','alerting',100,'global',5,'0','0'),(422,'alert,admins','true','false','single-array','Issue alerts to admins','radio:false,true','alerting',100,'global',5,'0','0'),(423,'alert,default_only','true','false','single-array','Alert settings','radio:false,true','alerting',100,'global',5,'0','0'),(424,'alert,default_mail','','','single-array','Alert settings','text:','alerting',100,'global',5,'0','0'),(425,'alert,transports,pagerduty','false','false','single-array','Pagerduty transport','','alerting',100,'transports',8,'0','0'),(426,'alert,pagerduty,account','false','false','single-array','Pagerduty account name','','alerting',100,'transports',8,'0','0'),(427,'alert,pagerduty,service','false','false','single-array','Pagerduty service name','','alerting',100,'transports',8,'0','0'); From e1c0e7725d56e6182558ed1c837a2226ff1a2724 Mon Sep 17 00:00:00 2001 From: laf Date: Sun, 17 May 2015 21:45:06 +0100 Subject: [PATCH 006/308] More dynconfig alerting code --- html/forms/update-config-item.inc.php | 9 +- html/pages/settings/alerting.inc.php | 280 ++++++++++++++++++++++---- 2 files changed, 248 insertions(+), 41 deletions(-) diff --git a/html/forms/update-config-item.inc.php b/html/forms/update-config-item.inc.php index 1671d2f27..b7604a325 100644 --- a/html/forms/update-config-item.inc.php +++ b/html/forms/update-config-item.inc.php @@ -22,12 +22,7 @@ if (!is_numeric($_POST['config_id'])) { $message = 'ERROR: No alert selected'; exit; } else { - if($_POST['config_value'] === true) { - $state = TRUE; - } else { - $state = FALSE; - } - $state = $_POST['config_value']; + $state = mres($_POST['config_value']); $update = dbUpdate(array('config_value' => $state), 'config', '`config_id`=?', array($_POST['config_id'])); if(!empty($update) || $update == '0') { @@ -39,4 +34,4 @@ if (!is_numeric($_POST['config_id'])) { } $response = array('status'=>$status,'message'=>$message); -echo _json_encode($response); \ No newline at end of file +echo _json_encode($response); diff --git a/html/pages/settings/alerting.inc.php b/html/pages/settings/alerting.inc.php index 66a058440..0cc6811a1 100644 --- a/html/pages/settings/alerting.inc.php +++ b/html/pages/settings/alerting.inc.php @@ -22,6 +22,7 @@ if (isset($_GET['account']) && isset($_GET['service_key']) && isset($_GET['servi set_config_name('alert,pagerduty,service',$_GET['service_name']); } +// Default settings config $admin_config = get_config_by_name('alert,admins'); if (strcasecmp($admin_config[0]['config_value'],"true") == 0) { $admin_checked = 'checked'; @@ -41,6 +42,31 @@ if (strcasecmp($default_only_config[0]['config_value'],"true") == 0) { $default_only_checked = ''; } $default_mail_config = get_config_by_name('alert,default_mail'); +$tolerance_window_config = get_config_by_name('alert,tolerance_window'); + +// Mail transport config +$email_transport_config = get_config_by_name('alert,transports,mail'); +if (strcasecmp($email_transport_config[0]['config_value'],"true") == 0) { + $email_transport_checked = 'checked'; +} else { + $email_transport_checked = ''; +} +$email_backend_config = get_config_by_name('email_backend'); +$email_from_config = get_config_by_name('email_from'); +$email_user_config = get_config_by_name('email_user'); +$email_sendmail_path_config = get_config_by_name('email_sendmail_path'); +$email_smtp_host_config = get_config_by_name('email_smtp_host'); +$email_smtp_port_config = get_config_by_name('email_smtp_port'); +$email_smtp_timeout_config = get_config_by_name('email_smtp_timeout'); +$email_smtp_secure_config = get_config_by_name('email_smtp_secure'); +$email_smtp_auth_config = get_config_by_name('email_smtp_auth'); +if (strcasecmp($email_smtp_auth_config[0]['config_value'],"true") == 0) { + $email_smtp_auth_checked = 'checked'; +} else { + $email_smtp_auth_checked = ''; +} +$email_smtp_username_config = get_config_by_name('email_smtp_username'); +$email_smtp_password_config = get_config_by_name('email_smtp_password'); if (isset($config['base_url'])) { $callback = $config['base_url'].'/'.$_SERVER['REQUEST_URI'].'/'; @@ -50,48 +76,203 @@ if (isset($config['base_url'])) { $callback = urlencode($callback); echo ' -
-
-
- -
- -
- +
+ +
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+ + +
+
+
+ +
+
+ + +
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
- Connect to PagerDuty -
-
- +
-
+
+
+

+ Email transport +

+
+
+
+
+ +
+
+ +
+
+
+ +
+
+ + +
+
+
+ +
+
+ + +
+
+
+ +
+
+ + +
+
+
+ +
+
+ + +
+
+
+ +
+
+ + +
+
+
+ +
+
+ + +
+
+
+ +
+
+ + +
+
+
+ +
+
+ + +
+
+
+ +
+
+ +
+
+
+ +
+
+ + +
+
+
+ +
+
+ + +
+
+
+
+
+
+
+

+ API transport +

+
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+ Connect to PagerDuty +
+
+
+
+
+
'; ?> From 4765cebea0eb2f43cda30e5040b5f53bad52fcf0 Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 20 May 2015 21:46:54 +0100 Subject: [PATCH 007/308] Added support for interval for alerting --- html/forms/create-alert-item.inc.php | 4 +++- html/includes/modal/new_alert_rule.inc.php | 16 +++++++++++++++- html/includes/print-alert-rules.php | 4 ++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/html/forms/create-alert-item.inc.php b/html/forms/create-alert-item.inc.php index e11c56124..91907e26f 100644 --- a/html/forms/create-alert-item.inc.php +++ b/html/forms/create-alert-item.inc.php @@ -22,6 +22,7 @@ $rule = rtrim($rule,'||'); $alert_id = $_POST['alert_id']; $count = mres($_POST['count']); $delay = mres($_POST['delay']); +$interval = mres($_POST['interval']); $mute = mres($_POST['mute']); $invert = mres($_POST['invert']); $name = mres($_POST['name']); @@ -34,6 +35,7 @@ if(empty($rule)) { $count='-1'; } $delay_sec = convert_delay($delay); + $interval_sec = convert_delay($interval); if($mute == 'on') { $mute = true; } else { @@ -44,7 +46,7 @@ if(empty($rule)) { } else { $invert = false; } - $extra = array('mute'=>$mute,'count'=>$count,'delay'=>$delay_sec,'invert'=>$invert); + $extra = array('mute'=>$mute,'count'=>$count,'delay'=>$delay_sec,'invert'=>$invert,'interval'=>$interval_sec); $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) { diff --git a/html/includes/modal/new_alert_rule.inc.php b/html/includes/modal/new_alert_rule.inc.php index 59f464e3b..3d952ea95 100644 --- a/html/includes/modal/new_alert_rule.inc.php +++ b/html/includes/modal/new_alert_rule.inc.php @@ -87,10 +87,14 @@ if(is_admin() !== false) {
- +
+ +
+ +
@@ -196,6 +200,16 @@ $('#create-alert').on('show.bs.modal', function (event) { var delay = extra['delay']; } $('#delay').val(delay); + if((extra['interval'] / 86400) >= 1) { + var interval = extra['interval'] / 86400 + ' d'; + } else if((extra['interval'] / 3600) >= 1) { + var interval = extra['interval'] / 3600 + ' h'; + } else if((extra['interval'] / 60) >= 1) { + var interval = extra['interval'] / 60 + ' m'; + } else { + var interval = extra['interval']; + } + $('#interval').val(interval); $("[name='mute']").bootstrapSwitch('state',extra['mute']); $("[name='invert']").bootstrapSwitch('state',extra['invert']); $('#name').val(output['name']); diff --git a/html/includes/print-alert-rules.php b/html/includes/print-alert-rules.php index 03b6707c4..08753ca61 100644 --- a/html/includes/print-alert-rules.php +++ b/html/includes/print-alert-rules.php @@ -122,7 +122,7 @@ foreach( dbFetchRows($full_query, $param) as $rule ) { echo ""; echo "#".((int) $rulei++).""; echo "".$rule['name'].""; - echo ""; + echo ""; if($rule_extra['invert'] === true) { echo "Inverted "; } @@ -132,7 +132,7 @@ foreach( dbFetchRows($full_query, $param) as $rule ) { if($rule_extra['mute'] === true) { echo ""; } - echo "Max: ".$rule_extra['count']."
Delay: ".$rule_extra['delay']."
"; + echo "Max: ".$rule_extra['count']."
Delay: ".$rule_extra['delay']."
Interval: ".$rule_extra['interval']."
"; echo ""; if ($_SESSION['userlevel'] >= '10') { echo ""; From 6496e6ece4d5518328cc6c4e1cef54c75d73b06f Mon Sep 17 00:00:00 2001 From: laf Date: Fri, 22 May 2015 13:38:52 +0100 Subject: [PATCH 008/308] Consistent date formatting from MySQL --- doc/Developing/Style-Guidelines.md | 22 ++++++++++++++++++++- html/includes/reports/alert-log.pdf.inc.php | 2 +- html/includes/table/alert-schedule.inc.php | 2 +- html/includes/table/alertlog.inc.php | 2 +- html/includes/table/eventlog.inc.php | 2 +- html/includes/table/syslog.inc.php | 2 +- html/pages/authlog.inc.php | 2 +- html/pages/bill.inc.php | 4 ++-- html/pages/bill/transfer.inc.php | 4 ++-- html/pages/device/logs/eventlog.inc.php | 2 +- html/pages/device/logs/syslog.inc.php | 2 +- html/pages/device/overview/eventlog.inc.php | 2 +- html/pages/device/overview/syslog.inc.php | 2 +- html/pages/device/port/events.inc.php | 2 +- html/pages/front/default.php | 6 +++--- html/pages/front/demo.php | 2 +- html/pages/front/example2.php | 2 +- html/pages/front/globe.php | 6 +++--- html/pages/front/jt.php | 2 +- html/pages/front/traffic.php | 2 +- includes/defaults.inc.php | 5 +++++ scripts/console-ui.php | 4 ++-- 22 files changed, 53 insertions(+), 28 deletions(-) diff --git a/doc/Developing/Style-Guidelines.md b/doc/Developing/Style-Guidelines.md index cef63a7ee..9fc9db3b9 100644 --- a/doc/Developing/Style-Guidelines.md +++ b/doc/Developing/Style-Guidelines.md @@ -37,4 +37,24 @@ do this but provides so much flexibility along with stopping the need for retrie place. As an example pull request, see [PR 706](https://github.com/librenms/librenms/pull/706/files) to get an idea of what -it's like to convert an existing pure html table to Bootgrid. \ No newline at end of file +it's like to convert an existing pure html table to Bootgrid. + +### Datetime format + +When displaying datetimes, please ensure you use the format YYYY-MM-DD mm:hh:ss where possible, you shouldn't change the +order of this as it will be confusing to users. Cutting it short to just display YYYY-MM-DD mm:hh is fine :). + +To keep things consistent we have the following variables which should be used rather than to format dates yourself. +This has the added benefit that users can customise the format: + +```php +# Date format for PHP date()s +$config['dateformat']['long'] = "r"; # RFC2822 style +$config['dateformat']['compact'] = "Y-m-d H:i:s"; +$config['dateformat']['time'] = "H:i:s"; + +# Date format for MySQL DATE_FORMAT +$config['dateformat']['mysql']['compact'] = "%Y-%m-%d %H:%i:%s"; +$config['dateformat']['mysql']['date'] = "%Y-%m-%d"; +$config['dateformat']['mysql']['time'] = "%H:%i:%s"; +``` diff --git a/html/includes/reports/alert-log.pdf.inc.php b/html/includes/reports/alert-log.pdf.inc.php index b44023620..5ee0e91ea 100644 --- a/html/includes/reports/alert-log.pdf.inc.php +++ b/html/includes/reports/alert-log.pdf.inc.php @@ -32,7 +32,7 @@ $pdf->AddPage('L'); $numresults = 250; } - $full_query = "SELECT D.device_id,name,state,time_logged,DATE_FORMAT(time_logged, '%D %b %Y %T') as humandate $query LIMIT $start,$numresults"; + $full_query = "SELECT D.device_id,name,state,time_logged,DATE_FORMAT(time_logged, '".$config['dateformat']['mysql']['compact']."') as humandate $query LIMIT $start,$numresults"; foreach (dbFetchRows($full_query, $param) as $alert_entry) { $hostname = gethostbyid(mres($alert_entry['device_id'])); diff --git a/html/includes/table/alert-schedule.inc.php b/html/includes/table/alert-schedule.inc.php index ba6f9884c..635e67be9 100644 --- a/html/includes/table/alert-schedule.inc.php +++ b/html/includes/table/alert-schedule.inc.php @@ -46,7 +46,7 @@ if ($rowCount != -1) { $sql .= " LIMIT $limit_low,$limit_high"; } -$sql = "SELECT `S`.`schedule_id`, DATE_FORMAT(`S`.`start`, '%D %b %Y %T') AS `start`, DATE_FORMAT(`S`.`end`, '%D %b %Y %T') AS `end`, `S`.`title` $sql"; +$sql = "SELECT `S`.`schedule_id`, DATE_FORMAT(`S`.`start`, '".$config['dateformat']['mysql']['compact']."') AS `start`, DATE_FORMAT(`S`.`end`, '".$config['dateformat']['mysql']['compact']."') AS `end`, `S`.`title` $sql"; foreach (dbFetchRows($sql,$param) as $schedule) { $status = 0; diff --git a/html/includes/table/alertlog.inc.php b/html/includes/table/alertlog.inc.php index 860d6066f..0c8e515e6 100644 --- a/html/includes/table/alertlog.inc.php +++ b/html/includes/table/alertlog.inc.php @@ -39,7 +39,7 @@ if ($rowCount != -1) { $sql .= " LIMIT $limit_low,$limit_high"; } -$sql = "SELECT D.device_id,name AS alert,state,time_logged,DATE_FORMAT(time_logged, '%D %b %Y %T') as humandate,details $sql"; +$sql = "SELECT D.device_id,name AS alert,state,time_logged,DATE_FORMAT(time_logged, '".$config['dateformat']['mysql']['compact']."') as humandate,details $sql"; $rulei = 0; foreach (dbFetchRows($sql,$param) as $alertlog) { diff --git a/html/includes/table/eventlog.inc.php b/html/includes/table/eventlog.inc.php index c2bd64e4f..d5e5e7d60 100644 --- a/html/includes/table/eventlog.inc.php +++ b/html/includes/table/eventlog.inc.php @@ -46,7 +46,7 @@ if ($rowCount != -1) { $sql .= " LIMIT $limit_low,$limit_high"; } -$sql = "SELECT `E`.*,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate $sql"; +$sql = "SELECT `E`.*,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate $sql"; foreach (dbFetchRows($sql,$param) as $eventlog) { $dev = device_by_id_cache($eventlog['host']); diff --git a/html/includes/table/syslog.inc.php b/html/includes/table/syslog.inc.php index ca041fe2a..81df05d28 100644 --- a/html/includes/table/syslog.inc.php +++ b/html/includes/table/syslog.inc.php @@ -60,7 +60,7 @@ if ($rowCount != -1) { $sql .= " LIMIT $limit_low,$limit_high"; } -$sql = "SELECT S.*, DATE_FORMAT(timestamp, '%Y-%m-%d %T') AS date $sql"; +$sql = "SELECT S.*, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date $sql"; foreach (dbFetchRows($sql,$param) as $syslog) { $dev = device_by_id_cache($syslog['device_id']); diff --git a/html/pages/authlog.inc.php b/html/pages/authlog.inc.php index 606345526..64b4080ad 100644 --- a/html/pages/authlog.inc.php +++ b/html/pages/authlog.inc.php @@ -4,7 +4,7 @@ if ($_SESSION['userlevel'] >= '10') { echo(""); - foreach (dbFetchRows("SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate FROM `authlog` ORDER BY `datetime` DESC LIMIT 0,250") as $entry) + foreach (dbFetchRows("SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `authlog` ORDER BY `datetime` DESC LIMIT 0,250") as $entry) { if ($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; } diff --git a/html/pages/bill.inc.php b/html/pages/bill.inc.php index c6c0029e6..13b640057 100644 --- a/html/pages/bill.inc.php +++ b/html/pages/bill.inc.php @@ -50,8 +50,8 @@ if (bill_permitted($bill_id)) $bill_color = "#0000cc"; } - $fromtext = dbFetchCell("SELECT DATE_FORMAT($datefrom, '%M %D %Y')"); - $totext = dbFetchCell("SELECT DATE_FORMAT($dateto, '%M %D %Y')"); + $fromtext = dbFetchCell("SELECT DATE_FORMAT($datefrom, '".$config['dateformat']['mysql']['date']."')"); + $totext = dbFetchCell("SELECT DATE_FORMAT($dateto, '".$config['dateformat']['mysql']['date']."')"); $unixfrom = dbFetchCell("SELECT UNIX_TIMESTAMP('$datefrom')"); $unixto = dbFetchCell("SELECT UNIX_TIMESTAMP('$dateto')"); diff --git a/html/pages/bill/transfer.inc.php b/html/pages/bill/transfer.inc.php index fd317393d..194db3446 100644 --- a/html/pages/bill/transfer.inc.php +++ b/html/pages/bill/transfer.inc.php @@ -25,8 +25,8 @@ $in_data = $bill_data['total_data_in']; $out_data = $bill_data['total_data_out']; - $fromtext = dbFetchCell("SELECT DATE_FORMAT($datefrom, '%M %D %Y')"); - $totext = dbFetchCell("SELECT DATE_FORMAT($dateto, '%M %D %Y')"); + $fromtext = dbFetchCell("SELECT DATE_FORMAT($datefrom, '".$config['dateformat']['mysql']['date']."')"); + $totext = dbFetchCell("SELECT DATE_FORMAT($dateto, '".$config['dateformat']['mysql']['date']."')"); $unixfrom = dbFetchCell("SELECT UNIX_TIMESTAMP('$datefrom')"); $unixto = dbFetchCell("SELECT UNIX_TIMESTAMP('$dateto')"); $unix_prev_from = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastfrom')"); diff --git a/html/pages/device/logs/eventlog.inc.php b/html/pages/device/logs/eventlog.inc.php index 57753f048..aec8bdd98 100644 --- a/html/pages/device/logs/eventlog.inc.php +++ b/html/pages/device/logs/eventlog.inc.php @@ -31,7 +31,7 @@ if( !empty($_POST['string']) ) { $sql .= " AND message LIKE '%".mres($_POST['string'])."%'"; } -$entries = dbFetchRows("SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate FROM `eventlog` WHERE `host` = ? $sql ORDER BY `datetime` DESC LIMIT 0,250", array($device['device_id'])); +$entries = dbFetchRows("SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` WHERE `host` = ? $sql ORDER BY `datetime` DESC LIMIT 0,250", array($device['device_id'])); echo('
diff --git a/html/pages/device/logs/syslog.inc.php b/html/pages/device/logs/syslog.inc.php index c3abdad80..5bd715912 100644 --- a/html/pages/device/logs/syslog.inc.php +++ b/html/pages/device/logs/syslog.inc.php @@ -40,7 +40,7 @@ if ($_POST['program']) $param[] = $_POST['program']; } -$sql = "SELECT *, DATE_FORMAT(timestamp, '%Y-%m-%d %T') AS date from syslog WHERE device_id = ? $where"; +$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog WHERE device_id = ? $where"; $sql .= " ORDER BY timestamp DESC LIMIT 1000"; echo('
diff --git a/html/pages/device/overview/eventlog.inc.php b/html/pages/device/overview/eventlog.inc.php index 1fb306c67..ff235aa4a 100644 --- a/html/pages/device/overview/eventlog.inc.php +++ b/html/pages/device/overview/eventlog.inc.php @@ -10,7 +10,7 @@ echo(" Recent Events"); echo('
'); -$eventlog = dbFetchRows("SELECT *,DATE_FORMAT(datetime, '%d/%b/%y %T') as humandate FROM `eventlog` WHERE `host` = ? ORDER BY `datetime` DESC LIMIT 0,10", array($device['device_id'])); +$eventlog = dbFetchRows("SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` WHERE `host` = ? ORDER BY `datetime` DESC LIMIT 0,10", array($device['device_id'])); foreach ($eventlog as $entry) { include("includes/print-event-short.inc.php"); diff --git a/html/pages/device/overview/syslog.inc.php b/html/pages/device/overview/syslog.inc.php index b473078a5..1d26fbb2a 100644 --- a/html/pages/device/overview/syslog.inc.php +++ b/html/pages/device/overview/syslog.inc.php @@ -2,7 +2,7 @@ if ($config['enable_syslog']) { - $syslog = dbFetchRows("SELECT *, DATE_FORMAT(timestamp, '%Y-%m-%d %T') AS date from syslog WHERE device_id = ? ORDER BY timestamp DESC LIMIT 20", array($device['device_id'])); + $syslog = dbFetchRows("SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog WHERE device_id = ? ORDER BY timestamp DESC LIMIT 20", array($device['device_id'])); if (count($syslog)) { echo('
'); diff --git a/html/pages/device/port/events.inc.php b/html/pages/device/port/events.inc.php index 3cdd09c7b..6de49ef26 100644 --- a/html/pages/device/port/events.inc.php +++ b/html/pages/device/port/events.inc.php @@ -1,6 +1,6 @@ '); foreach ($entries as $entry) diff --git a/html/pages/front/default.php b/html/pages/front/default.php index 9e689b006..7b17f08a4 100644 --- a/html/pages/front/default.php +++ b/html/pages/front/default.php @@ -165,7 +165,7 @@ echo(' if ($config['enable_syslog']) { - $sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; + $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; $query = mysql_query($sql); echo('
@@ -198,10 +198,10 @@ if ($config['enable_syslog']) if ($_SESSION['userlevel'] >= '10') { - $query = "SELECT *,DATE_FORMAT(datetime, '%D %b %T') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; $alertquery = "SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id ORDER BY `time_logged` DESC LIMIT 0,15"; } else { - $query = "SELECT *,DATE_FORMAT(datetime, '%D %b %T') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; $alertquery = "SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id LEFT JOIN alert_rules ON alert_log.rule_id=alert_rules.id RIGHT JOIN devices_perms ON alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = " . $_SESSION['user_id'] . " ORDER BY `time_logged` DESC LIMIT 0,15"; } diff --git a/html/pages/front/demo.php b/html/pages/front/demo.php index f9651a58e..1000fbca2 100644 --- a/html/pages/front/demo.php +++ b/html/pages/front/demo.php @@ -161,7 +161,7 @@ echo("

Recent Syslog Messages

"); -$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from `syslog` ORDER BY seq DESC LIMIT 20"; +$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from `syslog` ORDER BY seq DESC LIMIT 20"; echo("
"); foreach (dbFetchRows($sql) as $entry) { diff --git a/html/pages/front/example2.php b/html/pages/front/example2.php index 1950e9eee..717ee7518 100644 --- a/html/pages/front/example2.php +++ b/html/pages/front/example2.php @@ -96,7 +96,7 @@ echo(" "); -$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; +$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY timestamp DESC LIMIT 20"; echo("
"); foreach (dbFetchRows($sql) as $entry) { diff --git a/html/pages/front/globe.php b/html/pages/front/globe.php index badedcd68..8218d302c 100644 --- a/html/pages/front/globe.php +++ b/html/pages/front/globe.php @@ -123,7 +123,7 @@ echo ' //From default.php - This code is not part of above license. if ($config['enable_syslog']) { -$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog ORDER BY seq DESC LIMIT 20"; +$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY seq DESC LIMIT 20"; $query = mysql_query($sql); echo('
@@ -155,9 +155,9 @@ echo('
if ($_SESSION['userlevel'] == '10') { - $query = "SELECT *,DATE_FORMAT(datetime, '%D %b %T') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15"; } else { - $query = "SELECT *,DATE_FORMAT(datetime, '%D %b %T') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; } diff --git a/html/pages/front/jt.php b/html/pages/front/jt.php index bead12a52..2256cf085 100644 --- a/html/pages/front/jt.php +++ b/html/pages/front/jt.php @@ -104,7 +104,7 @@ echo(" "); -$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20"; +$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20"; echo("
"); foreach (dbFetchRows($sql) as $entry) { diff --git a/html/pages/front/traffic.php b/html/pages/front/traffic.php index da614b1fb..5f9a8acce 100644 --- a/html/pages/front/traffic.php +++ b/html/pages/front/traffic.php @@ -98,7 +98,7 @@ echo(" "); -$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20"; +$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20"; echo("
"); foreach (dbFetchRows($sql) as $entry) { diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index fc56cb2aa..2331c6923 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -640,6 +640,11 @@ $config['dateformat']['long'] = "r"; # RFC2822 style $config['dateformat']['compact'] = "Y-m-d H:i:s"; $config['dateformat']['time'] = "H:i:s"; +# Date format for MySQL DATE_FORMAT +$config['dateformat']['mysql']['compact'] = "%Y-%m-%d %H:%i:%s"; +$config['dateformat']['mysql']['date'] = "%Y-%m-%d"; +$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['enable_port_relationship'] = TRUE;// Set this to false to not display neighbour relationships for ports diff --git a/scripts/console-ui.php b/scripts/console-ui.php index 566b94dd4..2ab7b7368 100755 --- a/scripts/console-ui.php +++ b/scripts/console-ui.php @@ -52,7 +52,7 @@ while($end == 0) { $sql = "WHERE host='".$options['d']."'"; } - $query = "SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate FROM `eventlog` AS E $sql ORDER BY `datetime` DESC LIMIT 20"; + $query = "SELECT *,DATE_FORMAT(datetime, '".$config['dateformat']['mysql']['compact']."') as humandate FROM `eventlog` AS E $sql ORDER BY `datetime` DESC LIMIT 20"; foreach (dbFetchRows($query, $param) as $entry) { $tbl->addRow(array($entry['datetime'],gethostbyid($entry['host']),$entry['message'],$entry['type'],$entry['reference'])); @@ -67,7 +67,7 @@ while($end == 0) { $sql = "WHERE device_id='".$options['d']."'"; } - $query = "SELECT *, DATE_FORMAT(timestamp, '%Y-%m-%d %T') AS date from syslog AS S $sql_query ORDER BY `timestamp` DESC LIMIT 20"; + $query = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog AS S $sql_query ORDER BY `timestamp` DESC LIMIT 20"; foreach (dbFetchRows($query, $param) as $entry) { $tbl->addRow(array($entry['timestamp'],gethostbyid($entry['device_id']),$entry['program'],$entry['msg'],$entry['level'],$entry['facility'])); From ee4aaf1749639fa5a2676f4b9216f2ce23cd1e28 Mon Sep 17 00:00:00 2001 From: laf Date: Fri, 22 May 2015 14:05:09 +0100 Subject: [PATCH 009/308] Tidied up web interface to use standard dateformats --- html/includes/modal/alert_schedule.inc.php | 6 +++--- html/pages/device/showconfig.inc.php | 2 +- html/pages/graphs.inc.php | 4 ++-- html/pages/syslog.inc.php | 2 +- includes/defaults.inc.php | 1 + 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/html/includes/modal/alert_schedule.inc.php b/html/includes/modal/alert_schedule.inc.php index 6afb748fb..7c6b7b628 100644 --- a/html/includes/modal/alert_schedule.inc.php +++ b/html/includes/modal/alert_schedule.inc.php @@ -48,13 +48,13 @@ if(is_admin() !== false) {
- +
- +
@@ -208,7 +208,7 @@ $('#map-stub').typeahead({ $(function () { $("#start").datetimepicker({ - minDate: '' + minDate: '' }); $("#end").datetimepicker(); $("#start").on("dp.change", function (e) { diff --git a/html/pages/device/showconfig.inc.php b/html/pages/device/showconfig.inc.php index 5ce3e608c..ca96e6559 100644 --- a/html/pages/device/showconfig.inc.php +++ b/html/pages/device/showconfig.inc.php @@ -48,7 +48,7 @@ if ($_SESSION['userlevel'] >= "7") if ($vars['rev'] == $svnlog["rev"]) { echo(''); } - $linktext = "r" . $svnlog["rev"] . " " . date("d M H:i", strtotime($svnlog["date"])) . ""; + $linktext = "r" . $svnlog["rev"] . " " . date($config['dateformat']['byminute'], strtotime($svnlog["date"])) . ""; echo(generate_link($linktext, array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'showconfig', 'rev' => $svnlog["rev"]))); if ($vars['rev'] == $svnlog["rev"]) { diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index 2996766c7..89c47aeec 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -146,11 +146,11 @@ if (!$auth) echo('
- +
- +
diff --git a/html/pages/syslog.inc.php b/html/pages/syslog.inc.php index f17cc315f..7a9eec004 100644 --- a/html/pages/syslog.inc.php +++ b/html/pages/syslog.inc.php @@ -100,7 +100,7 @@ $(function () { if( $("#dtpickerto").val() != "" ) { $("#dtpickerfrom").data("DateTimePicker").maxDate($("#dtpickerto").val()); } else { - $("#dtpickerto").data("DateTimePicker").maxDate(''); + $("#dtpickerto").data("DateTimePicker").maxDate(''); } }); diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 2331c6923..fa667bf65 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -638,6 +638,7 @@ $config['perf_times_purge'] = 30; # Number in days # Date format for PHP date()s $config['dateformat']['long'] = "r"; # RFC2822 style $config['dateformat']['compact'] = "Y-m-d H:i:s"; +$config['dateformat']['byminute'] = "Y-m-d H:i"; $config['dateformat']['time'] = "H:i:s"; # Date format for MySQL DATE_FORMAT From 463108e9c3aa5173d59fb10faf4e55595aa4bae7 Mon Sep 17 00:00:00 2001 From: laf Date: Fri, 22 May 2015 14:07:38 +0100 Subject: [PATCH 010/308] Added missing config option --- doc/Developing/Style-Guidelines.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/Developing/Style-Guidelines.md b/doc/Developing/Style-Guidelines.md index 9fc9db3b9..157dde17a 100644 --- a/doc/Developing/Style-Guidelines.md +++ b/doc/Developing/Style-Guidelines.md @@ -51,6 +51,7 @@ This has the added benefit that users can customise the format: # Date format for PHP date()s $config['dateformat']['long'] = "r"; # RFC2822 style $config['dateformat']['compact'] = "Y-m-d H:i:s"; +$config['dateformat']['byminute'] = "Y-m-d H:i"; $config['dateformat']['time'] = "H:i:s"; # Date format for MySQL DATE_FORMAT From 388d30d2a6d1e5fc1f89c5ddbd147e160ed51160 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 25 May 2015 02:12:48 +0100 Subject: [PATCH 011/308] updating to f0os function --- includes/definitions.inc.php | 93 +++++++++--------------------------- includes/functions.php | 1 + 2 files changed, 24 insertions(+), 70 deletions(-) diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 564697dfe..65245dc73 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -13,82 +13,35 @@ if (!$database_link) } $database_db = mysql_select_db($config['db_name'], $database_link); -function create_array(&$arr,$string,$data,$type) -{ - // The original source of this code is from Stackoverflow (www.stackoverflow.com). - // http://stackoverflow.com/questions/9145902/create-variable-length-array-from-string - // Answer provided by stewe (http://stackoverflow.com/users/511300/stewe) - // This code is slightly adapted from the original posting. - - $a=explode(',',$string); - $last=count($a)-1; - $p=&$arr; - - foreach($a as $k=>$key) - { - if ($k==$last) - { - if($type == 'multi') - { - if (!isset($p[$key])) { - $p[$key]=explode(',',$data); +function mergecnf($obj) { + global $config; + $val = $obj['config_value']; + $obj = $obj['config_name']; + $obj = explode('.',$obj); + $str = ""; + foreach ($obj as $sub) { + if (!empty($sub)) { + $str .= "['".addslashes($sub)."']"; + } else { + $str .= "[]"; } - } - elseif($type == 'single') - { - if (!isset($p[$key])) { - $p[$key]=$data; - } - } } - else if (is_array($p)) - { -// $p[$key]=array(); + $str = '$config'.$str.' = '; + if (filter_var($val,FILTER_VALIDATE_INT)) { + $str .= "(int) '$val';"; + } elseif (filter_var($val,FILTER_VALIDATE_FLOAT)) { + $str .= "(float) '$val';"; + } elseif (filter_var($val,FILTER_VALIDATE_BOOLEAN)) { + $str .= "(boolean) '$val';"; + } else { + $str .= "'$val';"; } - $p=&$p[$key]; - } + eval('return array('.$str.')'); } -// We should be able to get config values from the DB now. -// Single field config values -$config_vars = get_defined_vars(); -$single_config = dbFetchRows("SELECT `config_name`, `config_value` FROM `config` WHERE `config_type` = 'single' AND `config_disabled` = '0'"); -foreach ($single_config as $config_data) -{ - $tmp_name = $config_data['config_name']; - if(!isset($config[$tmp_name])) - { - $config[$tmp_name] = stripslashes($config_data['config_value']); - } +foreach( dbFetchRows('select config_name,config_value from config') as $obj ) { + $config = array_merge_recursive($config,mergecnf($obj)); } -// Array config values -$config_vars = get_defined_vars(); -$array_config = dbFetchRows("SELECT `config_name`, GROUP_CONCAT( `config_value` ) AS `config_value` FROM `config` WHERE `config_type` = 'array' AND `config_disabled` = '0' GROUP BY config_name"); -foreach ($array_config as $config_data) -{ - $tmp_name = $config_data['config_name']; - if(!isset($config[$tmp_name])) - { - $config[$tmp_name] = explode(',',stripslashes($config_data['config_value'])); - } -} - -// Multi-array config values -$config_vars = get_defined_vars(); -$multi_array_config = dbFetchRows("SELECT `config_name`, GROUP_CONCAT( `config_value` ) AS `config_value` FROM `config` WHERE `config_type` = 'multi-array' AND `config_disabled` = '0' GROUP BY config_name"); -foreach ($multi_array_config as $config_data) -{ - create_array($config,$config_data['config_name'],stripslashes($config_data['config_value']),'multi'); -} - -// Single-array config values -$config_vars = get_defined_vars(); -$single_array_config = dbFetchRows("SELECT `config_name`, GROUP_CONCAT( `config_value` ) AS `config_value` FROM `config` WHERE `config_type` = 'single-array' AND `config_disabled` = '0' GROUP BY config_name"); -foreach ($single_array_config as $config_data) -{ - create_array($config,$config_data['config_name'],stripslashes($config_data['config_value']),'single'); -} -unset($config_vars); ///////////////////////////////////////////////////////// # NO CHANGES TO THIS FILE, IT IS NOT USER-EDITABLE # diff --git a/includes/functions.php b/includes/functions.php index d91259d0c..618117efc 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -28,6 +28,7 @@ include_once($config['install_dir'] . "/includes/syslog.php"); include_once($config['install_dir'] . "/includes/rewrites.php"); include_once($config['install_dir'] . "/includes/snmp.inc.php"); include_once($config['install_dir'] . "/includes/services.inc.php"); +echo $config['install_dir'] . "/includes/console_colour.php"; include_once($config['install_dir'] . "/includes/console_colour.php"); $console_color = new Console_Color2(); From 0ccbc7a6b1b97b74bf6b6c0dddeb464fc4e7180f Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 25 May 2015 18:05:11 +0100 Subject: [PATCH 012/308] More updates --- html/includes/functions.inc.php | 13 +- html/pages/settings/alerting.inc.php | 213 ++++++++++++++------------- includes/defaults.inc.php | 3 + includes/definitions.inc.php | 34 ++--- includes/functions.php | 1 - 5 files changed, 144 insertions(+), 120 deletions(-) diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 2a86aa055..3bb433ddd 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -789,7 +789,18 @@ function add_config_item($new_conf_name,$new_conf_value,$new_conf_type,$new_conf function get_config_by_group($group) { $group = array($group); foreach (dbFetchRows("SELECT * FROM `config` WHERE `config_group` = '?'", array($group)) as $config_item) { - $items[] = $config_item; + $val = $config_item['config_value']; + if (filter_var($val,FILTER_VALIDATE_INT)) { + $val = (int) $val; + } elseif (filter_var($val,FILTER_VALIDATE_FLOAT)) { + $val = (float) $val; + } elseif (filter_var($val,FILTER_VALIDATE_BOOLEAN)) { + $val =(boolean) $val; + } + if ($val === TRUE) { + $config_item += array('config_checked'=>'checked'); + } + $items[$config_item['config_name']] = $config_item; } return $items; } diff --git a/html/pages/settings/alerting.inc.php b/html/pages/settings/alerting.inc.php index 0cc6811a1..2092b1084 100644 --- a/html/pages/settings/alerting.inc.php +++ b/html/pages/settings/alerting.inc.php @@ -17,56 +17,12 @@ if (isset($_GET['error'])) { } if (isset($_GET['account']) && isset($_GET['service_key']) && isset($_GET['service_name'])) { - set_config_name('alert,transports,pagerduty',$_GET['service_key']); - set_config_name('alert,pagerduty,account',$_GET['account']); - set_config_name('alert,pagerduty,service',$_GET['service_name']); + set_config_name('alert.transports.pagerduty',$_GET['service_key']); + set_config_name('alert.pagerduty.account',$_GET['account']); + set_config_name('alert.pagerduty.service',$_GET['service_name']); } -// Default settings config -$admin_config = get_config_by_name('alert,admins'); -if (strcasecmp($admin_config[0]['config_value'],"true") == 0) { - $admin_checked = 'checked'; -} else { - $admin_checked = ''; -} -$read_config = get_config_by_name('alert,globals'); -if (strcasecmp($read_config[0]['config_value'],"true") == 0) { - $read_checked = 'checked'; -} else { - $read_checked = ''; -} -$default_only_config = get_config_by_name('alert,default_only'); -if (strcasecmp($default_only_config[0]['config_value'],"true") == 0) { - $default_only_checked = 'checked'; -} else { - $default_only_checked = ''; -} -$default_mail_config = get_config_by_name('alert,default_mail'); -$tolerance_window_config = get_config_by_name('alert,tolerance_window'); - -// Mail transport config -$email_transport_config = get_config_by_name('alert,transports,mail'); -if (strcasecmp($email_transport_config[0]['config_value'],"true") == 0) { - $email_transport_checked = 'checked'; -} else { - $email_transport_checked = ''; -} -$email_backend_config = get_config_by_name('email_backend'); -$email_from_config = get_config_by_name('email_from'); -$email_user_config = get_config_by_name('email_user'); -$email_sendmail_path_config = get_config_by_name('email_sendmail_path'); -$email_smtp_host_config = get_config_by_name('email_smtp_host'); -$email_smtp_port_config = get_config_by_name('email_smtp_port'); -$email_smtp_timeout_config = get_config_by_name('email_smtp_timeout'); -$email_smtp_secure_config = get_config_by_name('email_smtp_secure'); -$email_smtp_auth_config = get_config_by_name('email_smtp_auth'); -if (strcasecmp($email_smtp_auth_config[0]['config_value'],"true") == 0) { - $email_smtp_auth_checked = 'checked'; -} else { - $email_smtp_auth_checked = ''; -} -$email_smtp_username_config = get_config_by_name('email_smtp_username'); -$email_smtp_password_config = get_config_by_name('email_smtp_password'); +$config_groups = get_config_by_group('alerting'); if (isset($config['base_url'])) { $callback = $config['base_url'].'/'.$_SERVER['REQUEST_URI'].'/'; @@ -87,39 +43,39 @@ echo '
- -
+ +
- +
- -
+ +
- +
- -
+ +
- +
- -
+ +
- +
- -
+ +
- +
@@ -135,96 +91,114 @@ echo '
- -
+ +
- +
- -
+ +
- +
- -
+ +
- +
- -
+ +
- +
- -
+ +
- +
- -
+ +
- +
- -
+ +
- +
- -
+ +
- +
- -
+ +
- +
- -
+ +
- +
- -
+ +
- +
- -
+ +
- +
@@ -256,9 +230,16 @@ echo '
-
+
Connect to PagerDuty
+
'; + if (empty($config_groups['alert.transports.pagerduty']['config_value']) === FALSE) { + echo "". $config_groups['alert.transports.pagerduty']['config_value']; + } else { + echo ""; + } + echo '
@@ -325,4 +306,36 @@ echo ' } }); }); + $( 'select[name="global-config-select"]').change(function(event) { + event.preventDefault(); + var $this = $(this); + var config_id = $this.data("config_id"); + var config_value = $this.val(); + $.ajax({ + type: 'POST', + url: '/ajax_form.php', + data: {type: "update-config-item", config_id: config_id, config_value: config_value}, + dataType: "json", + success: function (data) { + if (data.status == 'ok') { + $this.closest('.form-group').addClass('has-success'); + $this.next().addClass('glyphicon-ok'); + setTimeout(function(){ + $this.closest('.form-group').removeClass('has-success'); + $this.next().removeClass('glyphicon-ok'); + }, 2000); + } else { + $(this).closest('.form-group').addClass('has-error'); + $this.next().addClass('glyphicon-remove'); + setTimeout(function(){ + $this.closest('.form-group').removeClass('has-error'); + $this.next().removeClass('glyphicon-remove'); + }, 2000); + } + }, + error: function () { + $("#message").html('
An error occurred.
'); + } + }); + }); diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 62b67b5f4..3190c1f85 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -625,4 +625,7 @@ $config['ipmi']['type'][] = "lan"; $config['ipmi']['type'][] = "imb"; $config['ipmi']['type'][] = "open"; +// Options needed for dyn config - do NOT edit +$dyn_config['email_backend'] = array('mail','sendmail','smtp'); +$dyn_config['email_smtp_secure'] = array('', 'tls', 'ssl'); ?> diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 65245dc73..6897cb6dc 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -14,29 +14,27 @@ if (!$database_link) $database_db = mysql_select_db($config['db_name'], $database_link); function mergecnf($obj) { - global $config; + $pointer = array(); $val = $obj['config_value']; $obj = $obj['config_name']; - $obj = explode('.',$obj); - $str = ""; - foreach ($obj as $sub) { - if (!empty($sub)) { - $str .= "['".addslashes($sub)."']"; - } else { - $str .= "[]"; + $obj = explode('.',$obj,2); + if (!isset($obj[1])) { + if (filter_var($val,FILTER_VALIDATE_INT)) { + $val = (int) $val; + } elseif (filter_var($val,FILTER_VALIDATE_FLOAT)) { + $val = (float) $val; + } elseif (filter_var($val,FILTER_VALIDATE_BOOLEAN)) { + $val =(boolean) $val; + } + if (!empty($obj[0])) { + return array($obj[0] => $val); + } else { + return array($val); } - } - $str = '$config'.$str.' = '; - if (filter_var($val,FILTER_VALIDATE_INT)) { - $str .= "(int) '$val';"; - } elseif (filter_var($val,FILTER_VALIDATE_FLOAT)) { - $str .= "(float) '$val';"; - } elseif (filter_var($val,FILTER_VALIDATE_BOOLEAN)) { - $str .= "(boolean) '$val';"; } else { - $str .= "'$val';"; + $pointer[$obj[0]] = mergecnf(array('config_name'=>$obj[1],'config_value'=>$val)); } - eval('return array('.$str.')'); + return $pointer; } foreach( dbFetchRows('select config_name,config_value from config') as $obj ) { diff --git a/includes/functions.php b/includes/functions.php index 618117efc..d91259d0c 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -28,7 +28,6 @@ include_once($config['install_dir'] . "/includes/syslog.php"); include_once($config['install_dir'] . "/includes/rewrites.php"); include_once($config['install_dir'] . "/includes/snmp.inc.php"); include_once($config['install_dir'] . "/includes/services.inc.php"); -echo $config['install_dir'] . "/includes/console_colour.php"; include_once($config['install_dir'] . "/includes/console_colour.php"); $console_color = new Console_Color2(); From 5b57e75b2e90c899efd94fac575cbed7c8324354 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 25 May 2015 21:51:27 +0100 Subject: [PATCH 013/308] Final work getting alerts dynconfig done --- alerts.php | 2 +- doc/Extensions/Alerting.md | 14 + doc/Support/Configuration.md | 2 + html/forms/config-item.inc.php | 108 +++++ html/forms/update-config-item.inc.php | 31 +- html/includes/functions.inc.php | 11 +- html/pages/settings.inc.php | 237 +---------- html/pages/settings/alerting.inc.php | 567 +++++++++++++++++++++++++- includes/definitions.inc.php | 44 +- 9 files changed, 751 insertions(+), 265 deletions(-) create mode 100644 html/forms/config-item.inc.php diff --git a/alerts.php b/alerts.php index 6af7370b3..83194849c 100755 --- a/alerts.php +++ b/alerts.php @@ -247,7 +247,7 @@ function ExtTransports($obj) { global $config; $tmp = false; //To keep scrutinizer from naging because it doesnt understand eval foreach( $config['alert']['transports'] as $transport=>$opts ) { - if( ($opts === true || !empty($opts)) && file_exists($config['install_dir']."/includes/alerts/transport.".$transport.".php") ) { + if( ($opts === true || !empty($opts)) && $opts != false && file_exists($config['install_dir']."/includes/alerts/transport.".$transport.".php") ) { echo $transport." => "; eval('$tmp = function($obj,$opts) { global $config; '.file_get_contents($config['install_dir']."/includes/alerts/transport.".$transport.".php").' };'); $tmp = $tmp($obj,$opts); diff --git a/doc/Extensions/Alerting.md b/doc/Extensions/Alerting.md index 59fb295f9..7448a279c 100644 --- a/doc/Extensions/Alerting.md +++ b/doc/Extensions/Alerting.md @@ -138,6 +138,8 @@ $config['alert']['admins'] = true; //Include Adminstrators into alert-contacts ## E-Mail +> You can configure these options within the WebUI now, please avoid setting these options within config.php + E-Mail transport is enabled with adding the following to your `config.php`: ```php $config['alert']['transports']['mail'] = true; @@ -164,6 +166,8 @@ $config['alert']['default_mail'] = ''; //Default ema ## API +> You can configure these options within the WebUI now, please avoid setting these options within config.php + API transports definitions are a bit more complex than the E-Mail configuration. The basis for configuration is `$config['alert']['transports']['api'][METHOD]` where `METHOD` can be `get`,`post` or `put`. This basis has to contain an array with URLs of each API to call. @@ -179,6 +183,8 @@ $config['alert']['transports']['api']['get'][] = "https://api.thirdparti.es/issu ## Nagios Compatible +> You can configure these options within the WebUI now, please avoid setting these options within config.php + The nagios transport will feed a FIFO at the defined location with the same format that nagios would. This allows you to use other Alerting-Systems to work with LibreNMS, for example [Flapjack](http://flapjack.io). ```php @@ -187,6 +193,8 @@ $config['alert']['transports']['nagios'] = "/path/to/my.fifo"; //Flapjack expect ## IRC +> You can configure these options within the WebUI now, please avoid setting these options within config.php + The IRC transports only works together with the LibreNMS IRC-Bot. Configuration of the LibreNMS IRC-Bot is described [here](https://github.com/librenms/librenms/blob/master/doc/Extensions/IRC-Bot.md). ```php @@ -195,6 +203,8 @@ $config['alert']['transports']['irc'] = true; ## Slack +> You can configure these options within the WebUI now, please avoid setting these options within config.php + The Slack transport will POST the alert message to your Slack Incoming WebHook, you are able to specify multiple webhooks along with the relevant options to go with it. All options are optional, the only required value is for url, without this then no call to Slack will be made. Below is an example of how to send alerts to two channels with different customised options: ```php @@ -206,6 +216,8 @@ $config['alert']['transports']['slack'][] = array('url' => "https://hooks.slack. ## HipChat +> You can configure these options within the WebUI now, please avoid setting these options within config.php + The HipChat transport requires the following: __room_id__ = HipChat Room ID @@ -251,6 +263,8 @@ $config['alert']['transports']['hipchat'][] = array("url" => "https://api.hipcha ## PagerDuty +> You can configure these options within the WebUI now, please avoid setting these options within config.php + Enabling PagerDuty transports is almost as easy as enabling email-transports. All you need is to create a Service with type Generic API on your PagerDuty dashboard. diff --git a/doc/Support/Configuration.md b/doc/Support/Configuration.md index 4ef27c2c0..79b24e91b 100644 --- a/doc/Support/Configuration.md +++ b/doc/Support/Configuration.md @@ -211,6 +211,8 @@ Arrays of subnets to exclude in auto discovery mode. #### Email configuration +> You can configure these options within the WebUI now, please avoid setting these options within config.php + ```php $config['email_backend'] = 'mail'; $config['email_from'] = NULL; diff --git a/html/forms/config-item.inc.php b/html/forms/config-item.inc.php new file mode 100644 index 000000000..1a481b64a --- /dev/null +++ b/html/forms/config-item.inc.php @@ -0,0 +1,108 @@ + + * + * 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(is_admin() === false) { + $response = array('status'=>'error','message'=>'Need to be admin'); + echo _json_encode($response); + exit; +} + +$action = mres($_POST['action']); +$config_group = mres($_POST['config_group']); +$config_sub_group = mres($_POST['config_sub_group']); +$config_name = mres($_POST['config_name']); +$config_value = mres($_POST['config_value']); +$config_extra = mres($_POST['config_extra']); +$config_room_id = mres($_POST['config_room_id']); +$config_from = mres($_POST['config_from']); +$status = 'error'; +$message = 'Error with config'; + +if ($action == 'remove' || $action == 'remove-slack' || $action == 'remove-hipchat') { + $config_id = mres($_POST['config_id']); + if (empty($config_id)) { + $message = 'No config id passed'; + } else { + if (dbDelete('config', '`config_id`=?', array($config_id))) { + if ($action == 'remove-slack') { + dbDelete('config', "`config_name` LIKE 'alert.transports.slack.$config_id.%'"); + } elseif ($action == 'remove-hipchat') { + dbDelete('config', "`config_name` LIKE 'alert.transports.hipchat.$config_id.%'"); + } + $status = 'ok'; + $message = 'Config item removed'; + } else { + $message = 'General error, could not remove config'; + } + } +} elseif ($action == 'add-slack') { + if (empty($config_value)) { + $message = 'No Slack url provided'; + } else { + $config_id = dbInsert(array('config_name' => 'alert.transports.slack.', 'config_value' => $config_value, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$config_value, 'config_descr'=>'Slack Transport'), 'config'); + if ($config_id > 0) { + dbUpdate(array('config_name' => 'alert.transports.slack.'.$config_id.'.url'), 'config', 'config_id=?', array($config_id)); + $status = 'ok'; + $message = 'Config item created'; + $extras = explode('\n',$config_extra); + foreach ($extras as $option) { + list($k,$v) = explode("=", $option,2); + if (!empty($k) || !empty($v)) { + dbInsert(array('config_name' => 'alert.transports.slack.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$v, 'config_descr'=>'Slack Transport'), 'config'); + } + } + } else { + $message = 'Could not create config item'; + } + } +} elseif ($action == 'add-hipchat') { + if (empty($config_value) || empty($config_room_id) || empty($config_from)) { + $message = 'No hipchat url, room id or from provided'; + } else { + $config_id = dbInsert(array('config_name' => 'alert.transports.hipchat.', 'config_value' => $config_value, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$config_value, 'config_descr'=>'Hipchat Transport'), 'config'); + if ($config_id > 0) { + dbUpdate(array('config_name' => 'alert.transports.hipchat.'.$config_id.'.url'), 'config', 'config_id=?', array($config_id)); + dbInsert(array('config_name' => 'alert.transports.hipchat.'.$config_id.'.room_id', 'config_value' => $config_room_id, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$config_room_id, 'config_descr'=>'Hipchat URL'), 'config'); + dbInsert(array('config_name' => 'alert.transports.hipchat.'.$config_id.'.from', 'config_value' => $config_from, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$config_from, 'config_descr'=>'Hipchat From'), 'config'); + $status = 'ok'; + $message = 'Config item created'; + $extras = explode('\n',$config_extra); + foreach ($extras as $option) { + list($k,$v) = explode("=", $option,2); + if (!empty($k) || !empty($v)) { + dbInsert(array('config_name' => 'alert.transports.hipchat.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$v, 'config_descr'=>'Hipchat '.$v), 'config'); + } + } + } else { + $message = 'Could not create config item'; + } + } +} else { + + if (empty($config_group) || empty($config_sub_group) || empty($config_name) || empty($config_value)) { + $message = 'Missing config name or value'; + } else { + $config_id = dbInsert(array('config_name' => $config_name, 'config_value' => $config_value, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$config_value, 'config_descr'=>'API Transport'), 'config'); + if ($config_id > 0) { + dbUpdate(array('config_name'=>$config_name.$config_id),'config','config_id=?',array($config_id)); + $status = 'ok'; + $message = 'Config item created'; + } else { + $message = 'Could not create config item'; + } + } +} + +$response = array('status'=>$status,'message'=>$message, 'config_id'=>$config_id); +echo _json_encode($response); diff --git a/html/forms/update-config-item.inc.php b/html/forms/update-config-item.inc.php index b7604a325..4c8cc5545 100644 --- a/html/forms/update-config-item.inc.php +++ b/html/forms/update-config-item.inc.php @@ -16,14 +16,39 @@ if(is_admin() === false) { die('ERROR: You need to be admin'); } +$config_id = mres($_POST['config_id']); +$action = mres($_POST['action']); +$config_type = mres($_POST['config_type']); + $status = 'error'; -if (!is_numeric($_POST['config_id'])) { +if (!is_numeric($config_id)) { $message = 'ERROR: No alert selected'; - exit; +} elseif ($action == 'update-textarea') { + $extras = explode(PHP_EOL,$_POST['config_value']); + foreach ($extras as $option) { + list($k,$v) = explode("=", $option,2); + if (!empty($k) || !empty($v)) { + if ($config_type == 'slack') { + $db_id[] = dbInsert(array('config_name' => 'alert.transports.slack.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default'=>$v, 'config_descr'=>'Slack Transport'), 'config'); + } elseif ($config_type == 'hipchat') { + $db_id[] = dbInsert(array('config_name' => 'alert.transports.hipchat.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default'=>$v, 'config_descr'=>'Hipchat Transport'), 'config'); + } + } + } + $db_inserts = implode(",",$db_id); + if (!empty($db_inserts)) { + if ($config_type == 'slack') { + dbDelete('config',"(`config_name` LIKE 'alert.transports.slack.$config_id.%' AND `config_name` != 'alert.transports.slack.$config_id.url' AND `config_id` NOT IN ($db_inserts))"); + } elseif ($config_type == 'hipchat') { + dbDelete('config',"(`config_name` LIKE 'alert.transports.hipchat.$config_id.%' AND (`config_name` != 'alert.transports.hipchat.$config_id.url' AND `config_name` != 'alert.transports.hipchat.$config_id.room_id' AND `config_name` != 'alert.transports.hipchat.$config_id.from') AND `config_id` NOT IN ($db_inserts))"); + } + } + $message = 'Config item has been updated:'; + $status = 'ok'; } else { $state = mres($_POST['config_value']); - $update = dbUpdate(array('config_value' => $state), 'config', '`config_id`=?', array($_POST['config_id'])); + $update = dbUpdate(array('config_value' => $state), 'config', '`config_id`=?', array($config_id)); if(!empty($update) || $update == '0') { $message = 'Alert rule has been updated.'; diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 65772e2e3..d846d2ce8 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -805,14 +805,19 @@ function get_config_by_group($group) { return $items; } -function get_config_by_name($name) { +function get_config_like_name($name) { $name = array($name); - foreach (dbFetchRows("SELECT * FROM `config` WHERE `config_name` = '?'", array($name)) as $config_item) { - $items[] = $config_item; + foreach (dbFetchRows("SELECT * FROM `config` WHERE `config_name` LIKE '%?%'", array($name)) as $config_item) { + $items[$config_item['config_name']] = $config_item; } return $items; } +function get_config_by_name($name) { + $config_item = dbFetchRow("SELECT * FROM `config` WHERE `config_name` = ?", array($name)); + return $config_item; +} + function set_config_name($name,$config_value) { return dbUpdate(array('config_value' => $config_value), 'config', '`config_name`=?', array($name)); } diff --git a/html/pages/settings.inc.php b/html/pages/settings.inc.php index 3dac71da6..cb2d3ca94 100644 --- a/html/pages/settings.inc.php +++ b/html/pages/settings.inc.php @@ -54,14 +54,14 @@ foreach (dbFetchRows("SELECT `config_group` FROM `config` GROUP BY `config_group $sub_page = $sub_page['config_group']; ?>
- +
= 10 ) { include("includes/error-no-perm.inc.php"); } -if ($_SESSION['userlevel'] >= '10') { + if ($_SESSION['userlevel'] >= '10') { -?> - - - - -
- -
-
-
-
-

System Settings

-
-
- -
-
-
-
-'); - - foreach (dbFetchRows("SELECT config_id,config_group FROM `config` WHERE config_hidden='0' GROUP BY config_group ORDER BY config_group ASC ,config_group_order DESC") as $group) - { - $grp_num = $group['config_group_order']; - $grp_title = $group['config_group']; - $found++; - echo(' -
- -
-
-'); - foreach (dbFetchRows("SELECT * FROM `config` WHERE config_group='".$group['config_group']."' ORDER BY config_sub_group ASC, config_sub_group_order DESC, config_name ASC") as $cfg) - { - $cfg_ids[] = $cfg['config_id']; - $cfg_disabled = ''; - if($cfg['config_disabled'] == '1') - { - $cfg_disabled = 'checked'; - } - echo(' -
- -
- -
-
-
- -
-
- -
-
-'); - - } - - echo(' -
-
-
-'); - - } - - - echo(' - -'); - - if ($debug) - { - echo("
");
-    print_r($config);
-    echo("
"); - } - -?> - - - - - + + + + + + + + + + + + + +
-
+
- + +
+
+
+ +
+
+
@@ -79,6 +188,13 @@ echo '
+
+ +
+
+ +
+
@@ -92,9 +208,9 @@ echo '
-
+
- +
@@ -215,7 +331,32 @@ echo '
- + +
+
'; + $api_urls = get_config_like_name('alert.transports.api.%.'); + foreach ($api_urls as $api_url) { + $api_split = split("\.", $api_url['config_name']); + $api_method = $api_split[3]; + echo '
+ +
+ + +
+
+ +
+
'; + } + echo '
+ +
+ + +
+
+
@@ -235,7 +376,7 @@ echo '
'; if (empty($config_groups['alert.transports.pagerduty']['config_value']) === FALSE) { - echo "". $config_groups['alert.transports.pagerduty']['config_value']; + echo ""; } else { echo ""; } @@ -244,6 +385,201 @@ echo '
+
+ +
+
+
+ +
+
+ + +
+
+
+
+
+
+
+

+ IRC transport +

+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+

+ Slack transport +

+
+
+
+
+
+ +
+
'; + $slack_urls = get_config_like_name('alert.transports.slack.%.url'); + foreach ($slack_urls as $slack_url) { + unset($upd_slack_extra); + $new_slack_extra = array(); + $slack_extras = get_config_like_name('alert.transports.slack.'.$slack_url['config_id'].'.%'); + foreach ($slack_extras as $extra) { + $split_extra = explode('.',$extra['config_name']); + if ($split_extra[4] != 'url') { + $new_slack_extra[] = $split_extra[4] . '=' . $extra['config_value']; + } + } + $upd_slack_extra = implode(PHP_EOL,$new_slack_extra); + echo '
+
+ +
+ + +
+
+ +
+
+
+
+ + +
+
+
'; + } + echo '
+
+ +
+ + +
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+ +
+
'; + $hipchat_urls = get_config_like_name('alert.transports.hipchat.%.url'); + foreach ($hipchat_urls as $hipchat_url) { + unset($upd_hipchat_extra); + $new_hipchat_extra = array(); + $hipchat_extras = get_config_like_name('alert.transports.hipchat.'.$hipchat_url['config_id'].'.%'); + $hipchat_room_id = get_config_by_name('alert.transports.hipchat.'.$hipchat_url['config_id'].'.room_id'); + $hipchat_from = get_config_by_name('alert.transports.hipchat.'.$hipchat_url['config_id'].'.from'); + foreach ($hipchat_extras as $extra) { + $split_extra = explode('.',$extra['config_name']); + if ($split_extra[4] != 'url' && $split_extra[4] != 'room_id' && $split_extra[4] != 'from') { + $new_hipchat_extra[] = $split_extra[4] . '=' . $extra['config_value']; + } + } + $upd_hipchat_extra = implode(PHP_EOL,$new_hipchat_extra); + echo '
+
+ +
+ + +
+
+ +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+ + +
+
+
'; + } + echo '
+
+ +
+ + +
+
+ +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+ +
+
+
+
+
+
'; @@ -252,8 +588,192 @@ echo ' diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index c8029c51f..ea8dd65c6 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -14,32 +14,34 @@ if (!$database_link) $database_db = mysql_select_db($config['db_name'], $database_link); function mergecnf($obj) { - $pointer = array(); - $val = $obj['config_value']; - $obj = $obj['config_name']; - $obj = explode('.',$obj,2); - if (!isset($obj[1])) { - if (filter_var($val,FILTER_VALIDATE_INT)) { - $val = (int) $val; - } elseif (filter_var($val,FILTER_VALIDATE_FLOAT)) { - $val = (float) $val; - } elseif (filter_var($val,FILTER_VALIDATE_BOOLEAN)) { - $val =(boolean) $val; - } - if (!empty($obj[0])) { - return array($obj[0] => $val); - } else { - return array($val); - } - } else { - $pointer[$obj[0]] = mergecnf(array('config_name'=>$obj[1],'config_value'=>$val)); + $pointer = array(); + $val = $obj['config_value']; + $obj = $obj['config_name']; + $obj = explode('.',$obj,2); + if( !isset($obj[1]) ) { + if( filter_var($val,FILTER_VALIDATE_INT) ) { + $val = (int) $val; + } elseif( filter_var($val,FILTER_VALIDATE_FLOAT) ) { + $val = (float) $val; + } elseif( filter_var($val,FILTER_VALIDATE_BOOLEAN,FILTER_NULL_ON_FAILURE) !== NULL ) { + $val = filter_var($val,FILTER_VALIDATE_BOOLEAN); } - return $pointer; + if( !empty($obj[0]) ) { + return array($obj[0] => $val); + } else { + return array($val); + } + } else { + $pointer[$obj[0]] = mergecnf(array('config_name'=>$obj[1],'config_value'=>$val)); + } + return $pointer; } +$clone = $config; foreach( dbFetchRows('select config_name,config_value from config') as $obj ) { - $config = array_merge_recursive($config,mergecnf($obj)); + $clone = array_replace_recursive($clone,mergecnf($obj)); } +$config = array_replace_recursive($clone,$config); ///////////////////////////////////////////////////////// # NO CHANGES TO THIS FILE, IT IS NOT USER-EDITABLE # From 6fab7cf718e7258befcfa2e14a336707ceefbcd1 Mon Sep 17 00:00:00 2001 From: laf Date: Thu, 28 May 2015 17:07:14 +0100 Subject: [PATCH 014/308] Some last changes --- includes/defaults.inc.php | 18 ------------------ sql-schema/051.sql | 7 +++++-- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 3190c1f85..e97c64fc9 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -187,24 +187,6 @@ $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"; -// Mailer backend Settings - -$config['email_backend'] = 'mail'; // Mail backend. Allowed: "mail" (PHP's built-in), "sendmail", "smtp". -$config['email_from'] = NULL; // Mail from. Default: "ProjectName" -$config['email_user'] = $config['project_id']; -$config['email_sendmail_path'] = '/usr/sbin/sendmail'; // The location of the sendmail program. -$config['email_smtp_host'] = 'localhost'; // Outgoing SMTP server name. -$config['email_smtp_port'] = 25; // The port to connect. -$config['email_smtp_timeout'] = 10; // SMTP connection timeout in seconds. -$config['email_smtp_secure'] = NULL; // Enable encryption. Use 'tls' or 'ssl' -$config['email_smtp_auth'] = FALSE; // Whether or not to use SMTP authentication. -$config['email_smtp_username'] = NULL; // SMTP username. -$config['email_smtp_password'] = NULL; // Password for SMTP authentication. - -//Legacy options - -$config['alerts']['email']['default'] = NULL; // Default alert recipient -$config['alerts']['email']['default_only'] = FALSE; // Only use default recipient $config['alerts']['email']['enable'] = TRUE; // Enable email alerts $config['alerts']['bgp']['whitelist'] = NULL; // Populate as an array() with ASNs to alert on. $config['alerts']['port']['ifdown'] = FALSE; // Generate alerts for ports that go down diff --git a/sql-schema/051.sql b/sql-schema/051.sql index 6538df71f..10fb97fb3 100644 --- a/sql-schema/051.sql +++ b/sql-schema/051.sql @@ -1,2 +1,5 @@ -CREATE TABLE `config` ( `config_id` int(11) NOT NULL AUTO_INCREMENT, `config_name` varchar(255) NOT NULL, `config_value` varchar(512) NOT NULL, `config_default` varchar(512) NOT NULL, `config_type` enum('array','single','multi-array','single-array') NOT NULL DEFAULT 'single', `config_desc` varchar(100) NOT NULL, `config_form` text NOT NULL, `config_group` varchar(50) NOT NULL, `config_group_order` int(11) NOT NULL, `config_sub_group` varchar(50) NOT NULL, `config_sub_group_order` int(11) NOT NULL, `config_hidden` enum('0','1') NOT NULL DEFAULT '0', `config_disabled` enum('0','1') NOT NULL DEFAULT '0', PRIMARY KEY (`config_id`) ENGINE=InnoDB AUTO_INCREMENT=428 DEFAULT CHARSET=latin1; -INSERT INTO `config` VALUES (405,'alert,macros,rule,now','NOW()','NOW()','single-array','Time macro','text:','alerting',100,'macros',10,'0','0'),(406,'alert,macros,rule,past_5m','DATE_SUB(NOW(),INTERVAL 5 MINUTE)','DATE_SUB(NOW(),INTERVAL 5 MINUTE)','single-array','Time macro','text:','alerting',100,'macros',10,'0','0'),(407,'alert,macros,rule,past_10m','DATE_SUB(NOW(),INTERVAL 10 MINUTE)','DATE_SUB(NOW(),INTERVAL 10 MINUTE)','single-array','Time macro','text:','alerting',100,'macros',10,'0','0'),(408,'alert,macros,rule,past_15m','DATE_SUB(NOW(),INTERVAL 15 MINUTE)','DATE_SUB(NOW(),INTERVAL 10 MINUTE)','single-array','Time macro','text:','alerting',100,'macros',10,'0','0'),(409,'alert,macros,rule,past_30m','DATE_SUB(NOW(),INTERVAL 30 MINUTE)','DATE_SUB(NOW(),INTERVAL 10 MINUTE)','single-array','Time macro','text:','alerting',100,'macros',10,'0','0'),(410,'alert,macros,rule,past_60m','DATE_SUB(NOW(),INTERVAL 60 MINUTE)','DATE_SUB(NOW(),INTERVAL 10 MINUTE)','single-array','Time macro','text:','alerting',100,'macros',10,'0','0'),(411,'alert,macros,rule,device','(%devices.disabled = \"0\" && %devices.ignore = \"0\")','(%devices.disabled = \"0\" && %devices.ignore = \"0\")','single-array','Device macro','text:','alerting',100,'macros',10,'0','0'),(412,'alert,macros,rule,device_up','(%devices.status = \"1\" && %macros.device)','(%devices.status = \"1\" && %macros.device)','single-array','Device macro','text:','alerting',100,'macros',10,'0','0'),(413,'alert,macros,rule,device_down','(%devices.status = \"0\" && %macros.device)','(%devices.status = \"0\" && %macros.device)','single-array','Device macro','text:','alerting',100,'macros',10,'0','0'),(414,'alert,macros,rule,port','(%ports.deleted = \\\"0\\\" && %ports.ignore = \\\"0\\\" && %ports.disabled = \\\"0\\\")','(%ports.deleted = \"0\" && %ports.ignore = \"0\" && %ports.disabled = \"0\")','single-array','Port macro','text:','alerting',100,'macros',10,'0','0'),(415,'alert,macros,rule,port_up','(%ports.ifOperStatus = \"up\" && %ports.ifAdminStatus = \"up\" && %macros.port)','(%ports.ifOperStatus = \"up\" && %ports.ifAdminStatus = \"up\" && %macros.port)','single-array','Port macro','text:','alerting',100,'macros',10,'0','0'),(416,'alert,macros,rule,port_down','(%ports.ifOperStatus = \\\"down\\\" && %ports.ifAdminStatus != \\\"down\\\" && %macros.port)','(%ports.ifOperStatus = \"down\" && %ports.ifAdminStatus != \"down\" && %macros.port)','single-array','Port macro','text:','alerting',100,'macros',10,'0','0'),(417,'alert,macros,rule,port_usage_perc','((%ports.ifInOctets_rate*8)/%ports.ifSpeed)*100','((%ports.ifInOctets_rate*8)/%ports.ifSpeed)*100','single-array','Port macro','text:','alerting',100,'macros',10,'0','0'),(418,'alert,transports,dummy','false','false','single-array','Transports','radio:false,true','alerting',100,'transports',8,'0','0'),(419,'alert,transports,mail','false','false','single-array','Transports','radio:false,true','alerting',100,'transports',8,'0','0'),(420,'alert,transports,irc','false','false','single-array','Transports','radio:false,true','alerting',100,'transports',8,'0','0'),(421,'alert,globals','false','false','single-array','Issue alerts to global-read users','radio:false,true','alerting',100,'global',5,'0','0'),(422,'alert,admins','true','false','single-array','Issue alerts to admins','radio:false,true','alerting',100,'global',5,'0','0'),(423,'alert,default_only','true','false','single-array','Alert settings','radio:false,true','alerting',100,'global',5,'0','0'),(424,'alert,default_mail','','','single-array','Alert settings','text:','alerting',100,'global',5,'0','0'),(425,'alert,transports,pagerduty','false','false','single-array','Pagerduty transport','','alerting',100,'transports',8,'0','0'),(426,'alert,pagerduty,account','false','false','single-array','Pagerduty account name','','alerting',100,'transports',8,'0','0'),(427,'alert,pagerduty,service','false','false','single-array','Pagerduty service name','','alerting',100,'transports',8,'0','0'); +DROP TABLE IF EXISTS `config`; +CREATE TABLE `config` ( `config_id` int(11) NOT NULL AUTO_INCREMENT, `config_name` varchar(255) NOT NULL, `config_value` varchar(512) NOT NULL, `config_default` varchar(512) NOT NULL, `config_descr` varchar(100) NOT NULL, `config_group` varchar(50) NOT NULL, `config_group_order` int(11) NOT NULL, `config_sub_group` varchar(50) NOT NULL, `config_sub_group_order` int(11) NOT NULL, `config_hidden` enum('0','1') NOT NULL DEFAULT '0', `config_disabled` enum('0','1') NOT NULL DEFAULT '0', PRIMARY KEY (`config_id`)) ENGINE=InnoDB AUTO_INCREMENT=720 DEFAULT CHARSET=latin1; +LOCK TABLES `config` WRITE; +INSERT INTO `config` VALUES (441,'alert.macros.rule.now','NOW()','NOW()','Macro currenttime','alerting',0,'macros',0,'1','0'),(442,'alert.macros.rule.past_5m','DATE_SUB(NOW(),INTERVAL 5 MINUTE)','DATE_SUB(NOW(),INTERVAL 5 MINUTE)','Macro past 5 minutes','alerting',0,'macros',0,'1','0'),(443,'alert.macros.rule.past_10m','DATE_SUB(NOW(),INTERVAL 10 MINUTE)','DATE_SUB(NOW(),INTERVAL 10 MINUTE)','Macro past 10 minutes','alerting',0,'macros',0,'1','0'),(444,'alert.macros.rule.past_15m','DATE_SUB(NOW(),INTERVAL 15 MINUTE)','DATE_SUB(NOW(),INTERVAL 15 MINUTE)','Macro past 15 minutes','alerting',0,'macros',0,'1','0'),(445,'alert.macros.rule.past_30m','DATE_SUB(NOW(),INTERVAL 30 MINUTE)','DATE_SUB(NOW(),INTERVAL 30 MINUTE)','Macro past 30 minutes','alerting',0,'macros',0,'1','0'),(446,'alert.macros.rule.device','(%devices.disabled = 0 && %devices.ignore = 0)','(%devices.disabled = 0 && %devices.ignore = 0)','Devices that aren\'t disabled or ignored','alerting',0,'macros',0,'1','0'),(447,'alert.macros.rule.device_up','(%devices.status = 1 && %macros.device)','(%devices.status = 1 && %macros.device)','Devices that are up','alerting',0,'macros',0,'1','0'),(448,'alert.macros.rule.device_down','(%devices.status = 0 && %macros.device)','(%devices.status = 0 && %macros.device)','Devices that are down','alerting',0,'macros',0,'1','0'),(449,'alert.macros.rule.port','(%ports.deleted = 0 && %ports.ignore = 0 && %ports.disabled = 0)','(%ports.deleted = 0 && %ports.ignore = 0 && %ports.disabled = 0)','Ports that aren\'t disabled, ignored or delete','alerting',0,'macros',0,'1','0'),(450,'alert.macros.rule.port_up','(%ports.ifOperStatus = \"up\" && %ports.ifAdminStatus = \"up\" && %macros.port)','(%ports.ifOperStatus = \"up\" && %ports.ifAdminStatus = \"up\" && %macros.port)','Ports that are up','alerting',0,'macros',0,'1','0'),(451,'alert.admins','true','true','Alert administrators','alerting',0,'general',0,'0','0'),(452,'alert.default_only','true','true','Only alert default mail contact','alerting',0,'general',0,'0','0'),(453,'alert.default_mail','','','The default mail contact','alerting',0,'general',0,'0','0'),(454,'alert.transports.pagerduty','','','Pagerduty transport - put your API key here','alerting',0,'transports',0,'0','0'),(455,'alert.pagerduty.account','','','Pagerduty account name','alerting',0,'transports',0,'0','0'),(456,'alert.pagerduty.service','','','Pagerduty service name','alerting',0,'transports',0,'0','0'),(457,'alert.tolerance_window','5','5','Tolerance window in seconds','alerting',0,'general',0,'0','0'),(458,'email_backend','mail','mail','The backend to use for sending email, can be mail, sendmail or smtp','alerting',0,'general',0,'0','0'),(459,'alert.macros.rule.past_60m','DATE_SUB(NOW(),INTERVAL 60 MINUTE)','DATE_SUB(NOW(),INTERVAL 60 MINUTE)','Macro past 60 minutes','alerting',0,'macros',0,'1','0'),(460,'alert.macros.rule.port_usage_perc','((%ports.ifInOctets_rate*8)/%ports.ifSpeed)*100','((%ports.ifInOctets_rate*8)/%ports.ifSpeed)*100','Ports using more than X perc','alerting',0,'macros',0,'1','0'),(461,'alert.transports.dummy','false','false','Dummy transport','alerting',0,'transports',0,'0','0'),(462,'alert.transports.mail','true','true','Mail alerting transport','alerting',0,'transports',0,'0','0'),(463,'alert.transports.irc','FALSE','false','IRC alerting transport','alerting',0,'transports',0,'0','0'),(464,'alert.globals','true','TRUE','Alert read only administrators','alerting',0,'general',0,'0','0'),(465,'email_from','NULL','NULL','Email address used for sending emails (from)','alerting',0,'general',0,'0','0'),(466,'email_user','LibreNMS','LibreNMS','Name used as part of the from address','alerting',0,'general',0,'0','0'),(467,'email_sendmail_path','/usr/sbin/sendmail','/usr/sbin/sendmail','Location of sendmail if using this option','alerting',0,'general',0,'0','0'),(468,'email_smtp_host','localhost','localhost','SMTP Host for sending email if using this option','alerting',0,'general',0,'0','0'),(469,'email_smtp_port','25','25','SMTP port setting','alerting',0,'general',0,'0','0'),(470,'email_smtp_timeout','10','10','SMTP timeout setting','alerting',0,'general',0,'0','0'),(471,'email_smtp_secure','','','Enable / disable encryption (use tls or ssl)','alerting',0,'general',0,'0','0'),(472,'email_smtp_auth','false','FALSE','Enable / disable smtp authentication','alerting',0,'general',0,'0','0'),(473,'email_smtp_username','NULL','NULL','SMTP Auth username','alerting',0,'general',0,'0','0'),(474,'email_smtp_password','NULL','NULL','SMTP Auth password','alerting',0,'general',0,'0','0'),(475,'alert.macros.rule.port_down','(%ports.ifOperStatus = \"down\" && %ports.ifAdminStatus != \"down\" && %macros.port)','(%ports.ifOperStatus = \"down\" && %ports.ifAdminStatus != \"down\" && %macros.port)','Ports that are down','alerting',0,'macros',0,'1','0'),(486,'alert.syscontact','true','TRUE','Issue alerts to sysContact','alerting',0,'general',0,'0','0'),(487,'alert.fixed-contacts','true','TRUE','If TRUE any changes to sysContact or users emails will not be honoured whilst alert is active','alerting',0,'general',0,'0','0'),(488,'alert.transports.nagios','','','Nagios compatible via FIFO','alerting',0,'transports',0,'0','0'); +UNLOCK TABLES; From 7e6b51f75c4fe77c8e3dd1f67310a3419a22744f Mon Sep 17 00:00:00 2001 From: laf Date: Thu, 28 May 2015 17:18:05 +0100 Subject: [PATCH 015/308] Added f0os license --- includes/definitions.inc.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index ea8dd65c6..e13cb405a 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -14,6 +14,29 @@ if (!$database_link) $database_db = mysql_select_db($config['db_name'], $database_link); function mergecnf($obj) { +/* Copyright (C) 2014 Daniel Preussker + * 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 . */ + +/** + * Merge config function + * @author f0o + * @copyright 2015 f0o, LibreNMS + * @license GPL + * @package LibreNMS + * @subpackage Config + */ + $pointer = array(); $val = $obj['config_value']; $obj = $obj['config_name']; From 451d0322c15f7cc45a9c252f854ad1439896d5bc Mon Sep 17 00:00:00 2001 From: laf Date: Fri, 29 May 2015 14:26:29 +0100 Subject: [PATCH 016/308] Fixed scrut issues --- html/includes/functions.inc.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index d846d2ce8..d7fe5b323 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -788,6 +788,7 @@ function add_config_item($new_conf_name,$new_conf_value,$new_conf_type,$new_conf function get_config_by_group($group) { $group = array($group); + $items = array(); foreach (dbFetchRows("SELECT * FROM `config` WHERE `config_group` = '?'", array($group)) as $config_item) { $val = $config_item['config_value']; if (filter_var($val,FILTER_VALIDATE_INT)) { @@ -807,6 +808,7 @@ function get_config_by_group($group) { function get_config_like_name($name) { $name = array($name); + $items = array(); foreach (dbFetchRows("SELECT * FROM `config` WHERE `config_name` LIKE '%?%'", array($name)) as $config_item) { $items[$config_item['config_name']] = $config_item; } From d24ca84b76945d0334371675e3b0a81956d88b40 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 1 Jun 2015 21:37:26 +0100 Subject: [PATCH 017/308] Forcing scrut run --- doc/Developing/Style-Guidelines.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/Developing/Style-Guidelines.md b/doc/Developing/Style-Guidelines.md index 157dde17a..d6acb1265 100644 --- a/doc/Developing/Style-Guidelines.md +++ b/doc/Developing/Style-Guidelines.md @@ -59,3 +59,4 @@ $config['dateformat']['mysql']['compact'] = "%Y-%m-%d %H:%i:%s"; $config['dateformat']['mysql']['date'] = "%Y-%m-%d"; $config['dateformat']['mysql']['time'] = "%H:%i:%s"; ``` + From 4bb63bf7f08251ede3498d3de5dc8ae81fb7ae7e Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 1 Jun 2015 21:56:22 +0100 Subject: [PATCH 018/308] Updated remaining MyIsam tables to innodb --- sql-schema/052.sql | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 sql-schema/052.sql diff --git a/sql-schema/052.sql b/sql-schema/052.sql new file mode 100644 index 000000000..ff6c8544a --- /dev/null +++ b/sql-schema/052.sql @@ -0,0 +1,8 @@ +ALTER TABLE `munin_plugins` CHANGE `mplug_type` `mplug_type` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL; +ALTER TABLE slas ENGINE=InnoDB; +ALTER TABLE packages ENGINE=InnoDB; +ALTER TABLE munin_plugins_ds ENGINE=InnoDB; +ALTER TABLE munin_plugins ENGINE=InnoDB; +ALTER TABLE loadbalancer_vservers ENGINE=InnoDB; +ALTER TABLE loadbalancer_rservers ENGINE=InnoDB; +ALTER TABLE ipsec_tunnels ENGINE=InnoDB; From cabcc048770e815925eba91d7b5f5ffa60622501 Mon Sep 17 00:00:00 2001 From: James Campbell Date: Mon, 1 Jun 2015 21:41:55 +1000 Subject: [PATCH 019/308] Created Pushover transport, requires testing Moved print_r references to top for debug Modified Pushover transport, testing required Pushover transport, fixed syntax issue Pushover transport, fixed another syntax issue Pushover transport, added debug Pushover transport, updated message code Pushover transport, debug Pushover transport, testing new code Pushover transport, adding more parameters and adding debug parameters Pushover transport, added severity level support Pushover transport, modified severity level code Pushover transport, updated severity code Pushover transport, debugging severity level Pushover transport, more debugging Pushover transport, debugging sound Pushover transport, fixed sound syntax issue Pushover transport, debugging sound API Pushover transport, adjusted sound code Updated contributors file to add myself Updated Alerting doc to include Pushover Pushover transport, modified code Pushover transport, fixed syntax error Pushover transport, removed debug code Ready for deployment Pushover transport, updated copyright --- AUTHORS.md | 1 + doc/Extensions/Alerting.md | 26 ++++++++++ includes/alerts/transport.pushover.php | 66 ++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 includes/alerts/transport.pushover.php diff --git a/AUTHORS.md b/AUTHORS.md index e47f58a79..127de9825 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -30,5 +30,6 @@ Contributors to LibreNMS: - Freddie Cash (fjwcash@gmail.com) (fjwcash) - Thom Seddon (thomseddon) - Vitali Kari (vitalisator) +- James Campbell (neokjames) [1]: http://observium.org/ "Observium web site" diff --git a/doc/Extensions/Alerting.md b/doc/Extensions/Alerting.md index 59fb295f9..a542be682 100644 --- a/doc/Extensions/Alerting.md +++ b/doc/Extensions/Alerting.md @@ -15,6 +15,7 @@ Table of Content: - [Slack](#transports-slack) - [HipChat](#transports-hipchat) - [PagerDuty](#transports-pagerduty) + - [Pushover](#transports-pushover) - [Entities](#entities) - [Devices](#entity-devices) - [BGP Peers](#entity-bgppeers) @@ -265,6 +266,31 @@ That's it! __Note__: Currently ACK notifications are not transported to PagerDuty, This is going to be fixed within the next major version (version by date of writing: 2015.05) +## Pushover + +Enabling Pushover support is fairly easy, there are only two required parameters. + +Firstly you need to create a new Application (called LibreNMS, for example) in your account on the Pushover website (https://pushover.net/apps) + +Now copy your API Token/Key from the newly created Application and setup the transport in your config.php like: + +```php +$config['alert']['transports']['pushover'][] = array( + "appkey" => 'APPLICATIONAPIKEYGOESHERE', + "userkey" => 'USERKEYGOESHERE', + ); +``` + +To modify the Critical alert sound, add the 'sound_critical' parameter, example: + +```php +$config['alert']['transports']['pushover'][] = array( + "appkey" => 'APPLICATIONAPIKEYGOESHERE', + "userkey" => 'USERKEYGOESHERE', + "sound_critical" => 'siren', + ); +``` + # Entities Entities as described earlier are based on the table and column names within the database, if you are ensure of what the entity is you want then have a browse around inside MySQL using `show tables` and `desc `. diff --git a/includes/alerts/transport.pushover.php b/includes/alerts/transport.pushover.php new file mode 100644 index 000000000..7d49e10b9 --- /dev/null +++ b/includes/alerts/transport.pushover.php @@ -0,0 +1,66 @@ +/* Copyright (C) 2015 James Campbell + * 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 . */ + +/* Copyright (C) 2015 Daniel Preussker + * 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 . */ + +/** + * Pushover API Transport + * @author neokjames + * @copyright 2015 neokjames, f0o, LibreNMS + * @license GPL + * @package LibreNMS + * @subpackage Alerts + */ + +foreach( $opts as $api ) { + $data = array(); + $data['token'] = $api['appkey']; + $data['user'] = $api['userkey']; + if( $obj['severity'] == "critical" ) { + if( !empty($api['sound_critical']) ) { + $data['sound'] = $api['sound_critical']; + } + $severity = "Critical"; + $data['priority'] = 1; + } + elseif( $obj['severity'] == "warning" ) { + $severity = "Warning"; + $data['priority'] = 0; + } + $curl = curl_init(); + $data['title'] = $severity." - ".$obj['hostname']; + $data['message'] = $obj['name']; + curl_setopt($curl, CURLOPT_URL, 'https://api.pushover.net/1/messages.json'); + curl_setopt($curl, CURLOPT_SAFE_UPLOAD, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, $data); + $ret = curl_exec($curl); + $code = curl_getinfo($curl, CURLINFO_HTTP_CODE); + if( $code != 200 ) { + var_dump("Pushover returned error"); //FIXME: proper debugging + return false; + } +} +return true; From c5ed14fb91185d2458382d217eb911d4ace51df1 Mon Sep 17 00:00:00 2001 From: James Campbell Date: Tue, 2 Jun 2015 12:25:23 +1000 Subject: [PATCH 020/308] Added logo to login page --- html/pages/logon.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/html/pages/logon.inc.php b/html/pages/logon.inc.php index e9819b1b0..bffc411f8 100644 --- a/html/pages/logon.inc.php +++ b/html/pages/logon.inc.php @@ -3,6 +3,7 @@ if( $config['twofactor'] && isset($twofactorform) ) { echo twofactor_form(); } else { ?> +
LibreNMS Logo
From d3a55b42f475a5b8a272e9013dd456f935d84db3 Mon Sep 17 00:00:00 2001 From: James Campbell Date: Tue, 2 Jun 2015 12:26:56 +1000 Subject: [PATCH 021/308] Revert "Added logo to login page" This reverts commit c5ed14fb91185d2458382d217eb911d4ace51df1. --- html/pages/logon.inc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/html/pages/logon.inc.php b/html/pages/logon.inc.php index bffc411f8..e9819b1b0 100644 --- a/html/pages/logon.inc.php +++ b/html/pages/logon.inc.php @@ -3,7 +3,6 @@ if( $config['twofactor'] && isset($twofactorform) ) { echo twofactor_form(); } else { ?> -
LibreNMS Logo
From 0bd6a9736ef75ff7db80f2c234765e411d6a53bc Mon Sep 17 00:00:00 2001 From: Mike Rostermund Date: Tue, 2 Jun 2015 13:55:53 +0200 Subject: [PATCH 022/308] Only unshift first time. --- html/pages/services.inc.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/html/pages/services.inc.php b/html/pages/services.inc.php index baabceef9..8070d5d61 100644 --- a/html/pages/services.inc.php +++ b/html/pages/services.inc.php @@ -56,11 +56,17 @@ if ($_SESSION['userlevel'] >= '5') $host_sql = "SELECT * FROM devices AS D, services AS S, devices_perms AS P WHERE D.device_id = S.device_id AND D.device_id = P.device_id AND P.user_id = ? GROUP BY D.hostname ORDER BY D.hostname"; $host_par = array($_SESSION['user_id']); } + $shift = 1; foreach (dbFetchRows($host_sql, $host_par) as $device) { $device_id = $device['device_id']; $device_hostname = $device['hostname']; - array_unshift($sql_param,$device_id); + if ($shift == 1) { + array_unshift($sql_param, $device_id); + $shift = 0; + } else { + $sql_param[0] = $device_id; + } foreach (dbFetchRows("SELECT * FROM `services` WHERE `device_id` = ? $where", $sql_param) as $service) { include("includes/print-service.inc.php"); From b9dabae7d8db1ebb5e44c2243109a488ca89ec60 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 2 Jun 2015 16:32:39 +0100 Subject: [PATCH 023/308] Updated BGP polling for Cisco to support CISCO-BGP4-MIB better --- html/pages/device/routing/bgp.inc.php | 6 +- includes/discovery/bgp-peers.inc.php | 46 +- includes/functions.php | 14 + includes/polling/bgp-peers.inc.php | 124 +- mibs/CISCO-BGP4-MIB | 3353 ++++++++++++++++--------- 5 files changed, 2382 insertions(+), 1161 deletions(-) diff --git a/html/pages/device/routing/bgp.inc.php b/html/pages/device/routing/bgp.inc.php index 96a195615..a1199f672 100644 --- a/html/pages/device/routing/bgp.inc.php +++ b/html/pages/device/routing/bgp.inc.php @@ -1,7 +1,3 @@ -
-
Local AS :
-
- 'device', @@ -13,6 +9,8 @@ if(!isset($vars['view'])) { $vars['view'] = "basic"; } print_optionbar_start(); +echo "Local AS : " .$device['bgpLocalAs']." "; + echo("BGP » "); if ($vars['view'] == "basic") { echo(""); } diff --git a/includes/discovery/bgp-peers.inc.php b/includes/discovery/bgp-peers.inc.php index 6413ec673..b3778e195 100644 --- a/includes/discovery/bgp-peers.inc.php +++ b/includes/discovery/bgp-peers.inc.php @@ -20,18 +20,26 @@ if ($config['enable_bgp']) echo("Updated AS "); } - $peers_data = snmp_walk($device, "BGP4-MIB::bgpPeerRemoteAs", "-Oq", "BGP4-MIB", $config['mibdir']); + $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 ($debug) { echo("Peers : $peers_data \n"); } - $peers = trim(str_replace("BGP4-MIB::bgpPeerRemoteAs.", "", $peers_data)); + $peers = trim(str_replace("CISCO-BGP4-MIB::cbgpPeer2RemoteAs.", "", $peers_data)); + $peers = trim(str_replace("BGP4-MIB::bgpPeerRemoteAs.", "", $peers)); foreach (explode("\n", $peers) as $peer) { + list($ver, $peer) = explode(".", $peer,2); list($peer_ip, $peer_as) = explode(" ", $peer); if ($peer && $peer_ip != "0.0.0.0") { if ($debug) { echo("Found peer $peer_ip (AS$peer_as)\n"); } - $peerlist[] = array('ip' => $peer_ip, 'as' => $peer_as); + $peerlist[] = array('ip' => $peer_ip, 'as' => $peer_as, 'ver' => $ver); } } # Foreach @@ -92,18 +100,28 @@ if ($config['enable_bgp']) // Get afi/safi and populate cbgp on cisco ios (xe/xr) unset($af_list); - $af_data = snmp_walk($device, "cbgpPeerAddrFamilyName." . $peer['ip'], "-OsQ", "CISCO-BGP4-MIB", $config['mibdir']); - if ($debug) { echo("afi data :: $af_data \n"); } - - $afs = trim(str_replace("cbgpPeerAddrFamilyName.".$peer['ip'].".", "", $af_data)); - foreach (explode("\n", $afs) as $af) + 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']); + } + if ($debug) { + echo("afi data :: "); + print_r($af_data); + } + foreach ($af_data as $k => $v) { - if ($debug) { echo("AFISAFI = $af\n"); } - list($afisafi, $text) = explode(" = ", $af); - list($afi, $safi) = explode(".", $afisafi); - if ($afi && $safi) + if ($peer2 === TRUE) { + list(,$k) = explode('.',$k,2); + } + if ($debug) { 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); + if ($afi && $safi && $bgp_ip == $peer['ip']) { - $af_list[$afi][$safi] = 1; + $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'); @@ -170,7 +188,7 @@ if ($config['enable_bgp']) { $afi = $entry['afi']; $safi = $entry['safi']; - if (!$af_list[$afi][$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)); } diff --git a/includes/functions.php b/includes/functions.php index ef3cd98e3..282d1e34f 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -1201,3 +1201,17 @@ function first_oid_match($device, $list) { } } } + +function ip_to_hex($ip) { + + if (strstr($ip, ":")) { + $ipv6 = explode(':', $ip); + foreach ($ipv6 as $item) { + $return .= hexdec($item).'.'; + } + $return = substr($return, 0, -1); + } else { + $return = $ip; + } + return $return; +} diff --git a/includes/polling/bgp-peers.inc.php b/includes/polling/bgp-peers.inc.php index 991c8aa1b..3dc752490 100644 --- a/includes/polling/bgp-peers.inc.php +++ b/includes/polling/bgp-peers.inc.php @@ -10,17 +10,52 @@ if ($config['enable_bgp']) { // Poll BGP Peer + $peer2 = FALSE; echo("Checking BGP peer ".$peer['bgpPeerIdentifier']." "); - if (!strstr($peer['bgpPeerIdentifier'],':')) + if (!empty($peer['bgpPeerIdentifier']) && $device['os'] != "junos") { # v4 BGP4 MIB // FIXME - needs moved to function - $peer_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m BGP4-MIB -OUvq " . snmp_gen_auth($device) . " " . $device['hostname'].":".$device['port'] . " "; - $peer_cmd .= "bgpPeerState." . $peer['bgpPeerIdentifier'] . " bgpPeerAdminStatus." . $peer['bgpPeerIdentifier'] . " bgpPeerInUpdates." . $peer['bgpPeerIdentifier'] . " bgpPeerOutUpdates." . $peer['bgpPeerIdentifier'] . " bgpPeerInTotalMessages." . $peer['bgpPeerIdentifier'] . " "; - $peer_cmd .= "bgpPeerOutTotalMessages." . $peer['bgpPeerIdentifier'] . " bgpPeerFsmEstablishedTime." . $peer['bgpPeerIdentifier'] . " bgpPeerInUpdateElapsedTime." . $peer['bgpPeerIdentifier'] . " "; - $peer_cmd .= "bgpPeerLocalAddr." . $peer['bgpPeerIdentifier'] . ""; - $peer_data = trim(`$peer_cmd`); + $peer_data_check = snmpwalk_cache_oid($device, "cbgpPeer2RemoteAs", array(), "CISCO-BGP4-MIB", $config['mibdir']); + if (count($peer_data_check) > 0) { + $peer2 = TRUE; + } + + if ($peer2 === TRUE) { + $bgp_peer_ip = ip_to_hex($peer['bgpPeerIdentifier']); + if (strstr($peer['bgpPeerIdentifier'],":")) { + $ip_type = 2; + $ip_len = 16; + $ip_ver = 'ipv6'; + } else { + $ip_type = 1; + $ip_len = 4; + $ip_ver = 'ipv4'; + } + $peer_identifier = $ip_type . '.' . $ip_len . '.' . $bgp_peer_ip; + $peer_data_tmp = snmp_get_multi($device, + " cbgpPeer2State.". $peer_identifier . + " cbgpPeer2AdminStatus.". $peer_identifier . + " cbgpPeer2InUpdates." . $peer_identifier . + " cbgpPeer2OutUpdates." . $peer_identifier . + " cbgpPeer2InTotalMessages." . $peer_identifier . + " cbgpPeer2OutTotalMessages." . $peer_identifier . + " cbgpPeer2FsmEstablishedTime." . $peer_identifier . + " cbgpPeer2InUpdateElapsedTime." . $peer_identifier . + " cbgpPeer2LocalAddr." . $peer_identifier, "-OQUs", "CISCO-BGP4-MIB",$config['mibdir']); + $ident = "$ip_ver.\"".$peer['bgpPeerIdentifier'].'"'; + unset($peer_data); + foreach ($peer_data_tmp[$ident] as $k => $v) { + $peer_data .= "$v\n"; + } + } else { + $peer_cmd = $config['snmpget'] . " -M " . $config['mibdir'] . " -m BGP4-MIB -OUvq " . snmp_gen_auth($device) . " " . $device['hostname'] . ":" . $device['port'] . " "; + $peer_cmd .= "bgpPeerState." . $peer['bgpPeerIdentifier'] . " bgpPeerAdminStatus." . $peer['bgpPeerIdentifier'] . " bgpPeerInUpdates." . $peer['bgpPeerIdentifier'] . " bgpPeerOutUpdates." . $peer['bgpPeerIdentifier'] . " bgpPeerInTotalMessages." . $peer['bgpPeerIdentifier'] . " "; + $peer_cmd .= "bgpPeerOutTotalMessages." . $peer['bgpPeerIdentifier'] . " bgpPeerFsmEstablishedTime." . $peer['bgpPeerIdentifier'] . " bgpPeerInUpdateElapsedTime." . $peer['bgpPeerIdentifier'] . " "; + $peer_cmd .= "bgpPeerLocalAddr." . $peer['bgpPeerIdentifier'] . ""; + $peer_data = trim(`$peer_cmd`); + } list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data); } else @@ -134,23 +169,68 @@ if ($config['enable_bgp']) $safi = $peer_afi['safi']; if ($debug) { echo("$afi $safi\n"); } - if ($device['os_group'] == "cisco") - { - // FIXME - move to function - $cbgp_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m CISCO-BGP4-MIB -Ovq " . snmp_gen_auth($device) . " " . $device['hostname'].":".$device['port']; - $cbgp_cmd .= " cbgpPeerAcceptedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi"; - $cbgp_cmd .= " cbgpPeerDeniedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi"; - $cbgp_cmd .= " cbgpPeerPrefixAdminLimit." . $peer['bgpPeerIdentifier'] . ".$afi.$safi"; - $cbgp_cmd .= " cbgpPeerPrefixThreshold." . $peer['bgpPeerIdentifier'] . ".$afi.$safi"; - $cbgp_cmd .= " cbgpPeerPrefixClearThreshold." . $peer['bgpPeerIdentifier'] . ".$afi.$safi"; - $cbgp_cmd .= " cbgpPeerAdvertisedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi"; - $cbgp_cmd .= " cbgpPeerSuppressedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi"; - $cbgp_cmd .= " cbgpPeerWithdrawnPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi"; + if ($device['os_group'] == "cisco") { - if ($debug) { echo("$cbgp_cmd\n"); } - $cbgp_data = preg_replace("/^OID.*$/", "", trim(`$cbgp_cmd`)); - $cbgp_data = preg_replace("/No Such Instance currently exists at this OID/", "0", $cbgp_data); - if ($debug) { echo("$cbgp_data\n"); } + $bgp_peer_ip = ip_to_hex($peer['bgpPeerIdentifier']); + if (strstr($peer['bgpPeerIdentifier'], ":")) { + $ip_type = 2; + $ip_len = 16; + $ip_ver = 'ipv6'; + } else { + $ip_type = 1; + $ip_len = 4; + $ip_ver = 'ipv4'; + } + $ip_cast = 1; + if ($peer_afi['safi'] == "multicast") { + $ip_cast = 2; + } elseif ($peer_afi['safi'] == "unicastAndMulticast") { + $ip_cast = 3; + } elseif ($peer_afi['safi'] == "vpn") { + $ip_cast = 128; + } + $check = snmp_get($device,"cbgpPeer2AcceptedPrefixes.".$ip_type.'.'.$ip_len.'.'.$bgp_peer_ip.'.'.$ip_type.'.'.$ip_cast,"","CISCO-BGP4-MIB", $config['mibdir']); + + if(!empty($check)) { + + $cgp_peer_identifier = $ip_type . '.' . $ip_len . '.' . $bgp_peer_ip . '.' . $ip_type . '.' . $ip_cast; + $cbgp_data_tmp = snmp_get_multi($device, + " cbgpPeer2AcceptedPrefixes.". $cgp_peer_identifier . + " cbgpPeer2DeniedPrefixes.". $cgp_peer_identifier . + " cbgpPeer2PrefixAdminLimit." . $cgp_peer_identifier . + " cbgpPeer2PrefixThreshold." . $cgp_peer_identifier . + " cbgpPeer2PrefixClearThreshold." . $cgp_peer_identifier . + " cbgpPeer2AdvertisedPrefixes." . $cgp_peer_identifier . + " cbgpPeer2SuppressedPrefixes." . $cgp_peer_identifier . + " cbgpPeer2WithdrawnPrefixes." . $cgp_peer_identifier, "-OQUs", "CISCO-BGP4-MIB",$config['mibdir']); + $ident = "$ip_ver.\"".$peer['bgpPeerIdentifier'].'"'. '.' . $ip_type . '.' . $ip_cast; + unset($cbgp_data); + foreach ($cbgp_data_tmp[$ident] as $k => $v) { + $cbgp_data .= "$v\n"; + } + + } else { + + // FIXME - move to function + $cbgp_cmd = $config['snmpget'] . " -M " . $config['mibdir'] . " -m CISCO-BGP4-MIB -Ovq " . snmp_gen_auth($device) . " " . $device['hostname'] . ":" . $device['port']; + $cbgp_cmd .= " cbgpPeerAcceptedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi"; + $cbgp_cmd .= " cbgpPeerDeniedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi"; + $cbgp_cmd .= " cbgpPeerPrefixAdminLimit." . $peer['bgpPeerIdentifier'] . ".$afi.$safi"; + $cbgp_cmd .= " cbgpPeerPrefixThreshold." . $peer['bgpPeerIdentifier'] . ".$afi.$safi"; + $cbgp_cmd .= " cbgpPeerPrefixClearThreshold." . $peer['bgpPeerIdentifier'] . ".$afi.$safi"; + $cbgp_cmd .= " cbgpPeerAdvertisedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi"; + $cbgp_cmd .= " cbgpPeerSuppressedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi"; + $cbgp_cmd .= " cbgpPeerWithdrawnPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi"; + + if ($debug) { + echo("$cbgp_cmd\n"); + } + $cbgp_data = preg_replace("/^OID.*$/", "", trim(`$cbgp_cmd`)); + $cbgp_data = preg_replace("/No Such Instance currently exists at this OID/", "0", $cbgp_data); + if ($debug) { + echo("$cbgp_data\n"); + } + } list($cbgpPeerAcceptedPrefixes,$cbgpPeerDeniedPrefixes,$cbgpPeerPrefixAdminLimit,$cbgpPeerPrefixThreshold,$cbgpPeerPrefixClearThreshold,$cbgpPeerAdvertisedPrefixes,$cbgpPeerSuppressedPrefixes,$cbgpPeerWithdrawnPrefixes) = explode("\n", $cbgp_data); } diff --git a/mibs/CISCO-BGP4-MIB b/mibs/CISCO-BGP4-MIB index 683e4dc8d..628f1c57b 100644 --- a/mibs/CISCO-BGP4-MIB +++ b/mibs/CISCO-BGP4-MIB @@ -1,224 +1,293 @@ -- ***************************************************************** --- CISCO-BGP4-MIB.my --- +-- CISCO-BGP4-MIB.my +-- -- June 2001, Ravindra Rathi --- --- Copyright (c) 2001, 2003 by Cisco Systems, Inc. +-- +-- Copyright (c) 2001, 2010 by Cisco Systems, Inc. -- All rights reserved. --- +-- -- ***************************************************************** -CISCO-BGP4-MIB DEFINITIONS ::=BEGIN +CISCO-BGP4-MIB DEFINITIONS ::= BEGIN IMPORTS - MODULE-IDENTITY, - OBJECT-TYPE, - NOTIFICATION-TYPE, - Unsigned32, Gauge32, Counter32 - FROM SNMPv2-SMI - TruthValue, - TEXTUAL-CONVENTION - FROM SNMPv2-TC - MODULE-COMPLIANCE, - OBJECT-GROUP, - NOTIFICATION-GROUP - FROM SNMPv2-CONF - ciscoMgmt - FROM CISCO-SMI - InetAddressType, - InetAddress - FROM INET-ADDRESS-MIB - SnmpAdminString - FROM SNMP-FRAMEWORK-MIB - bgpPeerEntry, - bgpPeerRemoteAddr, - bgpPeerLastError, - bgpPeerState - FROM BGP4-MIB; - + MODULE-IDENTITY, + OBJECT-TYPE, + NOTIFICATION-TYPE, + Integer32, + Unsigned32, + Gauge32, + Counter32, + IpAddress + FROM SNMPv2-SMI + MODULE-COMPLIANCE, + OBJECT-GROUP, + NOTIFICATION-GROUP + FROM SNMPv2-CONF + TruthValue, + TEXTUAL-CONVENTION + FROM SNMPv2-TC + InetAddressType, + InetAddress, + InetPortNumber, + InetAutonomousSystemNumber + FROM INET-ADDRESS-MIB + SnmpAdminString + FROM SNMP-FRAMEWORK-MIB + bgpPeerEntry, + bgpPeerRemoteAddr, + bgpPeerLastError, + bgpPeerState + FROM BGP4-MIB + ciscoMgmt + FROM CISCO-SMI; + ciscoBgp4MIB MODULE-IDENTITY - LAST-UPDATED "200302240000Z" - ORGANIZATION "Cisco Systems, Inc." - CONTACT-INFO - " Cisco Systems - Customer Service + LAST-UPDATED "201009300000Z" + ORGANIZATION "Cisco Systems, Inc." + CONTACT-INFO + "Cisco Systems + Customer Service - Postal: 170 W Tasman Drive - San Jose, CA 95134 - USA + Postal: 170 W Tasman Drive + San Jose, CA 95134 + USA - Tel: +1 800 553-NETS + Tel: +1 800 553-NETS - E-mail: cs-iprouting-bgp@cisco.com" - DESCRIPTION - "An extension to the IETF BGP4 MIB module defined in - RFC 1657. - - Following is the terminology associated with Border - Gateway Protocol(BGP). - - UPDATE message - UPDATE messages are used to transfer routing - information between BGP peers. An UPDATE message - is used to advertise a single feasible route to a - peer, or to withdraw multiple unfeasible routes - from service. + E-mail: cs-iprouting-bgp@cisco.com" + DESCRIPTION + "An extension to the IETF BGP4 MIB module defined in + RFC 1657. - Adj-RIBs-In - The Adj-RIBs-In store routing information that has - been learned from inbound UPDATE messages. Their - contents represent routes that are available as an - input to the Decision Process. + Following is the terminology associated with Border + Gateway Protocol(BGP). - Loc-RIB(BGP table) - The Loc-RIB contains the local routing information - that the BGP speaker has selected by applying its - local policies to the routing information contained - in its Adj-RIBs-In. + UPDATE message + UPDATE messages are used to transfer routing + information between BGP peers. An UPDATE message + is used to advertise a single feasible route to a + peer, or to withdraw multiple unfeasible routes + from service. - Adj-RIBs-Out - The Adj-RIBs-Out store the information that the - local BGP speaker has selected for advertisement to - its peers. The routing information stored in the - Adj-RIBs-Out will be carried in the local BGP - speaker's UPDATE messages and advertised to its - peers. - - Path Attributes - A variable length sequence of path attributes is - present in every UPDATE. Each path attribute is a - triple of variable length. - - Network Layer Reachability Information(NLRI) - A variable length field present in UPDATE messages - which contains a list of Network Layer address - prefixes. + Adj-RIBs-In + The Adj-RIBs-In store routing information that has + been learned from inbound UPDATE messages. Their + contents represent routes that are available as an + input to the Decision Process. - Address Family Identifier(AFI) - Primary identifier to indicate the type of the - Network Layer Reachability Information(NLRI) being - carried. + Loc-RIB(BGP table) + The Loc-RIB contains the local routing information + that the BGP speaker has selected by applying its + local policies to the routing information contained + in its Adj-RIBs-In. - Subsequent Address Family Identifier(SAFI) - Secondary identifier to indicate the type of the - Network Layer Reachability Information(NLRI) being - carried." - REVISION "200302240000Z" - DESCRIPTION - "+Added cbgpPeerCapsTable - +Added cbgpPeerAddrFamilyTable - +Added cbgpPeerAddrFamilyPrefixTable - +Added notification event cbgpBackwardTransition - +Added notification event cbgpPrefixThresholdExceeded - +Added notification event cbgpPrefixThresholdClear" - REVISION "200212190000Z" - DESCRIPTION - "+Added cbgpPeerPrefixTable - +Added notification event cbgpFsmStateChange" - REVISION "200108130000Z" - DESCRIPTION - "Initial version of the MIB module." - ::= { ciscoMgmt 187 } + Adj-RIBs-Out + The Adj-RIBs-Out store the information that the + local BGP speaker has selected for advertisement to + its peers. The routing information stored in the + Adj-RIBs-Out will be carried in the local BGP + speaker's UPDATE messages and advertised to its + peers. - ciscoBgp4MIBObjects - OBJECT IDENTIFIER ::= { ciscoBgp4MIB 1 } - cbgpRoute OBJECT IDENTIFIER ::= { ciscoBgp4MIBObjects 1 } - cbgpPeer OBJECT IDENTIFIER ::= { ciscoBgp4MIBObjects 2 } + Path Attributes + A variable length sequence of path attributes is + present in every UPDATE. Each path attribute is a + triple of variable length. - -- Textual convention + Network Layer Reachability Information(NLRI) + A variable length field present in UPDATE messages + which contains a list of Network Layer address + prefixes. - CbgpSafi ::= TEXTUAL-CONVENTION - STATUS current - DESCRIPTION - "Subsequent Address Family Identifier(SAFI) is used - by BGP speaker to indicate the type of the the Network - Layer Reachability Information(NLRI) being carried. - RFC-2858 has defined the following values for SAFI. - 1 - Network Layer Reachability Information used for - unicast forwarding - 2 - Network Layer Reachability Information used for - multicast forwarding - 3 - Network Layer Reachability Information used for - both unicast and multicast forwarding. - SAFI values 128 through 255 are for private use." - REFERENCE - "RFC-2858: Multiprotocol Extensions for BGP-4, - RFC-2547: BGP/MPLS VPNs" - SYNTAX INTEGER { - unicast(1), - multicast(2), - unicastAndMulticast(3), - vpn(128) - } + Address Family Identifier(AFI) + Primary identifier to indicate the type of the + Network Layer Reachability Information(NLRI) being + carried. - CbgpNetworkAddress ::= TEXTUAL-CONVENTION - STATUS current - DESCRIPTION - "Represents the Network Address prefix carried in the - BGP UPDATE messages. In the following table, column - 'Type' gives the kind of Network Layer address which - will be stored in the object of this type based on the - values of Address Family Identifier(AFI) and SAFI. + Subsequent Address Family Identifier(SAFI) + Secondary identifier to indicate the type of the + Network Layer Reachability Information(NLRI) being + carried." + REVISION "201009300000Z" + DESCRIPTION + "+Added cbgpNotifsEnable and cbgpLocalAs + +Modified CbgpNetworkAddress TC + +Added cbgpPeer2Table + +Added cbgpPeer2CapsTable + +Added cbgpPeer2AddrFamilyTable + +Added cbgpPeer2AddrFamilyPrefixTable + +Added notification cbgpPeer2EstablishedNotification + +Added notification cbgpPeer2BackwardTransNotification + +Added notification cbgpPeer2FsmStateChange + +Added notification cbgpPeer2BackwardTransition + +Added notification cbgpPeer2PrefixThresholdExceeded + +Added notification cbgpPeer2PrefixThresholdClear" + REVISION "200302240000Z" + DESCRIPTION + "+Added cbgpPeerCapsTable + +Added cbgpPeerAddrFamilyTable + +Added cbgpPeerAddrFamilyPrefixTable + +Added notification event cbgpBackwardTransition + +Added notification event cbgpPrefixThresholdExceeded + +Added notification event cbgpPrefixThresholdClear" + REVISION "200212190000Z" + DESCRIPTION + "+Added cbgpPeerPrefixTable + +Added notification event cbgpFsmStateChange" + REVISION "200108130000Z" + DESCRIPTION + "Initial version of the MIB module." + ::= { ciscoMgmt 187 } - AFI SAFI Type - - ipv4(1) unicast(1) IPv4 address - - ipv4(1) multicast(2) IPv4 address +ciscoBgp4MIBObjects OBJECT IDENTIFIER + ::= { ciscoBgp4MIB 1 } - ipv4(1) vpn(128) VPN-IPv4 address - - ipv6(2) unicast(1) IPv6 address +cbgpRoute OBJECT IDENTIFIER + ::= { ciscoBgp4MIBObjects 1 } - A VPN-IPv4 address is a 12-byte quantity, beginning - with an 8-byte 'Route Distinguisher (RD)' and ending - with a 4-byte IPv4 address." - REFERENCE - "RFC-2858: Multiprotocol Extensions for BGP-4 - RFC-2547: BGP/MPLS VPNs, section 4.1" - SYNTAX OCTET STRING (SIZE (0..255)) +cbgpPeer OBJECT IDENTIFIER + ::= { ciscoBgp4MIBObjects 2 } - -- BGP4 Received Routes for all the supported address families - - cbgpRouteTable OBJECT-TYPE - SYNTAX SEQUENCE OF CbgpRouteEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "This table contains information about routes to - destination networks from all BGP4 peers. Since - BGP4 can carry routes for multiple Network Layer - protocols, this table has the Address Family - Identifier(AFI) of the Network Layer protocol as the - first index. Further for a given AFI, routes carried - by BGP4 are distinguished based on Subsequent Address - Family Identifiers(SAFI). Hence that is used as the - second index. Conceptually there is a separate Loc-RIB - maintained by the BGP speaker for each combination of - AFI and SAFI supported by it." - REFERENCE - "RFC-1771: A Border Gateway Protocol 4 (BGP-4), - RFC-2858: Multiprotocol Extensions for BGP-4, - RFC-2547: BGP/MPLS VPNs" - ::= { cbgpRoute 1 } +cbgpGlobal OBJECT IDENTIFIER + ::= { ciscoBgp4MIBObjects 3 } - cbgpRouteEntry OBJECT-TYPE - SYNTAX CbgpRouteEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "Information about a path to a network received from - a peer." - INDEX { cbgpRouteAfi, - cbgpRouteSafi, - cbgpRoutePeerType, - cbgpRoutePeer, - cbgpRouteAddrPrefix, - cbgpRouteAddrPrefixLen } - ::= { cbgpRouteTable 1 } - CbgpRouteEntry ::= SEQUENCE { +-- Textual convention + +CbgpSafi ::= TEXTUAL-CONVENTION + STATUS current + DESCRIPTION + "Subsequent Address Family Identifier(SAFI) is used + by BGP speaker to indicate the type of the the Network + Layer Reachability Information(NLRI) being carried. + RFC-2858 has defined the following values for SAFI. + 1 - Network Layer Reachability Information used for + unicast forwarding + 2 - Network Layer Reachability Information used for + multicast forwarding + 3 - Network Layer Reachability Information used for + both unicast and multicast forwarding. + SAFI values 128 through 255 are for private use." + + REFERENCE + "RFC-2858: Multiprotocol Extensions for BGP-4, + RFC-2547: BGP/MPLS VPNs" + SYNTAX INTEGER { + unicast(1), + multicast(2), + unicastAndMulticast(3), + vpn(128) + } + +CbgpNetworkAddress ::= TEXTUAL-CONVENTION + STATUS current + DESCRIPTION + "Represents the Network Address prefix carried in the + BGP UPDATE messages. In the following table, column + 'Type' gives the kind of Network Layer address which + will be stored in the object of this type based on the + values of Address Family Identifier(AFI) and SAFI. + + AFI SAFI Type + + ipv4(1) unicast(1) IPv4 address + ipv4(1) multicast(2) IPv4 address + ipv4(1) vpn(128) VPN-IPv4 address + ipv6(2) unicast(1) IPv6 address + ipv6(2) multicast(2) IPv6 address + ipv6(2) vpn(128) VPN-IPv6 address + + A VPN-IPv4 address is a 12-byte quantity, beginning + with an 8-byte 'Route Distinguisher (RD)' and ending + with a 4-byte IPv4 address. + + A VPN-IPv6 address is a 24-byte quantity, beginning + with an 8-byte 'Route Distinguisher (RD)' and ending + with a 16-byte IPv6 address." + + REFERENCE + "RFC 2858, Multiprotocol Extensions for BGP-4. + RFC 2547, Section 4.1, BGP/MPLS VPNs." + SYNTAX OCTET STRING (SIZE (0..255)) + + +-- Global objects. + +cbgpNotifsEnable OBJECT-TYPE + SYNTAX BITS { + notifsEnable(0), + notifsPeer2Enable(1) + } + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "Indicates whether the specific notifications are + enabled. + If notifsEnable(0) bit is set to 1, + then the notifications defined in + ciscoBgp4NotificationsGroup1 are enabled; + If notifsPeer2Enable(1) bit is set to 1, + then the notifications defined in + ciscoBgp4Peer2NotificationsGroup are enabled." + ::= { cbgpGlobal 1 } + +cbgpLocalAs OBJECT-TYPE + SYNTAX InetAutonomousSystemNumber + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The local autonomous system (AS) number." + REFERENCE + "RFC 4271, Section 4.2, 'My Autonomous System'. + RFC 4893, BGP Support for Four-octet AS + Number Space." + ::= { cbgpGlobal 2 } + + +-- BGP4 Received Routes for all the supported address families + +cbgpRouteTable OBJECT-TYPE + SYNTAX SEQUENCE OF CbgpRouteEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "This table contains information about routes to + destination networks from all BGP4 peers. Since + BGP4 can carry routes for multiple Network Layer + protocols, this table has the Address Family + Identifier(AFI) of the Network Layer protocol as the + first index. Further for a given AFI, routes carried + by BGP4 are distinguished based on Subsequent Address + Family Identifiers(SAFI). Hence that is used as the + second index. Conceptually there is a separate Loc-RIB + maintained by the BGP speaker for each combination of + AFI and SAFI supported by it." + REFERENCE + "RFC-1771: A Border Gateway Protocol 4 (BGP-4), + RFC-2858: Multiprotocol Extensions for BGP-4, + RFC-2547: BGP/MPLS VPNs" + ::= { cbgpRoute 1 } + +cbgpRouteEntry OBJECT-TYPE + SYNTAX CbgpRouteEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Information about a path to a network received from + a peer." + INDEX { + cbgpRouteAfi, + cbgpRouteSafi, + cbgpRoutePeerType, + cbgpRoutePeer, + cbgpRouteAddrPrefix, + cbgpRouteAddrPrefixLen + } + ::= { cbgpRouteTable 1 } + +CbgpRouteEntry ::= SEQUENCE { cbgpRouteAfi InetAddressType, cbgpRouteSafi CbgpSafi, cbgpRoutePeerType InetAddressType, @@ -238,932 +307,1974 @@ ciscoBgp4MIB MODULE-IDENTITY cbgpRouteAggregatorAddr InetAddress, cbgpRouteBest TruthValue, cbgpRouteUnknownAttr OCTET STRING - } - - cbgpRouteAfi OBJECT-TYPE - SYNTAX InetAddressType - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "Represents Address Family Identifier(AFI) of the - Network Layer protocol associated with the route. - An implementation is only required to support IPv4 - unicast and VPNv4 (Value - 1) address families." - ::= { cbgpRouteEntry 1 } - - cbgpRouteSafi OBJECT-TYPE - SYNTAX CbgpSafi - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "Represents Subsequent Address Family Identifier(SAFI) - of the route. It gives additional information about - the type of the route. An implementation is only - required to support IPv4 unicast(Value - 1) and VPNv4( - Value - 128) address families." - ::= { cbgpRouteEntry 2 } - - cbgpRoutePeerType OBJECT-TYPE - SYNTAX InetAddressType - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "Represents the type of Network Layer address stored - in cbgpRoutePeer. An implementation is only required - to support IPv4 address type(Value - 1)." - ::= { cbgpRouteEntry 3 } - - cbgpRoutePeer OBJECT-TYPE - SYNTAX InetAddress - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "The Network Layer address of the peer where the route - information was learned. An implementation is only - required to support an IPv4 peer." - ::= { cbgpRouteEntry 4 } - - cbgpRouteAddrPrefix OBJECT-TYPE - SYNTAX CbgpNetworkAddress - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "A Network Address prefix in the Network Layer - Reachability Information field of BGP UPDATE message. - This object is a Network Address containing the prefix - with length specified by cbgpRouteAddrPrefixLen. Any - bits beyond the length specified by - cbgpRouteAddrPrefixLen are zeroed." - ::= { cbgpRouteEntry 5 } - - cbgpRouteAddrPrefixLen OBJECT-TYPE - SYNTAX Unsigned32 (0..2040) - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "Length in bits of the Network Address prefix in the - Network Layer Reachability Information field." - ::= { cbgpRouteEntry 6 } - - cbgpRouteOrigin OBJECT-TYPE - SYNTAX INTEGER { - igp(1), -- networks are interior - egp(2), -- networks learned via EGP - incomplete(3) -- undetermined - } - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The ultimate origin of the route information." - ::= { cbgpRouteEntry 7 } - - cbgpRouteASPathSegment OBJECT-TYPE - SYNTAX OCTET STRING (SIZE (0..255)) - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The sequence of AS path segments. Each AS - path segment is represented by a triple - . - - The type is a 1-octet field which has two - possible values: - 1 AS_SET: unordered set of ASs a route in the - UPDATE message has traversed - 2 AS_SEQUENCE: ordered set of ASs a route in the - UPDATE message has traversed. - - The length is a 1-octet field containing the - number of ASs in the value field. - - The value field contains one or more AS - numbers, each AS is represented in the octet - string as a pair of octets according to the - following algorithm: - - first-byte-of-pair = ASNumber / 256; - second-byte-of-pair = ASNumber & 255;" - ::= { cbgpRouteEntry 8 } - - cbgpRouteNextHop OBJECT-TYPE - SYNTAX CbgpNetworkAddress - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The Network Layer address of the border router - that should be used for the destination network." - ::= { cbgpRouteEntry 9 } - - cbgpRouteMedPresent OBJECT-TYPE - SYNTAX TruthValue - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "Indicates the presence/absence of MULTI_EXIT_DISC - attribute for the route." - ::= { cbgpRouteEntry 10 } - - cbgpRouteMultiExitDisc OBJECT-TYPE - SYNTAX Unsigned32 (0..4294967295) - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "This metric is used to discriminate between multiple - exit points to an adjacent autonomous system. The - value of this object is irrelevant if the value of - of cbgpRouteMedPresent is false(2)." - ::= { cbgpRouteEntry 11 } - - cbgpRouteLocalPrefPresent OBJECT-TYPE - SYNTAX TruthValue - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "Indicates the presence/absence of LOCAL_PREF - attribute for the route." - ::= { cbgpRouteEntry 12 } - - cbgpRouteLocalPref OBJECT-TYPE - SYNTAX Unsigned32 (0..4294967295) - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The degree of preference calculated by the local BGP4 - speaker for the route. The value of this object is - irrelevant if the value of cbgpRouteLocalPrefPresent - is false(2)." - ::= { cbgpRouteEntry 13 } - - cbgpRouteAtomicAggregate OBJECT-TYPE - SYNTAX INTEGER { - lessSpecificRouteNotSelected(1), - lessSpecificRouteSelected(2) - } - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "Whether or not the local system has selected a less - specific route without selecting a more specific - route." - ::= { cbgpRouteEntry 14 } - - cbgpRouteAggregatorAS OBJECT-TYPE - SYNTAX Unsigned32 (0..65535) - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The AS number of the last BGP4 speaker that performed - route aggregation. A value of zero (0) indicates the - absence of this attribute." - ::= { cbgpRouteEntry 15 } - - cbgpRouteAggregatorAddrType OBJECT-TYPE - SYNTAX InetAddressType - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "Represents the type of Network Layer address stored - in cbgpRouteAggregatorAddr." - ::= { cbgpRouteEntry 16 } - - cbgpRouteAggregatorAddr OBJECT-TYPE - SYNTAX InetAddress - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The Network Layer address of the last BGP4 speaker - that performed route aggregation. A value of all zeros - indicates the absence of this attribute." - ::= { cbgpRouteEntry 17 } - - cbgpRouteBest OBJECT-TYPE - SYNTAX TruthValue - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "An indication of whether or not this route was chosen - as the best BGP4 route." - ::= { cbgpRouteEntry 18 } - - cbgpRouteUnknownAttr OBJECT-TYPE - SYNTAX OCTET STRING (SIZE(0..255)) - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "One or more path attributes not understood by this - BGP4 speaker. Size zero (0) indicates the absence of - such attribute(s). Octets beyond the maximum size, if - any, are not recorded by this object. - - Each path attribute is a triple of variable length. - Attribute Type is a two-octet field that consists of - the Attribute Flags octet followed by the Attribute - Type Code octet. If the Extended Length bit of the - Attribute Flags octet is set to 0, the third octet of - the Path Attribute contains the length of the - attribute data in octets. If the Extended Length bit - of the Attribute Flags octet is set to 1, then the - third and the fourth octets of the path attribute - contain the length of the attribute data in octets. - The remaining octets of the Path Attribute represent - the attribute value and are interpreted according to - the Attribute Flags and the Attribute Type Code." - REFERENCE - "RFC-1771: A Border Gateway Protocol 4 (BGP-4), - section 4.3" - ::= { cbgpRouteEntry 19 } - - -- BGP Peer table. - - cbgpPeerTable OBJECT-TYPE - SYNTAX SEQUENCE OF CbgpPeerEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "BGP peer table. This table contains, - one entry per BGP peer, information about - the connections with BGP peers." - ::= { cbgpPeer 1 } - - cbgpPeerEntry OBJECT-TYPE - SYNTAX CbgpPeerEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "Entry containing information about the - connection with a BGP peer." - AUGMENTS { bgpPeerEntry } - ::= { cbgpPeerTable 1 } - - CbgpPeerEntry ::= SEQUENCE { - cbgpPeerPrefixAccepted Counter32, - cbgpPeerPrefixDenied Counter32, - cbgpPeerPrefixLimit Unsigned32, - cbgpPeerPrefixAdvertised Counter32, - cbgpPeerPrefixSuppressed Counter32, - cbgpPeerPrefixWithdrawn Counter32, - cbgpPeerLastErrorTxt SnmpAdminString, - cbgpPeerPrevState INTEGER - } - - cbgpPeerPrefixAccepted OBJECT-TYPE - SYNTAX Counter32 - MAX-ACCESS read-only - STATUS deprecated - DESCRIPTION - "Number of Route prefixes received on this connnection, - which are accepted after applying filters. Possible - filters are route maps, prefix lists, distributed - lists, etc." - ::= { cbgpPeerEntry 1 } - - - cbgpPeerPrefixDenied OBJECT-TYPE - SYNTAX Counter32 - MAX-ACCESS read-only - STATUS deprecated - DESCRIPTION - "Counter which gets incremented when a route prefix - received on this connection is denied or when a route - prefix is denied during soft reset of this connection - if 'soft-reconfiguration' is on . This object is - initialized to zero when the peer is configured or - the router is rebooted" - ::= { cbgpPeerEntry 2 } - - cbgpPeerPrefixLimit OBJECT-TYPE - SYNTAX Unsigned32 (1..4294967295) - MAX-ACCESS read-write - STATUS deprecated - DESCRIPTION - "Max number of route prefixes accepted on this - connection" - ::= { cbgpPeerEntry 3 } - - cbgpPeerPrefixAdvertised OBJECT-TYPE - SYNTAX Counter32 - MAX-ACCESS read-only - STATUS deprecated - DESCRIPTION - "Counter which gets incremented when a route prefix - is advertised on this connection. This object is - initialized to zero when the peer is configured or - the router is rebooted" - ::= { cbgpPeerEntry 4 } - - cbgpPeerPrefixSuppressed OBJECT-TYPE - SYNTAX Counter32 - MAX-ACCESS read-only - STATUS deprecated - DESCRIPTION - "Counter which gets incremented when a route prefix - is suppressed from being sent on this connection. This - object is initialized to zero when the peer is - configured or the router is rebooted" - ::= { cbgpPeerEntry 5 } - - cbgpPeerPrefixWithdrawn OBJECT-TYPE - SYNTAX Counter32 - MAX-ACCESS read-only - STATUS deprecated - DESCRIPTION - "Counter which gets incremented when a route prefix - is withdrawn on this connection. This object is - initialized to zero when the peer is configured or - the router is rebooted" - - ::= { cbgpPeerEntry 6 } - - cbgpPeerLastErrorTxt OBJECT-TYPE - SYNTAX SnmpAdminString - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "Implementation specific error description for - bgpPeerLastErrorReceived." - ::= { cbgpPeerEntry 7 } - - cbgpPeerPrevState OBJECT-TYPE - SYNTAX INTEGER { - none(0), - idle(1), - connect(2), - active(3), - opensent(4), - openconfirm(5), - established(6) - } - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The BGP peer connection previous state." - REFERENCE - "Section 8, RFC 1771, A Border Gateway Protocol 4 - (BGP-4)." - ::= { cbgpPeerEntry 8 } - - -- - -- Peer capabilities - -- - cbgpPeerCapsTable OBJECT-TYPE - SYNTAX SEQUENCE OF CbgpPeerCapsEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "This table contains the capabilities that are - supported by a peer. Capabilities of a peer are - received during BGP connection establishment. - Values corresponding to each received capability - are stored in this table. When a new capability - is received, this table is updated with a new - entry. When an existing capability is not received - during the latest connection establishment, the - corresponding entry is deleted from the table." - REFERENCE - "RFC 2842, Capabilities Advertisement with - BGP-4. - - RFC2818, Route Refresh Capability for BGP-4. - - RFC2858, Multiprotocol Extensions for BGP-4. - - draft-ietf-idr-restart-05.txt, Graceful Restart - Mechanism for BGP" - ::= { cbgpPeer 2 } - - cbgpPeerCapsEntry OBJECT-TYPE - SYNTAX CbgpPeerCapsEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "Each entry represents a capability received from a - peer with a particular code and an index. When a - capability is received multiple times with different - values during a BGP connection establishment, - corresponding entries are differentiated with indices." - INDEX { - bgpPeerRemoteAddr, - cbgpPeerCapCode, - cbgpPeerCapIndex - } - ::= { cbgpPeerCapsTable 1 } - - - CbgpPeerCapsEntry ::= SEQUENCE { - cbgpPeerCapCode INTEGER, - cbgpPeerCapIndex Unsigned32, - cbgpPeerCapValue OCTET STRING - } - - cbgpPeerCapCode OBJECT-TYPE - SYNTAX INTEGER { - multiProtocol(1), - routeRefresh(2), - gracefulRestart(64), - routeRefreshOld(128) - } - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "The BGP Capability Advertisement Capability Code." - REFERENCE - "RFC 2842, Capabilities Advertisement with - BGP-4. - - RFC2818, Route Refresh Capability for BGP-4. - - RFC2858, Multiprotocol Extensions for BGP-4. - - draft-ietf-idr-restart-05.txt, Graceful Restart - Mechanism for BGP" - ::= { cbgpPeerCapsEntry 1 } - - cbgpPeerCapIndex OBJECT-TYPE - SYNTAX Unsigned32 (1..128) - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "Multiple instances of a given capability may be - sent by a BGP speaker. This variable is used - to index them." - ::= { cbgpPeerCapsEntry 2 } - - cbgpPeerCapValue OBJECT-TYPE - SYNTAX OCTET STRING (SIZE(0..255)) - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The value of the announced capability. This - MIB object value is organized as given below, - Capability : Route Refresh Capability - Null string - Capability : Multiprotocol Extensions - +----------------------------------+ - | AFI(16 bits) | - +----------------------------------+ - | SAFI (8 bits) | - +----------------------------------+ - Capability : Graceful Restart - +----------------------------------+ - | Restart Flags (4 bits) | - +----------------------------------+ - | Restart Time in seconds (12 bits)| - +----------------------------------+ - | AFI(16 bits) | - +----------------------------------+ - | SAFI (8 bits) | - +----------------------------------+ - | Flags for Address Family (8 bits)| - +----------------------------------+ - | ... | - +----------------------------------+ - | AFI(16 bits) | - +----------------------------------+ - | SAFI (8 bits) | - +----------------------------------+ - | Flags for Address Family (8 bits)| - +----------------------------------+" - REFERENCE - "RFC 2842, Capabilities Advertisement with - BGP-4. - - RFC2818, Route Refresh Capability for BGP-4. - - RFC2858, Multiprotocol Extensions for BGP-4. - - draft-ietf-idr-restart-05.txt, Graceful Restart - Mechanism for BGP" - ::= { cbgpPeerCapsEntry 3 } - - -- - -- BGP Peer Address Family table - -- - cbgpPeerAddrFamilyTable OBJECT-TYPE - SYNTAX SEQUENCE OF CbgpPeerAddrFamilyEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "This table contains information related to - address families supported by a peer. Supported - address families of a peer are known during BGP - connection establishment. When a new supported - address family is known, this table is updated - with a new entry. When an address family is not - supported any more, corresponding entry is deleted - from the table." - ::= { cbgpPeer 3 } - - cbgpPeerAddrFamilyEntry OBJECT-TYPE - SYNTAX CbgpPeerAddrFamilyEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "An entry is identified by an AFI/SAFI pair and - peer address. It contains names associated with - an address family." - INDEX { - bgpPeerRemoteAddr, - cbgpPeerAddrFamilyAfi, - cbgpPeerAddrFamilySafi - } - ::= { cbgpPeerAddrFamilyTable 1 } - - CbgpPeerAddrFamilyEntry ::= SEQUENCE { - cbgpPeerAddrFamilyAfi InetAddressType, - cbgpPeerAddrFamilySafi CbgpSafi, - cbgpPeerAddrFamilyName SnmpAdminString - } - - cbgpPeerAddrFamilyAfi OBJECT-TYPE - SYNTAX InetAddressType - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "The AFI index of the entry. An implementation - is only required to support IPv4 unicast and - VPNv4 (Value - 1) address families." - ::= { cbgpPeerAddrFamilyEntry 1 } - - cbgpPeerAddrFamilySafi OBJECT-TYPE - SYNTAX CbgpSafi - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "The SAFI index of the entry. An implementation - is only required to support IPv4 unicast(Value - - 1) and VPNv4( Value - 128) address families." - REFERENCE - "RFC-2858: Multiprotocol Extensions for BGP-4, - RFC-2547: BGP/MPLS VPNs" - ::= { cbgpPeerAddrFamilyEntry 2 } - - cbgpPeerAddrFamilyName OBJECT-TYPE - SYNTAX SnmpAdminString - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "Implementation specific Address Family name." - ::= { cbgpPeerAddrFamilyEntry 3 } - - -- - -- BGP Address Family Peer Prefix table - -- - - cbgpPeerAddrFamilyPrefixTable OBJECT-TYPE - SYNTAX SEQUENCE OF CbgpPeerAddrFamilyPrefixEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "This table contains prefix related information - related to address families supported by a peer. - Supported address families of a peer are known - during BGP connection establishment. When a new - supported address family is known, this table - is updated with a new entry. When an address - family is not supported any more, corresponding - entry is deleted from the table." - ::= { cbgpPeer 4 } - - cbgpPeerAddrFamilyPrefixEntry OBJECT-TYPE - SYNTAX CbgpPeerAddrFamilyPrefixEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "An entry is identified by an AFI/SAFI pair and - peer address. It contains information associated - with route prefixes belonging to an address family." - INDEX { - bgpPeerRemoteAddr, - cbgpPeerAddrFamilyAfi, - cbgpPeerAddrFamilySafi - } - ::= { cbgpPeerAddrFamilyPrefixTable 1 } - - CbgpPeerAddrFamilyPrefixEntry ::= SEQUENCE { - cbgpPeerAcceptedPrefixes Counter32, - cbgpPeerDeniedPrefixes Gauge32, - cbgpPeerPrefixAdminLimit Unsigned32, - cbgpPeerPrefixThreshold Unsigned32, - cbgpPeerPrefixClearThreshold Unsigned32, - cbgpPeerAdvertisedPrefixes Gauge32, - cbgpPeerSuppressedPrefixes Gauge32, - cbgpPeerWithdrawnPrefixes Gauge32 - } - - cbgpPeerAcceptedPrefixes OBJECT-TYPE - SYNTAX Counter32 - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "Number of accepted route prefixes on this connection, - which belong to an address family." - ::= { cbgpPeerAddrFamilyPrefixEntry 1 } - - cbgpPeerDeniedPrefixes OBJECT-TYPE - SYNTAX Gauge32 - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "This counter is incremented when a route prefix, which - belongs to an address family, received on this - connection is denied. It is initialized to zero when - the connection is undergone a hard reset." - ::= { cbgpPeerAddrFamilyPrefixEntry 2 } - - cbgpPeerPrefixAdminLimit OBJECT-TYPE - SYNTAX Unsigned32 (1..4294967295) - MAX-ACCESS read-write - STATUS current - DESCRIPTION - "Max number of route prefixes accepted for an address - family on this connection." - ::= { cbgpPeerAddrFamilyPrefixEntry 3 } - - cbgpPeerPrefixThreshold OBJECT-TYPE - SYNTAX Unsigned32 (1..100) - MAX-ACCESS read-write - STATUS current - DESCRIPTION - "Prefix threshold value (%) for an address family - on this connection at which warning message stating - the prefix count is crossed the threshold or - corresponding SNMP notification is generated." - ::= { cbgpPeerAddrFamilyPrefixEntry 4 } - - cbgpPeerPrefixClearThreshold OBJECT-TYPE - SYNTAX Unsigned32 (1..100) - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "Prefix threshold value (%) for an address family - on this connection at which SNMP clear notification - is generated if prefix threshold notification is - already generated." - ::= { cbgpPeerAddrFamilyPrefixEntry 5 } - - cbgpPeerAdvertisedPrefixes OBJECT-TYPE - SYNTAX Gauge32 - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "This counter is incremented when a route prefix, - which belongs to an address family is advertised - on this connection. It is initialized to zero when - the connection is undergone a hard reset." - ::= { cbgpPeerAddrFamilyPrefixEntry 6 } - - cbgpPeerSuppressedPrefixes OBJECT-TYPE - SYNTAX Gauge32 - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "This counter is incremented when a route prefix, - which belongs to an address family is suppressed - from being sent on this connection. It is - initialized to zero when the connection is undergone - a hard reset." - ::= { cbgpPeerAddrFamilyPrefixEntry 7 } - - cbgpPeerWithdrawnPrefixes OBJECT-TYPE - SYNTAX Gauge32 - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "This counter is incremented when a route prefix, - which belongs to an address family, is withdrawn on - this connection. It is initialized to zero when the - connection is undergone a hard reset." - ::= { cbgpPeerAddrFamilyPrefixEntry 8 } - - -- Notifications - - ciscoBgp4NotifyPrefix OBJECT IDENTIFIER ::= { ciscoBgp4MIB 0 } - - cbgpFsmStateChange NOTIFICATION-TYPE - OBJECTS { bgpPeerLastError, - bgpPeerState, - cbgpPeerLastErrorTxt, - cbgpPeerPrevState - } - STATUS current - DESCRIPTION - "The BGP cbgpFsmStateChange notification is generated - for every BGP FSM state change. The bgpPeerRemoteAddr - value is attached to the notification object ID." - ::= { ciscoBgp4NotifyPrefix 1 } - - cbgpBackwardTransition NOTIFICATION-TYPE - OBJECTS { bgpPeerLastError, - bgpPeerState, - cbgpPeerLastErrorTxt, - cbgpPeerPrevState - } - STATUS current - DESCRIPTION - "The cbgpBackwardTransition Event is generated when the - BGP FSM moves from a higher numbered state to a lower - numbered state. The bgpPeerRemoteAddr value is attached - to the notification object ID." - ::= { ciscoBgp4NotifyPrefix 2 } - - cbgpPrefixThresholdExceeded NOTIFICATION-TYPE - OBJECTS { cbgpPeerPrefixAdminLimit, - cbgpPeerPrefixThreshold - } - STATUS current - DESCRIPTION - "The cbgpPrfefixMaxThresholdExceeded notification is - generated when prefix count exceeds the configured - warning threshold on a session for an address - family. The bgpPeerRemoteAddr, cbgpPeerAddrFamilyAfi - and cbgpPeerAddrFamilySafi values are attached to the - notification object ID." - ::= { ciscoBgp4NotifyPrefix 3 } - - cbgpPrefixThresholdClear NOTIFICATION-TYPE - OBJECTS { cbgpPeerPrefixAdminLimit, - cbgpPeerPrefixClearThreshold - } - STATUS current - DESCRIPTION - "The cbgpPrefixThresholdClear notification is - generated when prefix count drops below the configured - clear threshold on a session for an address family once - cbgpPrefixThresholdExceeded is generated. This won't - be generated if the peer session goes down after the - generation of cbgpPrefixThresholdExceeded. - The bgpPeerRemoteAddr, cbgpPeerAddrFamilyAfi and - cbgpPeerAddrFamilySafi values are attached to the - notification object ID." - ::= { ciscoBgp4NotifyPrefix 4 } - - - -- ciscoBgp4NotificationPrefix is deprecated. - -- Do not define any objects and/or notifications - -- under this OID. - ciscoBgp4NotificationPrefix - OBJECT IDENTIFIER ::= { ciscoBgp4MIB 2 } - - -- conformance information - - ciscoBgp4MIBConformance - OBJECT IDENTIFIER ::= { ciscoBgp4MIB 3 } - ciscoBgp4MIBCompliances - OBJECT IDENTIFIER ::= { ciscoBgp4MIBConformance 1 } - ciscoBgp4MIBGroups - OBJECT IDENTIFIER ::= { ciscoBgp4MIBConformance 2 } - - -- compliance statements - - ciscoBgp4MIBCompliance MODULE-COMPLIANCE - STATUS deprecated - DESCRIPTION - "The compliance statement for entities which implement - the Cisco BGP4 MIB" - MODULE -- this module - MANDATORY-GROUPS { ciscoBgp4RouteGroup } - ::= { ciscoBgp4MIBCompliances 1 } - - ciscoBgp4MIBComplianceRev1 MODULE-COMPLIANCE - STATUS deprecated - DESCRIPTION - "The compliance statement for entities which implement - the Cisco BGP4 MIB" - MODULE -- this module - MANDATORY-GROUPS { ciscoBgp4RouteGroup, - ciscoBgp4PeerGroup, - ciscoBgp4NotificationsGroup } - - OBJECT cbgpRouteAggregatorAddrType - SYNTAX INTEGER { ipv4(1) } - DESCRIPTION - "An implementation is only required to support - IPv4 address type for aggregator address." - - OBJECT cbgpRouteAggregatorAddr - SYNTAX InetAddress (SIZE (4)) - DESCRIPTION - "An implementation is only required to support - IPv4 address type for aggregator address." - - OBJECT cbgpPeerPrefixLimit - SYNTAX Unsigned32 (1..4294967295) - MIN-ACCESS read-only - DESCRIPTION - "SET operation is not supported on this object" - - ::= { ciscoBgp4MIBCompliances 2 } - - ciscoBgp4MIBComplianceRev2 MODULE-COMPLIANCE - STATUS current - DESCRIPTION - "The compliance statement for entities which implement - the Cisco BGP4 MIB" - MODULE -- this module - MANDATORY-GROUPS { ciscoBgp4RouteGroup, - ciscoBgp4PeerGroup1, - ciscoBgp4NotificationsGroup1 } - - OBJECT cbgpRouteAggregatorAddrType - SYNTAX INTEGER { ipv4(1) } - DESCRIPTION - "An implementation is only required to support - IPv4 address type." - - OBJECT cbgpRouteAggregatorAddr - SYNTAX OCTET STRING (SIZE (0..4)) - DESCRIPTION - "An implementation is only required to support - IPv4 address type." - - OBJECT cbgpPeerPrefixAdminLimit - MIN-ACCESS read-only - DESCRIPTION - "SET operation is not supported on this object" - - OBJECT cbgpPeerPrefixThreshold - MIN-ACCESS read-only - DESCRIPTION - "SET operation is not supported on this object" - - ::= { ciscoBgp4MIBCompliances 3 } - - -- Units of conformance - - ciscoBgp4RouteGroup OBJECT-GROUP - OBJECTS { cbgpRouteOrigin, - cbgpRouteASPathSegment, - cbgpRouteNextHop, - cbgpRouteMedPresent, - cbgpRouteMultiExitDisc, - cbgpRouteLocalPrefPresent, - cbgpRouteLocalPref, - cbgpRouteAtomicAggregate, - cbgpRouteAggregatorAS, - cbgpRouteAggregatorAddrType, - cbgpRouteAggregatorAddr, - cbgpRouteBest, - cbgpRouteUnknownAttr - } - STATUS current - DESCRIPTION - "A collection of objects providing information - about routes received by BGP speaker." - ::= { ciscoBgp4MIBGroups 1 } - - ciscoBgp4PeerGroup OBJECT-GROUP - OBJECTS { - cbgpPeerPrefixAccepted, - cbgpPeerPrefixDenied, - cbgpPeerPrefixLimit, - cbgpPeerPrefixAdvertised, - cbgpPeerPrefixSuppressed, - cbgpPeerPrefixWithdrawn - } - STATUS deprecated - DESCRIPTION - "A collection of objects providing information - about routes received by BGP speaker." - ::= { ciscoBgp4MIBGroups 2 } - - ciscoBgp4NotificationsGroup NOTIFICATION-GROUP - NOTIFICATIONS { cbgpFsmStateChange } - STATUS deprecated - DESCRIPTION - "The collection of notifications related to BGP." - ::= { ciscoBgp4MIBGroups 3 } - - ciscoBgp4PeerGroup1 OBJECT-GROUP - OBJECTS { - cbgpPeerPrevState, - cbgpPeerLastErrorTxt, - cbgpPeerCapValue, - cbgpPeerAddrFamilyName, - cbgpPeerAcceptedPrefixes, - cbgpPeerDeniedPrefixes, - cbgpPeerPrefixAdminLimit, - cbgpPeerPrefixThreshold, - cbgpPeerPrefixClearThreshold, - cbgpPeerAdvertisedPrefixes, - cbgpPeerSuppressedPrefixes, - cbgpPeerWithdrawnPrefixes +} + +cbgpRouteAfi OBJECT-TYPE + SYNTAX InetAddressType + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Represents Address Family Identifier(AFI) of the + Network Layer protocol associated with the route. + An implementation is only required to support IPv4 + unicast and VPNv4 (Value - 1) address families." + ::= { cbgpRouteEntry 1 } + +cbgpRouteSafi OBJECT-TYPE + SYNTAX CbgpSafi + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Represents Subsequent Address Family Identifier(SAFI) + of the route. It gives additional information about + the type of the route. An implementation is only + required to support IPv4 unicast(Value - 1) and VPNv4( + Value - 128) address families." + ::= { cbgpRouteEntry 2 } + +cbgpRoutePeerType OBJECT-TYPE + SYNTAX InetAddressType + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Represents the type of Network Layer address stored + in cbgpRoutePeer. An implementation is only required + to support IPv4 address type(Value - 1)." + ::= { cbgpRouteEntry 3 } + +cbgpRoutePeer OBJECT-TYPE + SYNTAX InetAddress + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The Network Layer address of the peer where the route + information was learned. An implementation is only + required to support an IPv4 peer." + ::= { cbgpRouteEntry 4 } + +cbgpRouteAddrPrefix OBJECT-TYPE + SYNTAX CbgpNetworkAddress + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "A Network Address prefix in the Network Layer + Reachability Information field of BGP UPDATE message. + This object is a Network Address containing the prefix + with length specified by cbgpRouteAddrPrefixLen. Any + bits beyond the length specified by + cbgpRouteAddrPrefixLen are zeroed." + ::= { cbgpRouteEntry 5 } + +cbgpRouteAddrPrefixLen OBJECT-TYPE + SYNTAX Unsigned32 (0..2040) + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Length in bits of the Network Address prefix in the + Network Layer Reachability Information field." + ::= { cbgpRouteEntry 6 } + +cbgpRouteOrigin OBJECT-TYPE + SYNTAX INTEGER { + igp(1), -- networks are interior + egp(2), -- networks learned via EGP + incomplete(3) -- undetermined } - STATUS current - DESCRIPTION - "A collection of objects providing information - about a BGP peer." - ::= { ciscoBgp4MIBGroups 4 } + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The ultimate origin of the route information." + ::= { cbgpRouteEntry 7 } + +cbgpRouteASPathSegment OBJECT-TYPE + SYNTAX OCTET STRING (SIZE (0..255)) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The sequence of AS path segments. Each AS + path segment is represented by a triple + . + + The type is a 1-octet field which has two + possible values: + 1 AS_SET: unordered set of ASs a route in the + UPDATE message has traversed + 2 AS_SEQUENCE: ordered set of ASs a route in the + UPDATE message has traversed. + + The length is a 1-octet field containing the + number of ASs in the value field. + + The value field contains one or more AS + numbers, each AS is represented in the octet + string as a pair of octets according to the + following algorithm: + + first-byte-of-pair = ASNumber / 256; + second-byte-of-pair = ASNumber & 255;" + ::= { cbgpRouteEntry 8 } + +cbgpRouteNextHop OBJECT-TYPE + SYNTAX CbgpNetworkAddress + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The Network Layer address of the border router + that should be used for the destination network." + ::= { cbgpRouteEntry 9 } + +cbgpRouteMedPresent OBJECT-TYPE + SYNTAX TruthValue + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Indicates the presence/absence of MULTI_EXIT_DISC + attribute for the route." + ::= { cbgpRouteEntry 10 } + +cbgpRouteMultiExitDisc OBJECT-TYPE + SYNTAX Unsigned32 (0..4294967295) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "This metric is used to discriminate between multiple + exit points to an adjacent autonomous system. The + value of this object is irrelevant if the value of + of cbgpRouteMedPresent is false(2)." + ::= { cbgpRouteEntry 11 } + +cbgpRouteLocalPrefPresent OBJECT-TYPE + SYNTAX TruthValue + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Indicates the presence/absence of LOCAL_PREF + attribute for the route." + ::= { cbgpRouteEntry 12 } + +cbgpRouteLocalPref OBJECT-TYPE + SYNTAX Unsigned32 (0..4294967295) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The degree of preference calculated by the local BGP4 + speaker for the route. The value of this object is + irrelevant if the value of cbgpRouteLocalPrefPresent + is false(2)." + ::= { cbgpRouteEntry 13 } + +cbgpRouteAtomicAggregate OBJECT-TYPE + SYNTAX INTEGER { + lessSpecificRouteNotSelected(1), + lessSpecificRouteSelected(2) + } + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Whether or not the local system has selected a less + specific route without selecting a more specific + route." + ::= { cbgpRouteEntry 14 } + +cbgpRouteAggregatorAS OBJECT-TYPE + SYNTAX Unsigned32 (0..65535) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The AS number of the last BGP4 speaker that performed + route aggregation. A value of zero (0) indicates the + absence of this attribute." + ::= { cbgpRouteEntry 15 } + +cbgpRouteAggregatorAddrType OBJECT-TYPE + SYNTAX InetAddressType + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Represents the type of Network Layer address stored + in cbgpRouteAggregatorAddr." + ::= { cbgpRouteEntry 16 } + +cbgpRouteAggregatorAddr OBJECT-TYPE + SYNTAX InetAddress + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The Network Layer address of the last BGP4 speaker + that performed route aggregation. A value of all zeros + indicates the absence of this attribute." + ::= { cbgpRouteEntry 17 } + +cbgpRouteBest OBJECT-TYPE + SYNTAX TruthValue + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "An indication of whether or not this route was chosen + as the best BGP4 route." + ::= { cbgpRouteEntry 18 } + +cbgpRouteUnknownAttr OBJECT-TYPE + SYNTAX OCTET STRING (SIZE (0..255)) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "One or more path attributes not understood by this + BGP4 speaker. Size zero (0) indicates the absence of + such attribute(s). Octets beyond the maximum size, if + any, are not recorded by this object. + + Each path attribute is a triple of variable length. + Attribute Type is a two-octet field that consists of + the Attribute Flags octet followed by the Attribute + Type Code octet. If the Extended Length bit of the + Attribute Flags octet is set to 0, the third octet of + the Path Attribute contains the length of the + attribute data in octets. If the Extended Length bit + of the Attribute Flags octet is set to 1, then the + third and the fourth octets of the path attribute + contain the length of the attribute data in octets. + The remaining octets of the Path Attribute represent + the attribute value and are interpreted according to + the Attribute Flags and the Attribute Type Code." + REFERENCE + "RFC-1771: A Border Gateway Protocol 4 (BGP-4), + section 4.3" + ::= { cbgpRouteEntry 19 } + + +-- BGP Peer table. + +cbgpPeerTable OBJECT-TYPE + SYNTAX SEQUENCE OF CbgpPeerEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "BGP peer table. This table contains, + one entry per BGP peer, information about + the connections with BGP peers." + ::= { cbgpPeer 1 } + +cbgpPeerEntry OBJECT-TYPE + SYNTAX CbgpPeerEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Entry containing information about the + connection with a BGP peer." + AUGMENTS { bgpPeerEntry } + ::= { cbgpPeerTable 1 } + +CbgpPeerEntry ::= SEQUENCE { + cbgpPeerPrefixAccepted Counter32, + cbgpPeerPrefixDenied Counter32, + cbgpPeerPrefixLimit Unsigned32, + cbgpPeerPrefixAdvertised Counter32, + cbgpPeerPrefixSuppressed Counter32, + cbgpPeerPrefixWithdrawn Counter32, + cbgpPeerLastErrorTxt SnmpAdminString, + cbgpPeerPrevState INTEGER +} + +cbgpPeerPrefixAccepted OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS deprecated + DESCRIPTION + "Number of Route prefixes received on this connnection, + which are accepted after applying filters. Possible + filters are route maps, prefix lists, distributed + lists, etc." + ::= { cbgpPeerEntry 1 } + +cbgpPeerPrefixDenied OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS deprecated + DESCRIPTION + "Counter which gets incremented when a route prefix + received on this connection is denied or when a route + prefix is denied during soft reset of this connection + if 'soft-reconfiguration' is on . This object is + initialized to zero when the peer is configured or + the router is rebooted" + ::= { cbgpPeerEntry 2 } + +cbgpPeerPrefixLimit OBJECT-TYPE + SYNTAX Unsigned32 (1..4294967295) + MAX-ACCESS read-write + STATUS deprecated + DESCRIPTION + "Max number of route prefixes accepted on this + connection" + ::= { cbgpPeerEntry 3 } + +cbgpPeerPrefixAdvertised OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS deprecated + DESCRIPTION + "Counter which gets incremented when a route prefix + is advertised on this connection. This object is + initialized to zero when the peer is configured or + the router is rebooted" + ::= { cbgpPeerEntry 4 } + +cbgpPeerPrefixSuppressed OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS deprecated + DESCRIPTION + "Counter which gets incremented when a route prefix + is suppressed from being sent on this connection. This + object is initialized to zero when the peer is + configured or the router is rebooted" + ::= { cbgpPeerEntry 5 } + +cbgpPeerPrefixWithdrawn OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS deprecated + DESCRIPTION + "Counter which gets incremented when a route prefix + is withdrawn on this connection. This object is + initialized to zero when the peer is configured or + the router is rebooted" + ::= { cbgpPeerEntry 6 } + +cbgpPeerLastErrorTxt OBJECT-TYPE + SYNTAX SnmpAdminString + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Implementation specific error description for + bgpPeerLastErrorReceived." + ::= { cbgpPeerEntry 7 } + +cbgpPeerPrevState OBJECT-TYPE + SYNTAX INTEGER { + none(0), + idle(1), + connect(2), + active(3), + opensent(4), + openconfirm(5), + established(6) + } + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The BGP peer connection previous state." + REFERENCE + "Section 8, RFC 1771, A Border Gateway Protocol 4 + (BGP-4)." + ::= { cbgpPeerEntry 8 } + + +-- Peer capabilities + +cbgpPeerCapsTable OBJECT-TYPE + SYNTAX SEQUENCE OF CbgpPeerCapsEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "This table contains the capabilities that are + supported by a peer. Capabilities of a peer are + received during BGP connection establishment. + Values corresponding to each received capability + are stored in this table. When a new capability + is received, this table is updated with a new + entry. When an existing capability is not received + during the latest connection establishment, the + corresponding entry is deleted from the table." + REFERENCE + "RFC 2842, Capabilities Advertisement with + BGP-4. + + RFC2818, Route Refresh Capability for BGP-4. + + RFC2858, Multiprotocol Extensions for BGP-4. + + draft-ietf-idr-restart-05.txt, Graceful Restart + Mechanism for BGP" + ::= { cbgpPeer 2 } + +cbgpPeerCapsEntry OBJECT-TYPE + SYNTAX CbgpPeerCapsEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Each entry represents a capability received from a + peer with a particular code and an index. When a + capability is received multiple times with different + values during a BGP connection establishment, + corresponding entries are differentiated with indices." + INDEX { + bgpPeerRemoteAddr, + cbgpPeerCapCode, + cbgpPeerCapIndex + } + ::= { cbgpPeerCapsTable 1 } + +CbgpPeerCapsEntry ::= SEQUENCE { + cbgpPeerCapCode INTEGER, + cbgpPeerCapIndex Unsigned32, + cbgpPeerCapValue OCTET STRING +} + +cbgpPeerCapCode OBJECT-TYPE + SYNTAX INTEGER { + multiProtocol(1), + routeRefresh(2), + gracefulRestart(64), + routeRefreshOld(128) + } + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The BGP Capability Advertisement Capability Code." + REFERENCE + "RFC 2842, Capabilities Advertisement with + BGP-4. + + RFC2818, Route Refresh Capability for BGP-4. + + RFC2858, Multiprotocol Extensions for BGP-4. + + draft-ietf-idr-restart-05.txt, Graceful Restart + Mechanism for BGP" + ::= { cbgpPeerCapsEntry 1 } + +cbgpPeerCapIndex OBJECT-TYPE + SYNTAX Unsigned32 (1..128) + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Multiple instances of a given capability may be + sent by a BGP speaker. This variable is used + to index them." + ::= { cbgpPeerCapsEntry 2 } + +cbgpPeerCapValue OBJECT-TYPE + SYNTAX OCTET STRING (SIZE (0..255)) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The value of the announced capability. This + MIB object value is organized as given below, + Capability : Route Refresh Capability + Null string + Capability : Multiprotocol Extensions + +----------------------------------+ + | AFI(16 bits) | + +----------------------------------+ + | SAFI (8 bits) | + +----------------------------------+ + Capability : Graceful Restart + +----------------------------------+ + | Restart Flags (4 bits) | + +----------------------------------+ + | Restart Time in seconds (12 bits)| + +----------------------------------+ + | AFI(16 bits) | + +----------------------------------+ + | SAFI (8 bits) | + +----------------------------------+ + | Flags for Address Family (8 bits)| + +----------------------------------+ + | ... | + +----------------------------------+ + | AFI(16 bits) | + +----------------------------------+ + | SAFI (8 bits) | + +----------------------------------+ + | Flags for Address Family (8 bits)| + +----------------------------------+" + REFERENCE + "RFC 2842, Capabilities Advertisement with + BGP-4. + + RFC2818, Route Refresh Capability for BGP-4. + + RFC2858, Multiprotocol Extensions for BGP-4. + + draft-ietf-idr-restart-05.txt, Graceful Restart + Mechanism for BGP" + ::= { cbgpPeerCapsEntry 3 } + + +-- BGP Peer Address Family table + +cbgpPeerAddrFamilyTable OBJECT-TYPE + SYNTAX SEQUENCE OF CbgpPeerAddrFamilyEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "This table contains information related to + address families supported by a peer. Supported + address families of a peer are known during BGP + connection establishment. When a new supported + address family is known, this table is updated + with a new entry. When an address family is not + supported any more, corresponding entry is deleted + from the table." + ::= { cbgpPeer 3 } + +cbgpPeerAddrFamilyEntry OBJECT-TYPE + SYNTAX CbgpPeerAddrFamilyEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "An entry is identified by an AFI/SAFI pair and + peer address. It contains names associated with + an address family." + INDEX { + bgpPeerRemoteAddr, + cbgpPeerAddrFamilyAfi, + cbgpPeerAddrFamilySafi + } + ::= { cbgpPeerAddrFamilyTable 1 } + +CbgpPeerAddrFamilyEntry ::= SEQUENCE { + cbgpPeerAddrFamilyAfi InetAddressType, + cbgpPeerAddrFamilySafi CbgpSafi, + cbgpPeerAddrFamilyName SnmpAdminString +} + +cbgpPeerAddrFamilyAfi OBJECT-TYPE + SYNTAX InetAddressType + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The AFI index of the entry. An implementation + is only required to support IPv4 unicast and + VPNv4 (Value - 1) address families." + ::= { cbgpPeerAddrFamilyEntry 1 } + +cbgpPeerAddrFamilySafi OBJECT-TYPE + SYNTAX CbgpSafi + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The SAFI index of the entry. An implementation + is only required to support IPv4 unicast(Value + - 1) and VPNv4( Value - 128) address families." + REFERENCE + "RFC-2858: Multiprotocol Extensions for BGP-4, + RFC-2547: BGP/MPLS VPNs" + ::= { cbgpPeerAddrFamilyEntry 2 } + +cbgpPeerAddrFamilyName OBJECT-TYPE + SYNTAX SnmpAdminString + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Implementation specific Address Family name." + ::= { cbgpPeerAddrFamilyEntry 3 } + + +-- BGP Address Family Peer Prefix table + +cbgpPeerAddrFamilyPrefixTable OBJECT-TYPE + SYNTAX SEQUENCE OF CbgpPeerAddrFamilyPrefixEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "This table contains prefix related information + related to address families supported by a peer. + Supported address families of a peer are known + during BGP connection establishment. When a new + supported address family is known, this table + is updated with a new entry. When an address + family is not supported any more, corresponding + entry is deleted from the table." + ::= { cbgpPeer 4 } + +cbgpPeerAddrFamilyPrefixEntry OBJECT-TYPE + SYNTAX CbgpPeerAddrFamilyPrefixEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "An entry is identified by an AFI/SAFI pair and + peer address. It contains information associated + with route prefixes belonging to an address family." + INDEX { + bgpPeerRemoteAddr, + cbgpPeerAddrFamilyAfi, + cbgpPeerAddrFamilySafi + } + ::= { cbgpPeerAddrFamilyPrefixTable 1 } + +CbgpPeerAddrFamilyPrefixEntry ::= SEQUENCE { + cbgpPeerAcceptedPrefixes Counter32, + cbgpPeerDeniedPrefixes Gauge32, + cbgpPeerPrefixAdminLimit Unsigned32, + cbgpPeerPrefixThreshold Unsigned32, + cbgpPeerPrefixClearThreshold Unsigned32, + cbgpPeerAdvertisedPrefixes Gauge32, + cbgpPeerSuppressedPrefixes Gauge32, + cbgpPeerWithdrawnPrefixes Gauge32 +} + +cbgpPeerAcceptedPrefixes OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Number of accepted route prefixes on this connection, + which belong to an address family." + ::= { cbgpPeerAddrFamilyPrefixEntry 1 } + +cbgpPeerDeniedPrefixes OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "This counter is incremented when a route prefix, which + belongs to an address family, received on this + connection is denied. It is initialized to zero when + the connection is undergone a hard reset." + ::= { cbgpPeerAddrFamilyPrefixEntry 2 } + +cbgpPeerPrefixAdminLimit OBJECT-TYPE + SYNTAX Unsigned32 (1..4294967295) + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "Max number of route prefixes accepted for an address + family on this connection." + ::= { cbgpPeerAddrFamilyPrefixEntry 3 } + +cbgpPeerPrefixThreshold OBJECT-TYPE + SYNTAX Unsigned32 (1..100) + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "Prefix threshold value (%) for an address family + on this connection at which warning message stating + the prefix count is crossed the threshold or + corresponding SNMP notification is generated." + ::= { cbgpPeerAddrFamilyPrefixEntry 4 } + +cbgpPeerPrefixClearThreshold OBJECT-TYPE + SYNTAX Unsigned32 (1..100) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Prefix threshold value (%) for an address family + on this connection at which SNMP clear notification + is generated if prefix threshold notification is + already generated." + ::= { cbgpPeerAddrFamilyPrefixEntry 5 } + +cbgpPeerAdvertisedPrefixes OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "This counter is incremented when a route prefix, + which belongs to an address family is advertised + on this connection. It is initialized to zero when + the connection is undergone a hard reset." + ::= { cbgpPeerAddrFamilyPrefixEntry 6 } + +cbgpPeerSuppressedPrefixes OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "This counter is incremented when a route prefix, + which belongs to an address family is suppressed + from being sent on this connection. It is + initialized to zero when the connection is undergone + a hard reset." + ::= { cbgpPeerAddrFamilyPrefixEntry 7 } + +cbgpPeerWithdrawnPrefixes OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "This counter is incremented when a route prefix, + which belongs to an address family, is withdrawn on + this connection. It is initialized to zero when the + connection is undergone a hard reset." + ::= { cbgpPeerAddrFamilyPrefixEntry 8 } + +cbgpPeer2Table OBJECT-TYPE + SYNTAX SEQUENCE OF CbgpPeer2Entry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "BGP peer table. This table contains, + one entry per BGP peer, information about + the connections with BGP peers." + ::= { cbgpPeer 5 } + +cbgpPeer2Entry OBJECT-TYPE + SYNTAX CbgpPeer2Entry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Entry containing information about the + connection with a BGP peer." + INDEX { + cbgpPeer2Type, + cbgpPeer2RemoteAddr + } + ::= { cbgpPeer2Table 1 } + +CbgpPeer2Entry ::= SEQUENCE { + cbgpPeer2Type InetAddressType, + cbgpPeer2RemoteAddr InetAddress, + cbgpPeer2State INTEGER, + cbgpPeer2AdminStatus INTEGER, + cbgpPeer2NegotiatedVersion Integer32, + cbgpPeer2LocalAddr InetAddress, + cbgpPeer2LocalPort InetPortNumber, + cbgpPeer2LocalAs InetAutonomousSystemNumber, + cbgpPeer2LocalIdentifier IpAddress, + cbgpPeer2RemotePort InetPortNumber, + cbgpPeer2RemoteAs InetAutonomousSystemNumber, + cbgpPeer2RemoteIdentifier IpAddress, + cbgpPeer2InUpdates Counter32, + cbgpPeer2OutUpdates Counter32, + cbgpPeer2InTotalMessages Counter32, + cbgpPeer2OutTotalMessages Counter32, + cbgpPeer2LastError OCTET STRING, + cbgpPeer2FsmEstablishedTransitions Counter32, + cbgpPeer2FsmEstablishedTime Gauge32, + cbgpPeer2ConnectRetryInterval Integer32, + cbgpPeer2HoldTime Integer32, + cbgpPeer2KeepAlive Integer32, + cbgpPeer2HoldTimeConfigured Integer32, + cbgpPeer2KeepAliveConfigured Integer32, + cbgpPeer2MinASOriginationInterval Integer32, + cbgpPeer2MinRouteAdvertisementInterval Integer32, + cbgpPeer2InUpdateElapsedTime Gauge32, + cbgpPeer2LastErrorTxt SnmpAdminString, + cbgpPeer2PrevState INTEGER +} + +cbgpPeer2Type OBJECT-TYPE + SYNTAX InetAddressType + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Represents the type of Peer address stored + in cbgpPeer2Entry." + ::= { cbgpPeer2Entry 1 } + +cbgpPeer2RemoteAddr OBJECT-TYPE + SYNTAX InetAddress + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The remote IP address of this entry's BGP + peer." + ::= { cbgpPeer2Entry 2 } + +cbgpPeer2State OBJECT-TYPE + SYNTAX INTEGER { + idle(1), + connect(2), + active(3), + opensent(4), + openconfirm(5), + established(6) + } + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The BGP peer connection state." + REFERENCE "RFC 4271, Section 8.2.2." + ::= { cbgpPeer2Entry 3 } + +cbgpPeer2AdminStatus OBJECT-TYPE + SYNTAX INTEGER { + stop(1), + start(2) + } + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "The desired state of the BGP connection. + A transition from 'stop' to 'start' will cause + the BGP Manual Start Event to be generated. + A transition from 'start' to 'stop' will cause + the BGP Manual Stop Event to be generated. + This parameter can be used to restart BGP peer + connections. Care should be used in providing + write access to this object without adequate + authentication." + REFERENCE "RFC 4271, Section 8.1.2." + ::= { cbgpPeer2Entry 4 } + +cbgpPeer2NegotiatedVersion OBJECT-TYPE + SYNTAX Integer32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The negotiated version of BGP running between + the two peers. + + This entry MUST be zero (0) unless the + cbgpPeer2State is in the openconfirm or the + established state. + + Note that legal values for this object are + between 0 and 255." + REFERENCE + "RFC 4271, Section 4.2. + RFC 4271, Section 7." + ::= { cbgpPeer2Entry 5 } + +cbgpPeer2LocalAddr OBJECT-TYPE + SYNTAX InetAddress + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The local IP address of this entry's BGP + connection." + ::= { cbgpPeer2Entry 6 } + +cbgpPeer2LocalPort OBJECT-TYPE + SYNTAX InetPortNumber + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The local port for the TCP connection between + the BGP peers." + ::= { cbgpPeer2Entry 7 } + +cbgpPeer2LocalAs OBJECT-TYPE + SYNTAX InetAutonomousSystemNumber + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The local AS number for this session." + ::= { cbgpPeer2Entry 8 } + +cbgpPeer2LocalIdentifier OBJECT-TYPE + SYNTAX IpAddress + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The BGP Identifier of this entry's BGP peer." + ::= { cbgpPeer2Entry 9 } + +cbgpPeer2RemotePort OBJECT-TYPE + SYNTAX InetPortNumber + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The remote port for the TCP connection + between the BGP peers. Note that the + objects cbgpPeer2LocalAddr, + cbgpPeer2LocalPort, cbgpPeer2RemoteAddr, and + cbgpPeer2RemotePort provide the appropriate + reference to the standard MIB TCP + connection table." + ::= { cbgpPeer2Entry 10 } + +cbgpPeer2RemoteAs OBJECT-TYPE + SYNTAX InetAutonomousSystemNumber + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The remote autonomous system number received in + the BGP OPEN message." + REFERENCE "RFC 4271, Section 4.2." + ::= { cbgpPeer2Entry 11 } + +cbgpPeer2RemoteIdentifier OBJECT-TYPE + SYNTAX IpAddress + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The BGP Identifier of this entry's BGP peer. + This entry MUST be 0.0.0.0 unless the + cbgpPeer2State is in the openconfirm or the + established state." + REFERENCE "RFC 4271, Section 4.2, 'BGP Identifier'." + ::= { cbgpPeer2Entry 12 } + +cbgpPeer2InUpdates OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of BGP UPDATE messages + received on this connection." + REFERENCE "RFC 4271, Section 4.3." + ::= { cbgpPeer2Entry 13 } + +cbgpPeer2OutUpdates OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of BGP UPDATE messages + transmitted on this connection." + REFERENCE "RFC 4271, Section 4.3." + ::= { cbgpPeer2Entry 14 } + +cbgpPeer2InTotalMessages OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The total number of messages received + from the remote peer on this connection." + REFERENCE "RFC 4271, Section 4." + ::= { cbgpPeer2Entry 15 } + +cbgpPeer2OutTotalMessages OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The total number of messages transmitted to + the remote peer on this connection." + REFERENCE "RFC 4271, Section 4." + ::= { cbgpPeer2Entry 16 } + +cbgpPeer2LastError OBJECT-TYPE + SYNTAX OCTET STRING (SIZE (2)) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The last error code and subcode seen by this + peer on this connection. If no error has + occurred, this field is zero. Otherwise, the + first byte of this two byte OCTET STRING + contains the error code, and the second byte + contains the subcode." + REFERENCE "RFC 4271, Section 4.5." + ::= { cbgpPeer2Entry 17 } + +cbgpPeer2FsmEstablishedTransitions OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The total number of times the BGP FSM + transitioned into the established state + for this peer." + REFERENCE "RFC 4271, Section 8." + ::= { cbgpPeer2Entry 18 } + +cbgpPeer2FsmEstablishedTime OBJECT-TYPE + SYNTAX Gauge32 + UNITS "seconds" + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "This timer indicates how long (in + seconds) this peer has been in the + established state or how long + since this peer was last in the + established state. It is set to zero when + a new peer is configured or when the router is + booted." + REFERENCE "RFC 4271, Section 8." + ::= { cbgpPeer2Entry 19 } + +cbgpPeer2ConnectRetryInterval OBJECT-TYPE + SYNTAX Integer32 (1..65535) + UNITS "seconds" + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "Time interval (in seconds) for the + ConnectRetry timer. The suggested value + for this timer is 120 seconds." + REFERENCE + "RFC 4271, Section 8.2.2. This is the value used + to initialize the 'ConnectRetryTimer'." + ::= { cbgpPeer2Entry 20 } + +cbgpPeer2HoldTime OBJECT-TYPE + SYNTAX Integer32 (0 | 3..65535) + UNITS "seconds" + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Time interval (in seconds) for the Hold + Timer established with the peer. The + value of this object is calculated by this + BGP speaker, using the smaller of the + values in cbgpPeer2HoldTimeConfigured and the + Hold Time received in the OPEN message. + + This value must be at least three seconds + if it is not zero (0). + + If the Hold Timer has not been established + with the peer this object MUST have a value + of zero (0). + + If the cbgpPeer2HoldTimeConfigured object has + a value of (0), then this object MUST have a + value of (0)." + REFERENCE "RFC 4271, Section 4.2." + ::= { cbgpPeer2Entry 21 } + +cbgpPeer2KeepAlive OBJECT-TYPE + SYNTAX Integer32 (0 | 1..21845) + UNITS "seconds" + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Time interval (in seconds) for the KeepAlive + timer established with the peer. The value + of this object is calculated by this BGP + speaker such that, when compared with + cbgpPeer2HoldTime, it has the same proportion + that cbgpPeer2KeepAliveConfigured has, + compared with cbgpPeer2HoldTimeConfigured. + + If the KeepAlive timer has not been established + with the peer, this object MUST have a value + of zero (0). + + If the of cbgpPeer2KeepAliveConfigured object + has a value of (0), then this object MUST have + a value of (0)." + REFERENCE "RFC 4271, Section 4.4." + ::= { cbgpPeer2Entry 22 } + +cbgpPeer2HoldTimeConfigured OBJECT-TYPE + SYNTAX Integer32 (0 | 3..65535) + UNITS "seconds" + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "Time interval (in seconds) for the Hold Time + configured for this BGP speaker with this + peer. This value is placed in an OPEN + message sent to this peer by this BGP + speaker, and is compared with the Hold + Time field in an OPEN message received + from the peer when determining the Hold + Time (cbgpPeer2HoldTime) with the peer. + This value must not be less than three + seconds if it is not zero (0). If it is + zero (0), the Hold Time is NOT to be + established with the peer. The suggested + value for this timer is 90 seconds." + REFERENCE + "RFC 4271, Section 4.2. + RFC 4271, Section 10." + ::= { cbgpPeer2Entry 23 } + +cbgpPeer2KeepAliveConfigured OBJECT-TYPE + SYNTAX Integer32 (0 | 1..21845) + UNITS "seconds" + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "Time interval (in seconds) for the + KeepAlive timer configured for this BGP + speaker with this peer. The value of this + object will only determine the + KEEPALIVE messages' frequency relative to + the value specified in + cbgpPeer2HoldTimeConfigured; the actual + time interval for the KEEPALIVE messages is + indicated by cbgpPeer2KeepAlive. A + reasonable maximum value for this timer + would be one third of that of + cbgpPeer2HoldTimeConfigured. + If the value of this object is zero (0), + no periodical KEEPALIVE messages are sent + to the peer after the BGP connection has + been established. The suggested value for + this timer is 30 seconds." + REFERENCE + "RFC 4271, Section 4.4. + RFC 4271, Section 10." + ::= { cbgpPeer2Entry 24 } + +cbgpPeer2MinASOriginationInterval OBJECT-TYPE + SYNTAX Integer32 (1..65535) + UNITS "seconds" + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "Time interval (in seconds) for the + MinASOriginationInterval timer. + The suggested value for this timer is 15 + seconds." + REFERENCE + "RFC 4271, Section 9.2.1.2. + RFC 4271, Section 10." + ::= { cbgpPeer2Entry 25 } + +cbgpPeer2MinRouteAdvertisementInterval OBJECT-TYPE + SYNTAX Integer32 (1..65535) + UNITS "seconds" + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "Time interval (in seconds) for the + MinRouteAdvertisementInterval timer. + The suggested value for this timer is 30 + seconds for EBGP connections and 5 + seconds for IBGP connections." + REFERENCE + "RFC 4271, Section 9.2.1.1. + RFC 4271, Section 10." + ::= { cbgpPeer2Entry 26 } + +cbgpPeer2InUpdateElapsedTime OBJECT-TYPE + SYNTAX Gauge32 + UNITS "seconds" + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Elapsed time (in seconds) since the last BGP + UPDATE message was received from the peer. + Each time cbgpPeer2InUpdates is incremented, + the value of this object is set to zero (0)." + REFERENCE + "RFC 4271, Section 4.3. + RFC 4271, Section 8.2.2, Established state." + ::= { cbgpPeer2Entry 27 } + +cbgpPeer2LastErrorTxt OBJECT-TYPE + SYNTAX SnmpAdminString + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Implementation specific error description for + bgpPeerLastErrorReceived." + ::= { cbgpPeer2Entry 28 } + +cbgpPeer2PrevState OBJECT-TYPE + SYNTAX INTEGER { + none(0), + idle(1), + connect(2), + active(3), + opensent(4), + openconfirm(5), + established(6) + } + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The BGP peer connection previous state." + REFERENCE + "RFC 1771, Section 8, A Border Gateway Protocol 4 + (BGP-4)." + ::= { cbgpPeer2Entry 29 } + +cbgpPeer2CapsTable OBJECT-TYPE + SYNTAX SEQUENCE OF CbgpPeer2CapsEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "This table contains the capabilities that are + supported by a peer. Capabilities of a peer are + received during BGP connection establishment. + Values corresponding to each received capability + are stored in this table. When a new capability + is received, this table is updated with a new + entry. When an existing capability is not received + during the latest connection establishment, the + corresponding entry is deleted from the table." + REFERENCE + "RFC 2842, Capabilities Advertisement with + BGP-4. + RFC 2818, Route Refresh Capability for BGP-4. + RFC 2858, Multiprotocol Extensions for BGP-4. + RFC 4724, Graceful Restart Mechanism for BGP. + RFC 4893, BGP Support for Four-octet AS + Number Space. + draft-ietf-idr-add-paths-04.txt, Advertisement + of Multiple Paths in BGP." + ::= { cbgpPeer 6 } + +cbgpPeer2CapsEntry OBJECT-TYPE + SYNTAX CbgpPeer2CapsEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Each entry represents a capability received from a + peer with a particular code and an index. When a + capability is received multiple times with different + values during a BGP connection establishment, + corresponding entries are differentiated with indices." + INDEX { + cbgpPeer2Type, + cbgpPeer2RemoteAddr, + cbgpPeer2CapCode, + cbgpPeer2CapIndex + } + ::= { cbgpPeer2CapsTable 1 } + +CbgpPeer2CapsEntry ::= SEQUENCE { + cbgpPeer2CapCode INTEGER, + cbgpPeer2CapIndex Unsigned32, + cbgpPeer2CapValue OCTET STRING +} + +cbgpPeer2CapCode OBJECT-TYPE + SYNTAX INTEGER { + multiProtocol(1), + routeRefresh(2), + gracefulRestart(64), + fourByteAs(65), + addPath(69), + routeRefreshOld(128) + } + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The BGP Capability Advertisement Capability Code." + REFERENCE + "RFC 2842, Capabilities Advertisement with + BGP-4. + RFC 2818, Route Refresh Capability for BGP-4. + RFC 2858, Multiprotocol Extensions for BGP-4. + RFC 4724, Graceful Restart Mechanism for BGP. + RFC 4893, BGP Support for Four-octet AS + Number Space. + draft-ietf-idr-add-paths-04.txt, Advertisement + of Multiple Paths in BGP." + ::= { cbgpPeer2CapsEntry 1 } + +cbgpPeer2CapIndex OBJECT-TYPE + SYNTAX Unsigned32 (1..128) + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "Multiple instances of a given capability may be + sent by a BGP speaker. This variable is used + to index them." + ::= { cbgpPeer2CapsEntry 2 } + +cbgpPeer2CapValue OBJECT-TYPE + SYNTAX OCTET STRING (SIZE (0..255)) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The value of the announced capability. This + MIB object value is organized as given below, + Capability : Route Refresh Capability + 4-Byte AS Capability + Null string + Capability : Multiprotocol Extensions + +----------------------------------+ + | AFI(16 bits) | + +----------------------------------+ + | SAFI (8 bits) | + +----------------------------------+ + Capability : Graceful Restart + +----------------------------------+ + | Restart Flags (4 bits) | + +----------------------------------+ + | Restart Time in seconds (12 bits)| + +----------------------------------+ + | AFI(16 bits) | + +----------------------------------+ + | SAFI (8 bits) | + +----------------------------------+ + | Flags for Address Family (8 bits)| + +----------------------------------+ + | ... | + +----------------------------------+ + | AFI(16 bits) | + +----------------------------------+ + | SAFI (8 bits) | + +----------------------------------+ + | Flags for Address Family (8 bits)| + +----------------------------------+ + Capability : Additional Paths + +----------------------------------+ + | AFI(16 bits) | + +----------------------------------+ + | SAFI (8 bits) | + +----------------------------------+ + | Send/Receive (8 bits) | + +----------------------------------+" + REFERENCE + "RFC 2842, Capabilities Advertisement with + BGP-4. + RFC 2818, Route Refresh Capability for BGP-4. + RFC 2858, Multiprotocol Extensions for BGP-4. + RFC 4724, Graceful Restart Mechanism for BGP. + RFC 4893, BGP Support for Four-octet AS + Number Space. + draft-ietf-idr-add-paths-04.txt, Advertisement + of Multiple Paths in BGP." + ::= { cbgpPeer2CapsEntry 3 } + +cbgpPeer2AddrFamilyTable OBJECT-TYPE + SYNTAX SEQUENCE OF CbgpPeer2AddrFamilyEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "This table contains information related to + address families supported by a peer. Supported + address families of a peer are known during BGP + connection establishment. When a new supported + address family is known, this table is updated + with a new entry. When an address family is not + supported any more, corresponding entry is deleted + from the table." + ::= { cbgpPeer 7 } + +cbgpPeer2AddrFamilyEntry OBJECT-TYPE + SYNTAX CbgpPeer2AddrFamilyEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "An entry is identified by an AFI/SAFI pair and + peer address. It contains names associated with + an address family." + INDEX { + cbgpPeer2Type, + cbgpPeer2RemoteAddr, + cbgpPeer2AddrFamilyAfi, + cbgpPeer2AddrFamilySafi + } + ::= { cbgpPeer2AddrFamilyTable 1 } + +CbgpPeer2AddrFamilyEntry ::= SEQUENCE { + cbgpPeer2AddrFamilyAfi InetAddressType, + cbgpPeer2AddrFamilySafi CbgpSafi, + cbgpPeer2AddrFamilyName SnmpAdminString +} + +cbgpPeer2AddrFamilyAfi OBJECT-TYPE + SYNTAX InetAddressType + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The AFI index of the entry. An implementation + is only required to support IPv4 unicast and + VPNv4 (Value - 1) address families." + ::= { cbgpPeer2AddrFamilyEntry 1 } + +cbgpPeer2AddrFamilySafi OBJECT-TYPE + SYNTAX CbgpSafi + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The SAFI index of the entry. An implementation + is only required to support IPv4 unicast(Value + - 1) and VPNv4( Value - 128) address families." + REFERENCE + "RFC 2858, Multiprotocol Extensions for BGP-4. + RFC 2547, BGP/MPLS VPNs." + ::= { cbgpPeer2AddrFamilyEntry 2 } + +cbgpPeer2AddrFamilyName OBJECT-TYPE + SYNTAX SnmpAdminString + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Implementation specific Address Family name." + ::= { cbgpPeer2AddrFamilyEntry 3 } + +cbgpPeer2AddrFamilyPrefixTable OBJECT-TYPE + SYNTAX SEQUENCE OF CbgpPeer2AddrFamilyPrefixEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "This table contains prefix related information + related to address families supported by a peer. + Supported address families of a peer are known + during BGP connection establishment. When a new + supported address family is known, this table + is updated with a new entry. When an address + family is not supported any more, corresponding + entry is deleted from the table." + ::= { cbgpPeer 8 } + +cbgpPeer2AddrFamilyPrefixEntry OBJECT-TYPE + SYNTAX CbgpPeer2AddrFamilyPrefixEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "An entry is identified by an AFI/SAFI pair and + peer address. It contains information associated + with route prefixes belonging to an address family." + INDEX { + cbgpPeer2Type, + cbgpPeer2RemoteAddr, + cbgpPeer2AddrFamilyAfi, + cbgpPeer2AddrFamilySafi + } + ::= { cbgpPeer2AddrFamilyPrefixTable 1 } + +CbgpPeer2AddrFamilyPrefixEntry ::= SEQUENCE { + cbgpPeer2AcceptedPrefixes Counter32, + cbgpPeer2DeniedPrefixes Gauge32, + cbgpPeer2PrefixAdminLimit Unsigned32, + cbgpPeer2PrefixThreshold Unsigned32, + cbgpPeer2PrefixClearThreshold Unsigned32, + cbgpPeer2AdvertisedPrefixes Gauge32, + cbgpPeer2SuppressedPrefixes Gauge32, + cbgpPeer2WithdrawnPrefixes Gauge32 +} + +cbgpPeer2AcceptedPrefixes OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Number of accepted route prefixes on this connection, + which belong to an address family." + ::= { cbgpPeer2AddrFamilyPrefixEntry 1 } + +cbgpPeer2DeniedPrefixes OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "This counter is incremented when a route prefix, which + belongs to an address family, received on this + connection is denied. It is initialized to zero when + the connection is undergone a hard reset." + ::= { cbgpPeer2AddrFamilyPrefixEntry 2 } + +cbgpPeer2PrefixAdminLimit OBJECT-TYPE + SYNTAX Unsigned32 (1..4294967295) + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "Max number of route prefixes accepted for an address + family on this connection." + ::= { cbgpPeer2AddrFamilyPrefixEntry 3 } + +cbgpPeer2PrefixThreshold OBJECT-TYPE + SYNTAX Unsigned32 (1..100) + UNITS "percent" + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "Prefix threshold value (%) for an address family + on this connection at which warning message stating + the prefix count is crossed the threshold or + corresponding SNMP notification is generated." + ::= { cbgpPeer2AddrFamilyPrefixEntry 4 } + +cbgpPeer2PrefixClearThreshold OBJECT-TYPE + SYNTAX Unsigned32 (1..100) + UNITS "percent" + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Prefix threshold value (%) for an address family + on this connection at which SNMP clear notification + is generated if prefix threshold notification is + already generated." + ::= { cbgpPeer2AddrFamilyPrefixEntry 5 } + +cbgpPeer2AdvertisedPrefixes OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "This counter is incremented when a route prefix, + which belongs to an address family is advertised + on this connection. It is initialized to zero when + the connection is undergone a hard reset." + ::= { cbgpPeer2AddrFamilyPrefixEntry 6 } + +cbgpPeer2SuppressedPrefixes OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "This counter is incremented when a route prefix, + which belongs to an address family is suppressed + from being sent on this connection. It is + initialized to zero when the connection is undergone + a hard reset." + ::= { cbgpPeer2AddrFamilyPrefixEntry 7 } + +cbgpPeer2WithdrawnPrefixes OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "This counter is incremented when a route prefix, + which belongs to an address family, is withdrawn on + this connection. It is initialized to zero when the + connection is undergone a hard reset." + ::= { cbgpPeer2AddrFamilyPrefixEntry 8 } + + +-- Notifications + +ciscoBgp4NotifyPrefix OBJECT IDENTIFIER + ::= { ciscoBgp4MIB 0 } + +cbgpFsmStateChange NOTIFICATION-TYPE + OBJECTS { + bgpPeerLastError, + bgpPeerState, + cbgpPeerLastErrorTxt, + cbgpPeerPrevState + } + STATUS current + DESCRIPTION + "The BGP cbgpFsmStateChange notification is generated + for every BGP FSM state change. The bgpPeerRemoteAddr + value is attached to the notification object ID." + ::= { ciscoBgp4NotifyPrefix 1 } + +cbgpBackwardTransition NOTIFICATION-TYPE + OBJECTS { + bgpPeerLastError, + bgpPeerState, + cbgpPeerLastErrorTxt, + cbgpPeerPrevState + } + STATUS current + DESCRIPTION + "The cbgpBackwardTransition Event is generated when the + BGP FSM moves from a higher numbered state to a lower + numbered state. The bgpPeerRemoteAddr value is attached + to the notification object ID." + ::= { ciscoBgp4NotifyPrefix 2 } + +cbgpPrefixThresholdExceeded NOTIFICATION-TYPE + OBJECTS { + cbgpPeerPrefixAdminLimit, + cbgpPeerPrefixThreshold + } + STATUS current + DESCRIPTION + "The cbgpPrefixThresholdExceeded notification is + generated when prefix count exceeds the configured + warning threshold on a session for an address + family. The bgpPeerRemoteAddr, cbgpPeerAddrFamilyAfi + and cbgpPeerAddrFamilySafi values are attached to the + notification object ID." + ::= { ciscoBgp4NotifyPrefix 3 } + +cbgpPrefixThresholdClear NOTIFICATION-TYPE + OBJECTS { + cbgpPeerPrefixAdminLimit, + cbgpPeerPrefixClearThreshold + } + STATUS current + DESCRIPTION + "The cbgpPrefixThresholdClear notification is + generated when prefix count drops below the configured + clear threshold on a session for an address family once + cbgpPrefixThresholdExceeded is generated. This won't + be generated if the peer session goes down after the + generation of cbgpPrefixThresholdExceeded. + The bgpPeerRemoteAddr, cbgpPeerAddrFamilyAfi and + cbgpPeerAddrFamilySafi values are attached to the + notification object ID." + ::= { ciscoBgp4NotifyPrefix 4 } + +cbgpPeer2EstablishedNotification NOTIFICATION-TYPE + OBJECTS { + cbgpPeer2LastError, + cbgpPeer2State + } + STATUS current + DESCRIPTION + "The cbgpPeer2EstablishedNotification notification + is generated when the BGP FSM enters the established + state." + ::= { ciscoBgp4NotifyPrefix 5 } + +cbgpPeer2BackwardTransNotification NOTIFICATION-TYPE + OBJECTS { + cbgpPeer2LastError, + cbgpPeer2State + } + STATUS current + DESCRIPTION + "The cbgpPeer2BackwardTransNotification notification + is generated when the BGP FSM moves from a higher + numbered state to a lower numbered state." + ::= { ciscoBgp4NotifyPrefix 6 } + +cbgpPeer2FsmStateChange NOTIFICATION-TYPE + OBJECTS { + cbgpPeer2LastError, + cbgpPeer2State, + cbgpPeer2LastErrorTxt, + cbgpPeer2PrevState + } + STATUS current + DESCRIPTION + "The cbgpPeer2FsmStateChange notification is generated + for every BGP FSM state change." + ::= { ciscoBgp4NotifyPrefix 7 } + +cbgpPeer2BackwardTransition NOTIFICATION-TYPE + OBJECTS { + cbgpPeer2LastError, + cbgpPeer2State, + cbgpPeer2LastErrorTxt, + cbgpPeer2PrevState + } + STATUS current + DESCRIPTION + "The cbgpPeer2BackwardTransition notification is + generated when the BGP FSM moves from a higher numbered + state to a lower numbered state." + ::= { ciscoBgp4NotifyPrefix 8 } + +cbgpPeer2PrefixThresholdExceeded NOTIFICATION-TYPE + OBJECTS { + cbgpPeer2PrefixAdminLimit, + cbgpPeer2PrefixThreshold + } + STATUS current + DESCRIPTION + "The cbgpPeer2PrefixThresholdExceeded notification is + generated when prefix count exceeds the configured + warning threshold on a session for an address + family." + ::= { ciscoBgp4NotifyPrefix 9 } + +cbgpPeer2PrefixThresholdClear NOTIFICATION-TYPE + OBJECTS { + cbgpPeer2PrefixAdminLimit, + cbgpPeer2PrefixClearThreshold + } + STATUS current + DESCRIPTION + "The cbgpPeer2PrefixThresholdClear notification is + generated when prefix count drops below the configured + clear threshold on a session for an address family once + cbgpPeer2PrefixThresholdExceeded is generated. + This will not be generated if the peer session goes down + after the generation of cbgpPrefixThresholdExceeded." + ::= { ciscoBgp4NotifyPrefix 10 } +-- ciscoBgp4NotificationPrefix is deprecated. +-- Do not define any objects and/or notifications +-- under this OID. + +ciscoBgp4NotificationPrefix OBJECT IDENTIFIER + ::= { ciscoBgp4MIB 2 } + +-- conformance information + +ciscoBgp4MIBConformance OBJECT IDENTIFIER + ::= { ciscoBgp4MIB 3 } + +ciscoBgp4MIBCompliances OBJECT IDENTIFIER + ::= { ciscoBgp4MIBConformance 1 } + +ciscoBgp4MIBGroups OBJECT IDENTIFIER + ::= { ciscoBgp4MIBConformance 2 } + + +-- Compliance statements + +ciscoBgp4MIBCompliance MODULE-COMPLIANCE + STATUS deprecated + DESCRIPTION + "The compliance statement for entities which implement + the Cisco BGP4 MIB" + MODULE -- this module + MANDATORY-GROUPS { ciscoBgp4RouteGroup } + ::= { ciscoBgp4MIBCompliances 1 } + +ciscoBgp4MIBComplianceRev1 MODULE-COMPLIANCE + STATUS deprecated + DESCRIPTION + "The compliance statement for entities which implement + the Cisco BGP4 MIB" + MODULE -- this module + MANDATORY-GROUPS { + ciscoBgp4RouteGroup, + ciscoBgp4PeerGroup, + ciscoBgp4NotificationsGroup + } + + OBJECT cbgpRouteAggregatorAddrType + SYNTAX INTEGER { + ipv4(1) + } + DESCRIPTION + "An implementation is only required to support + IPv4 address type for aggregator address." + + OBJECT cbgpRouteAggregatorAddr + SYNTAX InetAddress (SIZE (4)) + DESCRIPTION + "An implementation is only required to support + IPv4 address type for aggregator address." + + OBJECT cbgpPeerPrefixLimit + SYNTAX Unsigned32 (1..4294967295) + MIN-ACCESS read-only + DESCRIPTION + "SET operation is not supported on this object" + ::= { ciscoBgp4MIBCompliances 2 } + +ciscoBgp4MIBComplianceRev2 MODULE-COMPLIANCE + STATUS deprecated + DESCRIPTION + "The compliance statement for entities which implement + the Cisco BGP4 MIB" + MODULE -- this module + MANDATORY-GROUPS { + ciscoBgp4RouteGroup, + ciscoBgp4PeerGroup1, + ciscoBgp4NotificationsGroup1 + } + + OBJECT cbgpRouteAggregatorAddrType + SYNTAX INTEGER { + ipv4(1) + } + DESCRIPTION + "An implementation is only required to support + IPv4 address type." + + OBJECT cbgpRouteAggregatorAddr + SYNTAX OCTET STRING (SIZE (0..4)) + DESCRIPTION + "An implementation is only required to support + IPv4 address type." + + OBJECT cbgpPeerPrefixAdminLimit + MIN-ACCESS read-only + DESCRIPTION + "SET operation is not supported on this object" + + OBJECT cbgpPeerPrefixThreshold + MIN-ACCESS read-only + DESCRIPTION + "SET operation is not supported on this object" + ::= { ciscoBgp4MIBCompliances 3 } + +ciscoBgp4MIBComplianceRev3 MODULE-COMPLIANCE + STATUS current + DESCRIPTION + "The compliance statement for entities which implement + the Cisco BGP4 MIB" + MODULE -- this module + MANDATORY-GROUPS { + ciscoBgp4RouteGroup, + ciscoBgp4PeerGroup1, + ciscoBgp4GlobalGroup, + ciscoBgp4NotificationsGroup1 + } + + GROUP ciscoBgp4Peer2Group + DESCRIPTION + "This group is unconditionally optional." + + GROUP ciscoBgp4Peer2NotificationsGroup + DESCRIPTION + "This group is unconditionally optional." + + OBJECT cbgpRouteAggregatorAddrType + SYNTAX INTEGER { + ipv4(1) + } + DESCRIPTION + "An implementation is only required to support + IPv4 address type." + + OBJECT cbgpRouteAggregatorAddr + SYNTAX OCTET STRING (SIZE (0..4)) + DESCRIPTION + "An implementation is only required to support + IPv4 address type." + + OBJECT cbgpPeerPrefixAdminLimit + MIN-ACCESS read-only + DESCRIPTION + "Write access is not required." + + OBJECT cbgpPeerPrefixThreshold + MIN-ACCESS read-only + DESCRIPTION + "Write access is not required." + + OBJECT cbgpPeer2LocalAddr + SYNTAX OCTET STRING (SIZE (0..4)) + DESCRIPTION + "An implementation is only required to support + IPv4 address type." + + OBJECT cbgpNotifsEnable + MIN-ACCESS read-only + DESCRIPTION + "Write access is not required." + + OBJECT cbgpPeer2PrefixAdminLimit + MIN-ACCESS read-only + DESCRIPTION + "Write access is not required." + + OBJECT cbgpPeer2PrefixThreshold + MIN-ACCESS read-only + DESCRIPTION + "Write access is not required." + ::= { ciscoBgp4MIBCompliances 4 } + + +-- Units of conformance + +ciscoBgp4RouteGroup OBJECT-GROUP + OBJECTS { + cbgpRouteOrigin, + cbgpRouteASPathSegment, + cbgpRouteNextHop, + cbgpRouteMedPresent, + cbgpRouteMultiExitDisc, + cbgpRouteLocalPrefPresent, + cbgpRouteLocalPref, + cbgpRouteAtomicAggregate, + cbgpRouteAggregatorAS, + cbgpRouteAggregatorAddrType, + cbgpRouteAggregatorAddr, + cbgpRouteBest, + cbgpRouteUnknownAttr + } + STATUS current + DESCRIPTION + "A collection of objects providing information + about routes received by BGP speaker." + ::= { ciscoBgp4MIBGroups 1 } + +ciscoBgp4PeerGroup OBJECT-GROUP + OBJECTS { + cbgpPeerPrefixAccepted, + cbgpPeerPrefixDenied, + cbgpPeerPrefixLimit, + cbgpPeerPrefixAdvertised, + cbgpPeerPrefixSuppressed, + cbgpPeerPrefixWithdrawn + } + STATUS deprecated + DESCRIPTION + "A collection of objects providing information + about routes received by BGP speaker." + ::= { ciscoBgp4MIBGroups 2 } + +ciscoBgp4NotificationsGroup NOTIFICATION-GROUP + NOTIFICATIONS { cbgpFsmStateChange } + STATUS deprecated + DESCRIPTION + "The collection of notifications related to BGP." + ::= { ciscoBgp4MIBGroups 3 } + +ciscoBgp4PeerGroup1 OBJECT-GROUP + OBJECTS { + cbgpPeerPrevState, + cbgpPeerLastErrorTxt, + cbgpPeerCapValue, + cbgpPeerAddrFamilyName, + cbgpPeerAcceptedPrefixes, + cbgpPeerDeniedPrefixes, + cbgpPeerPrefixAdminLimit, + cbgpPeerPrefixThreshold, + cbgpPeerPrefixClearThreshold, + cbgpPeerAdvertisedPrefixes, + cbgpPeerSuppressedPrefixes, + cbgpPeerWithdrawnPrefixes + } + STATUS current + DESCRIPTION + "A collection of objects providing information + about a BGP peer." + ::= { ciscoBgp4MIBGroups 4 } + +ciscoBgp4NotificationsGroup1 NOTIFICATION-GROUP + NOTIFICATIONS { + cbgpFsmStateChange, + cbgpBackwardTransition, + cbgpPrefixThresholdExceeded, + cbgpPrefixThresholdClear + } + STATUS current + DESCRIPTION + "The collection of notifications related to BGP." + ::= { ciscoBgp4MIBGroups 5 } + +ciscoBgp4Peer2Group OBJECT-GROUP + OBJECTS { + cbgpPeer2State, + cbgpPeer2AdminStatus, + cbgpPeer2NegotiatedVersion, + cbgpPeer2LocalAddr, + cbgpPeer2LocalPort, + cbgpPeer2LocalAs, + cbgpPeer2LocalIdentifier, + cbgpPeer2RemotePort, + cbgpPeer2RemoteAs, + cbgpPeer2RemoteIdentifier, + cbgpPeer2InUpdates, + cbgpPeer2OutUpdates, + cbgpPeer2InTotalMessages, + cbgpPeer2OutTotalMessages, + cbgpPeer2LastError, + cbgpPeer2FsmEstablishedTransitions, + cbgpPeer2FsmEstablishedTime, + cbgpPeer2ConnectRetryInterval, + cbgpPeer2HoldTime, + cbgpPeer2KeepAlive, + cbgpPeer2HoldTimeConfigured, + cbgpPeer2KeepAliveConfigured, + cbgpPeer2MinASOriginationInterval, + cbgpPeer2MinRouteAdvertisementInterval, + cbgpPeer2InUpdateElapsedTime, + cbgpPeer2LastErrorTxt, + cbgpPeer2PrevState, + cbgpPeer2CapValue, + cbgpPeer2AddrFamilyName, + cbgpPeer2AcceptedPrefixes, + cbgpPeer2DeniedPrefixes, + cbgpPeer2PrefixAdminLimit, + cbgpPeer2PrefixThreshold, + cbgpPeer2PrefixClearThreshold, + cbgpPeer2AdvertisedPrefixes, + cbgpPeer2SuppressedPrefixes, + cbgpPeer2WithdrawnPrefixes + } + STATUS current + DESCRIPTION + "A collection of objects providing information + about a BGP peer." + ::= { ciscoBgp4MIBGroups 6 } + +ciscoBgp4Peer2NotificationsGroup NOTIFICATION-GROUP + NOTIFICATIONS { + cbgpPeer2EstablishedNotification, + cbgpPeer2BackwardTransNotification, + cbgpPeer2FsmStateChange, + cbgpPeer2BackwardTransition, + cbgpPeer2PrefixThresholdExceeded, + cbgpPeer2PrefixThresholdClear + } + STATUS current + DESCRIPTION + "A collection of notifications related to BGP." + ::= { ciscoBgp4MIBGroups 7 } + +ciscoBgp4GlobalGroup OBJECT-GROUP + OBJECTS { + cbgpNotifsEnable, + cbgpLocalAs + } + STATUS current + DESCRIPTION + "A collection of global objects related to BGP." + ::= { ciscoBgp4MIBGroups 8 } - ciscoBgp4NotificationsGroup1 NOTIFICATION-GROUP - NOTIFICATIONS { - cbgpFsmStateChange, - cbgpBackwardTransition, - cbgpPrefixThresholdExceeded, - cbgpPrefixThresholdClear - } - STATUS current - DESCRIPTION - "The collection of notifications related to BGP." - ::= { ciscoBgp4MIBGroups 5 } END + + + + + From 1ca02fb3c58cb174cd92e825960e869e89de6a87 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 2 Jun 2015 17:07:20 +0100 Subject: [PATCH 024/308] Fix scrut issue --- includes/functions.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/functions.php b/includes/functions.php index 282d1e34f..22b6dc91d 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -1204,6 +1204,7 @@ function first_oid_match($device, $list) { function ip_to_hex($ip) { + $return = ''; if (strstr($ip, ":")) { $ipv6 = explode(':', $ip); foreach ($ipv6 as $item) { From ffce63968fd860dc6e34228523967f096e13d702 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 2 Jun 2015 17:36:10 +0100 Subject: [PATCH 025/308] Fixed negative values for storage: http://munin-monitoring.org/ticket/1371 --- includes/discovery/storage/hrstorage.inc.php | 2 ++ includes/functions.php | 9 +++++++++ includes/polling/storage/hrstorage.inc.php | 4 +++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/includes/discovery/storage/hrstorage.inc.php b/includes/discovery/storage/hrstorage.inc.php index 6183658f8..397872941 100644 --- a/includes/discovery/storage/hrstorage.inc.php +++ b/includes/discovery/storage/hrstorage.inc.php @@ -9,6 +9,8 @@ if (is_array($hrstorage_array)) { $fstype = $storage['hrStorageType']; $descr = $storage['hrStorageDescr']; + $storage['hrStorageSize'] = fix_integer_value($storage['hrStorageSize']); + $storage['hrStorageUsed'] = fix_integer_value($storage['hrStorageUsed']); $size = $storage['hrStorageSize'] * $storage['hrStorageAllocationUnits']; $used = $storage['hrStorageUsed'] * $storage['hrStorageAllocationUnits']; $units = $storage['hrStorageAllocationUnits']; diff --git a/includes/functions.php b/includes/functions.php index ef3cd98e3..1b995bfdb 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -1201,3 +1201,12 @@ function first_oid_match($device, $list) { } } } + +function fix_integer_value($value) { + if ($value < 0) { + $return = 4294967296+$value; + } else { + $return = $value; + } + return $return; +} diff --git a/includes/polling/storage/hrstorage.inc.php b/includes/polling/storage/hrstorage.inc.php index 304e61b7d..5ff95aa7b 100644 --- a/includes/polling/storage/hrstorage.inc.php +++ b/includes/polling/storage/hrstorage.inc.php @@ -11,8 +11,10 @@ if (!is_array($storage_cache['hrstorage'])) $entry = $storage_cache['hrstorage'][$storage[storage_index]]; $storage['units'] = $entry['hrStorageAllocationUnits']; +$entry['hrStorageUsed'] = fix_integer_value($entry['hrStorageUsed']); +$entry['hrStorageSize'] = fix_integer_value($entry['hrStorageSize']); $storage['used'] = $entry['hrStorageUsed'] * $storage['units']; $storage['size'] = $entry['hrStorageSize'] * $storage['units']; $storage['free'] = $storage['size'] - $storage['used']; -?> \ No newline at end of file +?> From bf97bad18499e157eedfaff581d403d7da346c7e Mon Sep 17 00:00:00 2001 From: Mike Rostermund Date: Tue, 2 Jun 2015 19:06:15 +0200 Subject: [PATCH 026/308] Fixed link for the dBm graphs from other Health-pages --- html/pages/health.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/pages/health.inc.php b/html/pages/health.inc.php index 50e1c1b58..e6f8d5b91 100644 --- a/html/pages/health.inc.php +++ b/html/pages/health.inc.php @@ -9,7 +9,7 @@ if ($used_sensors['voltage']) $datas[] = 'voltage'; if ($used_sensors['frequency']) $datas[] = 'frequency'; if ($used_sensors['current']) $datas[] = 'current'; if ($used_sensors['power']) $datas[] = 'power'; -if ($used_sensors['dBm']) $datas[] = 'dBm'; +if ($used_sensors['dbm']) $datas[] = 'dbm'; // FIXME generalize -> static-config ? $type_text['overview'] = "Overview"; @@ -26,7 +26,7 @@ $type_text['frequency'] = "Frequency"; $type_text['current'] = "Current"; $type_text['power'] = "Power"; $type_text['toner'] = "Toner"; -$type_text['dBm'] = "dBm"; +$type_text['dbm'] = "dBm"; if (!$vars['metric']) { $vars['metric'] = "processor"; } if (!$vars['view']) { $vars['view'] = "detail"; } From 903649dbce76c61acb95ff57d7140712e80b3d2a Mon Sep 17 00:00:00 2001 From: Rosiak Date: Tue, 2 Jun 2015 19:42:08 +0200 Subject: [PATCH 027/308] Minor name changes - Capitalise alert - Change health page menu to match the category --- html/pages/alert-log.inc.php | 2 +- html/pages/health.inc.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/html/pages/alert-log.inc.php b/html/pages/alert-log.inc.php index 44eeb404c..34551e60b 100644 --- a/html/pages/alert-log.inc.php +++ b/html/pages/alert-log.inc.php @@ -24,7 +24,7 @@ $pagetitle[] = "Alert Log";
- + diff --git a/html/pages/health.inc.php b/html/pages/health.inc.php index 50e1c1b58..feb6061bb 100644 --- a/html/pages/health.inc.php +++ b/html/pages/health.inc.php @@ -17,7 +17,7 @@ $type_text['temperature'] = "Temperature"; $type_text['charge'] = "Battery Charge"; $type_text['humidity'] = "Humidity"; $type_text['mempool'] = "Memory"; -$type_text['storage'] = "Disk Usage"; +$type_text['storage'] = "Storage"; $type_text['diskio'] = "Disk I/O"; $type_text['processor'] = "Processor"; $type_text['voltage'] = "Voltage"; From 054bf3ae209f34a2c3bc8968300722004903df1b Mon Sep 17 00:00:00 2001 From: Rosiak Date: Tue, 2 Jun 2015 22:15:36 +0200 Subject: [PATCH 028/308] Convert processors page to use bootgrid - Based on @laf code from the storage page --- html/includes/table/processor.inc.php | 67 +++++++++++++++ html/pages/health/processor.inc.php | 118 ++++++++------------------ 2 files changed, 103 insertions(+), 82 deletions(-) create mode 100644 html/includes/table/processor.inc.php diff --git a/html/includes/table/processor.inc.php b/html/includes/table/processor.inc.php new file mode 100644 index 000000000..a7b3d9745 --- /dev/null +++ b/html/includes/table/processor.inc.php @@ -0,0 +1,67 @@ + generate_device_link($processor), + 'processor_descr' => $processor['processor_descr'], + 'graph' => $mini_graph, + 'processor_usage' => $bar_link); + if ($_POST['view'] == "graphs") { + $graph_array['height'] = "100"; + $graph_array['width'] = "216"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $processor['processor_id']; + $graph_array['type'] = $graph_type; + $return_data = true; + include("includes/print-graphrow.inc.php"); + unset($return_data); + $response[] = array('hostname' => $graph_data[0], + 'processor_descr' => $graph_data[1], + 'graph' => $graph_data[2], + 'processor_usage' => $graph_data[3]); + } # endif graphs +} +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +echo _json_encode($output); diff --git a/html/pages/health/processor.inc.php b/html/pages/health/processor.inc.php index cf2cf461b..f0a39b717 100644 --- a/html/pages/health/processor.inc.php +++ b/html/pages/health/processor.inc.php @@ -1,83 +1,37 @@ - +
Time logged   DevicealertAlert Status
+ + + + + + + + +
DeviceProcessorUsage
+
-$graph_type = "processor_usage"; - -echo("
"); -echo(" "); - -echo(" - - - - - "); - -foreach (dbFetchRows("SELECT * FROM `processors` AS P, `devices` AS D WHERE D.device_id = P.device_id ORDER BY D.hostname") as $proc) -{ - if (device_permitted($proc['device_id'])) - { - $device = $proc; - - // FIXME should that really be done here? :-) - $text_descr = $proc['processor_descr']; - $text_descr = str_replace("Routing Processor", "RP", $text_descr); - $text_descr = str_replace("Switching Processor", "SP", $text_descr); - $text_descr = str_replace("Sub-Module", "Module ", $text_descr); - $text_descr = str_replace("DFC Card", "DFC", $text_descr); - - $proc_url = "device/device=".$device['device_id']."/tab=health/metric=processor/"; - - $mini_url = "graph.php?id=".$proc['processor_id']."&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=80&height=20&bg=f4f4f400"; - - $proc_popup = "onmouseover=\"return overlib('
".$device['hostname']." - ".$text_descr; - $proc_popup .= "
"; - $proc_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; - - $perc = round($proc['processor_usage']); - - $background = get_percentage_colours($perc); - - echo(" - - - - - '); - - if ($vars['view'] == "graphs") - { - echo(' - "); - - } #end graphs if - } -} - -echo("
DeviceProcessorUsage
".generate_device_link($proc)."" . $text_descr . " - ".print_percentage_bar (400, 20, $perc, $perc."%", "ffffff", $background['left'], (100 - $perc)."%" , "ffffff", $background['right'])); - echo('
'); - - $daily_graph = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=211&height=100"; - $daily_url = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=400&height=150"; - - $weekly_graph = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=".$config['time']['week']."&to=".$config['time']['now']."&width=211&height=100"; - $weekly_url = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=".$config['time']['week']."&to=".$config['time']['now']."&width=400&height=150"; - - $monthly_graph = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=".$config['time']['month']."&to=".$config['time']['now']."&width=211&height=100"; - $monthly_url = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=".$config['time']['month']."&to=".$config['time']['now']."&width=400&height=150"; - - $yearly_graph = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=".$config['time']['year']."&to=".$config['time']['now']."&width=211&height=100"; - $yearly_url = "graph.php?id=" . $proc['processor_id'] . "&type=".$graph_type."&from=".$config['time']['year']."&to=".$config['time']['now']."&width=400&height=150"; - - echo(" ', LEFT);\" onmouseout=\"return nd();\"> - "); - echo(" ', LEFT);\" onmouseout=\"return nd();\"> - "); - echo(" ', LEFT);\" onmouseout=\"return nd();\"> - "); - echo(" ', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("
"); -echo("
"); - -?> + From d191f34601bb62ccc4968aa583fc8268ba99d1f7 Mon Sep 17 00:00:00 2001 From: James Campbell Date: Wed, 3 Jun 2015 21:03:27 +1000 Subject: [PATCH 029/308] Improved Pushover transport code --- includes/alerts/transport.pushover.php | 54 +++++++++++++++++++------- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/includes/alerts/transport.pushover.php b/includes/alerts/transport.pushover.php index 7d49e10b9..6495ae551 100644 --- a/includes/alerts/transport.pushover.php +++ b/includes/alerts/transport.pushover.php @@ -39,20 +39,46 @@ foreach( $opts as $api ) { $data = array(); $data['token'] = $api['appkey']; $data['user'] = $api['userkey']; - if( $obj['severity'] == "critical" ) { - if( !empty($api['sound_critical']) ) { - $data['sound'] = $api['sound_critical']; - } - $severity = "Critical"; - $data['priority'] = 1; - } - elseif( $obj['severity'] == "warning" ) { - $severity = "Warning"; - $data['priority'] = 0; - } - $curl = curl_init(); - $data['title'] = $severity." - ".$obj['hostname']; - $data['message'] = $obj['name']; + switch( $obj['severity'] ) { + case "critical": + $severity = "Critical"; + $data['priority'] = 1; + if( !empty( $api['sound_critical'] ) ) { + $data['sound'] = $api['sound_critical']; + } + break; + case "warning": + $severity = "Warning"; + $data['priority'] = 0; + if( !empty( $api['sound_warning'] ) ) { + $data['sound'] = $api['sound_warning']; + } + break; + } + $curl = curl_init(); + switch( $obj['state'] ) { + case 0: + $title_text = "OK"; + if( !empty( $api['sound_ok'] ) ) { + $data['sound'] = $api['sound_ok']; + } + break; + case 1: + $title_text = $severity; + break; + case 2: + $title_text = "Acknowledged"; + break; + } + $data['title'] = $title_text." - ".$obj['hostname']." - ".$obj['name']; + $message_text = "Timestamp: ".$obj['timestamp']; + if( !empty( $obj['faults'] ) ) { + $message_text .= "\n\nFaults:\n"; + foreach($obj['faults'] as $k => $faults) { + $message_text .= "#".$k." ".$faults['string']."\n"; + } + } + $data['message'] = $message_text; curl_setopt($curl, CURLOPT_URL, 'https://api.pushover.net/1/messages.json'); curl_setopt($curl, CURLOPT_SAFE_UPLOAD, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); From 676812b87e7aef91edbeca13c85030ec44745c46 Mon Sep 17 00:00:00 2001 From: James Campbell Date: Wed, 3 Jun 2015 21:32:57 +1000 Subject: [PATCH 030/308] Updated indentation and moved some code --- includes/alerts/transport.pushover.php | 102 ++++++++++++------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/includes/alerts/transport.pushover.php b/includes/alerts/transport.pushover.php index 6495ae551..e315266d4 100644 --- a/includes/alerts/transport.pushover.php +++ b/includes/alerts/transport.pushover.php @@ -36,57 +36,57 @@ */ foreach( $opts as $api ) { - $data = array(); - $data['token'] = $api['appkey']; - $data['user'] = $api['userkey']; - switch( $obj['severity'] ) { - case "critical": - $severity = "Critical"; - $data['priority'] = 1; - if( !empty( $api['sound_critical'] ) ) { - $data['sound'] = $api['sound_critical']; - } - break; - case "warning": - $severity = "Warning"; - $data['priority'] = 0; - if( !empty( $api['sound_warning'] ) ) { - $data['sound'] = $api['sound_warning']; - } - break; + $data = array(); + $data['token'] = $api['appkey']; + $data['user'] = $api['userkey']; + switch( $obj['severity'] ) { + case "critical": + $severity = "Critical"; + $data['priority'] = 1; + if( !empty( $api['sound_critical'] ) ) { + $data['sound'] = $api['sound_critical']; + } + break; + case "warning": + $severity = "Warning"; + $data['priority'] = 0; + if( !empty( $api['sound_warning'] ) ) { + $data['sound'] = $api['sound_warning']; + } + break; + } + switch( $obj['state'] ) { + case 0: + $title_text = "OK"; + if( !empty( $api['sound_ok'] ) ) { + $data['sound'] = $api['sound_ok']; + } + break; + case 1: + $title_text = $severity; + break; + case 2: + $title_text = "Acknowledged"; + break; + } + $data['title'] = $title_text." - ".$obj['hostname']." - ".$obj['name']; + $message_text = "Timestamp: ".$obj['timestamp']; + if( !empty( $obj['faults'] ) ) { + $message_text .= "\n\nFaults:\n"; + foreach($obj['faults'] as $k => $faults) { + $message_text .= "#".$k." ".$faults['string']."\n"; } - $curl = curl_init(); - switch( $obj['state'] ) { - case 0: - $title_text = "OK"; - if( !empty( $api['sound_ok'] ) ) { - $data['sound'] = $api['sound_ok']; - } - break; - case 1: - $title_text = $severity; - break; - case 2: - $title_text = "Acknowledged"; - break; - } - $data['title'] = $title_text." - ".$obj['hostname']." - ".$obj['name']; - $message_text = "Timestamp: ".$obj['timestamp']; - if( !empty( $obj['faults'] ) ) { - $message_text .= "\n\nFaults:\n"; - foreach($obj['faults'] as $k => $faults) { - $message_text .= "#".$k." ".$faults['string']."\n"; - } - } - $data['message'] = $message_text; - curl_setopt($curl, CURLOPT_URL, 'https://api.pushover.net/1/messages.json'); - curl_setopt($curl, CURLOPT_SAFE_UPLOAD, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, $data); - $ret = curl_exec($curl); - $code = curl_getinfo($curl, CURLINFO_HTTP_CODE); - if( $code != 200 ) { - var_dump("Pushover returned error"); //FIXME: proper debugging - return false; - } + } + $data['message'] = $message_text; + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, 'https://api.pushover.net/1/messages.json'); + curl_setopt($curl, CURLOPT_SAFE_UPLOAD, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, $data); + $ret = curl_exec($curl); + $code = curl_getinfo($curl, CURLINFO_HTTP_CODE); + if( $code != 200 ) { + var_dump("Pushover returned error"); //FIXME: proper debugging + return false; + } } return true; From 00ace9ff76b68f5cb8e7a6825cbeaf089167d44f Mon Sep 17 00:00:00 2001 From: James Campbell Date: Wed, 3 Jun 2015 21:42:01 +1000 Subject: [PATCH 031/308] I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md. --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 127de9825..38e7bb690 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -33,3 +33,4 @@ Contributors to LibreNMS: - James Campbell (neokjames) [1]: http://observium.org/ "Observium web site" + From 702b75c0b7b8f5c2738b788684d426ad3ff6a4cd Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 3 Jun 2015 15:41:10 +0100 Subject: [PATCH 032/308] Updates --- includes/discovery/bgp-peers.inc.php | 4 +++- includes/functions.php | 19 +++++++++++++++++-- includes/polling/bgp-peers.inc.php | 21 ++++++++++++++------- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/includes/discovery/bgp-peers.inc.php b/includes/discovery/bgp-peers.inc.php index b3778e195..af9b931f5 100644 --- a/includes/discovery/bgp-peers.inc.php +++ b/includes/discovery/bgp-peers.inc.php @@ -33,7 +33,9 @@ if ($config['enable_bgp']) foreach (explode("\n", $peers) as $peer) { - list($ver, $peer) = explode(".", $peer,2); + if ($peer2 === TRUE) { + list($ver, $peer) = explode(".", $peer,2); + } list($peer_ip, $peer_as) = explode(" ", $peer); if ($peer && $peer_ip != "0.0.0.0") diff --git a/includes/functions.php b/includes/functions.php index 22b6dc91d..ef4d92aa6 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -1202,8 +1202,7 @@ function first_oid_match($device, $list) { } } -function ip_to_hex($ip) { - +function ip_to_dec($ip) { $return = ''; if (strstr($ip, ":")) { $ipv6 = explode(':', $ip); @@ -1216,3 +1215,19 @@ function ip_to_hex($ip) { } return $return; } + +function hex_to_ip($hex) { + $return = ""; + if (filter_var($hex, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === FALSE && filter_var($hex, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === FALSE) { + $hex_exp = explode(' ', $hex); + foreach ($hex_exp as $item) { + if (!empty($item) && $item != "\"") { + $return .= hexdec($item).'.'; + } + } + $return = substr($return, 0, -1); + } else { + $return = $ip; + } + return $return; +} diff --git a/includes/polling/bgp-peers.inc.php b/includes/polling/bgp-peers.inc.php index 3dc752490..47a2776ac 100644 --- a/includes/polling/bgp-peers.inc.php +++ b/includes/polling/bgp-peers.inc.php @@ -23,7 +23,7 @@ if ($config['enable_bgp']) } if ($peer2 === TRUE) { - $bgp_peer_ip = ip_to_hex($peer['bgpPeerIdentifier']); + $bgp_peer_ident = ip_to_dec($peer['bgpPeerIdentifier']); if (strstr($peer['bgpPeerIdentifier'],":")) { $ip_type = 2; $ip_len = 16; @@ -33,7 +33,7 @@ if ($config['enable_bgp']) $ip_len = 4; $ip_ver = 'ipv4'; } - $peer_identifier = $ip_type . '.' . $ip_len . '.' . $bgp_peer_ip; + $peer_identifier = $ip_type . '.' . $ip_len . '.' . $bgp_peer_ident; $peer_data_tmp = snmp_get_multi($device, " cbgpPeer2State.". $peer_identifier . " cbgpPeer2AdminStatus.". $peer_identifier . @@ -47,6 +47,15 @@ if ($config['enable_bgp']) $ident = "$ip_ver.\"".$peer['bgpPeerIdentifier'].'"'; unset($peer_data); foreach ($peer_data_tmp[$ident] as $k => $v) { + if (strstr($k, "cbgpPeer2LocalAddr")) { + if ($ip_ver == 'ipv6') { + $v = preg_replace("/ /", ":", $v); + $v = strtolower($v); + rtrim($v,":"); + } else { + $v = hex_to_ip($v); + } + } $peer_data .= "$v\n"; } } else { @@ -170,8 +179,7 @@ if ($config['enable_bgp']) if ($debug) { echo("$afi $safi\n"); } if ($device['os_group'] == "cisco") { - - $bgp_peer_ip = ip_to_hex($peer['bgpPeerIdentifier']); + $bgp_peer_ident = ip_to_dec($peer['bgpPeerIdentifier']); if (strstr($peer['bgpPeerIdentifier'], ":")) { $ip_type = 2; $ip_len = 16; @@ -189,11 +197,10 @@ if ($config['enable_bgp']) } elseif ($peer_afi['safi'] == "vpn") { $ip_cast = 128; } - $check = snmp_get($device,"cbgpPeer2AcceptedPrefixes.".$ip_type.'.'.$ip_len.'.'.$bgp_peer_ip.'.'.$ip_type.'.'.$ip_cast,"","CISCO-BGP4-MIB", $config['mibdir']); + $check = snmp_get($device,"cbgpPeer2AcceptedPrefixes.".$ip_type.'.'.$ip_len.'.'.$bgp_peer_ident.'.'.$ip_type.'.'.$ip_cast,"","CISCO-BGP4-MIB", $config['mibdir']); if(!empty($check)) { - - $cgp_peer_identifier = $ip_type . '.' . $ip_len . '.' . $bgp_peer_ip . '.' . $ip_type . '.' . $ip_cast; + $cgp_peer_identifier = $ip_type . '.' . $ip_len . '.' . $bgp_peer_ident . '.' . $ip_type . '.' . $ip_cast; $cbgp_data_tmp = snmp_get_multi($device, " cbgpPeer2AcceptedPrefixes.". $cgp_peer_identifier . " cbgpPeer2DeniedPrefixes.". $cgp_peer_identifier . From f9322a29c67cb6be06462a1bbde91b669caa1680 Mon Sep 17 00:00:00 2001 From: Rosiak Date: Wed, 3 Jun 2015 23:39:54 +0200 Subject: [PATCH 033/308] Convert memory page to use bootgrid --- html/includes/table/mempool.inc.php | 70 ++++++++++++++++ html/pages/health/mempool.inc.php | 121 +++++++++------------------- 2 files changed, 106 insertions(+), 85 deletions(-) create mode 100644 html/includes/table/mempool.inc.php diff --git a/html/includes/table/mempool.inc.php b/html/includes/table/mempool.inc.php new file mode 100644 index 000000000..a4b83263a --- /dev/null +++ b/html/includes/table/mempool.inc.php @@ -0,0 +1,70 @@ + generate_device_link($mempool), + 'mempool_descr' => $mempool['mempool_descr'], + 'graph' => $mini_graph, + 'mempool_usage' => $bar_link); + if ($_POST['view'] == "graphs") { + $graph_array['height'] = "100"; + $graph_array['width'] = "216"; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $mempool['mempool_id']; + $graph_array['type'] = $graph_type; + $return_data = true; + include("includes/print-graphrow.inc.php"); + unset($return_data); + $response[] = array('hostname' => $graph_data[0], + 'mempool_descr' => $graph_data[1], + 'graph' => $graph_data[2], + 'mempool_usage' => $graph_data[3]); + } # endif graphs +} +$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); +echo _json_encode($output); diff --git a/html/pages/health/mempool.inc.php b/html/pages/health/mempool.inc.php index b348724e5..621892444 100644 --- a/html/pages/health/mempool.inc.php +++ b/html/pages/health/mempool.inc.php @@ -1,86 +1,37 @@ - + + + + + + + + + +
DeviceMemoryUsage
+
-$graph_type = "mempool_usage"; - -echo("
"); -echo(""); - -echo(" - - - - - - "); - -foreach (dbFetchRows("SELECT * FROM `mempools` AS M, `devices` as D WHERE D.device_id = M.device_id ORDER BY D.hostname") as $mempool) -{ - if (device_permitted($mempool['device_id'])) - { - $text_descr = $mempool['mempool_descr']; - - if ($config['memcached']['enable']) - { - $state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state'); - if($debug) { print_r($state); } - if(is_array($state)) { $port = array_merge($mempool, $state); } - unset($state); - } - - - $mempool_url = "device/device=".$mempool['device_id']."/tab=health/metric=mempool/"; - $mini_url = "graph.php?id=".$mempool['mempool_id']."&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=80&height=20&bg=f4f4f4"; - - $mempool_popup = "onmouseover=\"return overlib('
".$device['hostname']." - ".$text_descr; - $mempool_popup .= "
"; - $mempool_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\""; - - $total = formatStorage($mempool['mempool_total']); - $used = formatStorage($mempool['mempool_used']); - $free = formatStorage($mempool['mempool_free']); - - $background = get_percentage_colours($mempool['mempool_perc']); - - echo(" - - - - - - "); - - if ($vars['view'] == "graphs") - { - echo(""); - } # endif graphs - } -} - -echo("
DeviceMemoryUsageUsed
".generate_device_link($mempool)."" . $text_descr . " - ".print_percentage_bar (400, 20, $mempool['mempool_perc'], "$used / $total", "ffffff", $background['left'], $free , "ffffff", $background['right'])." - ".$mempool['mempool_perc']."%
"); - - $daily_graph = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=211&height=100"; - $daily_url = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=400&height=150"; - - $weekly_graph = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=".$config['time']['week']."&to=".$config['time']['now']."&width=211&height=100"; - $weekly_url = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=".$config['time']['week']."&to=".$config['time']['now']."&width=400&height=150"; - - $monthly_graph = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=".$config['time']['month']."&to=".$config['time']['now']."&width=211&height=100"; - $monthly_url = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=".$config['time']['month']."&to=".$config['time']['now']."&width=400&height=150"; - - $yearly_graph = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=".$config['time']['year']."&to=".$config['time']['now']."&width=211&height=100"; - $yearly_url = "graph.php?id=" . $mempool['mempool_id'] . "&type=".$graph_type."&from=".$config['time']['year']."&to=".$config['time']['now']."&width=400&height=150"; - - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("
"); -echo("
"); - -?> + From 250b58ea8b78ac6c8e5ceb84c2e18c3b398ac097 Mon Sep 17 00:00:00 2001 From: Rosiak Date: Thu, 4 Jun 2015 00:08:53 +0200 Subject: [PATCH 034/308] Minor corrections to memory bootgrid --- html/includes/table/mempool.inc.php | 10 ++++++---- html/pages/health/mempool.inc.php | 5 +++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/html/includes/table/mempool.inc.php b/html/includes/table/mempool.inc.php index a4b83263a..5ebff60f0 100644 --- a/html/includes/table/mempool.inc.php +++ b/html/includes/table/mempool.inc.php @@ -31,8 +31,8 @@ $sql = "SELECT * $sql"; foreach (dbFetchRows($sql,$param) as $mempool) { $perc = round($mempool['mempool_perc'], 0); $total = formatStorage($mempool['mempool_total']); - $used = formatStorage($mempool['mempool_used']); $free = formatStorage($mempool['mempool_free']); + $used = formatStorage($mempool['mempool_used']); $graph_array['type'] = $graph_type; $graph_array['id'] = $mempool['mempool_id']; $graph_array['from'] = $config['time']['day']; @@ -45,12 +45,13 @@ foreach (dbFetchRows($sql,$param) as $mempool) { $link = "graphs/id=" . $graph_array['id'] . "/type=" . $graph_array['type'] . "/from=" . $graph_array['from'] . "/to=" . $graph_array['to'] . "/"; $mini_graph = overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL); $background = get_percentage_colours($perc); - $bar_link = overlib_link($link, print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $background['left'], $free , "ffffff", $background['right']), generate_graph_tag($graph_array_zoom), NULL); + $bar_link = overlib_link($link, print_percentage_bar (400, 20, $perc, "$used / $total", "ffffff", $background['left'], $free, "ffffff", $background['right']), generate_graph_tag($graph_array_zoom), NULL); $response[] = array('hostname' => generate_device_link($mempool), 'mempool_descr' => $mempool['mempool_descr'], 'graph' => $mini_graph, - 'mempool_usage' => $bar_link); + 'mempool_used' => $bar_link, + 'mempool_perc' => $perc . "%"); if ($_POST['view'] == "graphs") { $graph_array['height'] = "100"; $graph_array['width'] = "216"; @@ -63,7 +64,8 @@ foreach (dbFetchRows($sql,$param) as $mempool) { $response[] = array('hostname' => $graph_data[0], 'mempool_descr' => $graph_data[1], 'graph' => $graph_data[2], - 'mempool_usage' => $graph_data[3]); + 'mempool_used' => $graph_data[3], + 'mempool_perc' => ''); } # endif graphs } $output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total); diff --git a/html/pages/health/mempool.inc.php b/html/pages/health/mempool.inc.php index 621892444..a522f904c 100644 --- a/html/pages/health/mempool.inc.php +++ b/html/pages/health/mempool.inc.php @@ -5,7 +5,8 @@ Device Memory - Usage + Used + Usage @@ -14,7 +15,7 @@ +
+ + diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index a150c2daa..24b43b99f 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -43,6 +43,7 @@ $config['rrdtool'] = "/usr/bin/rrdtool"; $config['fping'] = "/usr/bin/fping"; $config['fping_options']['retries'] = 3; $config['fping_options']['timeout'] = 500; +$config['fping_options']['count'] = 3; $config['fping6'] = "/usr/bin/fping6"; $config['snmpwalk'] = "/usr/bin/snmpwalk"; $config['snmpget'] = "/usr/bin/snmpget"; @@ -581,6 +582,7 @@ $config['syslog_purge'] = 30; # Number in days $config['eventlog_purge'] = 30; # Number in days of how long to keep eventlog entries for. $config['authlog_purge'] = 30; # Number in days of how long to keep authlog entries for. $config['perf_times_purge'] = 30; # Number in days of how long to keep performace pooling stats entries for. +$config['device_perf_purge'] = 30; // Number in days of how long to keep device performance data for. # Date format for PHP date()s $config['dateformat']['long'] = "r"; # RFC2822 style diff --git a/includes/functions.php b/includes/functions.php index 725850897..f158067ca 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -495,25 +495,21 @@ function isPingable($hostname,$device_id = FALSE) if(is_numeric($config['fping_options']['timeout']) || $config['fping_options']['timeout'] > 1) { $fping_params .= ' -t ' . $config['fping_options']['timeout']; } - $status = shell_exec($config['fping'] . "$fping_params -e $hostname 2>/dev/null"); + if(is_numeric($config['fping_options']['count']) || $config['fping_options']['count'] > 0) { + $fping_params .= ' -c ' . $config['fping_options']['count']; + } + //$status = shell_exec($config['fping'] . "$fping_params -e $hostname 2>/dev/null"); $response = array(); - if (strstr($status, "alive")) - { - $response['result'] = TRUE; - } else { - $status = shell_exec($config['fping6'] . "$fping_params -e $hostname 2>/dev/null"); - if (strstr($status, "alive")) - { - $response['result'] = TRUE; - } else { + $status = fping($hostname,$fping_params); + if ($status['loss'] < 0 || $status['loss'] == 100) { $response['result'] = FALSE; - } + } else { + $response['result'] = TRUE; } - if(is_numeric($device_id) && !empty($device_id)) - { - preg_match('/(\d+\.*\d*) (ms)/', $status, $time); - $response['last_ping_timetaken'] = $time[1]; + if (is_numeric($status['avg'])) { + $response['last_ping_timetaken'] = $status['avg']; } + $response['db'] = $status; return($response); } @@ -1269,3 +1265,55 @@ function ip_exists($ip) { } return true; } + +function fping($host,$params) { + + global $config; + +// $handle = popen($config['fping'] . ' -e -q ' .$params . ' ' .$host.' 2>&1', 'r'); +// sleep(0.2); +// $read = fread($handle, 8192); +// pclose($handle); + +$descriptorspec = array( + 0 => array("pipe", "r"), + 1 => array("pipe", "w"), + 2 => array("pipe", "w") +); + +$process = proc_open($config['fping'] . ' -e -q ' .$params . ' ' .$host.' 2>&1', $descriptorspec, $pipes); + +if (is_resource($process)) { + + fwrite($pipes[0], $in); + /* fwrite writes to stdin, 'cat' will immediately write the data from stdin + * to stdout and blocks, when the stdout buffer is full. Then it will not + * continue reading from stdin and php will block here. + */ + + fclose($pipes[0]); + + while (!feof($pipes[1])) { + $read .= fgets($pipes[1], 1024); + } + fclose($pipes[1]); + + $return_value = proc_close($process); +} + + system("echo 'YEAH $read END\n' >> /tmp/testing"); + system("echo '". $config['fping'] ." -e -q $params $host' >> /tmp/testing"); + preg_match('/[0-9]+\/[0-9]+\/[0-9]+%/', $read, $loss_tmp); + preg_match('/[0-9\.]+\/[0-9\.]+\/[0-9\.]*$/', $read, $latency); + $loss = preg_replace("/%/","",$loss_tmp[0]); + list($xmt,$rcv,$loss) = preg_split("/\//", $loss); + list($min,$max,$avg) = preg_split("/\//", $latency[0]); + if ($loss < 0) { + $xmt = 1; + $rcv = 1; + $loss = 100; + } + $response = array('xmt'=>$xmt,'rcv'=>$rcv,'loss'=>$loss,'min'=>$min,'max'=>$max,'avg'=>$avg); + return $response; +} + diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index c705eccb8..03ec28b0a 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -132,6 +132,15 @@ function poll_device($device, $options) if (!is_dir($host_rrd)) { mkdir($host_rrd); echo("Created directory : $host_rrd\n"); } $ping_response = isPingable($device['hostname'],$device['device_id']); + + $device_perf = $ping_response['db']; + $device_perf['device_id'] = $device['device_id']; + $device_perf['timestamp'] = array('NOW()'); + if (is_array($device_perf)) { + dbInsert($device_perf, 'device_perf'); + } + + $device['pingable'] = $ping_response['result']; $ping_time = $ping_response['last_ping_timetaken']; $response = array(); diff --git a/sql-schema/056.sql b/sql-schema/056.sql new file mode 100644 index 000000000..f8617ab98 --- /dev/null +++ b/sql-schema/056.sql @@ -0,0 +1,3 @@ +CREATE TABLE IF NOT EXISTS `device_perf` ( `id` int(11) NOT NULL AUTO_INCREMENT, `device_id` int(11) NOT NULL, `timestamp` datetime NOT NULL, `xmt` float NOT NULL, `rcv` float NOT NULL, `loss` float NOT NULL, `min` float NOT NULL, `max` float NOT NULL, `avg` float NOT NULL, KEY `id` (`id`,`device_id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; +insert into config (config_name,config_value,config_default,config_descr,config_group,config_group_order,config_sub_group,config_sub_group_order,config_hidden,config_disabled) values ('alert.macros.rule.packet_loss_15m','(%macros.past_15m && %device_perf.loss)','(%macros.past_15m && %device_perf.loss)','Packet loss over the last 15 minutes','alerting',0,'macros',0,1,0); +insert into config (config_name,config_value,config_default,config_descr,config_group,config_group_order,config_sub_group,config_sub_group_order,config_hidden,config_disabled) values ('alert.macros.rule.packet_loss_5m','(%macros.past_5m && %device_perf.loss)','(%macros.past_5m && %device_perf.loss)','Packet loss over the last 5 minutes','alerting',0,'macros',0,1,0); From 820afa6dbb28a48eadc19ac698f30a807a89fa97 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 22 Jun 2015 22:11:02 +0100 Subject: [PATCH 189/308] Added logging of reason device was detected as down (icmp/snmp) --- doc/Extensions/Alerting.md | 2 ++ html/includes/table/devices.inc.php | 2 +- includes/polling/functions.inc.php | 10 ++++++---- sql-schema/056.sql | 2 ++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/doc/Extensions/Alerting.md b/doc/Extensions/Alerting.md index d90bf4ff0..253c90cc0 100644 --- a/doc/Extensions/Alerting.md +++ b/doc/Extensions/Alerting.md @@ -321,6 +321,8 @@ __devices.location__ = The devices location. __devices.status__ = The status of the device, 1 = up, 0 = down. +__devices.status_reason__ = The reason the device was detected as down (icmp or snmp). + __devices.ignore__ = If the device is ignored this will be set to 1. __devices.disabled__ = If the device is disabled this will be set to 1. diff --git a/html/includes/table/devices.inc.php b/html/includes/table/devices.inc.php index e89e0b6db..25cf21bd5 100644 --- a/html/includes/table/devices.inc.php +++ b/html/includes/table/devices.inc.php @@ -94,7 +94,7 @@ foreach (dbFetchRows($sql, $param) as $device) { if ($device['status'] == '0') { $extra = "danger"; - $msg = "down"; + $msg = $device['status_reason']; } else { $extra = "success"; $msg = "up"; diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index 03ec28b0a..6af89c3b9 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -144,21 +144,23 @@ function poll_device($device, $options) $device['pingable'] = $ping_response['result']; $ping_time = $ping_response['last_ping_timetaken']; $response = array(); + $status_reason = ''; if ($device['pingable']) { $device['snmpable'] = isSNMPable($device); if ($device['snmpable']) { $status = "1"; + $response['status_reason'] = ''; } else { echo("SNMP Unreachable"); $status = "0"; - $response['status'] = 'snmp'; + $response['status_reason'] = 'snmp'; } } else { echo("Unpingable"); $status = "0"; - $response['status'] = 'icmp'; + $response['status_reason'] = 'icmp'; } if ($device['status'] != $status) @@ -166,11 +168,11 @@ function poll_device($device, $options) $poll_update .= $poll_separator . "`status` = '$status'"; $poll_separator = ", "; - dbUpdate(array('status' => $status), 'devices', 'device_id=?', array($device['device_id'])); + dbUpdate(array('status' => $status,'status_reason' => $response['status_reason']), 'devices', 'device_id=?', array($device['device_id'])); dbInsert(array('importance' => '0', 'device_id' => $device['device_id'], 'message' => "Device is " .($status == '1' ? 'up' : 'down')), 'alerts'); log_event('Device status changed to ' . ($status == '1' ? 'Up' : 'Down'), $device, ($status == '1' ? 'up' : 'down')); - notify($device, "Device ".($status == '1' ? 'Up' : 'Down').": " . $device['hostname'], "Device ".($status == '1' ? 'up' : 'down').": " . $device['hostname'] . " " . $response['status']); + notify($device, "Device ".($status == '1' ? 'Up' : 'Down').": " . $device['hostname'], "Device ".($status == '1' ? 'up' : 'down').": " . $device['hostname'] . " " . $response['status_reason']); } if ($status == "1") diff --git a/sql-schema/056.sql b/sql-schema/056.sql index f8617ab98..a434a7d68 100644 --- a/sql-schema/056.sql +++ b/sql-schema/056.sql @@ -1,3 +1,5 @@ CREATE TABLE IF NOT EXISTS `device_perf` ( `id` int(11) NOT NULL AUTO_INCREMENT, `device_id` int(11) NOT NULL, `timestamp` datetime NOT NULL, `xmt` float NOT NULL, `rcv` float NOT NULL, `loss` float NOT NULL, `min` float NOT NULL, `max` float NOT NULL, `avg` float NOT NULL, KEY `id` (`id`,`device_id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; insert into config (config_name,config_value,config_default,config_descr,config_group,config_group_order,config_sub_group,config_sub_group_order,config_hidden,config_disabled) values ('alert.macros.rule.packet_loss_15m','(%macros.past_15m && %device_perf.loss)','(%macros.past_15m && %device_perf.loss)','Packet loss over the last 15 minutes','alerting',0,'macros',0,1,0); insert into config (config_name,config_value,config_default,config_descr,config_group,config_group_order,config_sub_group,config_sub_group_order,config_hidden,config_disabled) values ('alert.macros.rule.packet_loss_5m','(%macros.past_5m && %device_perf.loss)','(%macros.past_5m && %device_perf.loss)','Packet loss over the last 5 minutes','alerting',0,'macros',0,1,0); +ALTER TABLE `devices` ADD `status_reason` VARCHAR( 50 ) NOT NULL AFTER `status` ; +UPDATE `devices` SET `status_reason`='down' WHERE `status`=0; From 6c9810fc3cacfc034d31a4055d1d22495fa9b0f8 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 22 Jun 2015 22:55:32 +0100 Subject: [PATCH 190/308] Fix scrut issues --- includes/functions.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index f158067ca..43063fd52 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -1285,7 +1285,6 @@ $process = proc_open($config['fping'] . ' -e -q ' .$params . ' ' .$host.' 2>&1', if (is_resource($process)) { - fwrite($pipes[0], $in); /* fwrite writes to stdin, 'cat' will immediately write the data from stdin * to stdout and blocks, when the stdout buffer is full. Then it will not * continue reading from stdin and php will block here. @@ -1293,16 +1292,15 @@ if (is_resource($process)) { fclose($pipes[0]); + $read = ''; while (!feof($pipes[1])) { $read .= fgets($pipes[1], 1024); } fclose($pipes[1]); - $return_value = proc_close($process); + proc_close($process); } - system("echo 'YEAH $read END\n' >> /tmp/testing"); - system("echo '". $config['fping'] ." -e -q $params $host' >> /tmp/testing"); preg_match('/[0-9]+\/[0-9]+\/[0-9]+%/', $read, $loss_tmp); preg_match('/[0-9\.]+\/[0-9\.]+\/[0-9\.]*$/', $read, $latency); $loss = preg_replace("/%/","",$loss_tmp[0]); From 30a27d719eefe1c7bc040a517e39b4f543aed8a9 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 22 Jun 2015 23:02:11 +0100 Subject: [PATCH 191/308] Fix scrut issues + tidy more code --- includes/functions.php | 41 +++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index 43063fd52..fb4ba1b73 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -1270,36 +1270,25 @@ function fping($host,$params) { global $config; -// $handle = popen($config['fping'] . ' -e -q ' .$params . ' ' .$host.' 2>&1', 'r'); -// sleep(0.2); -// $read = fread($handle, 8192); -// pclose($handle); + $descriptorspec = array( + 0 => array("pipe", "r"), + 1 => array("pipe", "w"), + 2 => array("pipe", "w") + ); -$descriptorspec = array( - 0 => array("pipe", "r"), - 1 => array("pipe", "w"), - 2 => array("pipe", "w") -); + $process = proc_open($config['fping'] . ' -e -q ' .$params . ' ' .$host.' 2>&1', $descriptorspec, $pipes); + $read = ''; -$process = proc_open($config['fping'] . ' -e -q ' .$params . ' ' .$host.' 2>&1', $descriptorspec, $pipes); + if (is_resource($process)) { -if (is_resource($process)) { + fclose($pipes[0]); - /* fwrite writes to stdin, 'cat' will immediately write the data from stdin - * to stdout and blocks, when the stdout buffer is full. Then it will not - * continue reading from stdin and php will block here. - */ - - fclose($pipes[0]); - - $read = ''; - while (!feof($pipes[1])) { - $read .= fgets($pipes[1], 1024); - } - fclose($pipes[1]); - - proc_close($process); -} + while (!feof($pipes[1])) { + $read .= fgets($pipes[1], 1024); + } + fclose($pipes[1]); + proc_close($process); + } preg_match('/[0-9]+\/[0-9]+\/[0-9]+%/', $read, $loss_tmp); preg_match('/[0-9\.]+\/[0-9\.]+\/[0-9\.]*$/', $read, $latency); From 0525ca79bc1a872ddff7f97387c2245cd7b2f5de Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 22 Jun 2015 23:23:14 +0100 Subject: [PATCH 192/308] Updated to set millisec delay between packets --- doc/Support/Configuration.md | 2 ++ includes/defaults.inc.php | 1 + includes/functions.php | 4 +++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/Support/Configuration.md b/doc/Support/Configuration.md index 43d11cffd..68cb55251 100644 --- a/doc/Support/Configuration.md +++ b/doc/Support/Configuration.md @@ -33,6 +33,8 @@ $config['fping'] = "/usr/bin/fping"; $config['fping6'] = "/usr/bin/fping6"; $config['fping_options']['retries'] = 3; $config['fping_options']['timeout'] = 500; +$config['fping_options']['count'] = 3; +$config['fping_options']['millisec'] = 5; ``` fping configuration options, this includes setting the timeout and retry options. diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 24b43b99f..0880829de 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -44,6 +44,7 @@ $config['fping'] = "/usr/bin/fping"; $config['fping_options']['retries'] = 3; $config['fping_options']['timeout'] = 500; $config['fping_options']['count'] = 3; +$config['fping_options']['millisec'] = 5; $config['fping6'] = "/usr/bin/fping6"; $config['snmpwalk'] = "/usr/bin/snmpwalk"; $config['snmpget'] = "/usr/bin/snmpget"; diff --git a/includes/functions.php b/includes/functions.php index fb4ba1b73..a53d76d99 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -498,7 +498,9 @@ function isPingable($hostname,$device_id = FALSE) if(is_numeric($config['fping_options']['count']) || $config['fping_options']['count'] > 0) { $fping_params .= ' -c ' . $config['fping_options']['count']; } - //$status = shell_exec($config['fping'] . "$fping_params -e $hostname 2>/dev/null"); + if(is_numeric($config['fping_options']['millisec']) || $config['fping_options']['millisec'] > 0) { + $fping_params .= ' -p ' . $config['fping_options']['millisec']; + } $response = array(); $status = fping($hostname,$fping_params); if ($status['loss'] < 0 || $status['loss'] == 100) { From 9e5c6f87bbcff3b3bb21fc947b3253dfe0d40b6a Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 23 Jun 2015 09:01:36 +0100 Subject: [PATCH 193/308] Changed default millisec + removed check for loss < 0 --- includes/defaults.inc.php | 2 +- includes/functions.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 0880829de..ba46626ee 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -44,7 +44,7 @@ $config['fping'] = "/usr/bin/fping"; $config['fping_options']['retries'] = 3; $config['fping_options']['timeout'] = 500; $config['fping_options']['count'] = 3; -$config['fping_options']['millisec'] = 5; +$config['fping_options']['millisec'] = 20; $config['fping6'] = "/usr/bin/fping6"; $config['snmpwalk'] = "/usr/bin/snmpwalk"; $config['snmpget'] = "/usr/bin/snmpget"; diff --git a/includes/functions.php b/includes/functions.php index a53d76d99..487ed857f 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -503,7 +503,7 @@ function isPingable($hostname,$device_id = FALSE) } $response = array(); $status = fping($hostname,$fping_params); - if ($status['loss'] < 0 || $status['loss'] == 100) { + if ($status['loss'] == 100) { $response['result'] = FALSE; } else { $response['result'] = TRUE; From 03a5e768ec3a6929f4a3234edb4398e210f6d9bc Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 23 Jun 2015 09:48:36 +0100 Subject: [PATCH 194/308] min/avg/max were in the wrong order --- includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/functions.php b/includes/functions.php index 487ed857f..6ca29e67c 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -1296,7 +1296,7 @@ function fping($host,$params) { preg_match('/[0-9\.]+\/[0-9\.]+\/[0-9\.]*$/', $read, $latency); $loss = preg_replace("/%/","",$loss_tmp[0]); list($xmt,$rcv,$loss) = preg_split("/\//", $loss); - list($min,$max,$avg) = preg_split("/\//", $latency[0]); + list($min,$avg,$max) = preg_split("/\//", $latency[0]); if ($loss < 0) { $xmt = 1; $rcv = 1; From 21cf6b2019753b0714c1f554468c4005c45bbb0a Mon Sep 17 00:00:00 2001 From: Runar Borge Date: Tue, 23 Jun 2015 13:15:33 +0200 Subject: [PATCH 195/308] Disabled from Test plugin, user have to manually enable the plugin in Test plugin file --- html/plugins/Test/Test.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/html/plugins/Test/Test.php b/html/plugins/Test/Test.php index a2bd41744..3447d4254 100644 --- a/html/plugins/Test/Test.php +++ b/html/plugins/Test/Test.php @@ -5,11 +5,13 @@ class Test { echo('
  • '.get_class().'
  • '); } + /* public function device_overview_container($device) { echo('
    '.get_class().' Plugin
    '); echo(' Example plugin in "Device - Overview" tab
    '); echo('
    '); } + */ } ?> From 32c20b8a680bceca268a8a22b056bd983d1f148f Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 24 Jun 2015 15:38:54 +0100 Subject: [PATCH 196/308] Added removing of IP addresses before ports are deleted --- includes/functions.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/functions.php b/includes/functions.php index 725850897..18937bb53 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -248,6 +248,10 @@ function delete_device($id) return "No such host."; } + // Remove IPv4/IPv6 addresses before removing ports as they depend on port_id + dbQuery("DELETE `ipv4_addresses` FROM `ipv4_addresses` INNER JOIN `ports` ON `ports`.`port_id`=`ipv4_addresses`.`port_id` WHERE `device_id`=?",array($id)); + dbQuery("DELETE `ipv6_addresses` FROM `ipv6_addresses` INNER JOIN `ports` ON `ports`.`port_id`=`ipv6_addresses`.`port_id` WHERE `device_id`=?",array($id)); + foreach (dbFetch("SELECT * FROM `ports` WHERE `device_id` = ?", array($id)) as $int_data) { $int_if = $int_data['ifDescr']; From baac6478939fba1c0fe11635cd8b8edcf4be686a Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 24 Jun 2015 16:02:14 +0100 Subject: [PATCH 197/308] Fixed removing port from bills JS error --- html/pages/bill/edit.inc.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/html/pages/bill/edit.inc.php b/html/pages/bill/edit.inc.php index 6434c93e7..67e500018 100644 --- a/html/pages/bill/edit.inc.php +++ b/html/pages/bill/edit.inc.php @@ -138,7 +138,6 @@ for ($x=1;$x<32;$x++) { -

    Billed Ports

    ".$port['hostname'], "\" style=\"color: #000;\"> ".$port['hostname'], $devicebtn); $portbtn = str_replace("\">".strtolower($port['ifName']), "\" style=\"color: #000;\"> ".$port['ifName']."".$portalias, $portbtn); - echo(" \n"); + echo(" \n"); echo(" \n"); echo(" \n"); echo(" \n"); @@ -189,7 +188,6 @@ if (is_array($ports)) ?>
    -
    From c4572c206a6b65587a400eca3ccbb9273a957ea6 Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 24 Jun 2015 16:32:42 +0100 Subject: [PATCH 198/308] Added debugging output of invalid snmpv3 args --- addhost.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addhost.php b/addhost.php index 2c75d6573..d1e26a399 100755 --- a/addhost.php +++ b/addhost.php @@ -114,6 +114,9 @@ if (!empty($argv[1])) elseif (preg_match ('/^(sha|md5)$/i', $arg)) { $v3['authalgo'] = $arg; + } else { + echo "Invalid argument: " . $arg . "\n" ; + return ; } } @@ -147,6 +150,9 @@ if (!empty($argv[1])) elseif (preg_match ('/^(aes|des)$/i', $arg)) { $v3['cryptoalgo'] = $arg; + } else { + echo "Invalid argument: " . $arg . "\n" ; + return ; } } From 0624b6c1d01f7c19a350cdba7c6ceb7c6fc2a684 Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 24 Jun 2015 16:39:16 +0100 Subject: [PATCH 199/308] Temp fix to remove .index at the start of the poller run --- poller.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/poller.php b/poller.php index 6608b3254..5bb3fbee8 100755 --- a/poller.php +++ b/poller.php @@ -25,6 +25,11 @@ include("includes/alerts.inc.php"); $poller_start = utime(); echo($config['project_name_version']." Poller\n\n"); +if (is_file($config['mib_dir'].'/.index') === true) { + echo ".index exists, removing\n"; + unlink($config['mib_dir'].'/.index'); +} + $options = getopt("h:m:i:n:r::d::a::"); if ($options['h'] == "odd") { $options['n'] = "1"; $options['i'] = "2"; } From 44432c85e5dc06b757f23c824ac0de0aa5a64a8e Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 24 Jun 2015 16:53:10 +0100 Subject: [PATCH 200/308] Added load and state to device overview --- html/pages/device/overview.inc.php | 2 ++ html/pages/device/overview/sensors/load.inc.php | 8 ++++++++ html/pages/device/overview/sensors/state.inc.php | 8 ++++++++ 3 files changed, 18 insertions(+) create mode 100644 html/pages/device/overview/sensors/load.inc.php create mode 100644 html/pages/device/overview/sensors/state.inc.php diff --git a/html/pages/device/overview.inc.php b/html/pages/device/overview.inc.php index f414dd4e5..9e6bbdb51 100644 --- a/html/pages/device/overview.inc.php +++ b/html/pages/device/overview.inc.php @@ -48,6 +48,8 @@ include("overview/sensors/voltages.inc.php"); include("overview/sensors/current.inc.php"); include("overview/sensors/power.inc.php"); include("overview/sensors/frequencies.inc.php"); +include("overview/sensors/load.inc.php"); +include("overview/sensors/state.inc.php"); include("overview/eventlog.inc.php"); include("overview/services.inc.php"); include("overview/syslog.inc.php"); diff --git a/html/pages/device/overview/sensors/load.inc.php b/html/pages/device/overview/sensors/load.inc.php new file mode 100644 index 000000000..989a305b9 --- /dev/null +++ b/html/pages/device/overview/sensors/load.inc.php @@ -0,0 +1,8 @@ + Date: Wed, 24 Jun 2015 14:23:54 -0700 Subject: [PATCH 201/308] Added support for WebPower Pro II UPS cards. --- includes/defaults.inc.php | 1 + includes/definitions.inc.php | 6 ++++++ includes/discovery/os/webpower.inc.php | 5 +++++ includes/polling/os/webpower.inc.php | 19 +++++++++++++++++++ 4 files changed, 31 insertions(+) create mode 100644 includes/discovery/os/webpower.inc.php create mode 100644 includes/polling/os/webpower.inc.php diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index ba46626ee..abeceee2e 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -574,6 +574,7 @@ $config['modules_compat']['rfc1628']['netmanplus'] = 1; $config['modules_compat']['rfc1628']['deltaups'] = 1; $config['modules_compat']['rfc1628']['poweralert'] = 1; $config['modules_compat']['rfc1628']['multimatic'] = 1; +$config['modules_compat']['rfc1628']['webpower'] = 1; # Enable daily updates $config['update'] = 1; diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 1fb938f36..52d24bbc1 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -850,6 +850,12 @@ $config['os'][$os]['type'] = "power"; $config['os'][$os]['over'][0]['graph'] = "device_current"; $config['os'][$os]['over'][0]['text'] = "Current"; +$os = "webpower"; +$config['os'][$os]['text'] = "WebPower"; +$config['os'][$os]['type'] = "power"; +$config['os'][$os]['over'][0]['graph'] = "device_current"; +$config['os'][$os]['over'][0]['text'] = "Current"; + $os = "netbotz"; $config['os'][$os]['text'] = "Netbotz Environment sensor"; $config['os'][$os]['type'] = "environment"; diff --git a/includes/discovery/os/webpower.inc.php b/includes/discovery/os/webpower.inc.php new file mode 100644 index 000000000..1053667f5 --- /dev/null +++ b/includes/discovery/os/webpower.inc.php @@ -0,0 +1,5 @@ + diff --git a/includes/polling/os/webpower.inc.php b/includes/polling/os/webpower.inc.php new file mode 100644 index 000000000..ff368d76a --- /dev/null +++ b/includes/polling/os/webpower.inc.php @@ -0,0 +1,19 @@ + +* 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. +*/ + +$data = str_replace('"', '', snmp_get($device, "1.3.6.1.2.1.33.1.1.4.0", "-Ovq")); +preg_match_all('/^WebPower Pro II Card|v[0-9]+.[0-9]+|(SN [0-9]+)/', $data, $matches); +$hardware = $matches[0][0]; +$version = $matches[0][1]; +$serial = $matches[0][2]; + +?> From 01f12a3f0a0ae01d27067d4ca580eb9b07bba871 Mon Sep 17 00:00:00 2001 From: Mike Rostermund Date: Wed, 24 Jun 2015 14:25:58 -0700 Subject: [PATCH 202/308] Added discovery of load sensors of RFC1628 devices. --- includes/discovery/load/rfc1628.inc.php | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 includes/discovery/load/rfc1628.inc.php diff --git a/includes/discovery/load/rfc1628.inc.php b/includes/discovery/load/rfc1628.inc.php new file mode 100644 index 000000000..4f35e5265 --- /dev/null +++ b/includes/discovery/load/rfc1628.inc.php @@ -0,0 +1,27 @@ + From e769a4ffc626e1eac045189ca2cfddcbf05214e4 Mon Sep 17 00:00:00 2001 From: Mike Rostermund Date: Thu, 25 Jun 2015 03:47:20 -0700 Subject: [PATCH 203/308] Handle case where sensor_limit is not set for sensor_charge graphs --- html/includes/graphs/sensor/charge.inc.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/html/includes/graphs/sensor/charge.inc.php b/html/includes/graphs/sensor/charge.inc.php index 153d435dd..331d4ff1a 100644 --- a/html/includes/graphs/sensor/charge.inc.php +++ b/html/includes/graphs/sensor/charge.inc.php @@ -10,7 +10,10 @@ $rrd_options .= " COMMENT:' Last Max\\n'"; $rrd_options .= " DEF:sensor=$rrd_filename:sensor:AVERAGE"; $rrd_options .= " DEF:sensor_max=$rrd_filename:sensor:MAX"; $rrd_options .= " DEF:sensor_min=$rrd_filename:sensor:MIN"; -$rrd_options .= " CDEF:sensorwarm=sensor_max,".$sensor['sensor_limit'].",GT,sensor,UNKN,IF"; +if (isset($sensor['sensor_limit'])) { + $rrd_options .= " CDEF:sensorwarm=sensor_max,".$sensor['sensor_limit'].",GT,sensor,UNKN,IF"; + $rrd_options .= " LINE1:sensorwarm#660000"; +} $rrd_options .= " CDEF:sensorcold=sensor_min,20,LT,sensor,UNKN,IF"; $rrd_options .= " AREA:sensor_max#c5c5c5"; $rrd_options .= " AREA:sensor_min#ffffffff"; @@ -19,7 +22,6 @@ $rrd_options .= " AREA:sensor_min#ffffffff"; # $rrd_options .= " AREA:sensorwarm#FFCCCC"; # $rrd_options .= " AREA:sensorcold#CCCCFF"; $rrd_options .= " LINE1:sensor#cc0000:'" . rrdtool_escape($sensor['sensor_descr'],28)."'"; -$rrd_options .= " LINE1:sensorwarm#660000"; $rrd_options .= " GPRINT:sensor:LAST:%3.0lf%%"; $rrd_options .= " GPRINT:sensor:MAX:%3.0lf%%\\\\l"; From 0a5460202826108078a293fa4a9156264886ad11 Mon Sep 17 00:00:00 2001 From: Clint Armstrong Date: Thu, 25 Jun 2015 08:01:05 -0400 Subject: [PATCH 204/308] Do not rewrite server-status Currently users cannot use the check_mk apache plugin to monitor the apache instance that is running librenms. Excluding server-status from the rewrite rules allows users to use mod_status. --- html/.htaccess | 1 + 1 file changed, 1 insertion(+) diff --git a/html/.htaccess b/html/.htaccess index 0b7faa983..44bd1687d 100644 --- a/html/.htaccess +++ b/html/.htaccess @@ -9,6 +9,7 @@ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !\.(js|ico|txt|gif|jpg|png|css|php) RewriteRule ^api/v0(.*)$ api_v0.php/$1 [L] +RewriteCond %{REQUEST_URI} !=/server-status RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !\.(js|ico|txt|gif|jpg|png|css|php) From 07c1be5b0043e8a7cf6444d3c2ae43c8b368bff6 Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Thu, 25 Jun 2015 14:20:48 +0100 Subject: [PATCH 205/308] Revert "Temp fix to remove .index at the start of the poller run" --- poller.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/poller.php b/poller.php index 5bb3fbee8..6608b3254 100755 --- a/poller.php +++ b/poller.php @@ -25,11 +25,6 @@ include("includes/alerts.inc.php"); $poller_start = utime(); echo($config['project_name_version']." Poller\n\n"); -if (is_file($config['mib_dir'].'/.index') === true) { - echo ".index exists, removing\n"; - unlink($config['mib_dir'].'/.index'); -} - $options = getopt("h:m:i:n:r::d::a::"); if ($options['h'] == "odd") { $options['n'] = "1"; $options['i'] = "2"; } From dd5d1c5e05f3444f8a37b5235c4da0af5b7a49cf Mon Sep 17 00:00:00 2001 From: Clint Armstrong Date: Thu, 25 Jun 2015 13:24:02 -0400 Subject: [PATCH 206/308] Adding --daemon twice breaks collectd graphs When using rrdcached [rrdtool.inc.php](includes/rrdtool.inc.php#L163) already adds the necessary options. Collectd.inc.php adds them again which breaks drawing the graphs. --- html/includes/graphs/device/collectd.inc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/html/includes/graphs/device/collectd.inc.php b/html/includes/graphs/device/collectd.inc.php index b6e5e6a3a..05ce8b3cb 100644 --- a/html/includes/graphs/device/collectd.inc.php +++ b/html/includes/graphs/device/collectd.inc.php @@ -197,7 +197,6 @@ if (isset($MetaGraphDefs[$type])) { if(isset($rrd_cmd)) { - if ($config['rrdcached']) { $rrd_cmd .= " --daemon ".$config['rrdcached'] . " "; } if ($_GET['from']) { $from = mres($_GET['from']); } if ($_GET['to']) { $to = mres($_GET['to']); } $rrd_cmd .= " -s " . $from . " -e " . $to; From 8b06659c86ec2b49b26be383e363cb15e5b175e3 Mon Sep 17 00:00:00 2001 From: Clint Armstrong Date: Fri, 26 Jun 2015 07:45:29 -0400 Subject: [PATCH 207/308] I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md. --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index bc4f417c9..10bcc61b8 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -34,6 +34,7 @@ Contributors to LibreNMS: - Steve Calvário (Calvario) - Christian Marg (einhirn) - Louis Rossouw (spinza) +- Clint Armstrong (clinta) [1]: http://observium.org/ "Observium web site" From 523cb83e917fdafe5fd5703d9b86df1f018076aa Mon Sep 17 00:00:00 2001 From: Clint Armstrong Date: Fri, 26 Jun 2015 07:50:37 -0400 Subject: [PATCH 208/308] Correct Apache collectd DS --- html/includes/collectd/definitions.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/html/includes/collectd/definitions.php b/html/includes/collectd/definitions.php index a3a227775..b7a0fcac1 100644 --- a/html/includes/collectd/definitions.php +++ b/html/includes/collectd/definitions.php @@ -47,9 +47,9 @@ function load_graph_definitions($logarithmic = false, $tinylegend = false) { $GraphDefs = array(); $GraphDefs['apache_bytes'] = array( - 'DEF:min_raw={file}:count:MIN', - 'DEF:avg_raw={file}:count:AVERAGE', - 'DEF:max_raw={file}:count:MAX', + 'DEF:min_raw={file}:value:MIN', + 'DEF:avg_raw={file}:value:AVERAGE', + 'DEF:max_raw={file}:value:MAX', 'CDEF:min=min_raw,8,*', 'CDEF:avg=avg_raw,8,*', 'CDEF:max=max_raw,8,*', @@ -67,9 +67,9 @@ function load_graph_definitions($logarithmic = false, $tinylegend = false) { 'GPRINT:min:MIN:%5.1lf%s\l', 'GPRINT:avg_sum:LAST: (ca. %5.1lf%sB Total)'); $GraphDefs['apache_requests'] = array( - 'DEF:min={file}:count:MIN', - 'DEF:avg={file}:count:AVERAGE', - 'DEF:max={file}:count:MAX', + 'DEF:min={file}:value:MIN', + 'DEF:avg={file}:value:AVERAGE', + 'DEF:max={file}:value:MAX', 'COMMENT: Cur Avg Min Max\l', "AREA:max#$HalfBlue", "AREA:min#$Canvas", @@ -79,9 +79,9 @@ function load_graph_definitions($logarithmic = false, $tinylegend = false) { 'GPRINT:min:MIN:%5.2lf%s', 'GPRINT:max:MAX:%5.2lf%s\l'); $GraphDefs['apache_scoreboard'] = array( - 'DEF:min={file}:count:MIN', - 'DEF:avg={file}:count:AVERAGE', - 'DEF:max={file}:count:MAX', + 'DEF:min={file}:value:MIN', + 'DEF:avg={file}:value:AVERAGE', + 'DEF:max={file}:value:MAX', 'COMMENT: Cur Min Ave Max\l', "AREA:max#$HalfBlue", "AREA:min#$Canvas", @@ -2043,7 +2043,7 @@ function meta_graph_apache_scoreboard($host, $plugin, $plugin_instance, $type, $ if ($file == '') continue; - $sources[] = array('name'=>$inst, 'file'=>$file, 'ds'=>'count'); + $sources[] = array('name'=>$inst, 'file'=>$file, 'ds'=>'value'); } return collectd_draw_meta_stack($opts, $sources); From 02780b8e72c1927c6653b450aa22b13c5bb970b1 Mon Sep 17 00:00:00 2001 From: Clint Armstrong Date: Fri, 26 Jun 2015 08:02:20 -0400 Subject: [PATCH 209/308] entropy DS name is value. --- html/includes/collectd/definitions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/html/includes/collectd/definitions.php b/html/includes/collectd/definitions.php index b7a0fcac1..6e1269c90 100644 --- a/html/includes/collectd/definitions.php +++ b/html/includes/collectd/definitions.php @@ -397,9 +397,9 @@ function load_graph_definitions($logarithmic = false, $tinylegend = false) { 'GPRINT:avg:LAST:%4.1lf\l'); $GraphDefs['entropy'] = array( #'-v', 'Bits', - 'DEF:avg={file}:entropy:AVERAGE', - 'DEF:min={file}:entropy:MIN', - 'DEF:max={file}:entropy:MAX', + 'DEF:avg={file}:value:AVERAGE', + 'DEF:min={file}:value:MIN', + 'DEF:max={file}:value:MAX', 'COMMENT: Min Avg Max Cur\l', "AREA:max#$HalfBlue", "AREA:min#$Canvas", From dbae0e371ffa16368fbce9447b0a665118e6e6ce Mon Sep 17 00:00:00 2001 From: Clint Armstrong Date: Fri, 26 Jun 2015 10:26:52 -0400 Subject: [PATCH 210/308] url encode graph names --- html/includes/functions.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 8912bb636..fc7c52a09 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -69,7 +69,7 @@ function generate_url($vars, $new_vars = array()) { if ($value == "0" || $value != "" && strstr($var, "opt") === FALSE && is_numeric($var) === FALSE) { - $url .= $var ."=".$value."/"; + $url .= $var ."=".urlencode($value)."/"; } } @@ -339,7 +339,7 @@ function generate_graph_tag($args) $urlargs = array(); foreach ($args as $key => $arg) { - $urlargs[] = $key."=".$arg; + $urlargs[] = $key."=".urlencode($arg); } return ''; From 4bef35c90a4cf69ff9c5f0d7bef193589334e662 Mon Sep 17 00:00:00 2001 From: laf Date: Sat, 27 Jun 2015 17:41:31 +0100 Subject: [PATCH 211/308] Now save the connection value selected and remove when not needed --- html/forms/create-device-group.inc.php | 2 -- html/forms/parse-device-group.inc.php | 6 +++++- includes/device-groups.inc.php | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/html/forms/create-device-group.inc.php b/html/forms/create-device-group.inc.php index 94c410c9e..0992f73a1 100644 --- a/html/forms/create-device-group.inc.php +++ b/html/forms/create-device-group.inc.php @@ -23,8 +23,6 @@ $desc = mres($_POST['desc']); if( is_array($pattern) ) { $pattern = implode(" ", $pattern); - $pattern = rtrim($pattern,'&&'); - $pattern = rtrim($pattern,'||'); } elseif( !empty($_POST['pattern']) && !empty($_POST['condition']) && !empty($_POST['value']) ) { $pattern = '%'.$_POST['pattern'].' '.$_POST['condition'].' '; if( is_numeric($_POST['value']) ) { diff --git a/html/forms/parse-device-group.inc.php b/html/forms/parse-device-group.inc.php index 7009459f2..74af38cf6 100644 --- a/html/forms/parse-device-group.inc.php +++ b/html/forms/parse-device-group.inc.php @@ -22,7 +22,11 @@ if(is_numeric($group_id) && $group_id > 0) { $group = dbFetchRow("SELECT * FROM `device_groups` WHERE `id` = ? LIMIT 1",array($group_id)); $group_split = preg_split('/([a-zA-Z0-9_\-\.\=\%\<\>\ \"\'\!\~\(\)\*\/\@]+[&&\|\|]+)/',$group['pattern'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); $count = count($group_split) - 1; - $group_split[$count] = $group_split[$count].' &&'; + if (preg_match("/\&\&$/",$group_split[$count]) == 1 || preg_match("/\|\|$/", $group_split[$count]) == 1) { + $group_split[$count] = $group_split[$count]; + } else { + $group_split[$count] = $group_split[$count].' &&'; + } $output = array('name'=>$group['name'],'desc'=>$group['desc'],'pattern'=>$group_split); echo _json_encode($output); } diff --git a/includes/device-groups.inc.php b/includes/device-groups.inc.php index 533b433b5..36835c80a 100644 --- a/includes/device-groups.inc.php +++ b/includes/device-groups.inc.php @@ -63,6 +63,8 @@ function GenGroupSQL($pattern,$search='') { */ function GetDevicesFromGroup($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)); } From 6ed37c67a505d6c560a421021501d80ac9dab1c0 Mon Sep 17 00:00:00 2001 From: laf Date: Sat, 27 Jun 2015 21:22:59 +0100 Subject: [PATCH 212/308] Added Services extension doc to help people set this up --- doc/Extensions/Services.md | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 doc/Extensions/Services.md diff --git a/doc/Extensions/Services.md b/doc/Extensions/Services.md new file mode 100644 index 000000000..ca2e14ed3 --- /dev/null +++ b/doc/Extensions/Services.md @@ -0,0 +1,50 @@ +# Setting up Services + +Services within LibreNMS provides the ability to use Nagios plugins to perform additional monitoring outside of SNMP. + +These services are tied into an existing device so you need at least one device that supports SNMP to be able to add it +to LibreNMS - localhot is a good one. + +## Setup + +Firstly, install Nagios plugins however you would like, this could be via yum, apt-get or direct from source. + +Next, you need to enable the services within config.php with the following: + +```php +$config['show_services'] = 1; +``` +This will enable a new service menu within your navbar. + +```php +$config['nagios_plugins'] = "/usr/lib/nagios/plugins"; +``` + +This will point LibreNMS at the location of the nagios plugins - please ensure that any plugins you use are set to executable. + +Finally, you now need to add check-services.php to the current cron file (/etc/cron.d/librenms typically) like: +```bash +*/5 * * * * librenms /opt/librenms/check-services.php >> /dev/null 2>&1 +``` + +Now you can add services via the main Services link in the navbar, or via the Services link within the device page. + +> **Please note that at present the service checks will only return the status and the response from the check +no graphs will be generated. ** + +## Supported checks + +- ftp +- icmp +- spop +- ssh +- ssl_cert +- http +- domain_expire +- mysql +- imap +- dns +- telnet +- smtp +- pop +- simap From 505429db4dc33b3a08e4ec564e69fd0cdf9f8ee7 Mon Sep 17 00:00:00 2001 From: laf Date: Sat, 27 Jun 2015 22:11:54 +0100 Subject: [PATCH 213/308] Added some additional info from pfsense units --- includes/polling/os/unix.inc.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/polling/os/unix.inc.php b/includes/polling/os/unix.inc.php index 5feb16544..4f0f3eacb 100644 --- a/includes/polling/os/unix.inc.php +++ b/includes/polling/os/unix.inc.php @@ -107,6 +107,10 @@ elseif ($device['os'] == "dsm") $hardware = $value; } } +} elseif ($device['os'] == "pfsense") { + $output = preg_split("/ /", $poll_device['sysDescr']); + $version = $output[2]; + $hardware = $output[6]; } ?> From 5c6e4995ab46930cfaf95ddf7d4fb811696ebf02 Mon Sep 17 00:00:00 2001 From: laf Date: Sun, 28 Jun 2015 16:25:20 +0100 Subject: [PATCH 214/308] Updated regex for device groups --- html/forms/parse-device-group.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/forms/parse-device-group.inc.php b/html/forms/parse-device-group.inc.php index 7009459f2..9ecd4e52e 100644 --- a/html/forms/parse-device-group.inc.php +++ b/html/forms/parse-device-group.inc.php @@ -20,7 +20,7 @@ $group_id = $_POST['group_id']; if(is_numeric($group_id) && $group_id > 0) { $group = dbFetchRow("SELECT * FROM `device_groups` WHERE `id` = ? LIMIT 1",array($group_id)); - $group_split = preg_split('/([a-zA-Z0-9_\-\.\=\%\<\>\ \"\'\!\~\(\)\*\/\@]+[&&\|\|]+)/',$group['pattern'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + $group_split = preg_split('/([a-zA-Z0-9_\-\.\=\%\<\>\ \"\'\!\~\(\)\*\/\@\[\]]+[&&\|\|]+)/',$group['pattern'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); $count = count($group_split) - 1; $group_split[$count] = $group_split[$count].' &&'; $output = array('name'=>$group['name'],'desc'=>$group['desc'],'pattern'=>$group_split); From 90563c5b1deda6c6312af771b595ef605ed077ee Mon Sep 17 00:00:00 2001 From: Tony Ditchfield Date: Sun, 28 Jun 2015 18:54:55 +0100 Subject: [PATCH 215/308] Added HOST-RESOURCES-MIB:: to allow detection of Synology devices --- includes/discovery/os/linux.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/discovery/os/linux.inc.php b/includes/discovery/os/linux.inc.php index c09e957ff..7e4b2d238 100644 --- a/includes/discovery/os/linux.inc.php +++ b/includes/discovery/os/linux.inc.php @@ -29,7 +29,7 @@ if (!$os) else { // Check for Synology DSM - $hrSystemInitialLoadParameters = trim(snmp_get($device, "hrSystemInitialLoadParameters.0", "-Osqnv")); + $hrSystemInitialLoadParameters = trim(snmp_get($device, "HOST-RESOURCES-MIB::hrSystemInitialLoadParameters.0", "-Osqnv")); if (strpos($hrSystemInitialLoadParameters, "syno_hw_version") !== FALSE) { $os = "dsm"; } else From 4e34aecce5b2339cf543df239b4218ea5a5f5820 Mon Sep 17 00:00:00 2001 From: Tony Ditchfield Date: Sun, 28 Jun 2015 19:05:43 +0100 Subject: [PATCH 216/308] AUTHORS addition --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 10bcc61b8..61343a9ad 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -35,6 +35,7 @@ Contributors to LibreNMS: - Christian Marg (einhirn) - Louis Rossouw (spinza) - Clint Armstrong (clinta) +- Tony Ditchfield (arnoldthebat) [1]: http://observium.org/ "Observium web site" From 8e785ebaaaca3ca9eb8c2d346b0a73ed0a255736 Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Mon, 29 Jun 2015 10:34:03 -0400 Subject: [PATCH 217/308] Fix issue #1362, added a line to reset , because the calling page is expecting new graphs, not appended ones --- html/includes/print-graphrow.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/html/includes/print-graphrow.inc.php b/html/includes/print-graphrow.inc.php index 240362632..c55091044 100644 --- a/html/includes/print-graphrow.inc.php +++ b/html/includes/print-graphrow.inc.php @@ -15,6 +15,7 @@ if($_SESSION['widescreen']) $graph_array['to'] = $config['time']['now']; +$graph_data = array(); foreach ($periods as $period) { $graph_array['from'] = $config['time'][$period]; From a7d83be1af6807269dcc1da9c8a45ed4a54c8392 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 30 Jun 2015 10:48:08 +0100 Subject: [PATCH 218/308] Fixed API graphs not loading --- html/includes/graphs/graph.inc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/html/includes/graphs/graph.inc.php b/html/includes/graphs/graph.inc.php index 5c6bfe1c1..6ba9de57a 100644 --- a/html/includes/graphs/graph.inc.php +++ b/html/includes/graphs/graph.inc.php @@ -38,7 +38,9 @@ $graphfile = $config['temp_dir'] . "/" . strgen() . ".png"; $type = $graphtype['type']; $subtype = $graphtype['subtype']; -$auth = is_client_authorized($_SERVER['REMOTE_ADDR']); +if ($auth !== true && $auth != 1) { + $auth = is_client_authorized($_SERVER['REMOTE_ADDR']); +} include($config['install_dir'] . "/html/includes/graphs/$type/auth.inc.php"); if ($auth === true && is_file($config['install_dir'] . "/html/includes/graphs/$type/$subtype.inc.php")) { From b92e9f2d8f1ab01b702342de25c951ef899b4109 Mon Sep 17 00:00:00 2001 From: Clint Armstrong Date: Tue, 30 Jun 2015 07:46:09 -0400 Subject: [PATCH 219/308] Update to the freqency DS used in collectd > 5.0 Similar to #1347 and #1349 --- html/includes/collectd/definitions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/html/includes/collectd/definitions.php b/html/includes/collectd/definitions.php index 6e1269c90..e93e35cfd 100644 --- a/html/includes/collectd/definitions.php +++ b/html/includes/collectd/definitions.php @@ -422,9 +422,9 @@ function load_graph_definitions($logarithmic = false, $tinylegend = false) { 'GPRINT:avg:LAST:%4.1lf\l'); $GraphDefs['frequency'] = array( #'-v', 'Hertz', - 'DEF:avg={file}:frequency:AVERAGE', - 'DEF:min={file}:frequency:MIN', - 'DEF:max={file}:frequency:MAX', + 'DEF:avg={file}:value:AVERAGE', + 'DEF:min={file}:value:MIN', + 'DEF:max={file}:value:MAX', "AREA:max#b5b5b5", "AREA:min#$Canvas", "LINE1:avg#$FullBlue:Frequency [Hz]", From 3b5223994508f48758020d91ebbfd332d76482d9 Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Tue, 30 Jun 2015 10:12:07 -0400 Subject: [PATCH 220/308] I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md. --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 61343a9ad..86db6c60e 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -36,6 +36,7 @@ Contributors to LibreNMS: - Louis Rossouw (spinza) - Clint Armstrong (clinta) - Tony Ditchfield (arnoldthebat) +- Travis Hegner (travishegner) [1]: http://observium.org/ "Observium web site" From e9d7d74b726271dbbc8af8b38595da0185e04ed3 Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 1 Jul 2015 21:35:37 +0100 Subject: [PATCH 221/308] Fixed issue with name not being set + some validation around this --- html/includes/api_functions.inc.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/html/includes/api_functions.inc.php b/html/includes/api_functions.inc.php index d2e9f3061..a3593e684 100644 --- a/html/includes/api_functions.inc.php +++ b/html/includes/api_functions.inc.php @@ -567,6 +567,10 @@ function add_edit_rule() { if(empty($rule)) { $message = 'Missing the alert rule'; } + $name = mres($data['name']); + if (empty($name)) { + $message = 'Missing the alert rule name'; + } $severity = mres($data['severity']); $sevs = array("ok","warning","critical"); if(!in_array($severity, $sevs)) { @@ -590,15 +594,19 @@ function add_edit_rule() { $extra = array('mute'=>$mute,'count'=>$count,'delay'=>$delay_sec); $extra_json = json_encode($extra); + if (dbFetchCell("SELECT `name` FROM `alert_rules` WHERE `name`=?",array($name)) == $name) { + $message = 'Name has already been used'; + } + if(empty($message)) { if(is_numeric($rule_id)) { - if( dbUpdate(array('rule' => $rule,'severity'=>$severity,'disabled'=>$disabled,'extra'=>$extra_json), 'alert_rules', 'id=?',array($rule_id)) >= 0) { + if( dbUpdate(array('name' => $name, 'rule' => $rule,'severity'=>$severity,'disabled'=>$disabled,'extra'=>$extra_json), 'alert_rules', 'id=?',array($rule_id)) >= 0) { $status = 'ok'; $code = 200; } else { $message = 'Failed to update existing alert rule'; } - } elseif( dbInsert(array('device_id'=>$device_id,'rule'=>$rule,'severity'=>$severity,'disabled'=>$disabled,'extra'=>$extra_json),'alert_rules') ) { + } elseif( dbInsert(array('name' => $name, 'device_id'=>$device_id,'rule'=>$rule,'severity'=>$severity,'disabled'=>$disabled,'extra'=>$extra_json),'alert_rules') ) { $status = 'ok'; $code = 200; } else { From 8d49395b1098ebf422510784d3d45d8370a0f2b8 Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Thu, 2 Jul 2015 13:41:54 -0400 Subject: [PATCH 222/308] test static TZ parse --- html/pages/graphs.inc.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index 8e438489d..7806e9833 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -118,8 +118,10 @@ if (!$auth) function submitCustomRange(frmdata) { var reto = /to=([0-9])+/g; var refrom = /from=([0-9])+/g; - var tsto = new Date(frmdata.dtpickerto.value.replace(' ','T')); - var tsfrom = new Date(frmdata.dtpickerfrom.value.replace(' ','T')); + var strto = frmdata.dtpickerto.value.replace(' ', 'T')+':00Z0400'; + var tsto = new Date(strto); + var strfrom = frmdata.dtpickerfrom.value.replace(' ', 'T')+':00Z0400'; + var tsfrom = new Date(strfrom); tsto = tsto.getTime() / 1000; tsfrom = tsfrom.getTime() / 1000; frmdata.selfaction.value = frmdata.selfaction.value.replace(reto, 'to=' + tsto); From f2fe24c6023296ff61fc791d772412008ca561dd Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Thu, 2 Jul 2015 13:54:27 -0400 Subject: [PATCH 223/308] use js to convert --- html/pages/graphs.inc.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index 7806e9833..9b82a0a11 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -118,10 +118,8 @@ if (!$auth) function submitCustomRange(frmdata) { var reto = /to=([0-9])+/g; var refrom = /from=([0-9])+/g; - var strto = frmdata.dtpickerto.value.replace(' ', 'T')+':00Z0400'; - var tsto = new Date(strto); - var strfrom = frmdata.dtpickerfrom.value.replace(' ', 'T')+':00Z0400'; - var tsfrom = new Date(strfrom); + var tsto = new Date(frmdata.dtpickerto.value.replace(' ','T')); + var tsfrom = new Date(frmdata.dtpickerfrom.value.replace(' ','T')); tsto = tsto.getTime() / 1000; tsfrom = tsfrom.getTime() / 1000; frmdata.selfaction.value = frmdata.selfaction.value.replace(reto, 'to=' + tsto); @@ -137,16 +135,18 @@ if (!$auth) echo('
    - +
    - +
    From a2e248cf4bd921b26511e6ecbbdbe2f4234249f8 Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Thu, 2 Jul 2015 14:06:02 -0400 Subject: [PATCH 225/308] trying to set the date from js --- html/pages/graphs.inc.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index 1baac09a2..9a55e1de2 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -145,10 +145,12 @@ if (!$auth) From abeb015e33cb06e0c75b6fe3d04446ae97995427 Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Thu, 2 Jul 2015 14:09:23 -0400 Subject: [PATCH 226/308] debug output --- html/pages/graphs.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index 9a55e1de2..c33f90f39 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -145,6 +145,7 @@ if (!$auth) From 0fbcc0d1b6a0dfcb57fe60f3a2931a937e533441 Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Thu, 2 Jul 2015 14:54:36 -0400 Subject: [PATCH 236/308] ff failing to parse --- html/pages/graphs.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index e598af269..4bb521592 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -118,8 +118,8 @@ if (!$auth) function submitCustomRange(frmdata) { var reto = /to=([0-9])+/g; var refrom = /from=([0-9])+/g; - var tsto = new Date(frmdata.dtpickerto.value); - var tsfrom = new Date(frmdata.dtpickerfrom.value); + var tsto = new Date(frmdata.dtpickerto.value+":00"); + var tsfrom = new Date(frmdata.dtpickerfrom.value+":00"); tsto = tsto.getTime() / 1000; tsfrom = tsfrom.getTime() / 1000; frmdata.selfaction.value = frmdata.selfaction.value.replace(reto, 'to=' + tsto); From 0ab00ba0fb89392ede98067d462df7a1a90e4f48 Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Thu, 2 Jul 2015 14:55:42 -0400 Subject: [PATCH 237/308] debug output --- html/pages/graphs.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index 4bb521592..42b6dd3d2 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -119,6 +119,7 @@ if (!$auth) var reto = /to=([0-9])+/g; var refrom = /from=([0-9])+/g; var tsto = new Date(frmdata.dtpickerto.value+":00"); + alert(frmdata.dtpickerto.value+":00") var tsfrom = new Date(frmdata.dtpickerfrom.value+":00"); tsto = tsto.getTime() / 1000; tsfrom = tsfrom.getTime() / 1000; From 01e4a6650e476b4f33ead8ca95fa7b2546421906 Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Thu, 2 Jul 2015 14:59:11 -0400 Subject: [PATCH 238/308] putting the T back with Z this time --- html/pages/graphs.inc.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index 42b6dd3d2..cd4f6181b 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -118,9 +118,8 @@ if (!$auth) function submitCustomRange(frmdata) { var reto = /to=([0-9])+/g; var refrom = /from=([0-9])+/g; - var tsto = new Date(frmdata.dtpickerto.value+":00"); - alert(frmdata.dtpickerto.value+":00") - var tsfrom = new Date(frmdata.dtpickerfrom.value+":00"); + var tsto = new Date(frmdata.dtpickerto.value.replace(' ', 'T')+":00.000Z"); + var tsfrom = new Date(frmdata.dtpickerfrom.value.replace(' ', 'T')+":00.000Z"); tsto = tsto.getTime() / 1000; tsfrom = tsfrom.getTime() / 1000; frmdata.selfaction.value = frmdata.selfaction.value.replace(reto, 'to=' + tsto); From d3aea6757b2098382f200de963f038495aef1090 Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Thu, 2 Jul 2015 15:05:05 -0400 Subject: [PATCH 239/308] trying a more universal (perhaps not standard) format --- html/pages/graphs.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index cd4f6181b..b3f6a36b5 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -118,8 +118,8 @@ if (!$auth) function submitCustomRange(frmdata) { var reto = /to=([0-9])+/g; var refrom = /from=([0-9])+/g; - var tsto = new Date(frmdata.dtpickerto.value.replace(' ', 'T')+":00.000Z"); - var tsfrom = new Date(frmdata.dtpickerfrom.value.replace(' ', 'T')+":00.000Z"); + var tsto = new Date(frmdata.dtpickerto.value.replace('-', '/')+":00"); + var tsfrom = new Date(frmdata.dtpickerfrom.value.replace('-', '/')+":00"); tsto = tsto.getTime() / 1000; tsfrom = tsfrom.getTime() / 1000; frmdata.selfaction.value = frmdata.selfaction.value.replace(reto, 'to=' + tsto); From 6878e380b3a0712769c88dc88dd46d9153bbf3b2 Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Thu, 2 Jul 2015 15:10:49 -0400 Subject: [PATCH 240/308] using moment.js since we have it anyway --- html/pages/graphs.inc.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index b3f6a36b5..72fb1bd82 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -118,10 +118,10 @@ if (!$auth) function submitCustomRange(frmdata) { var reto = /to=([0-9])+/g; var refrom = /from=([0-9])+/g; - var tsto = new Date(frmdata.dtpickerto.value.replace('-', '/')+":00"); - var tsfrom = new Date(frmdata.dtpickerfrom.value.replace('-', '/')+":00"); - tsto = tsto.getTime() / 1000; - tsfrom = tsfrom.getTime() / 1000; + var tsto = moment(frmdata.dtpickerto.value).unix(); + var tsfrom = moment(frmdata.dtpickerfrom.value).unix(); + //tsto = tsto.getTime() / 1000; + //tsfrom = tsfrom.getTime() / 1000; frmdata.selfaction.value = frmdata.selfaction.value.replace(reto, 'to=' + tsto); frmdata.selfaction.value = frmdata.selfaction.value.replace(refrom, 'from=' + tsfrom); frmdata.action = frmdata.selfaction.value; From 6314aaddd4f85dd9c515b9633238b6911c515109 Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Thu, 2 Jul 2015 15:12:42 -0400 Subject: [PATCH 241/308] removing commented code --- html/pages/graphs.inc.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index 72fb1bd82..0cc268fce 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -120,8 +120,6 @@ if (!$auth) var refrom = /from=([0-9])+/g; var tsto = moment(frmdata.dtpickerto.value).unix(); var tsfrom = moment(frmdata.dtpickerfrom.value).unix(); - //tsto = tsto.getTime() / 1000; - //tsfrom = tsfrom.getTime() / 1000; frmdata.selfaction.value = frmdata.selfaction.value.replace(reto, 'to=' + tsto); frmdata.selfaction.value = frmdata.selfaction.value.replace(refrom, 'from=' + tsfrom); frmdata.action = frmdata.selfaction.value; From fd0617acca065ae3df8db6d002ad2c3aba35c04b Mon Sep 17 00:00:00 2001 From: Clint Armstrong Date: Thu, 2 Jul 2015 15:30:57 -0400 Subject: [PATCH 242/308] Do not allow the master to join twice If the poller master doesn't complete in time and ends up with overlapping jobs, neither job will ever complete because both running jobs will think they are the master and wait for the remaining node to exit. --- poller-wrapper.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/poller-wrapper.py b/poller-wrapper.py index 02efa825d..d9b542011 100755 --- a/poller-wrapper.py +++ b/poller-wrapper.py @@ -133,6 +133,9 @@ if ('distributed_poller' in config and import uuid memc = memcache.Client([config['distributed_poller_memcached_host'] + ':' + str(config['distributed_poller_memcached_port'])]) + if str(memc.get("poller.master")) == config['distributed_poller_name']: + print "This sytem is already joined as the poller master." + sys.exit(2) if memc_alive(): if memc.get("poller.master") is None: print "Registered as Master" @@ -148,7 +151,7 @@ if ('distributed_poller' in config and print "Could not connect to memcached, disabling distributed poller." distpoll = False IsNode = False - except: + except ImportError: print "ERROR: missing memcache python module:" print "On deb systems: apt-get install python-memcache" print "On other systems: easy_install python-memcached" From 69e9929ddba7443669e9871bbe59c69a3fd2042c Mon Sep 17 00:00:00 2001 From: sthen Date: Sat, 4 Jul 2015 20:14:28 +0100 Subject: [PATCH 243/308] Support Huawei UPS, tested with UPS5000 --- includes/defaults.inc.php | 1 + includes/definitions.inc.php | 9 +++++++++ includes/discovery/os/huaweiups.inc.php | 12 ++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 includes/discovery/os/huaweiups.inc.php diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index abeceee2e..8586266ee 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -575,6 +575,7 @@ $config['modules_compat']['rfc1628']['deltaups'] = 1; $config['modules_compat']['rfc1628']['poweralert'] = 1; $config['modules_compat']['rfc1628']['multimatic'] = 1; $config['modules_compat']['rfc1628']['webpower'] = 1; +$config['modules_compat']['rfc1628']['huaweiups'] = 1; # Enable daily updates $config['update'] = 1; diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 52d24bbc1..3c551d571 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -1162,6 +1162,15 @@ $config['os'][$os]['text'] = "Multimatic UPS"; $config['os'][$os]['type'] = "power"; $config['os'][$os]['icon'] = "multimatic"; +// Huawei UPS +$os = "huaweiups"; +$config['os'][$os]['text'] = "Huawei UPS"; +$config['os'][$os]['group'] = "ups"; +$config['os'][$os]['type'] = "power"; +$config['os'][$os]['icon'] = "huawei"; +$config['os'][$os]['over'][0]['graph'] = "device_current"; +$config['os'][$os]['over'][0]['text'] = "Current"; + foreach ($config['os'] as $this_os => $blah) { if (isset($config['os'][$this_os]['group'])) diff --git a/includes/discovery/os/huaweiups.inc.php b/includes/discovery/os/huaweiups.inc.php new file mode 100644 index 000000000..6b7f4f38d --- /dev/null +++ b/includes/discovery/os/huaweiups.inc.php @@ -0,0 +1,12 @@ + From ffbe06f64bccdf2356f74f9b128a9c270392fb32 Mon Sep 17 00:00:00 2001 From: sthen Date: Sat, 4 Jul 2015 20:15:17 +0100 Subject: [PATCH 244/308] Check netmanplus UPS by OID as well as descr, tested with Netman 204 --- includes/discovery/os/netmanplus.inc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/discovery/os/netmanplus.inc.php b/includes/discovery/os/netmanplus.inc.php index 42e081971..969c8bdb2 100644 --- a/includes/discovery/os/netmanplus.inc.php +++ b/includes/discovery/os/netmanplus.inc.php @@ -3,6 +3,7 @@ if (!$os) { if (preg_match("/^NetMan.*plus/", $sysDescr)) { $os = "netmanplus"; } + if (strstr($sysObjectId, ".1.3.6.1.4.1.5491.6")) { $os = "netmanplus"; } } -?> \ No newline at end of file +?> From 75704eba8738117244d98925a327318f23c8db8a Mon Sep 17 00:00:00 2001 From: sthen Date: Sat, 4 Jul 2015 20:47:46 +0100 Subject: [PATCH 245/308] Use correct divisor for frequencies on Huawei UPS --- includes/discovery/frequencies/rfc1628.inc.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/includes/discovery/frequencies/rfc1628.inc.php b/includes/discovery/frequencies/rfc1628.inc.php index 58f1fd6e4..340d0a38d 100644 --- a/includes/discovery/frequencies/rfc1628.inc.php +++ b/includes/discovery/frequencies/rfc1628.inc.php @@ -15,6 +15,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul $current = snmp_get($device, $freq_oid, "-Oqv") / 10; $type = "rfc1628"; $divisor = 10; + if ($device['os'] == "huaweiups") { $divisor = 100; }; $index = '3.2.0.'.$i; discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); } @@ -24,6 +25,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul $current = snmp_get($device, $freq_oid, "-Oqv") / 10; $type = "rfc1628"; $divisor = 10; + if ($device['os'] == "huaweiups") { $divisor = 100; }; $index = '4.2.0'; discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); @@ -32,6 +34,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul $current = snmp_get($device, $freq_oid, "-Oqv") / 10; $type = "rfc1628"; $divisor = 10; + if ($device['os'] == "huaweiups") { $divisor = 100; }; $index = '5.1.0'; discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); } From 049fd54bebed8b973818002c840d46b97799b1c9 Mon Sep 17 00:00:00 2001 From: vitalisator Date: Sat, 4 Jul 2015 23:22:26 +0200 Subject: [PATCH 246/308] Add support fo PBN CPE device" Fixes #1382 --- includes/discovery/os/pbn.inc.php | 5 ++--- includes/polling/os/pbn.inc.php | 7 +++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/includes/discovery/os/pbn.inc.php b/includes/discovery/os/pbn.inc.php index d8930fbb9..d2a5a805c 100644 --- a/includes/discovery/os/pbn.inc.php +++ b/includes/discovery/os/pbn.inc.php @@ -1,9 +1,8 @@ diff --git a/includes/polling/os/pbn.inc.php b/includes/polling/os/pbn.inc.php index aae6675f2..d498dddf8 100644 --- a/includes/polling/os/pbn.inc.php +++ b/includes/polling/os/pbn.inc.php @@ -3,6 +3,13 @@ if (preg_match('/^Pacific Broadband Networks .+\n.+ Version ([^,]+), .+\n.+\n.+\nSerial num:([^,]+), .+/', $poll_device['sysDescr'], $regexp_result)) { $version = $regexp_result[1]; $serial = $regexp_result[2]; + +# for PBN CPE 120/121 +} elseif (strstr(snmp_get($device, "SNMPv2-MIB::sysObjectID.0", "-Ovqn"), ".1.3.6.1.4.1.11606.24.1.1.10")) { + $version = snmp_get($device, "1.3.6.1.4.1.11606.24.1.1.6.0", "-Ovq"); + $hardware = snmp_get($device, "1.3.6.1.4.1.11606.24.1.1.7.0", "-Ovq"); + $features = snmp_get($device, "1.3.6.1.4.1.11606.24.1.1.10.0", "-Ovq"); + $serial = snmp_get($device, "1.3.6.1.4.1.11606.24.1.1.4.0", "-Ovq"); } ?> From bf8df0fbe2b4828108fdec5bdcab0d5964d054a6 Mon Sep 17 00:00:00 2001 From: Louis Rossouw Date: Sun, 5 Jul 2015 00:35:33 +0200 Subject: [PATCH 247/308] Pass service parameters to check_ssh allowing one to specify alternative port for ssh for example using -p flag. --- includes/services/ssh/check.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/services/ssh/check.inc b/includes/services/ssh/check.inc index 72bf4c2c5..d9cb7b98f 100644 --- a/includes/services/ssh/check.inc +++ b/includes/services/ssh/check.inc @@ -1,6 +1,6 @@ Date: Sun, 5 Jul 2015 00:47:51 +0200 Subject: [PATCH 248/308] When check_mysql is run with -n option it returns MySQL OK. Also accept that as an status=1 indication. --- includes/services/mysql/check.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/services/mysql/check.inc b/includes/services/mysql/check.inc index 93c97199c..d4d98bc85 100644 --- a/includes/services/mysql/check.inc +++ b/includes/services/mysql/check.inc @@ -7,7 +7,7 @@ $check = shell_exec($config['nagios_plugins'] . "/check_mysql -H ".$service['hos list($check, $time) = split("\|", $check); -if(strstr($check, "Uptime:")) { +if(strstr($check, "Uptime:") || strstr($check, "MySQL OK")) { $status = '1'; } else { $status = '0'; From 96f70b1b9bc9234bb1e4e3f686338f1a6fd92e4a Mon Sep 17 00:00:00 2001 From: Louis Rossouw Date: Sun, 5 Jul 2015 15:24:37 +0200 Subject: [PATCH 249/308] Add ntp service monitoring. --- includes/services/ntp/check.inc | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 includes/services/ntp/check.inc diff --git a/includes/services/ntp/check.inc b/includes/services/ntp/check.inc new file mode 100644 index 000000000..8115e55ad --- /dev/null +++ b/includes/services/ntp/check.inc @@ -0,0 +1,13 @@ + From abe773c1c3b9b8746cbfec8fb312127eea28ebfe Mon Sep 17 00:00:00 2001 From: Louis Rossouw Date: Sun, 5 Jul 2015 15:24:58 +0200 Subject: [PATCH 250/308] Update docs to reflect ntp service being added. --- doc/Extensions/Services.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/Extensions/Services.md b/doc/Extensions/Services.md index ca2e14ed3..ddae31f27 100644 --- a/doc/Extensions/Services.md +++ b/doc/Extensions/Services.md @@ -48,3 +48,4 @@ no graphs will be generated. ** - smtp - pop - simap +- ntp From 33e8723840d9fe80e9f52c037274fb7fbf1f2ab6 Mon Sep 17 00:00:00 2001 From: dontforget Date: Sun, 5 Jul 2015 17:14:50 +0300 Subject: [PATCH 251/308] fix nginx config file location fix nginx config file location --- doc/Installation/Installation-(RHEL-CentOS).md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Installation/Installation-(RHEL-CentOS).md b/doc/Installation/Installation-(RHEL-CentOS).md index a1aafc2b8..42f277f18 100644 --- a/doc/Installation/Installation-(RHEL-CentOS).md +++ b/doc/Installation/Installation-(RHEL-CentOS).md @@ -96,7 +96,7 @@ Modify permissions and configuration for `php-fpm` to use nginx credentials. vi /etc/php-fpm.d/www.conf # At line #12: Change `listen` to `/var/run/php5-fpm.sock` # At line #39-41: Change the `user` and `group` to `nginx` -Add configuration for `nginx` at `/etc/nginx/conf.d/librenms` with the following content: +Add configuration for `nginx` at `/etc/nginx/conf.d/librenms.conf` with the following content: ```nginx server { From c050ff374fef42609de187f6cbebe933005c70d3 Mon Sep 17 00:00:00 2001 From: Louis Rossouw Date: Sun, 5 Jul 2015 21:12:59 +0200 Subject: [PATCH 252/308] Add IRCd service. --- doc/Extensions/Services.md | 1 + includes/services/ircd/check.inc | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 includes/services/ircd/check.inc diff --git a/doc/Extensions/Services.md b/doc/Extensions/Services.md index ddae31f27..7ad7c9d29 100644 --- a/doc/Extensions/Services.md +++ b/doc/Extensions/Services.md @@ -49,3 +49,4 @@ no graphs will be generated. ** - pop - simap - ntp +- ircd diff --git a/includes/services/ircd/check.inc b/includes/services/ircd/check.inc new file mode 100644 index 000000000..cecfcb6d4 --- /dev/null +++ b/includes/services/ircd/check.inc @@ -0,0 +1,13 @@ + From 90f220108474ce87c7ab721b844cdc94dc990c45 Mon Sep 17 00:00:00 2001 From: Louis Rossouw Date: Sun, 5 Jul 2015 21:31:11 +0200 Subject: [PATCH 253/308] Fix up formatting to http://docs.librenms.org/Developing/Code-Guidelines/ --- includes/services/ircd/check.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/services/ircd/check.inc b/includes/services/ircd/check.inc index cecfcb6d4..80b540a5b 100644 --- a/includes/services/ircd/check.inc +++ b/includes/services/ircd/check.inc @@ -4,10 +4,10 @@ $check = shell_exec($config['nagios_plugins'] . "/check_ircd -H ".$service['host list($check, $time) = split("\|", $check); -if(strstr($check, "IRCD ok")) { - $status = '1'; +if (strstr($check, "IRCD ok")) { + $status = '1'; } else { - $status = '0'; + $status = '0'; } ?> From 06c0803b7be283890279952a71f24c765aaa80d3 Mon Sep 17 00:00:00 2001 From: laf Date: Sun, 5 Jul 2015 20:58:01 +0100 Subject: [PATCH 254/308] Updated changelog 05/07/2015 --- doc/General/Changelog.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/doc/General/Changelog.md b/doc/General/Changelog.md index ff43400c1..31ce4d0de 100644 --- a/doc/General/Changelog.md +++ b/doc/General/Changelog.md @@ -1,3 +1,16 @@ +### July 2015 + +#### Bug fixes + - Fixed API not functioning. (PR1367) + - Fixed API not storing alert rule names (PR1372) + - Fixed datetimepicker use (PR + - Do not allow master to rejoin itself. (PR1377) + - Fixed Nginx config file (PR1389) + +#### Improvements + - Added additional support for Rielo UPS (PR1381) + - Improved service check support (PR1385,PR1386,PR1387,PR1388) + ### June 2015 #### Bug fixes @@ -15,6 +28,14 @@ - Fixed legend ifLabels (PR1296) - Fixed bug causing map to not load when stale link data was present (PR1297) - Fixed javascript issue preventing removal of alert rules (PR1312) + - Fixed removal of IPs before ports are deleted (PR1329) + - Fixed JS issue when removing ports from bills (PR1330) + - Fixed adding --daemon a second time to collectd Graphs (PR1342) + - Fixed CollectD DS names (PR1347,PR1349,PR1368) + - Fixed graphing issues when rrd contains special chars (PR1350) + - Fixed regex for device groups (PR1359) + - Added HOST-RESOURCES-MIB into Synology detection (RP1360) + - Fix health page graphs showing the first graph for all (PR1363) #### Improvements - Updated Syslog docs to include syslog-ng 3.5.1 updates (PR1171) @@ -48,6 +69,18 @@ - Added WebUI support for Pushover (PR1313) - Updated path check for Oxidized config (PR1316) - Added Multimatic UPS to rfc1628 detection (PR1317) + - Added timeout for Unix agent (PR1319) + - Added support for a poller to use more than one poller group (PR1323) + - Added ability to use Plugins on device overview page (PR1325) + - Added latency loss/avg/max/min results to DB and Graph (PR1326) + - Added recording of device down (snmp/icmp) (PR1326) + - Added debugging output for when invalid SNMPv3 options used (PR1331) + - Added load and state output to device overview page (PR1333) + - Added load sensors to RFC1628 Devices (PR1336) + - Added support for WebPower Pro II UPS Cards (PR1338) + - No longer rewrite server-status in .htaccess (PR1339) + - Added docs for setting up Service extensions (PR1354) + - Added additional info from pfsense devices (PR1356) ### May 2015 From 23fdc03ded2f437162b539732ccead8730e71597 Mon Sep 17 00:00:00 2001 From: Tony Ditchfield Date: Sun, 5 Jul 2015 20:58:56 +0100 Subject: [PATCH 255/308] Added load and state icons from silkicons set --- html/images/icons/load.png | Bin 0 -> 541 bytes html/images/icons/state.png | Bin 0 -> 537 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 html/images/icons/load.png create mode 100644 html/images/icons/state.png diff --git a/html/images/icons/load.png b/html/images/icons/load.png new file mode 100644 index 0000000000000000000000000000000000000000..9051fbc609b92b15af9be410e368b7adc20283b8 GIT binary patch literal 541 zcmV+&0^V&qIn(Wzh!))n z^W^$!aM&X3bCX~Vo|JLOLCb!-`g!yN7b-yh!|sbVZ|M~fElQAyiB?lO%sjz z7TJ==TTk%_A{ znxkIa+E~RC#EKF{U0G~y<6)R9(uCp7&f7|JN}RHwEO@{EgbF~D3a1<@ip|9yZb^6$ fo@6A$W#9P^w2GuX0-m@}00000NkvXXu0mjfB69Bi literal 0 HcmV?d00001 diff --git a/html/images/icons/state.png b/html/images/icons/state.png new file mode 100644 index 0000000000000000000000000000000000000000..a9925a06ab02db30c1e7ead9c701c15bc63145cb GIT binary patch literal 537 zcmV+!0_OdRP)Hs{AQG2a)rMyf zFQK~pm1x3+7!nu%-M`k}``c>^00{o_1pjWJUTfl8mg=3qGEl8H@}^@w`VUx0_$uy4 z2FhRqKX}xI*?Tv1DJd8z#F#0c%*~rM30HE1@2o5m~}ZyoWhqv>ql{V z1ZGE0lgcoK^lx+eqc*rAX1Ky;Xx3U%u#zG!m-;eD1Qsn@kf3|F9qz~|95=&g3(7!X zB}JAT>RU;a%vaNOGnJ%e1=K6eAh43c(QN8RQ6~GP%O}Jju$~Ld*%`mO1p Date: Sun, 5 Jul 2015 21:18:11 +0100 Subject: [PATCH 256/308] Missing pr number --- doc/General/Changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/General/Changelog.md b/doc/General/Changelog.md index 31ce4d0de..8cdb6a1e5 100644 --- a/doc/General/Changelog.md +++ b/doc/General/Changelog.md @@ -3,7 +3,7 @@ #### Bug fixes - Fixed API not functioning. (PR1367) - Fixed API not storing alert rule names (PR1372) - - Fixed datetimepicker use (PR + - Fixed datetimepicker use (PR1376) - Do not allow master to rejoin itself. (PR1377) - Fixed Nginx config file (PR1389) From 1a5f98ac149d4d8693f22ba29474988ec543dd1b Mon Sep 17 00:00:00 2001 From: Will Jones Date: Mon, 6 Jul 2015 02:08:19 +0100 Subject: [PATCH 257/308] Create merakimr.inc.php OS detection module for Meraki MR --- includes/discovery/os/merakimr.inc.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 includes/discovery/os/merakimr.inc.php diff --git a/includes/discovery/os/merakimr.inc.php b/includes/discovery/os/merakimr.inc.php new file mode 100644 index 000000000..a8255a6b3 --- /dev/null +++ b/includes/discovery/os/merakimr.inc.php @@ -0,0 +1,17 @@ + + * 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 (preg_match("/^Meraki MR/", $sysDescr)) { $os = "merakimr"; } +} + +?> From f8b6038c9d0c3d9484f9e582449e7869728a9be5 Mon Sep 17 00:00:00 2001 From: Will Jones Date: Mon, 6 Jul 2015 02:09:40 +0100 Subject: [PATCH 258/308] Create merakims.inc.php OS Detection module for Meraki MS --- includes/discovery/os/merakims.inc.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 includes/discovery/os/merakims.inc.php diff --git a/includes/discovery/os/merakims.inc.php b/includes/discovery/os/merakims.inc.php new file mode 100644 index 000000000..8635c0e95 --- /dev/null +++ b/includes/discovery/os/merakims.inc.php @@ -0,0 +1,17 @@ + + * 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 (preg_match("/^Meraki MS/", $sysDescr)) { $os = "merakims"; } +} + +?> From be69210591509b880fa7424ae7418a8d7af240f9 Mon Sep 17 00:00:00 2001 From: Will Jones Date: Mon, 6 Jul 2015 02:10:25 +0100 Subject: [PATCH 259/308] Create merakimx.inc.php OS Detection module for Meraki MX --- includes/discovery/os/merakimx.inc.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 includes/discovery/os/merakimx.inc.php diff --git a/includes/discovery/os/merakimx.inc.php b/includes/discovery/os/merakimx.inc.php new file mode 100644 index 000000000..aa0f87e91 --- /dev/null +++ b/includes/discovery/os/merakimx.inc.php @@ -0,0 +1,17 @@ + + * 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 (preg_match("/^Meraki MX/", $sysDescr)) { $os = "merakimx"; } +} + +?> From f6f4a40c736a193b9e47d9c42461ac44731f1f9b Mon Sep 17 00:00:00 2001 From: Will Jones Date: Mon, 6 Jul 2015 02:13:50 +0100 Subject: [PATCH 260/308] Adding Meraki devices Definitions for Meraki MX. MR and MS hardware. --- includes/definitions.inc.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 3c551d571..1140ad6aa 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -1189,6 +1189,31 @@ foreach ($config['os'] as $this_os => $blah) } } +// Meraki Devices +$os = "merakimx"; +$config['os'][$os]['text'] = "Meraki MX Appliance"; +$config['os'][$os]['type'] = "firewall"; +$config['os'][$os]['icon'] = "meraki"; +$config['os'][$os]['ifname'] = 1; +$config['os'][$os]['over'][0]['graph'] = "device_bits"; +$config['os'][$os]['over'][0]['text'] = "Device Traffic"; + +$os = "merakimr"; +$config['os'][$os]['text'] = "Meraki AP"; +$config['os'][$os]['type'] = "wireless"; +$config['os'][$os]['icon'] = "meraki"; +$config['os'][$os]['ifname'] = 1; +$config['os'][$os]['over'][0]['graph'] = "device_bits"; +$config['os'][$os]['over'][0]['text'] = "Device Traffic"; + +$os = "merakims"; +$config['os'][$os]['text'] = "Meraki Switch"; +$config['os'][$os]['type'] = "network"; +$config['os'][$os]['icon'] = "meraki"; +$config['os'][$os]['ifname'] = 1; +$config['os'][$os]['over'][0]['graph'] = "device_bits"; +$config['os'][$os]['over'][0]['text'] = "Device Traffic"; + // Graph Types include_once($config['install_dir'] . "/includes/load_db_graph_types.inc.php"); From a015db74d94a6c3d134531e9f1cc80343bbab772 Mon Sep 17 00:00:00 2001 From: Will Jones Date: Mon, 6 Jul 2015 02:21:40 +0100 Subject: [PATCH 261/308] add Will Jones I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md. --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 86db6c60e..ce1ce2b57 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -37,6 +37,7 @@ Contributors to LibreNMS: - Clint Armstrong (clinta) - Tony Ditchfield (arnoldthebat) - Travis Hegner (travishegner) +- Will Jones (willjones) [1]: http://observium.org/ "Observium web site" From a584c08babf2f92a2853653b0419484feb982dd0 Mon Sep 17 00:00:00 2001 From: dontforget Date: Mon, 6 Jul 2015 17:14:52 +0300 Subject: [PATCH 262/308] fix chkconfig command Defining level is not needed for chkconfig according to official documentation https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/sect-System_Monitoring_Tools-Net-SNMP-Running.html --- doc/Installation/Installation-(RHEL-CentOS).md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/Installation/Installation-(RHEL-CentOS).md b/doc/Installation/Installation-(RHEL-CentOS).md index 42f277f18..cf36bb979 100644 --- a/doc/Installation/Installation-(RHEL-CentOS).md +++ b/doc/Installation/Installation-(RHEL-CentOS).md @@ -7,8 +7,8 @@ NOTE: These instructions assume you are the root user. If you are not, prepend yum install net-snmp mysql-server service snmpd start service mysqld start - chkconfig --levels 235 mysqld on - chkconfig --levels 235 snmpd on + chkconfig mysqld on + chkconfig snmpd on mysql_secure_installation mysql -uroot -p From 5d80beeeb5e3ec513cd8d1558ab8f2e3f51e8d31 Mon Sep 17 00:00:00 2001 From: dontforget Date: Mon, 6 Jul 2015 17:21:48 +0300 Subject: [PATCH 263/308] fix install for epel Install epel release using yum --- doc/Installation/Installation-(RHEL-CentOS).md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Installation/Installation-(RHEL-CentOS).md b/doc/Installation/Installation-(RHEL-CentOS).md index cf36bb979..350cc4c71 100644 --- a/doc/Installation/Installation-(RHEL-CentOS).md +++ b/doc/Installation/Installation-(RHEL-CentOS).md @@ -46,7 +46,7 @@ Install necessary software. The packages listed below are an all-inclusive list Note if not using HTTPd (Apache): RHEL requires `httpd` to be installed regardless of of `nginx`'s (or any other web-server's) presence. - rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm + yum install epel-release yum install php php-cli php-gd php-mysql php-snmp php-pear php-curl httpd net-snmp graphviz graphviz-php mysql ImageMagick jwhois nmap mtr rrdtool MySQL-python net-snmp-utils vixie-cron php-mcrypt fping git pear install Net_IPv4-1.3.4 pear install Net_IPv6-1.2.2b2 From e9aa9a2ae967be24f7aef94be2126044551daa13 Mon Sep 17 00:00:00 2001 From: dontforget Date: Mon, 6 Jul 2015 17:26:58 +0300 Subject: [PATCH 264/308] fix nginx and php --- doc/Installation/Installation-(RHEL-CentOS).md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/Installation/Installation-(RHEL-CentOS).md b/doc/Installation/Installation-(RHEL-CentOS).md index 350cc4c71..5968dacbb 100644 --- a/doc/Installation/Installation-(RHEL-CentOS).md +++ b/doc/Installation/Installation-(RHEL-CentOS).md @@ -87,8 +87,8 @@ If the file `/etc/httpd/conf.d/welcome.conf` exists, you might want to remove th Install necessary extra software and let it start on system boot. yum install nginx php-fpm - chkconfig --levels 235 nginx on - chkconfig --levels 235 php-fpm on + chkconfig nginx on + chkconfig php-fpm on Modify permissions and configuration for `php-fpm` to use nginx credentials. From 016b759858d76ca1db3a5a871f09ba73f64a6f07 Mon Sep 17 00:00:00 2001 From: willjones Date: Mon, 6 Jul 2015 21:17:50 +0100 Subject: [PATCH 265/308] Added Meraki OS discovery and polling --- html/images/os/meraki.png | Bin 0 -> 1664 bytes includes/definitions.inc.php | 25 +++++++++++++++++++++++++ includes/discovery/os/merakimr.inc.php | 17 +++++++++++++++++ includes/discovery/os/merakims.inc.php | 17 +++++++++++++++++ includes/discovery/os/merakimx.inc.php | 17 +++++++++++++++++ includes/polling/os/merakimr.inc.php | 18 ++++++++++++++++++ includes/polling/os/merakims.inc.php | 18 ++++++++++++++++++ includes/polling/os/merakimx.inc.php | 18 ++++++++++++++++++ 8 files changed, 130 insertions(+) create mode 100644 html/images/os/meraki.png create mode 100644 includes/discovery/os/merakimr.inc.php create mode 100644 includes/discovery/os/merakims.inc.php create mode 100644 includes/discovery/os/merakimx.inc.php create mode 100644 includes/polling/os/merakimr.inc.php create mode 100644 includes/polling/os/merakims.inc.php create mode 100644 includes/polling/os/merakimx.inc.php diff --git a/html/images/os/meraki.png b/html/images/os/meraki.png new file mode 100644 index 0000000000000000000000000000000000000000..51b3564f6dc9e20b528d3d7933766b418addb6fa GIT binary patch literal 1664 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^T}FfdWk9dNvV1jxdlK~3=B3ERzPNMYDuC(MQ%=Bu~mhw5?F;5kPQ;nS5g2gDap1~ zitr6kaLzAERWQ{v(KAr8<5EyiuqjGOvkG!?gK7uzY?U%fN(!v>^~=l4^~#O)@{7{- z4J|D#^$m>ljf`}GDs+o0^GXscbn}XpA%?)raY-#sF3Kz@$;{7F0GXSZlwVq6tE2?7 z2o50bEXhnm*pycc^%l^B`XCv7Lp=k1xY$-uu4$%|?`(myi^JB2i8yLB{aA6K{@*9Z*Na6&7HV|3F8S{gV8FUGH^67HS+9ht zeUSN*v)xB*e9AuGy89-%tn7OAyEJp_yS<$%6YMPwir=5H{XQrEoaOzU$}Te!q+Pf6 z?%VlVmf^M>eb=OT< z4mI?tURWcR5b(BDA>*;#lMh17CXJSo6&kNa;?`D6AHA9S@#~S3Z45jT{)}Ir06bo^Lkrh&VNsnch-Hi zGfiJauo-<}t@!f5IAfhnqt4;KcYekt8?QTG)A{b8^p;S?Y_W$sibdq_)bOzhZpg}d z$Zt7SnpNB7;DO#-5iD)beh1_;h%sOOk@|pLuF>+o$a+D|M{Wz{Uda4q<9)i8t89r+ zqss4(7yHu-OFt={@+tK^$H^%=SL20&{2Sj$<|WQM)n&V6Uh1DLi^81*g6lz4O*SHYJ@U`CVLx_8I|&q6@0eCTDC6IrMOD zL+wB7jwCacYg&IC*B^=zYA}3mP&H@zgq0_sU!AwYH{Que-|}P1QSKF*c3phGL${Q~ zxfM^DI;ZZf+=8`lN^N34+qk8@fAnRm_l>g*0;Z;qvi2)Pdor-4zgZ9v$s-mOA3QDM z_0o)qbM)<)C#Qw(*W1C;e2gRO>SsB2{gg%PLJwa`J{f+)hwZ_e#}E5O{TG$#$X?0X z|Le7L&7bGO70dT=KbQM$64-mb^U(S&vI*ykBYjO0u2c*6TBdJMUmUP-HG{+3vO~q~ z?OqF~K02uTzqd}_`}n42cc)3rG1@YGj_XYiJ&ixoQZK_=CF{iT>Du2b|E4D-WOpuF zpji0-?0fk}eVdlpSF0>)Gnidf0$m(=wJb!Xw<={bXe)8)obz#-sPJc#^yW+JZI+7n zZTZ}`b&;67h+xDgy#u0BEuNxhC;R!Nx23Q+ZT{eNTmGn?)GyJ8xI}6DE|G9D8n?>?_R+tpJhGXCzsdJb$rpfl%HD^&oG=^ zvtZiO-G7cKXHEPeFgM`2j*;1dBQf2#n%V<{OH5Y&cQ1E&&&9COX3|I3n}@rXrIibR zy4<}(uvdatKX>W;2@V(f8{RM*HnnJ^U5ifeKJB*7w0~>zwfgIVtPB(Xp6%JR?{db9 z1KI8O-Af-fd%6m5o-RH+rznJBfnMnajR!fG#Wl~r^Zn(uGxi{p)$h_QW44bndlPm}S^luCEN|i^zJ|FRf4EtjelDHltuzl*S9rSmxvX $blah) } } +// Meraki +$os = "merakimx"; +$config['os'][$os]['text'] = "Meraki MX Appliance"; +$config['os'][$os]['type'] = "firewall"; +$config['os'][$os]['icon'] = "meraki"; +$config['os'][$os]['ifname'] = 1; +$config['os'][$os]['over'][0]['graph'] = "device_bits"; +$config['os'][$os]['over'][0]['text'] = "Device Traffic"; + +$os = "merakimr"; +$config['os'][$os]['text'] = "Meraki AP"; +$config['os'][$os]['type'] = "wireless"; +$config['os'][$os]['icon'] = "meraki"; +$config['os'][$os]['ifname'] = 1; +$config['os'][$os]['over'][0]['graph'] = "device_bits"; +$config['os'][$os]['over'][0]['text'] = "Device Traffic"; + +$os = "merakims"; +$config['os'][$os]['text'] = "Meraki Switch"; +$config['os'][$os]['type'] = "network"; +$config['os'][$os]['icon'] = "meraki"; +$config['os'][$os]['ifname'] = 1; +$config['os'][$os]['over'][0]['graph'] = "device_bits"; +$config['os'][$os]['over'][0]['text'] = "Device Traffic"; + // Graph Types include_once($config['install_dir'] . "/includes/load_db_graph_types.inc.php"); diff --git a/includes/discovery/os/merakimr.inc.php b/includes/discovery/os/merakimr.inc.php new file mode 100644 index 000000000..a8255a6b3 --- /dev/null +++ b/includes/discovery/os/merakimr.inc.php @@ -0,0 +1,17 @@ + + * 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 (preg_match("/^Meraki MR/", $sysDescr)) { $os = "merakimr"; } +} + +?> diff --git a/includes/discovery/os/merakims.inc.php b/includes/discovery/os/merakims.inc.php new file mode 100644 index 000000000..8635c0e95 --- /dev/null +++ b/includes/discovery/os/merakims.inc.php @@ -0,0 +1,17 @@ + + * 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 (preg_match("/^Meraki MS/", $sysDescr)) { $os = "merakims"; } +} + +?> diff --git a/includes/discovery/os/merakimx.inc.php b/includes/discovery/os/merakimx.inc.php new file mode 100644 index 000000000..aa0f87e91 --- /dev/null +++ b/includes/discovery/os/merakimx.inc.php @@ -0,0 +1,17 @@ + + * 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 (preg_match("/^Meraki MX/", $sysDescr)) { $os = "merakimx"; } +} + +?> diff --git a/includes/polling/os/merakimr.inc.php b/includes/polling/os/merakimr.inc.php new file mode 100644 index 000000000..2158f6c25 --- /dev/null +++ b/includes/polling/os/merakimr.inc.php @@ -0,0 +1,18 @@ + + * 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(empty($hardware)) { + $hardware = snmp_get($device, "sysDescr.0", "-Osqv", "SNMPv2-MIB"); +} + + +?> diff --git a/includes/polling/os/merakims.inc.php b/includes/polling/os/merakims.inc.php new file mode 100644 index 000000000..1bfdaedc3 --- /dev/null +++ b/includes/polling/os/merakims.inc.php @@ -0,0 +1,18 @@ + + * 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(empty($hardware)) { + $hardware = snmp_get($device, "sysDescr.0", "-Osqv", "SNMPv2-MIB"); +} + + +?> diff --git a/includes/polling/os/merakimx.inc.php b/includes/polling/os/merakimx.inc.php new file mode 100644 index 000000000..217ca3afc --- /dev/null +++ b/includes/polling/os/merakimx.inc.php @@ -0,0 +1,18 @@ + + * 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(empty($hardware)) { + $hardware = snmp_get($device, "sysDescr.0", "-Osqv", "SNMPv2-MIB"); +} + + +?> From 93c0e8ae9c14ab7ecf2f446aa86b65a40af36aef Mon Sep 17 00:00:00 2001 From: Will Jones Date: Mon, 6 Jul 2015 21:37:18 +0100 Subject: [PATCH 266/308] Delete meraki.png --- html/images/os/meraki.png | Bin 1664 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 html/images/os/meraki.png diff --git a/html/images/os/meraki.png b/html/images/os/meraki.png deleted file mode 100644 index 51b3564f6dc9e20b528d3d7933766b418addb6fa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1664 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^T}FfdWk9dNvV1jxdlK~3=B3ERzPNMYDuC(MQ%=Bu~mhw5?F;5kPQ;nS5g2gDap1~ zitr6kaLzAERWQ{v(KAr8<5EyiuqjGOvkG!?gK7uzY?U%fN(!v>^~=l4^~#O)@{7{- z4J|D#^$m>ljf`}GDs+o0^GXscbn}XpA%?)raY-#sF3Kz@$;{7F0GXSZlwVq6tE2?7 z2o50bEXhnm*pycc^%l^B`XCv7Lp=k1xY$-uu4$%|?`(myi^JB2i8yLB{aA6K{@*9Z*Na6&7HV|3F8S{gV8FUGH^67HS+9ht zeUSN*v)xB*e9AuGy89-%tn7OAyEJp_yS<$%6YMPwir=5H{XQrEoaOzU$}Te!q+Pf6 z?%VlVmf^M>eb=OT< z4mI?tURWcR5b(BDA>*;#lMh17CXJSo6&kNa;?`D6AHA9S@#~S3Z45jT{)}Ir06bo^Lkrh&VNsnch-Hi zGfiJauo-<}t@!f5IAfhnqt4;KcYekt8?QTG)A{b8^p;S?Y_W$sibdq_)bOzhZpg}d z$Zt7SnpNB7;DO#-5iD)beh1_;h%sOOk@|pLuF>+o$a+D|M{Wz{Uda4q<9)i8t89r+ zqss4(7yHu-OFt={@+tK^$H^%=SL20&{2Sj$<|WQM)n&V6Uh1DLi^81*g6lz4O*SHYJ@U`CVLx_8I|&q6@0eCTDC6IrMOD zL+wB7jwCacYg&IC*B^=zYA}3mP&H@zgq0_sU!AwYH{Que-|}P1QSKF*c3phGL${Q~ zxfM^DI;ZZf+=8`lN^N34+qk8@fAnRm_l>g*0;Z;qvi2)Pdor-4zgZ9v$s-mOA3QDM z_0o)qbM)<)C#Qw(*W1C;e2gRO>SsB2{gg%PLJwa`J{f+)hwZ_e#}E5O{TG$#$X?0X z|Le7L&7bGO70dT=KbQM$64-mb^U(S&vI*ykBYjO0u2c*6TBdJMUmUP-HG{+3vO~q~ z?OqF~K02uTzqd}_`}n42cc)3rG1@YGj_XYiJ&ixoQZK_=CF{iT>Du2b|E4D-WOpuF zpji0-?0fk}eVdlpSF0>)Gnidf0$m(=wJb!Xw<={bXe)8)obz#-sPJc#^yW+JZI+7n zZTZ}`b&;67h+xDgy#u0BEuNxhC;R!Nx23Q+ZT{eNTmGn?)GyJ8xI}6DE|G9D8n?>?_R+tpJhGXCzsdJb$rpfl%HD^&oG=^ zvtZiO-G7cKXHEPeFgM`2j*;1dBQf2#n%V<{OH5Y&cQ1E&&&9COX3|I3n}@rXrIibR zy4<}(uvdatKX>W;2@V(f8{RM*HnnJ^U5ifeKJB*7w0~>zwfgIVtPB(Xp6%JR?{db9 z1KI8O-Af-fd%6m5o-RH+rznJBfnMnajR!fG#Wl~r^Zn(uGxi{p)$h_QW44bndlPm}S^luCEN|i^zJ|FRf4EtjelDHltuzl*S9rSmxvX Date: Mon, 6 Jul 2015 21:49:13 +0100 Subject: [PATCH 267/308] Meraki Logo. Source = Meraki Partner Portal --- html/images/os/meraki.png | Bin 0 -> 1664 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 html/images/os/meraki.png diff --git a/html/images/os/meraki.png b/html/images/os/meraki.png new file mode 100644 index 0000000000000000000000000000000000000000..51b3564f6dc9e20b528d3d7933766b418addb6fa GIT binary patch literal 1664 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^T}FfdWk9dNvV1jxdlK~3=B3ERzPNMYDuC(MQ%=Bu~mhw5?F;5kPQ;nS5g2gDap1~ zitr6kaLzAERWQ{v(KAr8<5EyiuqjGOvkG!?gK7uzY?U%fN(!v>^~=l4^~#O)@{7{- z4J|D#^$m>ljf`}GDs+o0^GXscbn}XpA%?)raY-#sF3Kz@$;{7F0GXSZlwVq6tE2?7 z2o50bEXhnm*pycc^%l^B`XCv7Lp=k1xY$-uu4$%|?`(myi^JB2i8yLB{aA6K{@*9Z*Na6&7HV|3F8S{gV8FUGH^67HS+9ht zeUSN*v)xB*e9AuGy89-%tn7OAyEJp_yS<$%6YMPwir=5H{XQrEoaOzU$}Te!q+Pf6 z?%VlVmf^M>eb=OT< z4mI?tURWcR5b(BDA>*;#lMh17CXJSo6&kNa;?`D6AHA9S@#~S3Z45jT{)}Ir06bo^Lkrh&VNsnch-Hi zGfiJauo-<}t@!f5IAfhnqt4;KcYekt8?QTG)A{b8^p;S?Y_W$sibdq_)bOzhZpg}d z$Zt7SnpNB7;DO#-5iD)beh1_;h%sOOk@|pLuF>+o$a+D|M{Wz{Uda4q<9)i8t89r+ zqss4(7yHu-OFt={@+tK^$H^%=SL20&{2Sj$<|WQM)n&V6Uh1DLi^81*g6lz4O*SHYJ@U`CVLx_8I|&q6@0eCTDC6IrMOD zL+wB7jwCacYg&IC*B^=zYA}3mP&H@zgq0_sU!AwYH{Que-|}P1QSKF*c3phGL${Q~ zxfM^DI;ZZf+=8`lN^N34+qk8@fAnRm_l>g*0;Z;qvi2)Pdor-4zgZ9v$s-mOA3QDM z_0o)qbM)<)C#Qw(*W1C;e2gRO>SsB2{gg%PLJwa`J{f+)hwZ_e#}E5O{TG$#$X?0X z|Le7L&7bGO70dT=KbQM$64-mb^U(S&vI*ykBYjO0u2c*6TBdJMUmUP-HG{+3vO~q~ z?OqF~K02uTzqd}_`}n42cc)3rG1@YGj_XYiJ&ixoQZK_=CF{iT>Du2b|E4D-WOpuF zpji0-?0fk}eVdlpSF0>)Gnidf0$m(=wJb!Xw<={bXe)8)obz#-sPJc#^yW+JZI+7n zZTZ}`b&;67h+xDgy#u0BEuNxhC;R!Nx23Q+ZT{eNTmGn?)GyJ8xI}6DE|G9D8n?>?_R+tpJhGXCzsdJb$rpfl%HD^&oG=^ zvtZiO-G7cKXHEPeFgM`2j*;1dBQf2#n%V<{OH5Y&cQ1E&&&9COX3|I3n}@rXrIibR zy4<}(uvdatKX>W;2@V(f8{RM*HnnJ^U5ifeKJB*7w0~>zwfgIVtPB(Xp6%JR?{db9 z1KI8O-Af-fd%6m5o-RH+rznJBfnMnajR!fG#Wl~r^Zn(uGxi{p)$h_QW44bndlPm}S^luCEN|i^zJ|FRf4EtjelDHltuzl*S9rSmxvX Date: Tue, 7 Jul 2015 10:04:10 +0100 Subject: [PATCH 268/308] Update definitions.inc.php removed conflict. --- includes/definitions.inc.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 16b4dcde0..1140ad6aa 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -1189,11 +1189,7 @@ foreach ($config['os'] as $this_os => $blah) } } -<<<<<<< HEAD -// Meraki -======= // Meraki Devices ->>>>>>> 8b9323852cb4acdbedecca17c7a1a2fc8a53155f $os = "merakimx"; $config['os'][$os]['text'] = "Meraki MX Appliance"; $config['os'][$os]['type'] = "firewall"; From a35fa43e447f5ac0107979a829240010e7777f51 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 7 Jul 2015 19:16:36 +0100 Subject: [PATCH 269/308] Added basic detection for Brocade --- includes/definitions.inc.php | 13 ++++++++++++- includes/discovery/os/nos.inc.php | 7 +++++++ includes/polling/os/nos.inc.php | 6 ++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 includes/discovery/os/nos.inc.php create mode 100644 includes/polling/os/nos.inc.php diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 3c551d571..9db59d3c4 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -408,7 +408,18 @@ $config['os'][$os]['over'][2]['graph'] = "device_mempool"; $config['os'][$os]['over'][2]['text'] = "Memory Usage"; $config['os'][$os]['icon'] = "cisco"; - +// Brocade NOS +$os = "nos"; +$config['os'][$os]['text'] = "Brocade NOS"; +$config['os'][$os]['type'] = "network"; +$config['os'][$os]['ifname'] = 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"; +$config['os'][$os]['icon'] = "brocade"; // Cisco Small Business diff --git a/includes/discovery/os/nos.inc.php b/includes/discovery/os/nos.inc.php new file mode 100644 index 000000000..de4141cb6 --- /dev/null +++ b/includes/discovery/os/nos.inc.php @@ -0,0 +1,7 @@ + Date: Tue, 7 Jul 2015 19:43:25 +0100 Subject: [PATCH 270/308] Improved the discovery of IP based devices --- includes/discovery/discovery-arp.inc.php | 13 +++---------- includes/discovery/functions.inc.php | 12 +++++++----- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/includes/discovery/discovery-arp.inc.php b/includes/discovery/discovery-arp.inc.php index fce4e2f9a..230752d9e 100644 --- a/includes/discovery/discovery-arp.inc.php +++ b/includes/discovery/discovery-arp.inc.php @@ -69,17 +69,10 @@ foreach (dbFetchRows($sql, array($deviceid)) as $entry) } arp_discovery_add_cache($ip); - // Log reverse DNS failures so the administrator can take action. $name = gethostbyaddr($ip); - if ($name != $ip) { // gethostbyaddr returns the original argument on failure - echo("+"); - $names[] = $name; - $ips[$name] = $ip; - } - else { - echo("-"); - log_event("ARP discovery of $ip failed due to absent reverse DNS", $deviceid, 'interface', $if); - } + echo("+"); + $names[] = $name; + $ips[$name] = $ip; } echo("\n"); diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php index f369fac79..9aa82d274 100644 --- a/includes/discovery/functions.inc.php +++ b/includes/discovery/functions.inc.php @@ -22,12 +22,14 @@ function discover_new_device($hostname) } if ($debug) { echo("discovering $dst_host\n"); } $ip = gethostbyname($dst_host); - if ($ip == $dst_host) { - if ($debug) { echo("name lookup of $dst_host failed\n"); } - return FALSE; - } else { - if ($debug) { echo("ip lookup result: $ip\n"); } + if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === FALSE && filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === FALSE) { + // $ip isn't a valid IP so it must be a name. + if ($ip == $dst_host) { + if ($debug) { echo("name lookup of $dst_host failed\n"); } + return FALSE; + } } + if ($debug) { echo("ip lookup result: $ip\n"); } $dst_host = rtrim($dst_host, '.'); // remove trailing dot From 4c3a6b5ff23f47792433ad3893b2c32350656cab Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 7 Jul 2015 21:04:39 +0100 Subject: [PATCH 271/308] Added using cronic for poller-wrapper, this will now allow email alerts from cron --- cronic | 48 +++++++++++++++++++++++++++++++++++++++++++ librenms.cron | 2 +- librenms.nonroot.cron | 2 +- 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100755 cronic diff --git a/cronic b/cronic new file mode 100755 index 000000000..8536f29a3 --- /dev/null +++ b/cronic @@ -0,0 +1,48 @@ +#!/bin/bash + +# Cronic v2 - cron job report wrapper +# Copyright 2007 Chuck Houpt. No rights reserved, whatsoever. +# Public Domain CC0: http://creativecommons.org/publicdomain/zero/1.0/ + +set -eu + +OUT=/tmp/cronic.out.$$ +ERR=/tmp/cronic.err.$$ +TRACE=/tmp/cronic.trace.$$ + +set +e +"$@" >$OUT 2>$TRACE +RESULT=$? +set -e + +PATTERN="^${PS4:0:1}\\+${PS4:1}" +if grep -aq "$PATTERN" $TRACE +then + ! grep -av "$PATTERN" $TRACE > $ERR +else + ERR=$TRACE +fi + +if [ $RESULT -ne 0 -o -s "$ERR" ] + then + echo "Cronic detected failure or error output for the command:" + echo "$@" + echo + echo "RESULT CODE: $RESULT" + echo + echo "ERROR OUTPUT:" + cat "$ERR" + echo + echo "STANDARD OUTPUT:" + cat "$OUT" + if [ $TRACE != $ERR ] + then + echo + echo "TRACE-ERROR OUTPUT:" + cat "$TRACE" + fi +fi + +rm -f "$OUT" +rm -f "$ERR" +rm -f "$TRACE" diff --git a/librenms.cron b/librenms.cron index 8ea97492c..ad03af7f5 100644 --- a/librenms.cron +++ b/librenms.cron @@ -2,6 +2,6 @@ 33 */6 * * * root /opt/librenms/discovery.php -h all >> /dev/null 2>&1 */5 * * * * root /opt/librenms/discovery.php -h new >> /dev/null 2>&1 -*/5 * * * * root /opt/librenms/poller-wrapper.py 16 >> /dev/null 2>&1 +*/5 * * * * root /opt/librenms/cronic /opt/librenms/poller-wrapper.py 16 15 0 * * * root sh /opt/librenms/daily.sh >> /dev/null 2>&1 * * * * * root /opt/librenms/alerts.php >> /dev/null 2>&1 diff --git a/librenms.nonroot.cron b/librenms.nonroot.cron index 7c0fdfc58..6183ebc18 100644 --- a/librenms.nonroot.cron +++ b/librenms.nonroot.cron @@ -2,6 +2,6 @@ 33 */6 * * * librenms /opt/librenms/discovery.php -h all >> /dev/null 2>&1 */5 * * * * librenms /opt/librenms/discovery.php -h new >> /dev/null 2>&1 -*/5 * * * * librenms /opt/librenms/poller-wrapper.py 16 >> /dev/null 2>&1 +*/5 * * * * librenms /opt/librenms/cronic /opt/librenms/poller-wrapper.py 16 15 0 * * * librenms sh /opt/librenms/daily.sh >> /dev/null 2>&1 * * * * * librenms /opt/librenms/alerts.php >> /dev/null 2>&1 From b1a052f357d231d797b3fbad6e98cc18abd87eb2 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 7 Jul 2015 23:18:57 +0100 Subject: [PATCH 272/308] Some permission updates for non-admin users --- html/includes/table/alerts.inc.php | 26 ++++++++++++++++---------- html/pages/search/arp.inc.php | 11 ++++++++++- html/pages/search/packages.inc.php | 13 +++++++++++-- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/html/includes/table/alerts.inc.php b/html/includes/table/alerts.inc.php index da2a6d1c6..799404b1a 100644 --- a/html/includes/table/alerts.inc.php +++ b/html/includes/table/alerts.inc.php @@ -7,10 +7,18 @@ if (is_numeric($_POST['device_id']) && $_POST['device_id'] > 0) { } if (isset($searchPhrase) && !empty($searchPhrase)) { - $sql .= " AND (`timestamp` LIKE '%$searchPhrase%' OR `rule` LIKE '%$searchPhrase%' OR `name` LIKE '%$searchPhrase%' OR `hostname` LIKE '%$searchPhrase%')"; + $sql_search .= " AND (`timestamp` LIKE '%$searchPhrase%' OR `rule` LIKE '%$searchPhrase%' OR `name` LIKE '%$searchPhrase%' OR `hostname` LIKE '%$searchPhrase%')"; } -$sql = " FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id` RIGHT JOIN alert_rules ON alerts.rule_id=alert_rules.id WHERE $where AND `state` IN (1,2,3,4) $sql"; +$sql = " FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id`"; + +if (is_admin() === FALSE && is_read() === FALSE) { + $sql .= " LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`"; + $where .= " AND `DP`.`user_id`=?"; + $param[] = $_SESSION['user_id']; +} + +$sql .= " RIGHT JOIN alert_rules ON alerts.rule_id=alert_rules.id WHERE $where AND `state` IN (1,2,3,4) $sql_search"; $count_sql = "SELECT COUNT(`alerts`.`id`) $sql"; $total = dbFetchCell($count_sql,$param); @@ -78,14 +86,12 @@ foreach (dbFetchRows($sql,$param) as $alert) { $severity .= " -"; } - if ($_SESSION['userlevel'] >= '10') { - $ack_ico = 'volume-up'; - $ack_col = 'success'; - if($alert['state'] == 2) { - $ack_ico = 'volume-off'; - $ack_col = 'danger'; - } - } + $ack_ico = 'volume-up'; + $ack_col = 'success'; + if($alert['state'] == 2) { + $ack_ico = 'volume-off'; + $ack_col = 'danger'; + } $hostname = '
    diff --git a/html/pages/search/arp.inc.php b/html/pages/search/arp.inc.php index 5e7df4266..a4dcbd113 100644 --- a/html/pages/search/arp.inc.php +++ b/html/pages/search/arp.inc.php @@ -30,7 +30,16 @@ var grid = $("#arp-search").bootgrid({ 0) { $count_query = "SELECT COUNT(*) FROM ( "; $full_query = ""; -$query = 'SELECT packages.name FROM packages,devices WHERE packages.device_id = devices.device_id AND packages.name LIKE "%'.mres($_POST['package']).'%" GROUP BY packages.name'; -$where = ''; +$query = 'SELECT packages.name FROM packages,devices '; $param = array(); + +if (is_admin() === FALSE && is_read() === FALSE) { + $query .= " LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id`"; + $sql_where .= " AND `DP`.`user_id`=?"; + $param[] = $_SESSION['user_id']; +} + +$query .= " WHERE packages.device_id = devices.device_id AND packages.name LIKE '%".mres($_POST['package'])."%' $sql_where GROUP BY packages.name"; + +$where = ''; $ver = ""; $opt = ""; From 3ed8d261a7937010f5bff6f657b2c5fd33beaddd Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 7 Jul 2015 23:26:03 +0100 Subject: [PATCH 273/308] Fixed arp search page user perm queries --- html/includes/table/arp-search.inc.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/html/includes/table/arp-search.inc.php b/html/includes/table/arp-search.inc.php index d4a9eaaf8..937553b42 100644 --- a/html/includes/table/arp-search.inc.php +++ b/html/includes/table/arp-search.inc.php @@ -2,14 +2,22 @@ $param = array(); -$sql = " FROM `ipv4_mac` AS M, `ports` AS P, `devices` AS D WHERE M.port_id = P.port_id AND P.device_id = D.device_id "; +$sql .= " FROM `ipv4_mac` AS M, `ports` AS P, `devices` AS D "; + +if (is_admin() === FALSE && is_read() === FALSE) { + $sql .= " LEFT JOIN `devices_perms` AS `DP` ON `D`.`device_id` = `DP`.`device_id`"; + $where .= " AND `DP`.`user_id`=?"; + $param[] = $_SESSION['user_id']; +} + +$sql .= " WHERE M.port_id = P.port_id AND P.device_id = D.device_id $where "; if (isset($_POST['searchby']) && $_POST['searchby'] == "ip") { $sql .= " AND `ipv4_address` LIKE ?"; - $param = array("%".trim($_POST['address'])."%"); + $param[] = "%".trim($_POST['address'])."%"; } elseif (isset($_POST['searchby']) && $_POST['searchby'] == "mac") { $sql .= " AND `mac_address` LIKE ?"; - $param = array("%".str_replace(array(':', ' ', '-', '.', '0x'),'',mres($_POST['address']))."%"); + $param[] = "%".str_replace(array(':', ' ', '-', '.', '0x'),'',mres($_POST['address']))."%"; } if (is_numeric($_POST['device_id'])) { @@ -41,6 +49,7 @@ if ($rowCount != -1) { $sql = "SELECT *,`P`.`ifDescr` AS `interface` $sql"; +system("echo '$sql' >> /tmp/test"); foreach (dbFetchRows($sql, $param) as $entry) { if (!$ignore) { @@ -70,7 +79,7 @@ foreach (dbFetchRows($sql, $param) as $entry) { $response[] = array('mac_address'=>formatMac($entry['mac_address']), 'ipv4_address'=>$entry['ipv4_address'], 'hostname'=>generate_device_link($entry), - 'interface'=>generate_port_link($entry, makeshortif(fixifname(ifLabel($entry)['label']))) . ' ' . $error_img, + 'interface'=>generate_port_link($entry, makeshortif(fixifname(ifLabel($entry['label'])))) . ' ' . $error_img, 'remote_device'=>$arp_name, 'remote_interface'=>$arp_if); } From fba1e6933af8e026010a3c320b55102391066920 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 7 Jul 2015 23:28:00 +0100 Subject: [PATCH 274/308] removed debug --- html/includes/table/arp-search.inc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/html/includes/table/arp-search.inc.php b/html/includes/table/arp-search.inc.php index 937553b42..dd5c6225e 100644 --- a/html/includes/table/arp-search.inc.php +++ b/html/includes/table/arp-search.inc.php @@ -49,7 +49,6 @@ if ($rowCount != -1) { $sql = "SELECT *,`P`.`ifDescr` AS `interface` $sql"; -system("echo '$sql' >> /tmp/test"); foreach (dbFetchRows($sql, $param) as $entry) { if (!$ignore) { From 9a43454700d9c38591a056b0403ba13b87aa00ca Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 7 Jul 2015 23:34:56 +0100 Subject: [PATCH 275/308] Fixed mac user perm queries --- html/pages/search/mac.inc.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/html/pages/search/mac.inc.php b/html/pages/search/mac.inc.php index 4306a412d..c040a1e16 100644 --- a/html/pages/search/mac.inc.php +++ b/html/pages/search/mac.inc.php @@ -26,7 +26,16 @@ var grid = $("#mac-search").bootgrid({ "