mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-12 16:06:25 +02:00
Merge branch 'master' of github.com:laf/librenms into smokeping
This commit is contained in:
@@ -34,6 +34,10 @@ Contributors to LibreNMS:
|
||||
- Steve Calvário <calvario.steve@gmail.com> (Calvario)
|
||||
- Christian Marg <marg@rz.tu-clausthal.de> (einhirn)
|
||||
- Louis Rossouw <lrossouw@gmail.com> (spinza)
|
||||
- Clint Armstrong <clint@clintarmstrong.net> (clinta)
|
||||
- Tony Ditchfield <tony.ditchfield@gmail.com> (arnoldthebat)
|
||||
- Travis Hegner <travis.hegner@gmail.com> (travishegner)
|
||||
- Will Jones <email@willjones.eu> (willjones)
|
||||
|
||||
[1]: http://observium.org/ "Observium web site"
|
||||
|
||||
|
||||
@@ -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 ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,5 +58,13 @@ if ($options['f'] === 'perf_times') {
|
||||
if ($options['f'] === 'callback') {
|
||||
require_once "callback.php";
|
||||
}
|
||||
if ($options['f'] === 'device_perf') {
|
||||
if (is_numeric($config['device_perf_purge'])) {
|
||||
if (dbDelete('device_perf', "timestamp < UNIX_TIMESTAMP(DATE_SUB(NOW(),INTERVAL ? DAY))", array($config['device_perf_purge'])) ) {
|
||||
echo 'Device performance times cleared for entries over ' . $config['device_perf_purge'] . " days\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -12,3 +12,4 @@ php daily.php -f eventlog
|
||||
php daily.php -f authlog
|
||||
php daily.php -f perf_times
|
||||
php daily.php -f callback
|
||||
php daily.php -f device_perf
|
||||
|
||||
@@ -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.
|
||||
@@ -502,3 +504,19 @@ Entity: `%macros.sensor`
|
||||
Description: Only select sensors that aren't ignored.
|
||||
|
||||
Source: `(%sensors.sensor_alert = 1)`
|
||||
|
||||
## <a name="macros-packetloss">Packet Loss</a> (Boolean)
|
||||
|
||||
Entity: `(%macros.packet_loss_5m)`
|
||||
|
||||
Description: Packet loss % value for the device within the last 5 minutes.
|
||||
|
||||
Example: `%macros.packet_loss_5m` > 50
|
||||
|
||||
Entity: `(%macros.packet_loss_15m)`
|
||||
|
||||
Description: Packet loss % value for the device within the last 15 minutes.
|
||||
|
||||
Example: `%macros.packet_loss_15m` > 50
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
# 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
|
||||
- ntp
|
||||
- ircd
|
||||
@@ -1,3 +1,16 @@
|
||||
### July 2015
|
||||
|
||||
#### Bug fixes
|
||||
- Fixed API not functioning. (PR1367)
|
||||
- Fixed API not storing alert rule names (PR1372)
|
||||
- Fixed datetimepicker use (PR1376)
|
||||
- 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
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -404,6 +406,7 @@ $config['syslog_purge'] = 30;
|
||||
$config['eventlog_purge'] = 30;
|
||||
$config['authlog_purge'] = 30;
|
||||
$config['perf_times_purge'] = 30;
|
||||
$config['device_perf_purge'] = 30;
|
||||
```
|
||||
This option will ensure data within LibreNMS over 1 month old is automatically purged. You can alter these individually,
|
||||
values are in days.
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 541 B |
Binary file not shown.
|
After Width: | Height: | Size: 537 B |
@@ -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 {
|
||||
|
||||
@@ -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",
|
||||
@@ -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",
|
||||
@@ -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]",
|
||||
@@ -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);
|
||||
|
||||
@@ -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 '<img src="graph.php?' . implode('&',$urlargs).'" border="0" />';
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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")) {
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -138,7 +138,6 @@ for ($x=1;$x<32;$x++) {
|
||||
<button type="submit" class="btn btn-success" name="Submit" value="Save" /><i class="icon-ok icon-white"></i> <strong>Save Properties</strong></button>
|
||||
</form>
|
||||
|
||||
<form class="form-horizontal" role="form">
|
||||
<h3>Billed Ports</h3>
|
||||
<div class="form-group">
|
||||
<?php
|
||||
@@ -164,7 +163,7 @@ if (is_array($ports))
|
||||
$portalias = (empty($port['ifAlias']) ? "" : " - ".$port['ifAlias']."");
|
||||
$devicebtn = str_replace("\">".$port['hostname'], "\" style=\"color: #000;\"><i class=\"glyphicon glyphicon-asterisk\"></i> ".$port['hostname'], $devicebtn);
|
||||
$portbtn = str_replace("\">".strtolower($port['ifName']), "\" style=\"color: #000;\"><i class=\"glyphicon glyphicon-random\"></i> ".$port['ifName']."".$portalias, $portbtn);
|
||||
echo(" <form action=\"\" method=\"post\" name=\"delete".$port['port_id']."\" style=\"display: none;\">\n");
|
||||
echo(" <form action=\"\" class=\"form-inline\" method=\"post\" name=\"delete".$port['port_id']."\" style=\"display: none;\">\n");
|
||||
echo(" <input type=\"hidden\" name=\"action\" value=\"delete_bill_port\" />\n");
|
||||
echo(" <input type=\"hidden\" name=\"port_id\" value=\"".$port['port_id']."\" />\n");
|
||||
echo(" </form>\n");
|
||||
@@ -189,7 +188,6 @@ if (is_array($ports))
|
||||
?>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
<form action="" method="post" class="form-horizontal" role="form">
|
||||
<input type="hidden" name="action" value="add_bill_port" />
|
||||
<input type="hidden" name="bill_id" value="<?php echo $bill_id; ?>" />
|
||||
|
||||
@@ -355,6 +355,13 @@ if (device_permitted($vars['device']) || $check_device == $vars['device'])
|
||||
</li>');
|
||||
}
|
||||
|
||||
echo('<li class="' . $select['performance'] . '">
|
||||
<a href="'.generate_device_url($device, array('tab' => 'performance')).'">
|
||||
<img src="images/16/chart_line.png" align="absmiddle" border="0" /> Performance
|
||||
</a>
|
||||
</li>');
|
||||
|
||||
|
||||
echo ('<li style="float: right;"><a href="https://' . $device['hostname'] . '"><img src="images/16/http.png" alt="https" title="Launch browser to https://' . $device['hostname'] . '" border="0" width="16" height="16" target="_blank"></a></li>
|
||||
<li style="float: right;"><a href="ssh://' . $device['hostname'] . '"><img src="images/16/ssh.png" alt="ssh" title="SSH to ' . $device['hostname'] . '" border="0" width="16" height="16"></a></li>
|
||||
<li style="float: right;"><a href="telnet://' . $device['hostname'] . '"><img src="images/16/telnet.png" alt="telnet" title="Telnet to ' . $device['hostname'] . '" border="0" width="16" height="16"></a></li>');
|
||||
|
||||
@@ -26,6 +26,8 @@ echo('
|
||||
<div class="col-md-6">
|
||||
');
|
||||
include("includes/dev-overview-data.inc.php");
|
||||
Plugins::call('device_overview_container',array($device));
|
||||
|
||||
include("overview/ports.inc.php");
|
||||
echo('
|
||||
</div>
|
||||
@@ -48,6 +50,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");
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
$graph_type = "sensor_load";
|
||||
$sensor_class = "load";
|
||||
$sensor_unit = "%";
|
||||
$sensor_type = "Load";
|
||||
|
||||
include('pages/device/overview/generic/sensor.inc.php');
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
$graph_type = "sensor_state";
|
||||
$sensor_class = "state";
|
||||
$sensor_unit = "#";
|
||||
$sensor_type = "State";
|
||||
|
||||
include('pages/device/overview/generic/sensor.inc.php');
|
||||
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* LibreNMS
|
||||
*
|
||||
* Copyright (c) 2015 Søren Friis Rosiak <sorenrosiak@gmail.com>
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
|
||||
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk/fa>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
if(!isset($vars['section'])) { $vars['section'] = "performance"; }
|
||||
|
||||
if (is_admin() === true || is_read() === true) {
|
||||
$query = "SELECT DATE_FORMAT(timestamp, '".$config['alert_graph_date_format']."') Date, xmt,rcv,loss,min,max,avg FROM `device_perf` WHERE `device_id` = ?";
|
||||
$param = array($device['device_id']);
|
||||
} else {
|
||||
$query = "SELECT DATE_FORMAT(timestamp, '".$config['alert_graph_date_format']."') Date, xmt,rcv,loss,min,max,avg FROM `device_perf`,`devices_perms` WHERE `device_id` = ? AND alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = " . $_SESSION['user_id'];
|
||||
$param = array($device['device_id']);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<script src="js/vis.min.js"></script>
|
||||
<div id="visualization"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
var container = document.getElementById('visualization');
|
||||
<?php
|
||||
$groups = array();
|
||||
$max_val = 0;
|
||||
|
||||
foreach(dbFetchRows($query, $param) as $return_value) {
|
||||
$date = $return_value['Date'];
|
||||
$loss = $return_value['loss'];
|
||||
$min = $return_value['min'];
|
||||
$max = $return_value['max'];
|
||||
$avg = $return_value['avg'];
|
||||
|
||||
if ($max > $max_val) {
|
||||
$max_val = $max;
|
||||
}
|
||||
|
||||
$data[] = array('x' => $date,'y' => $loss,'group' => 0);
|
||||
$data[] = array('x' => $date,'y' => $min,'group' => 1);
|
||||
$data[] = array('x' => $date,'y' => $max,'group' => 2);
|
||||
$data[] = array('x' => $date,'y' => $avg,'group' => 3);
|
||||
}
|
||||
|
||||
$graph_data = _json_encode($data);
|
||||
?>
|
||||
var names = ['Loss','Min latency','Max latency','Avg latency'];
|
||||
var groups = new vis.DataSet();
|
||||
groups.add({
|
||||
id: 0,
|
||||
content: names[0],
|
||||
options: {
|
||||
drawPoints: {
|
||||
style: 'circle'
|
||||
},
|
||||
shaded: {
|
||||
orientation: 'bottom'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
groups.add({
|
||||
id: 1,
|
||||
content: names[1],
|
||||
options: {
|
||||
yAxisOrientation: 'right',
|
||||
drawPoints: {
|
||||
style: 'circle'
|
||||
},
|
||||
shaded: {
|
||||
orientation: 'bottom'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
groups.add({
|
||||
id: 2,
|
||||
content: names[2],
|
||||
options: {
|
||||
yAxisOrientation: 'right',
|
||||
drawPoints: {
|
||||
style: 'circle'
|
||||
},
|
||||
shaded: {
|
||||
orientation: 'bottom'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
groups.add({
|
||||
id: 3,
|
||||
content: names[3],
|
||||
options: {
|
||||
yAxisOrientation: 'right',
|
||||
drawPoints: {
|
||||
style: 'circle'
|
||||
},
|
||||
shaded: {
|
||||
orientation: 'bottom'
|
||||
}
|
||||
}
|
||||
});
|
||||
<?php
|
||||
|
||||
?>
|
||||
|
||||
var items =
|
||||
<?php
|
||||
echo $graph_data; ?>
|
||||
;
|
||||
var dataset = new vis.DataSet(items);
|
||||
var options = {
|
||||
barChart: {width:50, align:'right',handleOverlap:'sideBySide'}, // align: left, center, right
|
||||
drawPoints: false,
|
||||
legend: {left:{position:"bottom-left"}},
|
||||
dataAxis: {
|
||||
icons:true,
|
||||
showMajorLabels: true,
|
||||
showMinorLabels: true,
|
||||
customRange: {
|
||||
left: {
|
||||
min: 0, max: 100
|
||||
},
|
||||
right: {
|
||||
min: 0, max: <?php echo $max_val; ?>
|
||||
}
|
||||
}
|
||||
},
|
||||
zoomMin: 86400, //24hrs
|
||||
zoomMax: <?php
|
||||
$first_date = reset($data);
|
||||
$last_date = end($data);
|
||||
$milisec_diff = abs(strtotime($first_date[x]) - strtotime($last_date[x])) * 1000;
|
||||
echo $milisec_diff;
|
||||
?>,
|
||||
orientation:'top'
|
||||
};
|
||||
var graph2d = new vis.Graph2d(container, items, groups, options);
|
||||
|
||||
</script>
|
||||
|
||||
@@ -118,13 +118,11 @@ 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'));
|
||||
tsto = tsto.getTime() / 1000;
|
||||
tsfrom = tsfrom.getTime() / 1000;
|
||||
var tsto = moment(frmdata.dtpickerto.value).unix();
|
||||
var tsfrom = moment(frmdata.dtpickerfrom.value).unix();
|
||||
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
|
||||
frmdata.action = frmdata.selfaction.value;
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
@@ -135,16 +133,30 @@ if (!$auth)
|
||||
echo('
|
||||
<div class="form-group">
|
||||
<label for="dtpickerfrom">From</label>
|
||||
<input type="text" class="form-control" id="dtpickerfrom" maxlength="16" value="' . date($config['dateformat']['byminute'], $graph_array['from']) . '" data-date-format="YYYY-MM-DD HH:mm">
|
||||
<input type="text" class="form-control" id="dtpickerfrom" maxlength="16" value="' . $graph_array['from'] . '" data-date-format="YYYY-MM-DD HH:mm">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="dtpickerto">To</label>
|
||||
<input type="text" class="form-control" id="dtpickerto" maxlength=16 value="' . date($config['dateformat']['byminute'], $graph_array['to']) . '" data-date-format="YYYY-MM-DD HH:mm">
|
||||
<input type="text" class="form-control" id="dtpickerto" maxlength=16 value="' . $graph_array['to'] . '" data-date-format="YYYY-MM-DD HH:mm">
|
||||
</div>
|
||||
<input type="submit" class="btn btn-default" id="submit" value="Update" onclick="javascript:submitCustomRange(this.form);">
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var strfrom = new Date($("#dtpickerfrom").val()*1000);
|
||||
$("#dtpickerfrom").val(strfrom.getFullYear()+"-"+
|
||||
("0"+(strfrom.getMonth()+1)).slice(-2)+"-"+
|
||||
("0"+strfrom.getDate()).slice(-2)+" "+
|
||||
("0"+strfrom.getHours()).slice(-2)+":"+
|
||||
("0"+strfrom.getMinutes()).slice(-2)
|
||||
);
|
||||
var strto = new Date($("#dtpickerto").val()*1000);
|
||||
$("#dtpickerto").val(strto.getFullYear()+"-"+
|
||||
("0"+(strto.getMonth()+1)).slice(-2)+"-"+
|
||||
("0"+strto.getDate()).slice(-2)+" "+
|
||||
("0"+strto.getHours()).slice(-2)+":"+
|
||||
("0"+strto.getMinutes()).slice(-2)
|
||||
);
|
||||
$("#dtpickerfrom").datetimepicker({useCurrent: true, sideBySide: true, useStrict: false});
|
||||
$("#dtpickerto").datetimepicker({useCurrent: true, sideBySide: true, useStrict: false});
|
||||
});
|
||||
|
||||
@@ -4,6 +4,14 @@ class Test {
|
||||
public function menu() {
|
||||
echo('<li><a href="plugin/p='.get_class().'">'.get_class().'</a></li>');
|
||||
}
|
||||
|
||||
/*
|
||||
public function device_overview_container($device) {
|
||||
echo('<div class="container-fluid"><div class="row"> <div class="col-md-12"> <div class="panel panel-default panel-condensed"> <div class="panel-heading"><strong>'.get_class().' Plugin </strong> </div>');
|
||||
echo(' Example plugin in "Device - Overview" tab <br>');
|
||||
echo('</div></div></div></div>');
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -43,6 +43,8 @@ $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['fping_options']['millisec'] = 20;
|
||||
$config['fping6'] = "/usr/bin/fping6";
|
||||
$config['snmpwalk'] = "/usr/bin/snmpwalk";
|
||||
$config['snmpget'] = "/usr/bin/snmpget";
|
||||
@@ -572,6 +574,8 @@ $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;
|
||||
$config['modules_compat']['rfc1628']['huaweiups'] = 1;
|
||||
|
||||
# Enable daily updates
|
||||
$config['update'] = 1;
|
||||
@@ -581,6 +585,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
|
||||
|
||||
@@ -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";
|
||||
@@ -1156,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']))
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
// RFC1628 UPS
|
||||
if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modules_compat']['rfc1628'][$device['os']]) {
|
||||
echo("RFC1628 ");
|
||||
|
||||
$oids = snmp_walk($device, "1.3.6.1.2.1.33.1.4.4.1.5", "-Osqn", "UPS-MIB");
|
||||
if ($debug) { echo($oids."\n"); }
|
||||
$oids = trim($oids);
|
||||
foreach (explode("\n", $oids) as $data) {
|
||||
$data = trim($data);
|
||||
if ($data) {
|
||||
list($oid,$descr) = explode(" ", $data,2);
|
||||
$split_oid = explode('.',$oid);
|
||||
$current_id = $split_oid[count($split_oid)-1];
|
||||
$current_oid = "1.3.6.1.2.1.33.1.4.4.1.5.$current_id";
|
||||
$current = snmp_get($device, $current_oid, "-O vq");
|
||||
$descr = "Percentage load" . (count(explode("\n",$oids)) == 1 ? '' : ' ' . ($current_id+1));
|
||||
$type = "rfc1628";
|
||||
$index = 500+$current_id;
|
||||
|
||||
discover_sensor($valid['sensor'], 'load', $device, $current_oid, $index, $type, $descr, '1', '1', NULL, NULL, NULL, NULL, $current);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
if (!$os)
|
||||
{
|
||||
if (preg_match("/^Linux GSE200M/", $sysDescr)) {
|
||||
if (strstr(snmp_get($device, "UPS-MIB::upsIdentManufacturer.0", "-Oqv", ""), "HUAWEI")){
|
||||
$os = "huaweiups";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -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
|
||||
|
||||
@@ -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"; }
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
<?php
|
||||
|
||||
if (!$os) {
|
||||
if (preg_match("/^Pacific Broadband Networks/", $sysDescr)) {
|
||||
$os = "pbn";
|
||||
}
|
||||
if (strstr($sysObjectId, ".1.3.6.1.4.1.11606")) { $os = "pbn"; }
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
if (!$os) {
|
||||
if (strstr($sysObjectId, ".1.3.6.1.4.1.2468.1.2.1")) { $os = "webpower"; }
|
||||
}
|
||||
?>
|
||||
+56
-15
@@ -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'];
|
||||
@@ -495,25 +499,23 @@ 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'];
|
||||
}
|
||||
if(is_numeric($config['fping_options']['millisec']) || $config['fping_options']['millisec'] > 0) {
|
||||
$fping_params .= ' -p ' . $config['fping_options']['millisec'];
|
||||
}
|
||||
$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'] == 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 +1271,42 @@ function ip_exists($ip) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function fping($host,$params) {
|
||||
|
||||
global $config;
|
||||
|
||||
$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 = '';
|
||||
|
||||
if (is_resource($process)) {
|
||||
|
||||
fclose($pipes[0]);
|
||||
|
||||
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);
|
||||
$loss = preg_replace("/%/","",$loss_tmp[0]);
|
||||
list($xmt,$rcv,$loss) = preg_split("/\//", $loss);
|
||||
list($min,$avg,$max) = 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -132,24 +132,35 @@ 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();
|
||||
$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)
|
||||
@@ -157,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")
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS WebPower OS information module
|
||||
*
|
||||
* Copyright (c) 2015 Mike Rostermund <mike@kollegienet.dk>
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
$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];
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
$check = shell_exec($config['nagios_plugins'] . "/check_ircd -H ".$service['hostname']." ".$service['service_param']);
|
||||
|
||||
list($check, $time) = split("\|", $check);
|
||||
|
||||
if (strstr($check, "IRCD ok")) {
|
||||
$status = '1';
|
||||
} else {
|
||||
$status = '0';
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -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';
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
$check = shell_exec($config['nagios_plugins'] . "/check_ntp -H ".$service['hostname']." ".$service['service_param']);
|
||||
|
||||
list($check, $time) = split("\|", $check);
|
||||
|
||||
if(strstr($check, "NTP OK")) {
|
||||
$status = '1';
|
||||
} else {
|
||||
$status = '0';
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$check = shell_exec($config['nagios_plugins'] . "/check_ssh -H ".$service['hostname']);
|
||||
$check = shell_exec($config['nagios_plugins'] . "/check_ssh -H ".$service['hostname']." ".$service['service_param']);
|
||||
|
||||
list($check, $time) = split("\|", $check);
|
||||
|
||||
|
||||
+4
-1
@@ -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"
|
||||
|
||||
@@ -0,0 +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;
|
||||
Reference in New Issue
Block a user