Merge branch 'master' of github:/juhovan/librenms into issue-2000

This commit is contained in:
Juho Vanhanen
2015-10-02 23:16:37 +03:00
81 changed files with 755 additions and 562 deletions
+2
View File
@@ -56,5 +56,7 @@ Contributors to LibreNMS:
- Christophe Martinet <martinet.christophe@gmail.com> (chrisgfx)
- Nils Steinger <librenms@voidptr.de> (n-st)
- Mark Nagel <mnagel@willingminds.com> (ciscoqid)
- Sławomir Paszkiewicz <paszczus@pld-linux.org> (paszczus)
- Frederik Mogensen <frederik@server-1.dk> (mogensen)
[1]: http://observium.org/ "Observium web site"
+1 -1
View File
@@ -66,7 +66,7 @@ __Conditions__ can be any of:
__Values__ can be Entities or any single-quoted data.
__Glues__ can be either `&&` for `AND` or `||` for `OR`.
__Note__: The difference between `Equals` and `Matches` (and it's negation) is that `Equals` does a strict comparison and `Matches` allows the usage of the placeholder `@`. The placeholder `@` is comparable with `.*` in RegExp.
__Note__: The difference between `Equals` and `Matches` (and it's negation) is that `Equals` does a strict comparison and `Matches` allows the usage of RegExp.
Arithmetics are allowed as well.
## <a name="rules-examples">Examples</a>
+2 -2
View File
@@ -8,12 +8,12 @@ Patterns work in the same was as Entities within the alerting system, the format
as __tablename.columnname__. If you are ensure of what the entity is you want then have a browse around inside MySQL using `show tables` and `desc <tablename>`.
As a working example and a common question, let's assume you want to group devices by hostname. If you hostname format is dcX.[devicetype].example.com. You would use the pattern
devices.hostname. Select the condition which in this case would Like and then enter dc1.@.example.com. This would then match dc1.sw01.example.com, dc1.rtr01.example.com but not
devices.hostname. Select the condition which in this case would Like and then enter `dc1\..*\.example.com`. This would then match dc1.sw01.example.com, dc1.rtr01.example.com but not
dc2.sw01.example.com.
#### Wildcards
As used in the example above, wildcards are represented by the @ symbol. I.e @.example.com would match any hostnames under example.com.
As with alerts, the `Like` operation allows RegExp.
A list of common entities is maintained in our [Alerting docs](http://docs.librenms.org/Extensions/Alerting/#entities).
+19 -2
View File
@@ -5,7 +5,11 @@ These machines can be in a different physical location and therefore minimize ne
Devices can also be groupped together into a `poller_group` to pin these devices to a single or a group of designated pollers.
All pollers need to share their RRD-folder, for example via NFS or a combination of NFS and rrdcached.
~~All pollers need to share their RRD-folder, for example via NFS or a combination of NFS and rrdcached.~~
> This is no longer a strict requirement with the use of rrdtool 1.5 and above. If you are NOT running 1.5 then you will still
need to share the RRD-folder.
It is also required that all pollers can access the central memcached to communicate with eachother.
In order to enable distributed polling, set `$config['distributed_poller'] = true` and your memcached details into `$config['distributed_poller_memcached_host']` and `$config['distributed_poller_memcached_port']`.
@@ -49,7 +53,14 @@ The pollers, web and API layers should all be able to access the database server
####RRD Storage
Central storage should be provided so all RRD files can be read from and written to in one location. As suggested above, it's recommended that RRD Cached is configured and used.
For this example, we are running RRDCached to allow all pollers and web/api servers to read/write to the rrd iles with the rrd directory also exported by NFS for simple access and maintenance.
For this example, we are running RRDCached to allow all pollers and web/api servers to read/write to the rrd iles ~~with the rrd directory also exported by NFS for simple access and maintenance.~~
Sharing rrd files via something like NFS is no longer required if you run rrdtool 1.5 or greater. If you don't - please share your rrd folder as before. If you run rrdtool
1.5 or greater then add this config to your pollers:
```php
$config['rrdtool_version'] = 1.5;
```
####Memcache
Memcache is required for the distributed pollers to be able to register to a central location and record what devices are polled. Memcache can run from any of the kit so long as it is accessable by all pollers.
@@ -88,4 +99,10 @@ $config['rrd_dir'] = "/opt/librenms/rrd";
$config['rrdcached_dir'] = "";
```
For rrdtool 1.5 or greater then you can enable support for rrdcached to create the rrd files:
```php
$config['rrdtool_version'] = 1.5;
```
$config['rrdcached_dir'] Is only needed if you are using tcp connections for rrd cached and needs only to be set if you want to store rrd files within a sub directory of your rrdcached base directory.
+16
View File
@@ -0,0 +1,16 @@
# Memcached
LibreNMS can store SQL results in memcached to achieve performance advantages of in-memory value storage and removing work load for frequent queries off the MySQL backend.
To enable memcached in your install you need to have `memcached` installed and the PHP extension `php5-memcached` or `php-memcached` and add the following lines to your `config.php`:
```php
$config['memcached']['enable'] = true;
$config['memcached']['host'] = "localhost";
$config['memcached']['port'] = 11211;
```
By default values are kept for 4 Minutes inside the memcached, you can adjust this retention time by modifying the `$config['memcached']['ttl']` value to any desired amount of seconds.
It's strongly discouraged to set this above `300` (5 Minutes) to avoid interferences with the polling, discovery and alerting processes.
If you use the Distributed Poller, you can point this to the same memcached instance. However a local memcached will perform better in any case.
+8 -1
View File
@@ -2,6 +2,13 @@
This document will explain how to setup RRDCached for LibreNMS.
> If you are using rrdtool / rrdcached version 1.5 or above then this now supports creating rrd files over rrdcached. To
enable this set the following config:
```php
$config['rrdtool_version'] = 1.5;
```
### RRDCached installation CentOS 6
This example is based on a fresh LibreNMS install, on a minimimal CentOS 6 installation.
In this example, we'll use the Repoforge repository.
@@ -34,7 +41,7 @@ service rrdcached start
```
- Edit /opt/librenms/config.php to include:
```ssh
```php
$config['rrdcached'] = "unix:/var/run/rrdcached/rrdcached.sock";
```
### RRDCached installation CentOS 7
+1 -1
View File
@@ -46,7 +46,7 @@ $config['rrdtool'] = "/usr/bin/rrdtool";
```php
$config['fping'] = "/usr/bin/fping";
$config['fping6'] = "/usr/bin/fping6";
$config['fping6'] = "fping6";
$config['fping_options']['retries'] = 3;
$config['fping_options']['timeout'] = 500;
$config['fping_options']['count'] = 3;
+1 -1
View File
@@ -28,7 +28,7 @@ if (!$_SESSION['authenticated']) {
$type = mres($_POST['type']);
if ($type == 'placeholder') {
$output = 'Please add a Widget to get started';
$output = "<span style='text-align:left;'><br><h3>Click on Edit-Dashboard to add Widgets</h3><br><h4><strong>Remember:</strong> You can only move & rezise widgets when you're in <strong>Edit-Mode</strong>.</h4><span>";
$status = 'ok';
$title = 'Placeholder';
}
+17 -34
View File
@@ -72,22 +72,16 @@ if (isset($_GET['term'],$_GET['device_id'])) {
$_GET['device_id'] = mres($_GET['device_id']);
if (strstr($_GET['term'], '.')) {
$term = explode('.', $_GET['term']);
if ($config['memcached']['enable']) {
$chk = $memcache->get('rule-suggest_'.$term[0]);
}
if (!(sizeof($chk) > 0) || $chk === false) {
if ($term[0] == 'macros') {
foreach ($config['alert']['macros']['rule'] as $macro => $v) {
$chk[] = 'macros.'.$macro;
}
if ($term[0] == 'macros') {
foreach ($config['alert']['macros']['rule'] as $macro => $v) {
$chk[] = 'macros.'.$macro;
}
else {
$tmp = dbFetchRows('SHOW COLUMNS FROM '.$term[0]);
foreach ($tmp as $tst) {
if (isset($tst['Field'])) {
$chk[] = $term[0].'.'.$tst['Field'];
}
}
else {
$tmp = dbFetchRows('SHOW COLUMNS FROM '.$term[0]);
foreach ($tmp as $tst) {
if (isset($tst['Field'])) {
$chk[] = $term[0].'.'.$tst['Field'];
}
}
}
@@ -95,29 +89,18 @@ if (isset($_GET['term'],$_GET['device_id'])) {
$current = true;
}
else {
if ($config['memcached']['enable']) {
$chk = $memcache->get('rule-suggest-toplvl');
$tmp = dbFetchRows("SELECT TABLE_NAME FROM information_schema.COLUMNS WHERE COLUMN_NAME = 'device_id'");
foreach ($tmp as $tst) {
$chk[] = $tst['TABLE_NAME'].'.';
}
if (!(sizeof($chk) > 0) || $chk === false) {
$tmp = dbFetchRows("SELECT TABLE_NAME FROM information_schema.COLUMNS WHERE COLUMN_NAME = 'device_id'");
foreach ($tmp as $tst) {
$chk[] = $tst['TABLE_NAME'].'.';
}
$chk[] = 'macros.';
$chk[] = 'bills.';
}
$chk[] = 'macros.';
$chk[] = 'bills.';
}
if (sizeof($chk) > 0) {
if ($config['memcached']['enable']) {
$memcache->set('rule-suggest-'.$oterm, $chk, 86400);
// Cache for 24h
}
$obj = levsort($_GET['term'], $chk);
$obj = array_chunk($obj, 20, true);
$obj = $obj[0];
$obj = levsort($_GET['term'], $chk);
$obj = array_chunk($obj, 20, true);
$obj = $obj[0];
$flds = array();
if ($current === true) {
foreach ($obj as $fld) {
+11
View File
@@ -318,6 +318,17 @@ if (isset($_REQUEST['search'])) {
$json = json_encode($device);
die($json);
}
else if ($_REQUEST['type'] == 'bill') {
// Device search
if (is_admin() === true || is_read() === true) {
$results = dbFetchRows("SELECT `bills`.bill_id, `bills`.bill_name FROM `bills` WHERE `bill_name` LIKE '%".$search."%' OR `bill_notes` LIKE '%".$search."%' LIMIT 8");
}
else {
$results = dbFetchRows("SELECT `bills`.bill_id, `bills`.bill_name FROM `bills` INNER JOIN `bill_perms` ON `bills`.bill_id = `bill_perms`.bill_id WHERE `bill_perms`.user_id = ? AND (`bill_name` LIKE '%".$search."%' OR `bill_notes` LIKE '%".$search."%') LIMIT 8", array($_SESSION['user_id']));
}
$json = json_encode($results);
die($json);
}//end if
}//end if
}//end if
-1
View File
@@ -683,7 +683,6 @@ table.simple {
padding: 10px;
}
table { border-collapse: collapse; margin: 0px; background-color:#ffffff }
form { margin: 0px; padding: 0px; }
hr { border: 0px; height: 1px; background-color: #ccc; color: #ccc; }
p { margin: 0px; padding: 0px; }
+7 -7
View File
@@ -3,7 +3,7 @@
function authenticate($username, $password) {
$encrypted_old = md5($password);
$row = dbFetchRow('SELECT username,password FROM `users` WHERE `username`= ?', array($username));
$row = dbFetchRow('SELECT username,password FROM `users` WHERE `username`= ?', array($username), true);
if ($row['username'] && $row['username'] == $username) {
// Migrate from old, unhashed password
if ($row['password'] == $encrypted_old) {
@@ -36,7 +36,7 @@ function authenticate($username, $password) {
function reauthenticate($sess_id, $token) {
list($uname,$hash) = explode('|', $token);
$session = dbFetchRow("SELECT * FROM `session` WHERE `session_username` = '$uname' AND session_value='$sess_id'");
$session = dbFetchRow("SELECT * FROM `session` WHERE `session_username` = '$uname' AND session_value='$sess_id'", array(), true);
$hasher = new PasswordHash(8, false);
if ($hasher->CheckPassword($uname.$session['session_token'], $hash)) {
$_SESSION['username'] = $uname;
@@ -59,7 +59,7 @@ function passwordscanchange($username='') {
return 1;
}
else {
return dbFetchCell('SELECT can_modify_passwd FROM users WHERE username = ?', array($username));
return dbFetchCell('SELECT can_modify_passwd FROM users WHERE username = ?', array($username), true);
}
}//end passwordscanchange()
@@ -114,20 +114,20 @@ function adduser($username, $password, $level, $email='', $realname='', $can_mod
function user_exists($username) {
$return = @dbFetchCell('SELECT COUNT(*) FROM users WHERE username = ?', array($username));
$return = @dbFetchCell('SELECT COUNT(*) FROM users WHERE username = ?', array($username), true);
return $return;
}//end user_exists()
function get_userlevel($username) {
return dbFetchCell('SELECT `level` FROM `users` WHERE `username` = ?', array($username));
return dbFetchCell('SELECT `level` FROM `users` WHERE `username` = ?', array($username), true);
}//end get_userlevel()
function get_userid($username) {
return dbFetchCell('SELECT `user_id` FROM `users` WHERE `username` = ?', array($username));
return dbFetchCell('SELECT `user_id` FROM `users` WHERE `username` = ?', array($username), true);
}//end get_userid()
@@ -158,7 +158,7 @@ function can_update_users() {
function get_user($user_id) {
return dbFetchRow('SELECT * FROM `users` WHERE `user_id` = ?', array($user_id));
return dbFetchRow('SELECT * FROM `users` WHERE `user_id` = ?', array($user_id), true);
}//end get_user()
@@ -66,6 +66,8 @@ if( defined('show_settings') || empty($widget_settings) ) {
<option value="peering"'.($widget_settings['graph_type'] == 'peering' ? ' selected' : '').'>&nbsp;&nbsp;&nbsp;Peering</option>
<option value="core"'.($widget_settings['graph_type'] == 'core' ? ' selected' : '').'>&nbsp;&nbsp;&nbsp;Core</option>
<option value="custom"'.($widget_settings['graph_type'] == 'custom' ? ' selected' : '').'>&nbsp;&nbsp;&nbsp;Custom Descr</option>
<option disabled></option>
<option value="bill_bits"'.($widget_settings['graph_type'] == 'bill_bits' ? ' selected' : '').'>Bill</option>
</select>
</div>
<div class="col-sm-offset-10 col-sm-2">
@@ -140,6 +142,14 @@ if( defined('show_settings') || empty($widget_settings) ) {
$common_output[] = ' </select>
</div>
</div>
<div class="form-group input_'.$unique_id.'" id="input_'.$unique_id.'_bill">
<div class="col-sm-2">
<label for="graph_bill" class="control-label">Bill: </label>
</div>
<div class="col-sm-10">
<input type="text" class="form-control input_'.$unique_id.'_bill" name="graph_bill" placeholder="Bill" value="'.htmlspecialchars($widget_settings['graph_bill']).'">
</div>
</div>
<div class="form-group">
<div class="col-sm-2">
<button type="submit" class="btn btn-default">Set</button>
@@ -301,6 +311,40 @@ function '.$unique_id.'() {
}
});
var '.$unique_id.'_bill = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace("munin"),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: "ajax_search.php?search=%QUERY&type=bill",
filter: function (output) {
return $.map(output, function (item) {
return {
name: item.bill_name,
bill_id: item.bill_id,
};
});
},
wildcard: "%QUERY"
}
});
'.$unique_id.'_bill.initialize();
$(".input_'.$unique_id.'_bill").typeahead({
hint: true,
highlight: true,
minLength: 1,
classNames: {
menu: "typeahead-left"
}
},
{
source: '.$unique_id.'_bill.ttAdapter(),
async: false,
templates: {
header: "<h5><strong><i class=\'fa fa-money\'></i>&nbsp;Bill</strong></h5>",
suggestion: Handlebars.compile(\'<p><small><strong>{{name}}</strong></small></p>\')
}
});
switch_'.$unique_id.'($("#select_'.$unique_id.'").val());
}
function switch_'.$unique_id.'(data) {
+4 -3
View File
@@ -222,7 +222,7 @@ function generate_device_link($device, $text=null, $vars=array(), $start=0, $end
$url = generate_device_url($device, $vars);
// beginning of overlib box contains large hostname followed by hardware & OS details
$contents = '<div><span class=list-large>'.$device['hostname'].'</span>';
$contents = '<div><span class="list-large">'.$device['hostname'].'</span>';
if ($device['hardware']) {
$contents .= ' - '.$device['hardware'];
}
@@ -248,8 +248,8 @@ function generate_device_link($device, $text=null, $vars=array(), $start=0, $end
foreach ($graphs as $entry) {
$graph = $entry['graph'];
$graphhead = $entry['text'];
$contents .= '<div class=overlib-box>';
$contents .= '<span class=overlib-title>'.$graphhead.'</span><br />';
$contents .= '<div class="overlib-box">';
$contents .= '<span class="overlib-title">'.$graphhead.'</span><br />';
$contents .= generate_minigraph_image($device, $start, $end, $graph);
$contents .= generate_minigraph_image($device, $config['time']['week'], $end, $graph);
$contents .= '</div>';
@@ -279,6 +279,7 @@ function generate_device_link($device, $text=null, $vars=array(), $start=0, $end
function overlib_link($url, $text, $contents, $class) {
global $config;
$contents = "<div style=\'background-color: #FFFFFF;\'>".$contents.'</div>';
$contents = str_replace('"', "\'", $contents);
$output = '<a class="'.$class.'" href="'.$url.'"';
if ($config['web_mouseover'] === false) {
@@ -0,0 +1,20 @@
<?php
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/ciscowlc.rrd';
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'Number of APs';
$rrd_list[0]['ds'] = 'NUMAPS';
$unit_text = 'APs';
$units = '';
$total_units = '';
$colours = 'mixed';
$scale_min = '0';
$nototal = 1;
if ($rrd_list) {
include 'includes/graphs/generic_multi_line.inc.php';
}
@@ -0,0 +1,21 @@
<?php
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/ciscowlc.rrd';
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'Clients';
$rrd_list[0]['ds'] = 'NUMCLIENTS';
$unit_text = 'Clients';
$units = '';
$total_units = '';
$colours = 'mixed';
$scale_min = '0';
$nototal = 1;
if ($rrd_list) {
include 'includes/graphs/generic_multi_line.inc.php';
}
@@ -74,7 +74,7 @@ foreach ($rrd_list as $rrd) {
$stack = 'STACK';
}
$rrd_options .= ' AREA:inbits'.$i.'#'.$colour_in.":'".rrdtool_escape($rrd['descr'], 9)."In ':$stack";
$rrd_options .= ' AREA:inbits'.$i.'#'.$colour_in.":'".rrdtool_escape($rrd['descr'], 9)."In '$stack";
$rrd_options .= ' GPRINT:inbits'.$i.':LAST:%6.2lf%s';
$rrd_options .= ' GPRINT:inbits'.$i.':AVERAGE:%6.2lf%s';
$rrd_options .= ' GPRINT:inbits'.$i.':MAX:%6.2lf%s';
@@ -84,8 +84,8 @@ foreach ($rrd_list as $rrd) {
}
$rrd_options .= " COMMENT:'\\n'";
$rrd_optionsb .= ' AREA:outbits'.$i.'_neg#'.$colour_out."::$stack";
$rrd_options .= ' HRULE:999999999999999#'.$colour_out.":'".str_pad('', 10)."Out':";
$rrd_optionsb .= ' AREA:outbits'.$i.'_neg#'.$colour_out.":$stack";
$rrd_options .= ' HRULE:999999999999999#'.$colour_out.":'".str_pad('', 10)."Out'";
$rrd_options .= ' GPRINT:outbits'.$i.':LAST:%6.2lf%s';
$rrd_options .= ' GPRINT:outbits'.$i.':AVERAGE:%6.2lf%s';
$rrd_options .= ' GPRINT:outbits'.$i.':MAX:%6.2lf%s';
@@ -141,21 +141,21 @@ if (!$args['nototal']) {
$rrd_options .= " COMMENT:' \\n'";
$rrd_options .= " HRULE:999999999999999#FFFFFF:'".str_pad('Total', 10)."In ':";
$rrd_options .= " HRULE:999999999999999#FFFFFF:'".str_pad('Total', 10)."In '";
$rrd_options .= ' GPRINT:inbits:LAST:%6.2lf%s';
$rrd_options .= ' GPRINT:inbits:AVERAGE:%6.2lf%s';
$rrd_options .= ' GPRINT:inbits:MAX:%6.2lf%s';
$rrd_options .= " GPRINT:totin:%6.2lf%s$total_units";
$rrd_options .= " COMMENT:'\\n'";
$rrd_options .= " HRULE:999999999999990#FFFFFF:'".str_pad('', 10)."Out':";
$rrd_options .= " HRULE:999999999999990#FFFFFF:'".str_pad('', 10)."Out'";
$rrd_options .= ' GPRINT:outbits:LAST:%6.2lf%s';
$rrd_options .= ' GPRINT:outbits:AVERAGE:%6.2lf%s';
$rrd_options .= ' GPRINT:outbits:MAX:%6.2lf%s';
$rrd_options .= " GPRINT:totout:%6.2lf%s$total_units";
$rrd_options .= " COMMENT:'\\n'";
$rrd_options .= " HRULE:999999999999990#FFFFFF:'".str_pad('', 10)."Agg':";
$rrd_options .= " HRULE:999999999999990#FFFFFF:'".str_pad('', 10)."Agg'";
$rrd_options .= ' GPRINT:bits:LAST:%6.2lf%s';
$rrd_options .= ' GPRINT:bits:AVERAGE:%6.2lf%s';
$rrd_options .= ' GPRINT:bits:MAX:%6.2lf%s';
+1 -1
View File
@@ -51,7 +51,7 @@ else {
<ul class="dropdown-menu">
<li><a href="<?php echo(generate_url(array('page'=>'overview'))); ?>"><i class="fa fa-lightbulb-o fa-fw fa-lg"></i> Overview</a></li>
<li class="dropdown-submenu">
<a><i class="fa fa-exclamation-circle fa-fw fa-lg"> </i>Alerts</a>
<a><i class="fa fa-exclamation-circle fa-fw fa-lg"> </i> Alerts</a>
<ul class="dropdown-menu scrollable-menu">
<li><a href="<?php echo(generate_url(array('page'=>'alerts'))); ?>"><i class="fa fa-bell fa-fw fa-lg"></i> Notifications</a></li>
<li><a href="<?php echo(generate_url(array('page'=>'alert-log'))); ?>"><i class="fa fa-th-list fa-fw fa-lg"></i> Historical Log</a></li>
+1 -1
View File
@@ -42,7 +42,7 @@ if ($rowCount != -1) {
$sql = "SELECT D.device_id,D.hostname AS `hostname`, D.last_polled AS `last_polled`, `group_name`, D.last_polled_timetaken AS `last_polled_timetaken` $sql";
foreach (dbFetchRows($sql) as $device) {
foreach (dbFetchRows($sql,array(),true) as $device) {
if (empty($device['group_name'])) {
$device['group_name'] = 'General';
}
+3
View File
@@ -66,6 +66,8 @@ require 'includes/functions.inc.php';
require 'includes/vars.inc.php';
require 'includes/plugins.inc.php';
$config['memcached']['ttl'] = $config['time']['now']+300;
Plugins::start();
$runtime_start = utime();
@@ -121,6 +123,7 @@ if (empty($config['favicon'])) {
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="images/favicon-72.png">
<link rel="apple-touch-icon-precomposed" href="images/favicon-57.png">
<link rel="icon" href="images/favicon-32.png" sizes="32x32">
<meta name="mobile-web-app-capable" content="yes">
<meta name="msapplication-TileImage" content="images/favicon-144.png">
<?php
}
+1 -1
View File
@@ -216,7 +216,7 @@ if($stage == 0) {
}
// Check for pear install
require_once 'System.php';
@include_once 'System.php';
if(class_exists('System') === true) {
$ext_loaded = 'yes';
+2 -2
View File
@@ -40,7 +40,7 @@ function showDetails($bill_id, $imgtype, $from, $to, $bittype='Quota') {
// $url = generate_url($vars, array('detail' => 'yes'));
$url = $PHP_SELF.'/bill/'.$bill_id.'/history/detail=all/';
echo '<table border=0 cellspacing=0 cellpadding=5 class=devicetable width=100%>
echo '<table class="table">
<tr style="font-weight: bold; ">
<td width="7"></td>
<td width="250">Period</td>
@@ -93,7 +93,7 @@ foreach (dbFetchRows('SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY
echo '
<tr style="background: '.$row_colour.';">
<td></td>
<td><span style="font-weight: bold;" class="interface">'.strftime('%Y-%m-%d', strtotime($datefrom)).' -> '.strftime('%Y-%m-%d', strtotime($dateto))."</span></td>
<td><span style="font-weight: bold;" class="interface">'.strftime('%Y-%m-%d', strtotime($datefrom)).' to '.strftime('%Y-%m-%d', strtotime($dateto))."</span></td>
<td>$type</td>
<td>$allowed</td>
<td>$in</td>
+2 -3
View File
@@ -88,9 +88,8 @@ function showPercent($per) {
echo '<h3>Bill Summary</h3>';
echo '<h4>Quota Bill</h4>';
echo '<table cellpadding="5" cellspacing="0" border="0" class="devicetable">';
echo ' <tr><td colspan="7">Billing Period from '.$fromtext.' to '.$totext.'</td></tr>';
echo '<h4>Quota Bill (Billing Period from '.$fromtext.' to '.$totext.')</h4>';
echo '<table class="table">';
echo ' <tr style="font-weight: bold;">';
echo ' <td width="125">Bandwidth</td>';
echo ' <td width="10"></td>';
+1 -1
View File
@@ -22,7 +22,7 @@ else if ($vars['purge']) {
echo '<table cellpadding=5 cellspacing=0 border=0 width=100%>';
echo "<tr><td></td><td></td><td></td><td><a href='deleted-ports/purge=all/'><img src='images/16/cross.png' align=absmiddle></img> Purge All</a></td></tr>";
foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id") as $interface) {
foreach (dbFetchRows("SELECT * FROM `ports` AS P, `devices` as D WHERE P.`deleted` = '1' AND D.device_id = P.device_id",array(),true) as $interface) {
$interface = ifLabel($interface, $interface);
if (port_permitted($interface['port_id'], $interface['device_id'])) {
echo '<tr class=list>';
+1
View File
@@ -1,6 +1,7 @@
<?php
$no_refresh = TRUE;
$config['memcached']['enable'] = false;
$link_array = array('page' => 'device',
'device' => $device['device_id'],
+1 -12
View File
@@ -13,17 +13,6 @@ foreach (dbFetchRows('SELECT * FROM `mempools` WHERE device_id = ?', array($devi
$row_colour = $list_colour_b;
}
if ($config['memcached']['enable'] === true) {
$state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state');
d_echo($state);
if (is_array($state)) {
$mempool = array_merge($mempool, $state);
}
unset($state);
}
$text_descr = rewrite_entity_descr($mempool['mempool_descr']);
$mempool_url = 'graphs/id='.$mempool['mempool_id'].'/type=mempool_usage/';
@@ -55,4 +44,4 @@ foreach (dbFetchRows('SELECT * FROM `mempools` WHERE device_id = ?', array($devi
echo "</div></div>";
$i++;
}//end foreach
}//end foreach
@@ -12,10 +12,6 @@ if (count($sensors)) {
echo ' </div>
<table class="table table-hover table-condensed table-striped">';
foreach ($sensors as $sensor) {
if ($config['memcached']['enable'] === true) {
$sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value');
}
if (empty($sensor['sensor_current'])) {
$sensor['sensor_current'] = 'NaN';
}
@@ -19,17 +19,6 @@ if (count($mempools)) {
';
foreach ($mempools as $mempool) {
if ($config['memcached']['enable'] === true) {
$state = $memcache->get('mempool-'.$mempool['mempool_id'].'-state');
d_echo($state);
if (is_array($state)) {
$mempool = array_merge($mempool, $state);
}
unset($state);
}
$percent = round($mempool['mempool_perc'], 0);
$text_descr = rewrite_entity_descr($mempool['mempool_descr']);
$total = formatStorage($mempool['mempool_total']);
-11
View File
@@ -6,17 +6,6 @@ if (!isset($vars['view'])) {
$port = dbFetchRow('SELECT * FROM `ports` WHERE `port_id` = ?', array($vars['port']));
if ($config['memcached']['enable'] === true) {
$state = $memcache->get('port-'.$port['port_id'].'-state');
d_echo($state);
if (is_array($state)) {
$port = array_merge($port, $state);
}
unset($state);
}
$port_details = 1;
$hostname = $device['hostname'];
-12
View File
@@ -136,19 +136,7 @@ else {
}
foreach ($ports as $port) {
if ($config['memcached']['enable'] === true) {
$state = $memcache->get('port-'.$port['port_id'].'-state');
d_echo($state);
if (is_array($state)) {
$port = array_merge($port, $state);
}
unset($state);
}
include 'includes/print-interface.inc.php';
$i++;
}
+1 -1
View File
@@ -64,7 +64,7 @@ if ($config['warn']['ifdown']) {
if (!$interface['deleted']) {
$interface = ifNameDescr($interface);
generate_front_box(
'port-down',
'alert alert-danger',
generate_device_link($interface, shorthost($interface['hostname']))."<br />
<span class=\"interface-updown\">Port Down</span><br />
<!-- <img src='graph.php?type=bits&amp;if=".$interface['port_id'].'&amp;from='.$config['time']['day'].'&amp;to='.$config['time']['now']."&amp;width=100&amp;height=32' /> -->
+40 -8
View File
@@ -41,7 +41,7 @@ foreach (dbFetchRows('SELECT user_widget_id,users_widgets.widget_id,title,widget
$data[] = $items;
}
if (empty($data)) {
$data[] = array('user_widget_id'=>'0','widget_id'=>1,'title'=>'Add a widget','widget'=>'placeholder','col'=>1,'row'=>1,'size_x'=>2,'size_y'=>2,'refresh'=>60);
$data[] = array('user_widget_id'=>'0','widget_id'=>1,'title'=>'Add a widget','widget'=>'placeholder','col'=>1,'row'=>1,'size_x'=>6,'size_y'=>2,'refresh'=>60);
}
$data = serialize(json_encode($data));
$dash_config = unserialize(stripslashes($data));
@@ -86,9 +86,9 @@ if (!empty($shared_dashboards)) {
?>
</ul>
</div>
<button class="btn btn-default" href="#edit_dash" onclick="dashboard_collapse($(this).attr('href'))"><i class="fa fa-pencil-square-o fa-fw"></i></button>
<button class="btn btn-danger" href="#del_dash" onclick="dashboard_collapse($(this).attr('href'))"><i class="fa fa-trash fa-fw"></i></button>
<button class="btn btn-success" href="#add_dash" onclick="dashboard_collapse($(this).attr('href'))"><i class="fa fa-plus fa-fw"></i></button>
<button class="btn btn-default edit-dash-btn" href="#edit_dash" onclick="dashboard_collapse($(this).attr('href'))" data-toggle="tooltip" data-placement="top" title="Edit Dashboard"><i class="fa fa-pencil-square-o fa-fw"></i></button>
<button class="btn btn-danger" href="#del_dash" onclick="dashboard_collapse($(this).attr('href'))" data-toggle="tooltip" data-placement="top" title="Remove Dashboard"><i class="fa fa-trash fa-fw"></i></button>
<button class="btn btn-success" href="#add_dash" onclick="dashboard_collapse($(this).attr('href'))" data-toggle="tooltip" data-placement="top" title="New Dashboard"><i class="fa fa-plus fa-fw"></i></button>
</div>
</div>
</div>
@@ -229,7 +229,10 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg
});
}
var gridster_state = 0;
$(function(){
$('[data-toggle="tooltip"]').tooltip();
dashboard_collapse();
gridster = $(".gridster ul").gridster({
widget_base_dimensions: [100, 100],
@@ -260,9 +263,25 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg
}).data('gridster');
gridster.remove_all_widgets();
gridster.disable();
gridster.disable_resize();
$.each(serialization, function() {
widget_dom(this);
});
$(document).on('click','.edit-dash-btn', function() {
if (gridster_state == 0) {
gridster.enable();
gridster.enable_resize();
gridster_state = 1;
$('.fade-edit').fadeIn();
}
else {
gridster.disable();
gridster.disable_resize();
gridster_state = 0;
$('.fade-edit').fadeOut();
}
});
$(document).on('click','#clear_widgets', function() {
var widget_id = $(this).data('widget-id');
@@ -330,7 +349,7 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg
});
$(document).on("click",".edit-widget",function() {
obj = $(this).parent().parent();
obj = $(this).parent().parent().parent();
if( obj.data('settings') == 1 ) {
obj.data('settings','0');
} else {
@@ -347,6 +366,12 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg
$(this).fadeOut(0);
});
$(target).fadeToggle(300);
if (target != "#edit_dash") {
gridster.disable();
gridster.disable_resize();
gridster_state = 0;
$('.fade-edit').fadeOut();
}
} else {
$('.dash-collapse').fadeOut(0);
}
@@ -418,9 +443,12 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg
function widget_dom(data) {
dom = '<li id="'+data.user_widget_id+'" data-type="'+data.widget+'" data-settings="0">'+
'<header class="widget_header"><span id="widget_title_'+data.user_widget_id+'">'+data.title+'</span>'+
'<button style="color: #ffffff;" type="button" class="fa fa-times close close-widget" data-widget-id="'+data.user_widget_id+'" aria-label="Close">&nbsp;</button>'+
'<button style="color: #ffffff;" type="button" class="fa fa-pencil-square-o close edit-widget" data-widget-id="'+data.user_widget_id+'" aria-label="Settings">&nbsp;</button>'+
'<header class="widget_header"><span id="widget_title_'+data.user_widget_id+'">'+data.title+
'</span>'+
'<span class="fade-edit pull-right">'+
'<a href="javascript:return false;" class="fa fa-pencil-square-o edit-widget" data-widget-id="'+data.user_widget_id+'" aria-label="Settings" data-toggle="tooltip" data-placement="top" title="Settings">&nbsp;</a>&nbsp;'+
'<a href="javascript:return false;" class="text-danger fa fa-times close-widget" data-widget-id="'+data.user_widget_id+'" aria-label="Close" data-toggle="tooltip" data-placement="top" title="Remove">&nbsp;</a>&nbsp;'+
'</span>'+
'</header>'+
'<div class="widget_body" id="widget_body_'+data.user_widget_id+'" style="height: 100%; width:100%;">'+data.widget+'</div>'+
'\<script\>var timeout'+data.user_widget_id+' = grab_data('+data.user_widget_id+','+data.refresh+',\''+data.widget+'\');\<\/script\>'+
@@ -430,6 +458,10 @@ foreach (dbFetchRows("SELECT * FROM `widgets` ORDER BY `widget_title`") as $widg
} else {
gridster.add_widget(dom, parseInt(data.size_x), parseInt(data.size_y));
}
if (gridster_state == 0) {
$('.fade-edit').fadeOut(0);
}
$('[data-toggle="tooltip"]').tooltip();
}
function widget_settings(data) {
+1 -1
View File
@@ -97,7 +97,7 @@ else {
$link = generate_url($link_array);
echo('<td align=center>');
echo('<span class="device-head">'.$text.'</span><br />');
echo('<b>'.$text.'</b><br>');
echo('<a href="'.$link.'">');
echo generate_lazy_graph_tag($graph_array);
echo('</a>');
-5
View File
@@ -22,11 +22,6 @@ echo '<tr class="tablehead">
</tr>';
foreach (dbFetchRows($sql, $param) as $sensor) {
if ($config['memcached']['enable'] === true) {
$sensor['sensor_current'] = $memcache->get('sensor-'.$sensor['sensor_id'].'-value');
d_echo('Memcached['.'sensor-'.$sensor['sensor_id'].'-value'.'='.$sensor['sensor_current'].']');
}
if (empty($sensor['sensor_current'])) {
$sensor['sensor_current'] = 'NaN';
}
+1 -1
View File
@@ -29,7 +29,7 @@ else {
</div>
<div class="form-group">
<label class "checkbox">
<label class="checkbox">
<input type="checkbox" name="remember" id="remember" /> Remember me.
</label>
+1
View File
@@ -24,6 +24,7 @@
* @subpackage Page
*/
$pagetitle[] = 'Global Settings';
$config['memcached']['enable'] = false;
?>
<div class="container-fluid">
+1 -1
View File
@@ -91,7 +91,7 @@ function GenSQL($rule) {
}
$i++;
}
$sql = "SELECT * FROM ".implode(",",$tables)." WHERE (".$join."".str_replace("(","",$tables[0]).".device_id = ?) && (".str_replace(array("%","@","!~","~"),array("","%","NOT LIKE","LIKE"),$rule).")";
$sql = "SELECT * FROM ".implode(",",$tables)." WHERE (".$join."".str_replace("(","",$tables[0]).".device_id = ?) && (".str_replace(array("%","@","!~","~"),array("",".*","NOT REGEXP","REGEXP"),$rule).")";
return $sql;
}
+30 -10
View File
@@ -238,8 +238,15 @@ function dbDelete($table, $where=null, $parameters=array()) {
* */
function dbFetchRows($sql, $parameters=array()) {
global $db_stats;
function dbFetchRows($sql, $parameters=array(), $nocache=false) {
global $db_stats, $config;
if ($config['memcached']['enable'] && $nocache === false) {
$result = $config['memcached']['resource']->get(hash('sha512',$sql.'|'.serialize($parameters)));
if (!empty($result)) {
return $result;
}
}
$time_start = microtime(true);
$result = dbQuery($sql, $parameters);
@@ -251,6 +258,9 @@ function dbFetchRows($sql, $parameters=array()) {
}
mysql_free_result($result);
if ($config['memcached']['enable'] && $nocache === false) {
$config['memcached']['resource']->set(hash('sha512',$sql.'|'.serialize($parameters)),$rows,$config['memcached']['ttl']);
}
return $rows;
}
@@ -273,8 +283,8 @@ function dbFetchRows($sql, $parameters=array()) {
* */
function dbFetch($sql, $parameters=array()) {
return dbFetchRows($sql, $parameters);
function dbFetch($sql, $parameters=array(), $nocache=false) {
return dbFetchRows($sql, $parameters, $nocache);
/*
// for now, don't do the iterator thing
$result = dbQuery($sql, $parameters);
@@ -295,8 +305,15 @@ function dbFetch($sql, $parameters=array()) {
* */
function dbFetchRow($sql=null, $parameters=array()) {
global $db_stats;
function dbFetchRow($sql=null, $parameters=array(), $nocache=false) {
global $db_stats, $config;
if ($config['memcached']['enable'] && $nocache === false) {
$result = $config['memcached']['resource']->get(hash('sha512',$sql.'|'.serialize($parameters)));
if (!empty($result)) {
return $result;
}
}
$time_start = microtime(true);
$result = dbQuery($sql, $parameters);
@@ -308,6 +325,9 @@ function dbFetchRow($sql=null, $parameters=array()) {
$db_stats['fetchrow_sec'] += number_format(($time_end - $time_start), 8);
$db_stats['fetchrow']++;
if ($config['memcached']['enable'] && $nocache === false) {
$config['memcached']['resource']->set(hash('sha512',$sql.'|'.serialize($parameters)),$row,$config['memcached']['ttl']);
}
return $row;
}
else {
@@ -324,10 +344,10 @@ function dbFetchRow($sql=null, $parameters=array()) {
* */
function dbFetchCell($sql, $parameters=array()) {
function dbFetchCell($sql, $parameters=array(), $nocache=false) {
global $db_stats;
$time_start = microtime(true);
$row = dbFetchRow($sql, $parameters);
$row = dbFetchRow($sql, $parameters, $nocache);
if ($row) {
return array_shift($row);
// shift first field off first row
@@ -349,11 +369,11 @@ function dbFetchCell($sql, $parameters=array()) {
* */
function dbFetchColumn($sql, $parameters=array()) {
function dbFetchColumn($sql, $parameters=array(), $nocache=false) {
global $db_stats;
$time_start = microtime(true);
$cells = array();
foreach (dbFetch($sql, $parameters) as $row) {
foreach (dbFetch($sql, $parameters, $nocache) as $row) {
$cells[] = array_shift($row);
}
+34 -13
View File
@@ -239,8 +239,15 @@ function dbDelete($table, $where=null, $parameters=array()) {
* */
function dbFetchRows($sql, $parameters=array()) {
global $db_stats;
function dbFetchRows($sql, $parameters=array(), $nocache=false) {
global $db_stats, $config;
if ($config['memcached']['enable'] && $nocache === false) {
$result = $config['memcached']['resource']->get(hash('sha512',$sql.'|'.serialize($parameters)));
if (!empty($result)) {
return $result;
}
}
$time_start = microtime(true);
$result = dbQuery($sql, $parameters);
@@ -252,6 +259,9 @@ function dbFetchRows($sql, $parameters=array()) {
}
mysqli_free_result($result);
if ($config['memcached']['enable'] && $nocache === false) {
$config['memcached']['resource']->set(hash('sha512',$sql.'|'.serialize($parameters)),$rows,$config['memcached']['ttl']);
}
return $rows;
}
@@ -274,8 +284,8 @@ function dbFetchRows($sql, $parameters=array()) {
* */
function dbFetch($sql, $parameters=array()) {
return dbFetchRows($sql, $parameters);
function dbFetch($sql, $parameters=array(), $nocache=false) {
return dbFetchRows($sql, $parameters, $nocache);
/*
// for now, don't do the iterator thing
$result = dbQuery($sql, $parameters);
@@ -296,8 +306,15 @@ function dbFetch($sql, $parameters=array()) {
* */
function dbFetchRow($sql=null, $parameters=array()) {
global $db_stats;
function dbFetchRow($sql=null, $parameters=array(), $nocache=false) {
global $db_stats, $config;
if ($config['memcached']['enable'] && $nocache === false) {
$result = $config['memcached']['resource']->get(hash('sha512',$sql.'|'.serialize($parameters)));
if (!empty($result)) {
return $result;
}
}
$time_start = microtime(true);
$result = dbQuery($sql, $parameters);
@@ -309,6 +326,9 @@ function dbFetchRow($sql=null, $parameters=array()) {
$db_stats['fetchrow_sec'] += number_format(($time_end - $time_start), 8);
$db_stats['fetchrow']++;
if ($config['memcached']['enable'] && $nocache === false) {
$config['memcached']['resource']->set(hash('sha512',$sql.'|'.serialize($parameters)),$row,$config['memcached']['ttl']);
}
return $row;
}
else {
@@ -325,10 +345,11 @@ function dbFetchRow($sql=null, $parameters=array()) {
* */
function dbFetchCell($sql, $parameters=array()) {
global $db_stats;
function dbFetchCell($sql, $parameters=array(), $nocache=false) {
global $db_stats, $config;
$time_start = microtime(true);
$row = dbFetchRow($sql, $parameters);
$row = dbFetchRow($sql, $parameters, $nocache);
if ($row) {
return array_shift($row);
// shift first field off first row
@@ -350,11 +371,11 @@ function dbFetchCell($sql, $parameters=array()) {
* */
function dbFetchColumn($sql, $parameters=array()) {
function dbFetchColumn($sql, $parameters=array(), $nocache=false) {
global $db_stats;
$time_start = microtime(true);
$cells = array();
foreach (dbFetch($sql, $parameters) as $row) {
foreach (dbFetch($sql, $parameters, $nocache) as $row) {
$cells[] = array_shift($row);
}
@@ -375,9 +396,9 @@ function dbFetchColumn($sql, $parameters=array()) {
*/
function dbFetchKeyValue($sql, $parameters=array()) {
function dbFetchKeyValue($sql, $parameters=array(), $nocache=false) {
$data = array();
foreach (dbFetch($sql, $parameters) as $row) {
foreach (dbFetch($sql, $parameters, $nocache) as $row) {
$key = array_shift($row);
if (sizeof($row) == 1) {
// if there were only 2 fields in the result
+3
View File
@@ -51,7 +51,9 @@ $config['own_hostname'] = 'localhost';
// Location of executables
$config['rrdtool'] = '/usr/bin/rrdtool';
$config['rrdtool_version'] = 1.4; // Doesn't need to contain minor numbers.
$config['fping'] = '/usr/bin/fping';
$config['fping6'] = 'fping6';
$config['fping_options']['retries'] = 3;
$config['fping_options']['timeout'] = 500;
$config['fping_options']['count'] = 3;
@@ -73,6 +75,7 @@ $config['sfdp'] = '/usr/bin/sfdp';
$config['memcached']['enable'] = false;
$config['memcached']['host'] = 'localhost';
$config['memcached']['port'] = 11211;
$config['memcached']['ttl'] = 240;
$config['slow_statistics'] = true;
// THIS WILL CHANGE TO FALSE IN FUTURE
+17 -13
View File
@@ -30,6 +30,19 @@ else {
$database_db = mysql_select_db($config['db_name'], $database_link);
}
if ($config['memcached']['enable'] === true) {
if (class_exists('Memcached')) {
$config['memcached']['ttl'] = 60;
$config['memcached']['resource'] = new Memcached();
$config['memcached']['resource']->addServer($config['memcached']['host'], $config['memcached']['port']);
}
else {
echo "WARNING: You have enabled memcached but have not installed the PHP bindings. Disabling memcached support.\n";
echo "Try 'apt-get install php5-memcached' or 'pecl install memcached'. You will need the php5-dev and libmemcached-dev packages to use pecl.\n\n";
$config['memcached']['enable'] = 0;
}
}
$clone = $config;
foreach (dbFetchRows('select config_name,config_value from config') as $obj) {
$clone = array_replace_recursive($clone, mergecnf($obj));
@@ -413,6 +426,10 @@ $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]['over'][3]['graph'] = 'device_ciscowlc_numaps';
$config['os'][$os]['over'][3]['text'] = 'Number of APs';
$config['os'][$os]['over'][4]['graph'] = 'device_ciscowlc_numclients';
$config['os'][$os]['over'][4]['text'] = 'Number of Clients';
$config['os'][$os]['icon'] = 'cisco';
// Brocade NOS
@@ -1703,19 +1720,6 @@ if (isset($_SERVER['HTTPS'])) {
$config['base_url'] = preg_replace('/^http:/', 'https:', $config['base_url']);
}
if ($config['memcached']['enable'] === true) {
if (class_exists('Memcached')) {
$memcache = new Memcached();
$memcache->addServer($config['memcached']['host'], $config['memcached']['port']);
$memcache->getStats();
}
else {
echo "WARNING: You have enabled memcached but have not installed the PHP bindings. Disabling memcached support.\n";
echo "Try 'apt-get install php5-memcached' or 'pecl install memcached'. You will need the php5-dev and libmemcached-dev packages to use pecl.\n\n";
$config['memcached']['enable'] = 0;
}
}
// Set some times needed by loads of scripts (it's dynamic, so we do it here!)
$config['time']['now'] = time();
$config['time']['now'] -= ($config['time']['now'] % 300);
+1 -1
View File
@@ -63,7 +63,7 @@ function GenGroupSQL($pattern, $search='') {
$search .= ' &&';
}
$sql = 'SELECT DISTINCT('.str_replace('(', '', $tables[0]).'.device_id) FROM '.implode(',', $tables).' WHERE '.$search.' ('.str_replace(array('%', '@', '!~', '~'), array('', '%', 'NOT LIKE', 'LIKE'), $pattern).')';
$sql = 'SELECT DISTINCT('.str_replace('(', '', $tables[0]).'.device_id) FROM '.implode(',', $tables).' WHERE '.$search.' ('.str_replace(array('%', '@', '!~', '~'), array('', '.*', 'NOT REGEXP', 'REGEXP'), $pattern).')';
return $sql;
}//end GenGroupSQL()
+49 -6
View File
@@ -251,7 +251,8 @@ function addHost($host, $snmpver, $port = '161', $transport = 'udp', $quiet = '0
}
if (ip_exists($ip) === false) {
// Test reachability
if ($force_add == 1 || isPingable($host)) {
$address_family = snmpTransportToAddressFamily($transport);
if ($force_add == 1 || isPingable($host, $address_family)) {
if (empty($snmpver)) {
// Try SNMPv2c
$snmpver = 'v2c';
@@ -477,7 +478,16 @@ function isSNMPable($device) {
}
}
function isPingable($hostname,$device_id = FALSE) {
/**
* Check if the given host responds to ICMP echo requests ("pings").
*
* @param string $hostname The hostname or IP address to send ping requests to.
* @param int $address_family The address family (AF_INET for IPv4 or AF_INET6 for IPv6) to use. Defaults to IPv4. Will *not* be autodetected for IP addresses, so it has to be set to AF_INET6 when pinging an IPv6 address or an IPv6-only host.
* @param int $device_id This parameter is currently ignored.
*
* @return bool TRUE if the host responded to at least one ping request, FALSE otherwise.
*/
function isPingable($hostname, $address_family = AF_INET, $device_id = FALSE) {
global $config;
$fping_params = '';
@@ -494,7 +504,7 @@ function isPingable($hostname,$device_id = FALSE) {
$fping_params .= ' -p ' . $config['fping_options']['millisec'];
}
$response = array();
$status = fping($hostname,$fping_params);
$status = fping($hostname,$fping_params,$address_family);
if ($status['loss'] == 100) {
$response['result'] = FALSE;
}
@@ -1162,7 +1172,7 @@ function ip_exists($ip) {
return true;
}
function fping($host,$params) {
function fping($host,$params,$address_family = AF_INET) {
global $config;
@@ -1172,7 +1182,13 @@ function fping($host,$params) {
2 => array("pipe", "w")
);
$process = proc_open($config['fping'] . ' -e -q ' .$params . ' ' .$host.' 2>&1', $descriptorspec, $pipes);
// Default to AF_INET (IPv4)
$fping_path = $config['fping'];
if ($address_family == AF_INET6) {
$fping_path = $config['fping6'];
}
$process = proc_open($fping_path . ' -e -q ' .$params . ' ' .$host.' 2>&1', $descriptorspec, $pipes);
$read = '';
if (is_resource($process)) {
@@ -1206,4 +1222,31 @@ function function_check($function) {
function get_last_commit() {
return `git log -n 1|head -n1`;
}//end get_last_commit
}//end get_last_commit
/**
* Try to determine the address family (IPv4 or IPv6) associated with an SNMP
* transport specifier (like "udp", "udp6", etc.).
*
* @param string $transport The SNMP transport specifier, for example "udp",
* "udp6", "tcp", or "tcp6". See `man snmpcmd`,
* section "Agent Specification" for a full list.
*
* @return int The address family associated with the given transport
* specifier: AF_INET for IPv4 (or local connections not associated
* with an IP stack), AF_INET6 for IPv6.
*/
function snmpTransportToAddressFamily($transport) {
if (!isset($transport)) {
$transport = 'udp';
}
$ipv6_snmp_transport_specifiers = array('udp6', 'udpv6', 'udpipv6', 'tcp6', 'tcpv6', 'tcpipv6');
if (in_array($transport, $ipv6_snmp_transport_specifiers)) {
return AF_INET6;
}
else {
return AF_INET;
}
}
+20 -20
View File
@@ -22,26 +22,26 @@ list ($total_access, $total_kbyte, $cpuload, $uptime, $reqpersec, $bytespersec,
if (!is_file($rrd_filename)) {
rrdtool_create(
$rrd_filename,
'--step 300 \
DS:access:DERIVE:600:0:125000000000 \
DS:kbyte:DERIVE:600:0:125000000000 \
DS:cpu:GAUGE:600:0:125000000000 \
DS:uptime:GAUGE:600:0:125000000000 \
DS:reqpersec:GAUGE:600:0:125000000000 \
DS:bytespersec:GAUGE:600:0:125000000000 \
DS:byesperreq:GAUGE:600:0:125000000000 \
DS:busyworkers:GAUGE:600:0:125000000000 \
DS:idleworkers:GAUGE:600:0:125000000000 \
DS:sb_wait:GAUGE:600:0:125000000000 \
DS:sb_start:GAUGE:600:0:125000000000 \
DS:sb_reading:GAUGE:600:0:125000000000 \
DS:sb_writing:GAUGE:600:0:125000000000 \
DS:sb_keepalive:GAUGE:600:0:125000000000 \
DS:sb_dns:GAUGE:600:0:125000000000 \
DS:sb_closing:GAUGE:600:0:125000000000 \
DS:sb_logging:GAUGE:600:0:125000000000 \
DS:sb_graceful:GAUGE:600:0:125000000000 \
DS:sb_idle:GAUGE:600:0:125000000000 \
'--step 300
DS:access:DERIVE:600:0:125000000000
DS:kbyte:DERIVE:600:0:125000000000
DS:cpu:GAUGE:600:0:125000000000
DS:uptime:GAUGE:600:0:125000000000
DS:reqpersec:GAUGE:600:0:125000000000
DS:bytespersec:GAUGE:600:0:125000000000
DS:byesperreq:GAUGE:600:0:125000000000
DS:busyworkers:GAUGE:600:0:125000000000
DS:idleworkers:GAUGE:600:0:125000000000
DS:sb_wait:GAUGE:600:0:125000000000
DS:sb_start:GAUGE:600:0:125000000000
DS:sb_reading:GAUGE:600:0:125000000000
DS:sb_writing:GAUGE:600:0:125000000000
DS:sb_keepalive:GAUGE:600:0:125000000000
DS:sb_dns:GAUGE:600:0:125000000000
DS:sb_closing:GAUGE:600:0:125000000000
DS:sb_logging:GAUGE:600:0:125000000000
DS:sb_graceful:GAUGE:600:0:125000000000
DS:sb_idle:GAUGE:600:0:125000000000
DS:sb_open:GAUGE:600:0:125000000000 '.$config['rrd_rra']
);
}//end if
+10 -10
View File
@@ -72,16 +72,16 @@ if (!empty($agent_data['app']['bind']) && $app['app_id'] > 0) {
if (!is_file($rrd_filename)) {
rrdtool_create(
$rrd_filename,
'--step 300 \
DS:any:COUNTER:600:0:125000000000 \
DS:a:COUNTER:600:0:125000000000 \
DS:aaaa:COUNTER:600:0:125000000000 \
DS:cname:COUNTER:600:0:125000000000 \
DS:mx:COUNTER:600:0:125000000000 \
DS:ns:COUNTER:600:0:125000000000 \
DS:ptr:COUNTER:600:0:125000000000 \
DS:soa:COUNTER:600:0:125000000000 \
DS:srv:COUNTER:600:0:125000000000 \
'--step 300
DS:any:COUNTER:600:0:125000000000
DS:a:COUNTER:600:0:125000000000
DS:aaaa:COUNTER:600:0:125000000000
DS:cname:COUNTER:600:0:125000000000
DS:mx:COUNTER:600:0:125000000000
DS:ns:COUNTER:600:0:125000000000
DS:ptr:COUNTER:600:0:125000000000
DS:soa:COUNTER:600:0:125000000000
DS:srv:COUNTER:600:0:125000000000
DS:spf:COUNTER:600:0:125000000000 '.$config['rrd_rra']
);
}
+11 -11
View File
@@ -12,17 +12,17 @@ foreach (explode('|', $agent_data['app']['drbd'][$app['app_instance']]) as $part
if (!is_file($rrd_filename)) {
rrdtool_create(
$rrd_filename,
'--step 300 \
DS:ns:DERIVE:600:0:125000000000 \
DS:nr:DERIVE:600:0:125000000000 \
DS:dw:DERIVE:600:0:125000000000 \
DS:dr:DERIVE:600:0:125000000000 \
DS:al:DERIVE:600:0:125000000000 \
DS:bm:DERIVE:600:0:125000000000 \
DS:lo:GAUGE:600:0:125000000000 \
DS:pe:GAUGE:600:0:125000000000 \
DS:ua:GAUGE:600:0:125000000000 \
DS:ap:GAUGE:600:0:125000000000 \
'--step 300
DS:ns:DERIVE:600:0:125000000000
DS:nr:DERIVE:600:0:125000000000
DS:dw:DERIVE:600:0:125000000000
DS:dr:DERIVE:600:0:125000000000
DS:al:DERIVE:600:0:125000000000
DS:bm:DERIVE:600:0:125000000000
DS:lo:GAUGE:600:0:125000000000
DS:pe:GAUGE:600:0:125000000000
DS:ua:GAUGE:600:0:125000000000
DS:ap:GAUGE:600:0:125000000000
DS:oos:GAUGE:600:0:125000000000 '.$config['rrd_rra']
);
}
@@ -14,13 +14,13 @@ list ($msg_recv, $msg_rejected, $msg_relay, $msg_sent, $msg_waiting, $spam, $vir
if (!is_file($rrd_filename)) {
rrdtool_create(
$rrd_filename,
'--step 300 \
DS:msg_recv:COUNTER:600:0:125000000000 \
DS:msg_rejected:COUNTER:600:0:125000000000 \
DS:msg_relay:COUNTER:600:0:125000000000 \
DS:msg_sent:COUNTER:600:0:125000000000 \
DS:msg_waiting:COUNTER:600:0:125000000000 \
DS:spam:COUNTER:600:0:125000000000 \
'--step 300
DS:msg_recv:COUNTER:600:0:125000000000
DS:msg_rejected:COUNTER:600:0:125000000000
DS:msg_relay:COUNTER:600:0:125000000000
DS:msg_sent:COUNTER:600:0:125000000000
DS:msg_waiting:COUNTER:600:0:125000000000
DS:spam:COUNTER:600:0:125000000000
DS:virus:COUNTER:600:0:125000000000 '.$config['rrd_rra']
);
}
+19 -19
View File
@@ -9,25 +9,25 @@ echo 'memcached('.$app['app_instance'].') ';
if (!is_file($rrd_filename)) {
rrdtool_create(
$rrd_filename,
'--step 300 \
DS:uptime:GAUGE:600:0:125000000000 \
DS:threads:GAUGE:600:0:125000000000 \
DS:rusage_user_ms:DERIVE:600:0:125000000000 \
DS:rusage_system_ms:DERIVE:600:0:125000000000 \
DS:curr_items:GAUGE:600:0:125000000000 \
DS:total_items:DERIVE:600:0:125000000000 \
DS:limit_maxbytes:GAUGE:600:0:125000000000 \
DS:curr_connections:GAUGE:600:0:125000000000 \
DS:total_connections:DERIVE:600:0:125000000000 \
DS:conn_structures:GAUGE:600:0:125000000000 \
DS:bytes:GAUGE:600:0:125000000000 \
DS:cmd_get:DERIVE:600:0:125000000000 \
DS:cmd_set:DERIVE:600:0:125000000000 \
DS:get_hits:DERIVE:600:0:125000000000 \
DS:get_misses:DERIVE:600:0:125000000000 \
DS:evictions:DERIVE:600:0:125000000000 \
DS:bytes_read:DERIVE:600:0:125000000000 \
DS:bytes_written:DERIVE:600:0:125000000000 \
'--step 300
DS:uptime:GAUGE:600:0:125000000000
DS:threads:GAUGE:600:0:125000000000
DS:rusage_user_ms:DERIVE:600:0:125000000000
DS:rusage_system_ms:DERIVE:600:0:125000000000
DS:curr_items:GAUGE:600:0:125000000000
DS:total_items:DERIVE:600:0:125000000000
DS:limit_maxbytes:GAUGE:600:0:125000000000
DS:curr_connections:GAUGE:600:0:125000000000
DS:total_connections:DERIVE:600:0:125000000000
DS:conn_structures:GAUGE:600:0:125000000000
DS:bytes:GAUGE:600:0:125000000000
DS:cmd_get:DERIVE:600:0:125000000000
DS:cmd_set:DERIVE:600:0:125000000000
DS:get_hits:DERIVE:600:0:125000000000
DS:get_misses:DERIVE:600:0:125000000000
DS:evictions:DERIVE:600:0:125000000000
DS:bytes_read:DERIVE:600:0:125000000000
DS:bytes_written:DERIVE:600:0:125000000000
'.$config['rrd_rra']
);
}
+79 -79
View File
@@ -118,85 +118,85 @@ $string = implode(':', $values);
if (!is_file($mysql_rrd)) {
rrdtool_create(
$mysql_rrd,
'--step 300 \
DS:IDBLBSe:GAUGE:600:0:125000000000 \
DS:IBLFh:DERIVE:600:0:125000000000 \
DS:IBLWn:DERIVE:600:0:125000000000 \
DS:SRows:DERIVE:600:0:125000000000 \
DS:SRange:DERIVE:600:0:125000000000 \
DS:SMPs:DERIVE:600:0:125000000000 \
DS:SScan:DERIVE:600:0:125000000000 \
DS:IBIRd:DERIVE:600:0:125000000000 \
DS:IBIWr:DERIVE:600:0:125000000000 \
DS:IBILg:DERIVE:600:0:125000000000 \
DS:IBIFSc:DERIVE:600:0:125000000000 \
DS:IDBRDd:DERIVE:600:0:125000000000 \
DS:IDBRId:DERIVE:600:0:125000000000 \
DS:IDBRRd:DERIVE:600:0:125000000000 \
DS:IDBRUd:DERIVE:600:0:125000000000 \
DS:IBRd:DERIVE:600:0:125000000000 \
DS:IBCd:DERIVE:600:0:125000000000 \
DS:IBWr:DERIVE:600:0:125000000000 \
DS:TLIe:DERIVE:600:0:125000000000 \
DS:TLWd:DERIVE:600:0:125000000000 \
DS:IBPse:GAUGE:600:0:125000000000 \
DS:IBPDBp:GAUGE:600:0:125000000000 \
DS:IBPFe:GAUGE:600:0:125000000000 \
DS:IBPMps:GAUGE:600:0:125000000000 \
DS:TOC:GAUGE:600:0:125000000000 \
DS:OFs:GAUGE:600:0:125000000000 \
DS:OTs:GAUGE:600:0:125000000000 \
DS:OdTs:COUNTER:600:0:125000000000 \
DS:IBSRs:DERIVE:600:0:125000000000 \
DS:IBSWs:DERIVE:600:0:125000000000 \
DS:IBOWs:DERIVE:600:0:125000000000 \
DS:QCs:GAUGE:600:0:125000000000 \
DS:QCeFy:GAUGE:600:0:125000000000 \
DS:MaCs:GAUGE:600:0:125000000000 \
DS:MUCs:GAUGE:600:0:125000000000 \
DS:ACs:DERIVE:600:0:125000000000 \
DS:AdCs:DERIVE:600:0:125000000000 \
DS:TCd:GAUGE:600:0:125000000000 \
DS:Cs:DERIVE:600:0:125000000000 \
DS:IBTNx:DERIVE:600:0:125000000000 \
DS:KRRs:DERIVE:600:0:125000000000 \
DS:KRs:DERIVE:600:0:125000000000 \
DS:KWR:DERIVE:600:0:125000000000 \
DS:KWs:DERIVE:600:0:125000000000 \
DS:QCQICe:DERIVE:600:0:125000000000 \
DS:QCHs:DERIVE:600:0:125000000000 \
DS:QCIs:DERIVE:600:0:125000000000 \
DS:QCNCd:DERIVE:600:0:125000000000 \
DS:QCLMPs:DERIVE:600:0:125000000000 \
DS:CTMPDTs:DERIVE:600:0:125000000000 \
DS:CTMPTs:DERIVE:600:0:125000000000 \
DS:CTMPFs:DERIVE:600:0:125000000000 \
DS:IBIIs:DERIVE:600:0:125000000000 \
DS:IBIMRd:DERIVE:600:0:125000000000 \
DS:IBIMs:DERIVE:600:0:125000000000 \
DS:IBILog:DERIVE:602:0:125000000000 \
DS:IBISc:DERIVE:602:0:125000000000 \
DS:IBIFLg:DERIVE:600:0:125000000000 \
DS:IBFBl:DERIVE:600:0:125000000000 \
DS:IBIIAo:DERIVE:600:0:125000000000 \
DS:IBIAd:DERIVE:600:0:125000000000 \
DS:IBIAe:DERIVE:600:0:125000000000 \
DS:SFJn:DERIVE:600:0:125000000000 \
DS:SFRJn:DERIVE:600:0:125000000000 \
DS:SRe:DERIVE:600:0:125000000000 \
DS:SRCk:DERIVE:600:0:125000000000 \
DS:SSn:DERIVE:600:0:125000000000 \
DS:SQs:DERIVE:600:0:125000000000 \
DS:BRd:DERIVE:600:0:125000000000 \
DS:BSt:DERIVE:600:0:125000000000 \
DS:CDe:DERIVE:600:0:125000000000 \
DS:CIt:DERIVE:600:0:125000000000 \
DS:CISt:DERIVE:600:0:125000000000 \
DS:CLd:DERIVE:600:0:125000000000 \
DS:CRe:DERIVE:600:0:125000000000 \
DS:CRSt:DERIVE:600:0:125000000000 \
DS:CSt:DERIVE:600:0:125000000000 \
DS:CUe:DERIVE:600:0:125000000000 \
'--step 300
DS:IDBLBSe:GAUGE:600:0:125000000000
DS:IBLFh:DERIVE:600:0:125000000000
DS:IBLWn:DERIVE:600:0:125000000000
DS:SRows:DERIVE:600:0:125000000000
DS:SRange:DERIVE:600:0:125000000000
DS:SMPs:DERIVE:600:0:125000000000
DS:SScan:DERIVE:600:0:125000000000
DS:IBIRd:DERIVE:600:0:125000000000
DS:IBIWr:DERIVE:600:0:125000000000
DS:IBILg:DERIVE:600:0:125000000000
DS:IBIFSc:DERIVE:600:0:125000000000
DS:IDBRDd:DERIVE:600:0:125000000000
DS:IDBRId:DERIVE:600:0:125000000000
DS:IDBRRd:DERIVE:600:0:125000000000
DS:IDBRUd:DERIVE:600:0:125000000000
DS:IBRd:DERIVE:600:0:125000000000
DS:IBCd:DERIVE:600:0:125000000000
DS:IBWr:DERIVE:600:0:125000000000
DS:TLIe:DERIVE:600:0:125000000000
DS:TLWd:DERIVE:600:0:125000000000
DS:IBPse:GAUGE:600:0:125000000000
DS:IBPDBp:GAUGE:600:0:125000000000
DS:IBPFe:GAUGE:600:0:125000000000
DS:IBPMps:GAUGE:600:0:125000000000
DS:TOC:GAUGE:600:0:125000000000
DS:OFs:GAUGE:600:0:125000000000
DS:OTs:GAUGE:600:0:125000000000
DS:OdTs:COUNTER:600:0:125000000000
DS:IBSRs:DERIVE:600:0:125000000000
DS:IBSWs:DERIVE:600:0:125000000000
DS:IBOWs:DERIVE:600:0:125000000000
DS:QCs:GAUGE:600:0:125000000000
DS:QCeFy:GAUGE:600:0:125000000000
DS:MaCs:GAUGE:600:0:125000000000
DS:MUCs:GAUGE:600:0:125000000000
DS:ACs:DERIVE:600:0:125000000000
DS:AdCs:DERIVE:600:0:125000000000
DS:TCd:GAUGE:600:0:125000000000
DS:Cs:DERIVE:600:0:125000000000
DS:IBTNx:DERIVE:600:0:125000000000
DS:KRRs:DERIVE:600:0:125000000000
DS:KRs:DERIVE:600:0:125000000000
DS:KWR:DERIVE:600:0:125000000000
DS:KWs:DERIVE:600:0:125000000000
DS:QCQICe:DERIVE:600:0:125000000000
DS:QCHs:DERIVE:600:0:125000000000
DS:QCIs:DERIVE:600:0:125000000000
DS:QCNCd:DERIVE:600:0:125000000000
DS:QCLMPs:DERIVE:600:0:125000000000
DS:CTMPDTs:DERIVE:600:0:125000000000
DS:CTMPTs:DERIVE:600:0:125000000000
DS:CTMPFs:DERIVE:600:0:125000000000
DS:IBIIs:DERIVE:600:0:125000000000
DS:IBIMRd:DERIVE:600:0:125000000000
DS:IBIMs:DERIVE:600:0:125000000000
DS:IBILog:DERIVE:602:0:125000000000
DS:IBISc:DERIVE:602:0:125000000000
DS:IBIFLg:DERIVE:600:0:125000000000
DS:IBFBl:DERIVE:600:0:125000000000
DS:IBIIAo:DERIVE:600:0:125000000000
DS:IBIAd:DERIVE:600:0:125000000000
DS:IBIAe:DERIVE:600:0:125000000000
DS:SFJn:DERIVE:600:0:125000000000
DS:SFRJn:DERIVE:600:0:125000000000
DS:SRe:DERIVE:600:0:125000000000
DS:SRCk:DERIVE:600:0:125000000000
DS:SSn:DERIVE:600:0:125000000000
DS:SQs:DERIVE:600:0:125000000000
DS:BRd:DERIVE:600:0:125000000000
DS:BSt:DERIVE:600:0:125000000000
DS:CDe:DERIVE:600:0:125000000000
DS:CIt:DERIVE:600:0:125000000000
DS:CISt:DERIVE:600:0:125000000000
DS:CLd:DERIVE:600:0:125000000000
DS:CRe:DERIVE:600:0:125000000000
DS:CRSt:DERIVE:600:0:125000000000
DS:CSt:DERIVE:600:0:125000000000
DS:CUe:DERIVE:600:0:125000000000
DS:CUMi:DERIVE:600:0:125000000000 '.$config['rrd_rra']
);
}//end if
+5 -5
View File
@@ -16,11 +16,11 @@ list($active, $reading, $writing, $waiting, $req) = explode("\n", $nginx);
if (!is_file($nginx_rrd)) {
rrdtool_create(
$nginx_rrd,
'--step 300 \
DS:Requests:DERIVE:600:0:125000000000 \
DS:Active:GAUGE:600:0:125000000000 \
DS:Reading:GAUGE:600:0:125000000000 \
DS:Writing:GAUGE:600:0:125000000000 \
'--step 300
DS:Requests:DERIVE:600:0:125000000000
DS:Active:GAUGE:600:0:125000000000
DS:Reading:GAUGE:600:0:125000000000
DS:Writing:GAUGE:600:0:125000000000
DS:Waiting:GAUGE:600:0:125000000000 '.$config['rrd_rra']
);
}
@@ -14,11 +14,11 @@ list ($offset, $frequency, $jitter, $noise, $stability) = explode("\n", $ntpclie
if (!is_file($rrd_filename)) {
rrdtool_create(
$rrd_filename,
'--step 300 \
DS:offset:GAUGE:600:-1000:1000 \
DS:frequency:GAUGE:600:-1000:1000 \
DS:jitter:GAUGE:600:-1000:1000 \
DS:noise:GAUGE:600:-1000:1000 \
'--step 300
DS:offset:GAUGE:600:-1000:1000
DS:frequency:GAUGE:600:-1000:1000
DS:jitter:GAUGE:600:-1000:1000
DS:noise:GAUGE:600:-1000:1000
DS:stability:GAUGE:600:-1000:1000 '.$config['rrd_rra']
);
}
@@ -16,20 +16,20 @@ list ($stratum, $offset, $frequency, $jitter, $noise, $stability, $uptime,
if (!is_file($rrd_filename)) {
rrdtool_create(
$rrd_filename,
'--step 300 \
DS:stratum:GAUGE:600:-1000:1000 \
DS:offset:GAUGE:600:-1000:1000 \
DS:frequency:GAUGE:600:-1000:1000 \
DS:jitter:GAUGE:600:-1000:1000 \
DS:noise:GAUGE:600:-1000:1000 \
DS:stability:GAUGE:600:-1000:1000 \
DS:uptime:GAUGE:600:0:125000000000 \
DS:buffer_recv:GAUGE:600:0:100000 \
DS:buffer_free:GAUGE:600:0:100000 \
DS:buffer_used:GAUGE:600:0:100000 \
DS:packets_drop:DERIVE:600:0:125000000000 \
DS:packets_ignore:DERIVE:600:0:125000000000 \
DS:packets_recv:DERIVE:600:0:125000000000 \
'--step 300
DS:stratum:GAUGE:600:-1000:1000
DS:offset:GAUGE:600:-1000:1000
DS:frequency:GAUGE:600:-1000:1000
DS:jitter:GAUGE:600:-1000:1000
DS:noise:GAUGE:600:-1000:1000
DS:stability:GAUGE:600:-1000:1000
DS:uptime:GAUGE:600:0:125000000000
DS:buffer_recv:GAUGE:600:0:100000
DS:buffer_free:GAUGE:600:0:100000
DS:buffer_used:GAUGE:600:0:100000
DS:packets_drop:DERIVE:600:0:125000000000
DS:packets_ignore:DERIVE:600:0:125000000000
DS:packets_recv:DERIVE:600:0:125000000000
DS:packets_sent:DERIVE:600:0:125000000000 '.$config['rrd_rra']
);
}
+22 -22
View File
@@ -18,28 +18,28 @@ list ($corrupt, $def_cacheInserts, $def_cacheLookup, $latency, $pc_hit,
if (!is_file($rrd_filename)) {
rrdtool_create(
$rrd_filename,
'--step 300 \
DS:corruptPackets:DERIVE:600:0:125000000000 \
DS:def_cacheInserts:DERIVE:600:0:125000000000 \
DS:def_cacheLookup:DERIVE:600:0:125000000000 \
DS:latency:DERIVE:600:0:125000000000 \
DS:pc_hit:DERIVE:600:0:125000000000 \
DS:pc_miss:DERIVE:600:0:125000000000 \
DS:pc_size:DERIVE:600:0:125000000000 \
DS:qsize:DERIVE:600:0:125000000000 \
DS:qc_hit:DERIVE:600:0:125000000000 \
DS:qc_miss:DERIVE:600:0:125000000000 \
DS:rec_answers:DERIVE:600:0:125000000000 \
DS:rec_questions:DERIVE:600:0:125000000000 \
DS:servfailPackets:DERIVE:600:0:125000000000 \
DS:q_tcpAnswers:DERIVE:600:0:125000000000 \
DS:q_tcpQueries:DERIVE:600:0:125000000000 \
DS:q_timedout:DERIVE:600:0:125000000000 \
DS:q_udpAnswers:DERIVE:600:0:125000000000 \
DS:q_udpQueries:DERIVE:600:0:125000000000 \
DS:q_udp4Answers:DERIVE:600:0:125000000000 \
DS:q_udp4Queries:DERIVE:600:0:125000000000 \
DS:q_udp6Answers:DERIVE:600:0:125000000000 \
'--step 300
DS:corruptPackets:DERIVE:600:0:125000000000
DS:def_cacheInserts:DERIVE:600:0:125000000000
DS:def_cacheLookup:DERIVE:600:0:125000000000
DS:latency:DERIVE:600:0:125000000000
DS:pc_hit:DERIVE:600:0:125000000000
DS:pc_miss:DERIVE:600:0:125000000000
DS:pc_size:DERIVE:600:0:125000000000
DS:qsize:DERIVE:600:0:125000000000
DS:qc_hit:DERIVE:600:0:125000000000
DS:qc_miss:DERIVE:600:0:125000000000
DS:rec_answers:DERIVE:600:0:125000000000
DS:rec_questions:DERIVE:600:0:125000000000
DS:servfailPackets:DERIVE:600:0:125000000000
DS:q_tcpAnswers:DERIVE:600:0:125000000000
DS:q_tcpQueries:DERIVE:600:0:125000000000
DS:q_timedout:DERIVE:600:0:125000000000
DS:q_udpAnswers:DERIVE:600:0:125000000000
DS:q_udpQueries:DERIVE:600:0:125000000000
DS:q_udp4Answers:DERIVE:600:0:125000000000
DS:q_udp4Queries:DERIVE:600:0:125000000000
DS:q_udp6Answers:DERIVE:600:0:125000000000
DS:q_udp6Queries:DERIVE:600:0:125000000000 '.$config['rrd_rra']
);
}//end if
@@ -63,8 +63,8 @@ if (count($pmxlines) > 2) {
if (!is_file($rrd_filename)) {
rrdtool_create(
$rrd_filename,
' --step 300 \
DS:INOCTETS:DERIVE:600:0:12500000000 \
' --step 300
DS:INOCTETS:DERIVE:600:0:12500000000
DS:OUTOCTETS:DERIVE:600:0:12500000000 '.$config['rrd_rra']);
}
@@ -29,14 +29,14 @@ foreach ($servers as $item => $server) {
if (!is_file($rrdfile)) {
rrdtool_create(
$rrdfile,
'--step 300 \
DS:bitrate:GAUGE:600:0:125000000000 \
DS:traf_in:GAUGE:600:0:125000000000 \
DS:traf_out:GAUGE:600:0:125000000000 \
DS:current:GAUGE:600:0:125000000000 \
DS:status:GAUGE:600:0:125000000000 \
DS:peak:GAUGE:600:0:125000000000 \
DS:max:GAUGE:600:0:125000000000 \
'--step 300
DS:bitrate:GAUGE:600:0:125000000000
DS:traf_in:GAUGE:600:0:125000000000
DS:traf_out:GAUGE:600:0:125000000000
DS:current:GAUGE:600:0:125000000000
DS:status:GAUGE:600:0:125000000000
DS:peak:GAUGE:600:0:125000000000
DS:max:GAUGE:600:0:125000000000
DS:unique:GAUGE:600:0:125000000000 '.$config['rrd_rra']
);
}
+20 -20
View File
@@ -30,26 +30,26 @@ if (!empty($agent_data['app']['tinydns']) && $app['app_id'] > 0) {
if (!is_file($rrd_filename)) {
rrdtool_create(
$rrd_filename,
'--step 300 \
DS:a:COUNTER:600:0:125000000000 \
DS:ns:COUNTER:600:0:125000000000 \
DS:cname:COUNTER:600:0:125000000000 \
DS:soa:COUNTER:600:0:125000000000 \
DS:ptr:COUNTER:600:0:125000000000 \
DS:hinfo:COUNTER:600:0:125000000000 \
DS:mx:COUNTER:600:0:125000000000 \
DS:txt:COUNTER:600:0:125000000000 \
DS:rp:COUNTER:600:0:125000000000 \
DS:sig:COUNTER:600:0:125000000000 \
DS:key:COUNTER:600:0:125000000000 \
DS:aaaa:COUNTER:600:0:125000000000 \
DS:axfr:COUNTER:600:0:125000000000 \
DS:any:COUNTER:600:0:125000000000 \
DS:total:COUNTER:600:0:125000000000 \
DS:other:COUNTER:600:0:125000000000 \
DS:notauth:COUNTER:600:0:125000000000 \
DS:notimpl:COUNTER:600:0:125000000000 \
DS:badclass:COUNTER:600:0:125000000000 \
'--step 300
DS:a:COUNTER:600:0:125000000000
DS:ns:COUNTER:600:0:125000000000
DS:cname:COUNTER:600:0:125000000000
DS:soa:COUNTER:600:0:125000000000
DS:ptr:COUNTER:600:0:125000000000
DS:hinfo:COUNTER:600:0:125000000000
DS:mx:COUNTER:600:0:125000000000
DS:txt:COUNTER:600:0:125000000000
DS:rp:COUNTER:600:0:125000000000
DS:sig:COUNTER:600:0:125000000000
DS:key:COUNTER:600:0:125000000000
DS:aaaa:COUNTER:600:0:125000000000
DS:axfr:COUNTER:600:0:125000000000
DS:any:COUNTER:600:0:125000000000
DS:total:COUNTER:600:0:125000000000
DS:other:COUNTER:600:0:125000000000
DS:notauth:COUNTER:600:0:125000000000
DS:notimpl:COUNTER:600:0:125000000000
DS:badclass:COUNTER:600:0:125000000000
DS:noquery:COUNTER:600:0:125000000000 '.$config['rrd_rra']
);
}//end if
+8 -8
View File
@@ -142,10 +142,10 @@ if ($config['enable_bgp']) {
$peerrrd = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('bgp-'.$peer['bgpPeerIdentifier'].'.rrd');
if (!is_file($peerrrd)) {
$create_rrd = 'DS:bgpPeerOutUpdates:COUNTER:600:U:100000000000 \
DS:bgpPeerInUpdates:COUNTER:600:U:100000000000 \
DS:bgpPeerOutTotal:COUNTER:600:U:100000000000 \
DS:bgpPeerInTotal:COUNTER:600:U:100000000000 \
$create_rrd = 'DS:bgpPeerOutUpdates:COUNTER:600:U:100000000000
DS:bgpPeerInUpdates:COUNTER:600:U:100000000000
DS:bgpPeerOutTotal:COUNTER:600:U:100000000000
DS:bgpPeerInTotal:COUNTER:600:U:100000000000
DS:bgpPeerEstablished:GAUGE:600:0:U '.$config['rrd_rra'];
rrdtool_create($peerrrd, $create_rrd);
@@ -305,10 +305,10 @@ if ($config['enable_bgp']) {
$cbgp_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('cbgp-'.$peer['bgpPeerIdentifier'].".$afi.$safi.rrd");
if (!is_file($cbgp_rrd)) {
$rrd_create = 'DS:AcceptedPrefixes:GAUGE:600:U:100000000000 \
DS:DeniedPrefixes:GAUGE:600:U:100000000000 \
DS:AdvertisedPrefixes:GAUGE:600:U:100000000000 \
DS:SuppressedPrefixes:GAUGE:600:U:100000000000 \
$rrd_create = 'DS:AcceptedPrefixes:GAUGE:600:U:100000000000
DS:DeniedPrefixes:GAUGE:600:U:100000000000
DS:AdvertisedPrefixes:GAUGE:600:U:100000000000
DS:SuppressedPrefixes:GAUGE:600:U:100000000000
DS:WithdrawnPrefixes:GAUGE:600:U:100000000000 '.$config['rrd_rra'];
rrdtool_create($cbgp_rrd, $rrd_create);
}
+3 -3
View File
@@ -52,9 +52,9 @@ if ($device['os_group'] == 'cisco') {
if (!is_file($filename)) {
rrdtool_create(
$filename,
'--step 300 \
DS:drop:DERIVE:600:0:1000000 \
DS:punt:DERIVE:600:0:1000000 \
'--step 300
DS:drop:DERIVE:600:0:1000000
DS:punt:DERIVE:600:0:1000000
DS:hostpunt:DERIVE:600:0:1000000 '.$config['rrd_rra']
);
}
@@ -65,9 +65,9 @@ if ($device['os_group'] == 'cisco') {
if (!is_file($rrdfile)) {
rrdtool_create(
$rrdfile,
'DS:IN:COUNTER:600:0:12500000000 \
DS:OUT:COUNTER:600:0:12500000000 \
DS:PIN:COUNTER:600:0:12500000000 \
'DS:IN:COUNTER:600:0:12500000000
DS:OUT:COUNTER:600:0:12500000000
DS:PIN:COUNTER:600:0:12500000000
DS:POUT:COUNTER:600:0:12500000000 '.$config['rrd_rra']
);
}
+1 -1
View File
@@ -42,7 +42,7 @@ foreach (dbFetchRows('SELECT * FROM `slas` WHERE `device_id` = ? AND `deleted` =
if (!is_file($slarrd)) {
rrdtool_create(
$slarrd,
'--step 300 \
'--step 300
DS:rtt:GAUGE:600:0:300000 '.$config['rrd_rra']
);
}
+5 -5
View File
@@ -39,11 +39,11 @@ if ($device['os'] == 'ios') {
if (!is_file($rrd)) {
rrdtool_create(
$rrd,
'--step 300 \
DS:inutil:GAUGE:600:0:100 \
DS:oututil:GAUGE:600:0:100 \
DS:outdropped:DERIVE:600:0:125000000000 \
DS:outerrors:DERIVE:600:0:125000000000 \
'--step 300
DS:inutil:GAUGE:600:0:100
DS:oututil:GAUGE:600:0:100
DS:outdropped:DERIVE:600:0:125000000000
DS:outerrors:DERIVE:600:0:125000000000
DS:inerrors:DERIVE:600:0:125000000000 '.$config['rrd_rra']
);
}
+5 -8
View File
@@ -96,7 +96,7 @@ function poll_sensor($device, $class, $unit) {
if (!is_file($rrd_file)) {
rrdtool_create(
$rrd_file,
'--step 300 \
'--step 300
DS:sensor:GAUGE:600:-20000:20000 '.$config['rrd_rra']
);
}
@@ -119,12 +119,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'] === true) {
$memcache->set('sensor-'.$sensor['sensor_id'].'-value', $sensor_value);
}
else {
dbUpdate(array('sensor_current' => $sensor_value), 'sensors', '`sensor_class` = ? AND `sensor_id` = ?', array($class, $sensor['sensor_id']));
}
dbUpdate(array('sensor_current' => $sensor_value), 'sensors', '`sensor_class` = ? AND `sensor_id` = ?', array($class, $sensor['sensor_id']));
}//end foreach
}//end poll_sensor()
@@ -158,7 +153,9 @@ function poll_device($device, $options) {
echo "Created directory : $host_rrd\n";
}
$ping_response = isPingable($device['hostname'], $device['device_id']);
$address_family = snmpTransportToAddressFamily($device['transport']);
$ping_response = isPingable($device['hostname'], $address_family, $device['device_id']);
$device_perf = $ping_response['db'];
$device_perf['device_id'] = $device['device_id'];
+2 -2
View File
@@ -12,7 +12,7 @@ if (is_numeric($hrSystem[0]['hrSystemProcesses'])) {
if (!is_file($rrd_file)) {
rrdtool_create(
$rrd_file,
'--step 300 \
'--step 300
DS:procs:GAUGE:600:0:U '.$config['rrd_rra']
);
}
@@ -31,7 +31,7 @@ if (is_numeric($hrSystem[0]['hrSystemNumUsers'])) {
if (!is_file($rrd_file)) {
rrdtool_create(
$rrd_file,
'--step 300 \
'--step 300
DS:users:GAUGE:600:0:U '.$config['rrd_rra']
);
}
+1 -1
View File
@@ -36,7 +36,7 @@ if ($ipmi['host'] = get_dev_attrib($device, 'ipmi_hostname')) {
if (!is_file($rrd_file)) {
rrdtool_create(
$rrd_file,
'--step 300 \
'--step 300
DS:sensor:GAUGE:600:-20000:20000 '.$config['rrd_rra']
);
}
+9 -9
View File
@@ -36,15 +36,15 @@ if (count($vp_rows)) {
if (!is_file($rrd)) {
rrdtool_create(
$rrd,
'--step 300 \
DS:incells:DERIVE:600:0:125000000000 \
DS:outcells:DERIVE:600:0:125000000000 \
DS:inpackets:DERIVE:600:0:125000000000 \
DS:outpackets:DERIVE:600:0:125000000000 \
DS:inpacketoctets:DERIVE:600:0:125000000000 \
DS:outpacketoctets:DERIVE:600:0:125000000000 \
DS:inpacketerrors:DERIVE:600:0:125000000000 \
DS:outpacketerrors:DERIVE:600:0:125000000000 \
'--step 300
DS:incells:DERIVE:600:0:125000000000
DS:outcells:DERIVE:600:0:125000000000
DS:inpackets:DERIVE:600:0:125000000000
DS:outpackets:DERIVE:600:0:125000000000
DS:inpacketoctets:DERIVE:600:0:125000000000
DS:outpacketoctets:DERIVE:600:0:125000000000
DS:inpacketerrors:DERIVE:600:0:125000000000
DS:outpacketerrors:DERIVE:600:0:125000000000
'.$config['rrd_rra']
);
}
+1 -8
View File
@@ -47,14 +47,7 @@ foreach (dbFetchRows('SELECT * FROM mempools WHERE device_id = ?', array($device
$mempool['state']['mempool_lowestfree'] = $mempool['lowestfree'];
}
if ($config['memcached']['enable'] === true) {
d_echo($mempool['state']);
$memcache->set('mempool-'.$mempool['mempool_id'].'-value', $mempool['state']);
}
else {
dbUpdate($mempool['state'], 'mempools', '`mempool_id` = ?', array($mempool['mempool_id']));
}
dbUpdate($mempool['state'], 'mempools', '`mempool_id` = ?', array($mempool['mempool_id']));
echo "\n";
}//end foreach
+51
View File
@@ -10,6 +10,8 @@
* the source code distribution for details.
*/
global $config;
$oids = 'entPhysicalModelName.1 entPhysicalSoftwareRev.1 entPhysicalSerialNum.1';
$data = snmp_get_multi($device, $oids, '-OQUs', 'ENTITY-MIB');
@@ -29,3 +31,52 @@ if (isset($data[1]['entPhysicalModelName']) && $data[1]['entPhysicalModelName']
if (empty($hardware)) {
$hardware = snmp_get($device, 'sysObjectID.0', '-Osqv', 'SNMPv2-MIB:CISCO-PRODUCTS-MIB');
}
$oids_AP_Name = array(
'bsnAPName',
);
$oids_AP_Users = array(
'bsnApIfNoOfUsers',
);
foreach ($oids_AP_Name as $oid) {
$stats = snmpwalk_cache_oid($device, $oid, $stats, 'AIRESPACE-WIRELESS-MIB', null, '-OQUsxb');
}
foreach ($oids_AP_Users as $oid) {
$APstats = snmpwalk_cache_oid($device, $oid, $APstats, 'AIRESPACE-WIRELESS-MIB', null, '-OQUsxb');
}
$numAccessPoints = count($stats);
$numClients = 0;
foreach ($APstats as $key => $value) {
$numClients += $value['bsnApIfNoOfUsers'];
}
$rrdfile = $host_rrd.'/ciscowlc'.safename('.rrd');
if (!is_file($rrdfile)) {
rrdtool_create($rrdfile, ' --step 300 DS:NUMAPS:GAUGE:600:0:12500000000 DS:NUMCLIENTS:GAUGE:600:0:12500000000 '.$config['rrd_rra']);
}
$fields = array(
'NUMAPS' => $numAccessPoints,
'NUMCLIENTS' => $numClients
);
$ret = rrdtool_update($rrdfile, $fields);
// also save the info about how many clients in the same place as the wireless module
$wificlientsrrd = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('wificlients-radio1.rrd');
if (!is_file($wificlientsrrd)) {
rrdtool_create($wificlientsrrd, '--step 300 DS:wificlients:GAUGE:600:-273:10000 '.$config['rrd_rra']);
}
$fields = array(
'wificlients' => $numClients
);
rrdtool_update($wificlientsrrd, $fields);
$graphs['wifi_clients'] = true;
+1 -1
View File
@@ -39,7 +39,7 @@ if (is_numeric($FdbAddressCount)) {
if (!is_file($fdb_rrd_file)) {
rrdtool_create(
$fdb_rrd_file,
' --step 300 \
' --step 300
DS:value:GAUGE:600:-1:100000 '.$config['rrd_rra']
);
}
+3 -3
View File
@@ -12,9 +12,9 @@ list ($sessalloc, $sessmax, $sessfailed) = explode("\n", $sess_data);
if (!is_file($sessrrd)) {
rrdtool_create(
$sessrrd,
' --step 300 \
DS:allocate:GAUGE:600:0:3000000 \
DS:max:GAUGE:600:0:3000000 \
' --step 300
DS:allocate:GAUGE:600:0:3000000
DS:max:GAUGE:600:0:3000000
DS:failed:GAUGE:600:0:1000 '.$config['rrd_rra']
);
}
+5 -5
View File
@@ -27,11 +27,11 @@ $rrdfile = $config['rrd_dir'].'/'.$device['hostname'].'/data.rrd';
if (!is_file($rrdfile)) {
rrdtool_create(
$rrdfile,
'DS:INOCTETS:COUNTER:600:U:100000000000 \
DS:OUTOCTETS:COUNTER:600:U:10000000000 \
DS:INPKTS:COUNTER:600:U:10000000000 \
DS:OUTPKTS:COUNTER:600:U:10000000000 \
DS:CALLS:COUNTER:600:U:10000000000 \
'DS:INOCTETS:COUNTER:600:U:100000000000
DS:OUTOCTETS:COUNTER:600:U:10000000000
DS:INPKTS:COUNTER:600:U:10000000000
DS:OUTPKTS:COUNTER:600:U:10000000000
DS:CALLS:COUNTER:600:U:10000000000
DS:REGISTRATIONS:COUNTER:600:U:10000000000 '.$config['rrd_rra']
);
}
+13 -1
View File
@@ -78,7 +78,19 @@ elseif ($device['os'] == "freebsd") {
else {
$hardware = "i386";
}
$features = "GENERIC";
# Distro "extend" support
$features = snmp_get($device, ".1.3.6.1.4.1.2021.7890.1.3.1.1.6.100.105.115.116.114.111", "-Oqv", "UCD-SNMP-MIB");
$features = str_replace("\"", "", $features);
if (!$features) { # No "extend" support, try "exec" support
$features = snmp_get($device, ".1.3.6.1.4.1.2021.7890.1.101.1", "-Oqv", "UCD-SNMP-MIB");
$features = str_replace("\"", "", $features);
}
if (!$features) {
$features = 'GENERIC';
}
}
elseif ($device['os'] == "dragonfly") {
list(,,$version,,,$features,,$hardware) = explode (" ", $poll_device['sysDescr']);
+4 -4
View File
@@ -362,10 +362,10 @@ $filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('ospf-statis
if (!is_file($filename)) {
rrdtool_create(
$filename,
'--step 300 \
DS:instances:GAUGE:600:0:1000000 \
DS:areas:GAUGE:600:0:1000000 \
DS:ports:GAUGE:600:0:1000000 \
'--step 300
DS:instances:GAUGE:600:0:1000000
DS:areas:GAUGE:600:0:1000000
DS:ports:GAUGE:600:0:1000000
DS:neighbours:GAUGE:600:0:1000000 '.$config['rrd_rra']
);
}
+15 -56
View File
@@ -244,17 +244,6 @@ foreach ($ports as $port) {
$this_port['ifDescr'] = $matches[1];
}
if ($config['memcached']['enable'] === true) {
$state = $memcache->get('port-'.$port['port_id'].'-state');
d_echo($state);
if (is_array($state)) {
$port = array_merge($port, $state);
}
unset($state);
}
$polled_period = ($polled - $port['poll_time']);
$port['update'] = array();
@@ -266,12 +255,6 @@ foreach ($ports as $port) {
$port['update']['poll_period'] = $polled_period;
}
if ($config['memcached']['enable'] === true) {
$port['state']['poll_time'] = $polled;
$port['state']['poll_prev'] = $port['poll_time'];
$port['state']['poll_period'] = $polled_period;
}
// Copy ifHC[In|Out]Octets values to non-HC if they exist
if ($this_port['ifHCInOctets'] > 0 && is_numeric($this_port['ifHCInOctets']) && $this_port['ifHCOutOctets'] > 0 && is_numeric($this_port['ifHCOutOctets'])) {
echo 'HC ';
@@ -400,11 +383,6 @@ foreach ($ports as $port) {
$port['update'][$oid.'_prev'] = $port[$oid];
}
if ($config['memcached']['enable'] === true) {
$port['state'][$oid] = $this_port[$oid];
$port['state'][$oid.'_prev'] = $port[$oid];
}
$oid_prev = $oid.'_prev';
if (isset($port[$oid])) {
$oid_diff = ($this_port[$oid] - $port[$oid]);
@@ -422,11 +400,6 @@ foreach ($ports as $port) {
$port['update'][$oid.'_delta'] = $oid_diff;
}
if ($config['memcached']['enable'] === true) {
$port['state'][$oid.'_rate'] = $oid_rate;
$port['state'][$oid.'_delta'] = $oid_diff;
}
d_echo("\n $oid ($oid_diff B) $oid_rate Bps $polled_period secs\n");
}//end if
}//end foreach
@@ -451,13 +424,6 @@ foreach ($ports as $port) {
echo 'bytes('.formatStorage($port['stats']['ifInOctets_diff']).'/'.formatStorage($port['stats']['ifOutOctets_diff']).')';
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'] === 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']);
$port['state']['ifErrors_rate'] = ($port['stats']['ifOutErrors_rate'] + $port['stats']['ifInErrors_rate']);
}
// Port utilisation % threshold alerting. // FIXME allow setting threshold per-port. probably 90% of ports we don't care about.
if ($config['alerts']['port_util_alert'] && $port['ignore'] == '0') {
// Check for port saturation of $config['alerts']['port_util_perc'] or higher. Alert if we see this.
@@ -474,21 +440,21 @@ foreach ($ports as $port) {
if (!is_file($rrdfile)) {
rrdtool_create(
$rrdfile,
' --step 300 \
DS:INOCTETS:DERIVE:600:0:12500000000 \
DS:OUTOCTETS:DERIVE:600:0:12500000000 \
DS:INERRORS:DERIVE:600:0:12500000000 \
DS:OUTERRORS:DERIVE:600:0:12500000000 \
DS:INUCASTPKTS:DERIVE:600:0:12500000000 \
DS:OUTUCASTPKTS:DERIVE:600:0:12500000000 \
DS:INNUCASTPKTS:DERIVE:600:0:12500000000 \
DS:OUTNUCASTPKTS:DERIVE:600:0:12500000000 \
DS:INDISCARDS:DERIVE:600:0:12500000000 \
DS:OUTDISCARDS:DERIVE:600:0:12500000000 \
DS:INUNKNOWNPROTOS:DERIVE:600:0:12500000000 \
DS:INBROADCASTPKTS:DERIVE:600:0:12500000000 \
DS:OUTBROADCASTPKTS:DERIVE:600:0:12500000000 \
DS:INMULTICASTPKTS:DERIVE:600:0:12500000000 \
' --step 300
DS:INOCTETS:DERIVE:600:0:12500000000
DS:OUTOCTETS:DERIVE:600:0:12500000000
DS:INERRORS:DERIVE:600:0:12500000000
DS:OUTERRORS:DERIVE:600:0:12500000000
DS:INUCASTPKTS:DERIVE:600:0:12500000000
DS:OUTUCASTPKTS:DERIVE:600:0:12500000000
DS:INNUCASTPKTS:DERIVE:600:0:12500000000
DS:OUTNUCASTPKTS:DERIVE:600:0:12500000000
DS:INDISCARDS:DERIVE:600:0:12500000000
DS:OUTDISCARDS:DERIVE:600:0:12500000000
DS:INUNKNOWNPROTOS:DERIVE:600:0:12500000000
DS:INBROADCASTPKTS:DERIVE:600:0:12500000000
DS:OUTBROADCASTPKTS:DERIVE:600:0:12500000000
DS:INMULTICASTPKTS:DERIVE:600:0:12500000000
DS:OUTMULTICASTPKTS:DERIVE:600:0:12500000000 '.$config['rrd_rra']
);
}//end if
@@ -547,13 +513,6 @@ foreach ($ports as $port) {
include 'port-alcatel.inc.php';
}
// Update Memcached
if ($config['memcached']['enable'] === true) {
d_echo($port['state']);
$memcache->set('port-'.$port['port_id'].'-state', $port['state']);
}
foreach ($port['update'] as $key => $val_check) {
if (!isset($val_check)) {
unset($port['update'][$key]);
+1 -1
View File
@@ -16,7 +16,7 @@ foreach (dbFetchRows('SELECT * FROM processors WHERE device_id = ?', array($devi
if (!is_file($procrrd)) {
rrdtool_create(
$procrrd,
'--step 300 \
'--step 300
DS:usage:GAUGE:600:-273:1000 '.$config['rrd_rra']
);
}
+1 -10
View File
@@ -37,16 +37,7 @@ foreach (dbFetchRows('SELECT * FROM storage WHERE device_id = ?', array($device[
rrdtool_update($storage_rrd, $fields);
if ($config['memcached']['enable'] === true) {
$memcache->set('storage-'.$storage['storage_id'].'-used', $storage['used']);
$memcache->set('storage-'.$storage['storage_id'].'-free', $storage['free']);
$memcache->set('storage-'.$storage['storage_id'].'-size', $storage['size']);
$memcache->set('storage-'.$storage['storage_id'].'-units', $storage['units']);
$memcache->set('storage-'.$storage['storage_id'].'-perc', $percent);
}
else {
$update = dbUpdate(array('storage_used' => $storage['used'], 'storage_free' => $storage['free'], 'storage_size' => $storage['size'], 'storage_units' => $storage['units'], 'storage_perc' => $percent), 'storage', '`storage_id` = ?', array($storage['storage_id']));
}
$update = dbUpdate(array('storage_used' => $storage['used'], 'storage_free' => $storage['free'], 'storage_size' => $storage['size'], 'storage_units' => $storage['units'], 'storage_perc' => $percent), 'storage', '`storage_id` = ?', array($storage['storage_id']));
echo "\n";
}//end foreach
+1 -1
View File
@@ -23,7 +23,7 @@ if ($config['enable_printers']) {
if (!is_file($tonerrrd)) {
rrdtool_create(
$tonerrrd,
'--step 300 \
'--step 300
DS:toner:GAUGE:600:0:20000 '.$config['rrd_rra']
);
}
+4 -4
View File
@@ -24,10 +24,10 @@ if (count($diskio_data)) {
if (!is_file($rrd)) {
rrdtool_create(
$rrd,
'--step 300 \
DS:read:DERIVE:600:0:125000000000 \
DS:written:DERIVE:600:0:125000000000 \
DS:reads:DERIVE:600:0:125000000000 \
'--step 300
DS:read:DERIVE:600:0:125000000000
DS:written:DERIVE:600:0:125000000000
DS:reads:DERIVE:600:0:125000000000
DS:writes:DERIVE:600:0:125000000000 '.$config['rrd_rra']
);
}
+12 -12
View File
@@ -34,10 +34,10 @@ $ss = snmpwalk_cache_oid($device, 'systemStats', array(), 'UCD-SNMP-MIB');
$ss = $ss[0];
// Insert Nazi joke here.
// Create CPU RRD if it doesn't already exist
$cpu_rrd_create = ' --step 300 \
DS:user:COUNTER:600:0:U \
DS:system:COUNTER:600:0:U \
DS:nice:COUNTER:600:0:U \
$cpu_rrd_create = ' --step 300
DS:user:COUNTER:600:0:U
DS:system:COUNTER:600:0:U
DS:nice:COUNTER:600:0:U
DS:idle:COUNTER:600:0:U '.$config['rrd_rra'];
// This is how we currently collect. We should collect one RRD per stat, for ease of handling differen formats,
@@ -125,14 +125,14 @@ if (is_numeric($ss['ssRawInterrupts'])) {
// UCD-SNMP-MIB::memCached.0 = INTEGER: 2595556 kB
// UCD-SNMP-MIB::memSwapError.0 = INTEGER: noError(0)
// UCD-SNMP-MIB::memSwapErrorMsg.0 = STRING:
$mem_rrd_create = ' --step 300 \
DS:totalswap:GAUGE:600:0:10000000000 \
DS:availswap:GAUGE:600:0:10000000000 \
DS:totalreal:GAUGE:600:0:10000000000 \
DS:availreal:GAUGE:600:0:10000000000 \
DS:totalfree:GAUGE:600:0:10000000000 \
DS:shared:GAUGE:600:0:10000000000 \
DS:buffered:GAUGE:600:0:10000000000 \
$mem_rrd_create = ' --step 300
DS:totalswap:GAUGE:600:0:10000000000
DS:availswap:GAUGE:600:0:10000000000
DS:totalreal:GAUGE:600:0:10000000000
DS:availreal:GAUGE:600:0:10000000000
DS:totalfree:GAUGE:600:0:10000000000
DS:shared:GAUGE:600:0:10000000000
DS:buffered:GAUGE:600:0:10000000000
DS:cached:GAUGE:600:0:10000000000 '.$config['rrd_rra'];
$snmpdata = snmp_get_multi($device, 'memTotalSwap.0 memAvailSwap.0 memTotalReal.0 memAvailReal.0 memTotalFree.0 memShared.0 memBuffer.0 memCached.0', '-OQUs', 'UCD-SNMP-MIB');
+2 -2
View File
@@ -74,7 +74,7 @@ if ($device['type'] == 'network' || $device['type'] == 'firewall' || $device['ty
if (!is_file($wificlientsrrd)) {
rrdtool_create(
$wificlientsrrd,
'--step 300 \
'--step 300
DS:wificlients:GAUGE:600:-273:1000 '.$config['rrd_rra']
);
}
@@ -94,7 +94,7 @@ if ($device['type'] == 'network' || $device['type'] == 'firewall' || $device['ty
if (!is_file($wificlientsrrd)) {
rrdtool_create(
$wificlientsrrd,
'--step 300 \
'--step 300
DS:wificlients:GAUGE:600:-273:1000 '.$config['rrd_rra']
);
}
+2 -14
View File
@@ -166,7 +166,7 @@ function rrdtool_graph($graph_file, $options) {
function rrdtool($command, $filename, $options) {
global $config, $debug, $rrd_pipes, $console_color;
if ($command != 'create' && $config['rrdcached']) {
if ($config['rrdcached'] && ($config['rrdtool_version'] >= 1.5 || $command != "create")) {
if (isset($config['rrdcached_dir']) && $config['rrdcached_dir'] !== false) {
$filename = str_replace($config['rrd_dir'].'/', './'.$config['rrdcached_dir'].'/', $filename);
$filename = str_replace($config['rrd_dir'], './'.$config['rrdcached_dir'].'/', $filename);
@@ -206,19 +206,7 @@ function rrdtool($command, $filename, $options) {
function rrdtool_create($filename, $options) {
global $config, $console_color;
if ($config['norrd']) {
print $console_color->convert('[%gRRD Disabled%n] ', false);
}
else {
$command = $config['rrdtool']." create $filename $options";
}
d_echo($console_color->convert('RRD[%g'.$command.'%n] '));
return shell_exec($command);
return rrdtool('create', $filename, str_replace(array("\r", "\n"), '', $options));
}
+8
View File
@@ -52,6 +52,14 @@ elif [ "${OS}" = "Linux" ] ; then
elif [ -f /etc/os-release ] ; then
DIST=$(grep '^NAME=' /etc/os-release | cut -d= -f2- | tr -d '"')
REV=$(grep '^VERSION_ID=' /etc/os-release | cut -d= -f2- | tr -d '"')
elif [ -f /etc/openwrt_version ] ; then
DIST="OpenWrt"
REV=$(cat /etc/openwrt_version)
elif [ -f /etc/pld-release ] ; then
DIST=$(cat /etc/pld-release)
REV=""
fi
if [ -f /etc/lsb-release -a "${IGNORE_LSB}" != 1 ] ; then