Merge master; resolve doc/Extensions/Agent-Setup.md conflict

This commit is contained in:
Paul Gear
2015-01-22 20:40:27 +10:00
20 changed files with 693 additions and 29 deletions
+54
View File
@@ -35,3 +35,57 @@ mkdir -p /usr/lib/check_mk_agent/plugins /usr/lib/check_mk_agent/local
* Then under Applications, enable the apps that you plan to monitor.
* Wait, in around 10 minutes you should start seeing data in your graphs under Apps for the device.
## Application Specific Configuration
### BIND9/named
Create stats file with appropriate permissions:
```shell
~$ touch /etc/bind/named.stats
~$ chown bind:bind /etc/bind/named.stats
```
Change `user:group` to the user and group that's running bind/named.
Bind/named configuration:
```text
options {
...
statistics-file "/etc/bind/named.stats";
zone-statistics yes;
...
};
```
Restart your bind9/named after changing the configuration.
Verify that everything works by executing `rdnc stats && cat /etc/bind/named.stats`.
In case you get a `Permission Denied` error, make sure you chown'ed correctly.
Note: if you change the path you will need to change the path in `scripts/agent-local/bind`.
### TinyDNS/djbdns
__Installation__:
1. Get tinystats sources from http://www.morettoni.net/tinystats.en.html
2. Compile like as advised.
_Note_: In case you get `Makefile:9: *** missing separator. Stop.`, compile manually using:
* With IPv6: `gcc -Wall -O2 -fstack-protector -DWITH_IPV6 -o tinystats tinystats.c`
* Without IPv6: `gcc -Wall -O2 -fstack-protector -o tinystats tinystats.c`
3. Install into prefered path, like `/usr/bin/`.
__Configuration__:
_Note_: In this part we assume that you use DJB's [Daemontools](http://cr.yp.to/daemontools.html) to start/stop tinydns.
And that your tinydns-instance is located in `/service/dns`, adjust this path if necesary.
1. Replace your _log_'s `run` file, typically located in `/service/dns/log/run` with:
```
#!/bin/sh
exec setuidgid dnslog tinystats ./main/tinystats/ multilog t n3 s250000 ./main/
```
2. Create tinystats directory and chown:
`mkdir /service/dns/log/main/tinystats && chown dnslog:nofiles /service/dns/log/main/tinystats`
3. Restart TinyDNS and Daemontools: `/etc/init.d/svscan restart`
_Note_: Some say `svc -t /service/dns` is enough, on my install (Gentoo) it doesnt rehook the logging and I'm forced to restart it entirely.
@@ -0,0 +1,50 @@
<?php
/* Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/**
* Bind9 Query Graph
* @author Daniel Preussker <f0o@devilcode.org>
* @copyright 2015 f0o, LibreNMS
* @license GPL
* @package LibreNMS
* @subpackage Graphs
*/
include("includes/graphs/common.inc.php");
$i = 0;
$scale_min = 0;
$nototal = 1;
$unit_text = "Query/sec";
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-bind-".$app['app_id'].".rrd";
$array = array( 'any', 'a', 'aaaa', 'cname', 'mx', 'ns', 'ptr', 'soa', 'srv', 'spf' );
$colours = "merged";
$rrd_list = array();
$config['graph_colours']['merged'] = array_merge($config['graph_colours']['greens'], $config['graph_colours']['blues']);
if( is_file($rrd_filename) ) {
foreach( $array as $ds ) {
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = strtoupper($ds);
$rrd_list[$i]['ds'] = $ds;
$i++;
}
} else {
echo "file missing: $file";
}
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
?>
@@ -0,0 +1,49 @@
<?php
/* Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/**
* TinyDNS DNSSec Graph
* @author Daniel Preussker <f0o@devilcode.org>
* @copyright 2015 f0o, LibreNMS
* @license GPL
* @package LibreNMS
* @subpackage Graphs
*/
include("includes/graphs/common.inc.php");
$i = 0;
$scale_min = 0;
$nototal = 1;
$unit_text = "Query/sec";
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-tinydns-".$app['app_id'].".rrd";
//$array = explode(":","hinfo:rp:sig:key:axfr:total");
$array = array( "key", "sig" );
$colours = "mixed";
$rrd_list = array();
if( is_file($rrd_filename) ) {
foreach( $array as $ds ) {
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = strtoupper($ds);
$rrd_list[$i]['ds'] = $ds;
$i++;
}
} else {
echo "file missing: $file";
}
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
?>
@@ -0,0 +1,48 @@
<?php
/* Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/**
* TinyDNS Error Graph
* @author Daniel Preussker <f0o@devilcode.org>
* @copyright 2015 f0o, LibreNMS
* @license GPL
* @package LibreNMS
* @subpackage Graphs
*/
include("includes/graphs/common.inc.php");
$i = 0;
$scale_min = 0;
$nototal = 1;
$unit_text = "Query/sec";
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-tinydns-".$app['app_id'].".rrd";
$array = array( "notauth", "notimpl", "badclass", "noquery" );
$colours = "oranges";
$rrd_list = array();
if( is_file($rrd_filename) ) {
foreach( $array as $ds ) {
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = strtoupper($ds);
$rrd_list[$i]['ds'] = $ds;
$i++;
}
} else {
echo "file missing: $file";
}
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
?>
@@ -0,0 +1,48 @@
<?php
/* Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/**
* TinyDNS Other Graph
* @author Daniel Preussker <f0o@devilcode.org>
* @copyright 2015 f0o, LibreNMS
* @license GPL
* @package LibreNMS
* @subpackage Graphs
*/
include("includes/graphs/common.inc.php");
$i = 0;
$scale_min = 0;
$nototal = 1;
$unit_text = "Query/sec";
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-tinydns-".$app['app_id'].".rrd";
$array = array( "other", "hinfo", "rp", "axfr" );
$colours = "mixed";
$rrd_list = array();
if( is_file($rrd_filename) ) {
foreach( $array as $ds ) {
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = strtoupper($ds);
$rrd_list[$i]['ds'] = $ds;
$i++;
}
} else {
echo "file missing: $file";
}
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
?>
@@ -0,0 +1,51 @@
<?php
/* Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/**
* TinyDNS Query Graph
* @author Daniel Preussker <f0o@devilcode.org>
* @copyright 2015 f0o, LibreNMS
* @license GPL
* @package LibreNMS
* @subpackage Graphs
*/
include("includes/graphs/common.inc.php");
$i = 0;
$scale_min = 0;
$nototal = 1;
$unit_text = "Query/sec";
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-tinydns-".$app['app_id'].".rrd";
//$array = explode(":","hinfo:rp:sig:key:axfr:total");
$array = array( "any", "a", "aaaa", "cname", "mx", "ns", "ptr", "soa", "txt" );
$colours = "merged";
$rrd_list = array();
$config['graph_colours']['merged'] = array_merge($config['graph_colours']['greens'], $config['graph_colours']['blues']);
if( is_file($rrd_filename) ) {
foreach( $array as $ds ) {
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = strtoupper($ds);
$rrd_list[$i]['ds'] = $ds;
$i++;
}
} else {
echo "file missing: $file";
}
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
?>
+6 -5
View File
@@ -291,22 +291,23 @@ if (is_array($pagetitle))
echo("<script type=\"text/javascript\">\ndocument.title = '$title';\n</script>");
}
?>
<?php
if($config['enable_footer'] == 1) {
?>
<footer>
<div class="container">
<div class="row">
<div class="col-md-12 text-center">
<?php
echo(' <br /> <br /> ' . (isset($config['footer']) ? $config['footer'] : ''));
echo(' <br />Powered by <a href="' . $config['project_url'] . '" target="_blank">' . $config['project_name_version'].'</a>.<br/>');
echo( $config['project_name'].' is <a href="http://www.gnu.org/philosophy/free-sw.html">Free Software</a>, released under the <a href="http://www.gnu.org/copyleft/gpl.html">GNU GPLv3</a>.<br/>');
echo(' Copyright &copy; 2013-'.date("Y").' by the '.$config['project_name'].' Contributors.<br/>');
echo(' Copyright &copy; 2006-2012 by Adam Armstrong.');
echo('<em> Powered by <a href="/about/" target="_blank">' . $config['project_name'].'</a>.</em><br/>');
?>
</div>
</div>
</div>
</footer>
<?php
}
if(is_array($msg_box)) {
echo("<script>
+20 -20
View File
@@ -19,7 +19,6 @@ $git_log = `git log -10`;
</div>
<div style="margin: 10px;">
<div style="float: right; padding: 0px; width: 49%">
<?php print_optionbar_start(NULL); ?>
<h3>License</h3>
<pre>
Copyright (C) 2006-2012 Adam Armstrong
@@ -37,11 +36,9 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>.</pre>
<?php print_optionbar_end(); ?>
&nbsp;
<?php print_optionbar_start(NULL); ?>
<h3>Statistics</h3>
@@ -71,10 +68,11 @@ $stat_vrf = dbFetchCell("SELECT COUNT(vrf_id) FROM `vrfs`");
$stat_vlans = dbFetchCell("SELECT COUNT(vlan_id) FROM `vlans`");
echo("
<table width=95% cellpadding=5 cellspacing=0>
<div class='table-responsive'>
<table class='table table-condensed'>
<tr>
<td width=45%><img src='images/icons/device.png' class='optionicon'> <b>Devices</b></td><td align=right>$stat_devices</td>
<td width=45%><img src='images/icons/port.png' class='optionicon'> <b>Ports</b></td><td align=right>$stat_ports</td>
<td><img src='images/icons/device.png' class='optionicon'> <b>Devices</b></td><td align=right>$stat_devices</td>
<td><img src='images/icons/port.png' class='optionicon'> <b>Ports</b></td><td align=right>$stat_ports</td>
</tr>
<tr>
<td><img src='images/icons/ipv4.png' class='optionicon'> <b>IPv4 Addresses<b></td><td align=right>$stat_ipv4_addy</td>
@@ -109,9 +107,10 @@ echo("
<td><img src='images/icons/toner.png' class='optionicon'> <b>Toner</b></td><td align=right>$stat_toner</td>
</tr>
</table>
</div>
");
print_optionbar_end(); ?>
?>
</div>
<div style="float: left; padding: 0px; width: 49%">
@@ -127,29 +126,30 @@ $mysql_version = dbFetchCell("SELECT version()");
$netsnmp_version = shell_exec($config['snmpget'] . " --version 2>&1");
$rrdtool_version = implode(" ",array_slice(explode(" ",shell_exec($config['rrdtool'] . " --version |head -n1")),1,1));
$schema_version = dbFetchCell("SELECT version FROM dbSchema");
$git_log = `git log -10`;
$version = `git rev-parse --short HEAD`;
print_optionbar_start(NULL);
echo("
<table width=100% cellpadding=3 cellspacing=0 border=0>
<tr valign=top><td width=150><b>$project_name</b></td><td><a href='http://www.librenms.org/changelog.html'>$project_version</a></td></tr>
<tr valign=top><td><b>DB Schema</b></td><td>#$schema_version</td></tr>
<tr valign=top><td><b>Apache</b></td><td>$apache_version</td></tr>
<tr valign=top><td><b>PHP</b></td><td>$php_version</td></tr>
<tr valign=top><td><b>MySQL</b></td><td>$mysql_version</td></tr>
<tr valign=top><td><b>RRDtool</b></td><td>$rrdtool_version</td></tr>
<div class='table-responsive'>
<table class='table table-condensed' border='0'>
<tr><td><b>Version</b></td><td><a href='http://www.librenms.org/changelog.html'>$version</a></td></tr>
<tr><td><b>DB Schema</b></td><td>#$schema_version</td></tr>
<tr><td><b>Apache</b></td><td>$apache_version</td></tr>
<tr><td><b>PHP</b></td><td>$php_version</td></tr>
<tr><td><b>MySQL</b></td><td>$mysql_version</td></tr>
<tr><td><b>RRDtool</b></td><td>$rrdtool_version</td></tr>
</table>
</div>
");
print_optionbar_end();
?>
<h5>LibreNMS is a community-based project. Please feel free to join us and contribute code, documentation, and bug reports:</h5>
<p>
<a href="https://github.com/librenms/">Web site</a> |
<a href="http://www.librenms.org/">Web site</a> |
<a href="https://github.com/librenms/">GitHub</a> |
<a href="https://github.com/librenms/librenms/issues">Bug tracker</a> |
<a href="https://groups.google.com/forum/#!forum/librenms-project">Mailing list</a> |
<a href="http://twitter.com/librenms">Twitter</a> |
@@ -160,12 +160,12 @@ print_optionbar_end();
<div style="margin-top:10px;">
</div>
<h4>The Team</h4>
<h3>The Team</h3>
<img src="images/icons/flags/au.png"> <strong>Paul Gear</strong> Project Founder<br />
<img src="images/icons/flags/us.png"> <strong>Tyler Christiansen</strong> Developer<br />
<h4>Acknowledgements</h4>
<h3>Acknowledgements</h3>
<b>Observium</b> Codebase for fork. <br />
<b>Mark James</b> Silk Iconset. <br />
+2
View File
@@ -5,6 +5,8 @@ $graphs['drbd'] = array('disk_bits', 'network_bits', 'queue', 'unsynced');
$graphs['mysql'] = array('network_traffic', 'connections', 'command_counters', 'select_types');
$graphs['memcached'] = array('bits', 'commands', 'data', 'items');
$graphs['nginx'] = array('connections', 'req');
$graphs['bind'] = array('queries');
$graphs['tinydns'] = array('queries', 'errors', 'dnssec', 'other');
print_optionbar_start();
+9
View File
@@ -82,6 +82,15 @@ if (device_permitted($vars['device']) || $check_device == $vars['device'])
</li>');
}
if (@dbFetchCell("SELECT 1 FROM processes WHERE device_id = '" . $device['device_id'] . "'") > '0')
{
echo('<li class="' . $select['processes'] . '">
<a href="'.generate_device_url($device, array('tab' => 'processes')).'">
<img src="images/16/application_osx_terminal.png" align="absmiddle" border="0" /> Processes
</a>
</li>');
}
if (isset($config['collectd_dir']) && is_dir($config['collectd_dir'] . "/" . $device['hostname'] ."/"))
{
echo('<li class="' . $select['collectd'] . '">
+38
View File
@@ -0,0 +1,38 @@
<?php
/* Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/**
* Bind9 Application
* @author Daniel Preussker <f0o@devilcode.org>
* @copyright 2015 f0o, LibreNMS
* @license GPL
* @package LibreNMS
* @subpackage Apps
*/
global $config;
$graphs = array('bind_queries' => 'Queries');
foreach( $graphs as $key => $text ) {
$graph_type = $key;
$graph_array['height'] = "100";
$graph_array['width'] = "215";
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = "application_".$key;
echo "<h3>$text</h3><tr bgcolor='$row_colour'><td colspan=5>";
include("includes/print-graphrow.inc.php");
echo "</td></tr>";
}
?>
+38
View File
@@ -0,0 +1,38 @@
<?php
/* Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/**
* TinyDNS Application
* @author Daniel Preussker <f0o@devilcode.org>
* @copyright 2015 f0o, LibreNMS
* @license GPL
* @package LibreNMS
* @subpackage Apps
*/
global $config;
$graphs = array('tinydns_queries' => 'Queries', 'tinydns_errors' => 'Errors', 'tinydns_dnssec' => 'DNSSec', 'tinydns_other' => 'Other');
foreach( $graphs as $key => $text ) {
$graph_type = $key;
$graph_array['height'] = "100";
$graph_array['width'] = "215";
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = "application_".$key;
echo "<h3>$text</h3><tr bgcolor='$row_colour'><td colspan=5>";
include("includes/print-graphrow.inc.php");
echo "</td></tr>";
}
?>
+98
View File
@@ -0,0 +1,98 @@
<?php
/* Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/**
* Process Listing
* @author Daniel Preussker <f0o@devilcode.org>
* @copyright 2015 f0o, LibreNMS
* @license GPL
* @package LibreNMS
* @subpackage Pages
*/
switch( $vars['order'] ) {
case "vsz":
$order = "`vsz`";
break;
case "rss":
$order = "`rss`";
break;
case "cputime":
$order = "`cputime`";
break;
case "user":
$order = "`user`";
break;
case "command":
$order = "`command`";
break;
default:
$order = "`pid`";
break;
}
if( $vars['by'] == "desc" ) {
$by = "desc";
} else {
$by = "asc";
}
$heads = array(
'PID' => '',
'VSZ' => 'Virtual Memory',
'RSS' => 'Resident Memory',
'cputime' => '',
'user' => '',
'command' => ''
);
echo "<div class='table-responsive'><table class='table table-hover'><thead><tr>";
foreach( $heads as $head=>$extra ) {
unset($lhead, $bhead);
$lhead = strtolower($head);
$bhead = 'asc';
$icon = "";
if( '`'.$lhead.'`' == $order ) {
$icon = " class='glyphicon glyphicon-chevron-";
if( $by == 'asc' ) {
$bhead = 'desc';
$icon .= 'up';
} else {
$icon .= 'down';
}
$icon .= "'";
}
echo '<th><a href="/device/device='.$device['device_id'].'/tab=processes/order='.$lhead.'/by='.$bhead.'"><span'.$icon.'>&nbsp;';
if( !empty($extra) ) {
echo "<abbr title='$extra'>$head</abbr>";
} else {
echo $head;
}
echo '</span></a></th>';
}
echo "</tr></thead><tbody>";
foreach (dbFetchRows("SELECT * FROM `processes` WHERE `device_id` = ? ORDER BY ".$order." ".$by, array($device['device_id'])) as $entry) {
echo '<tr>';
echo '<td>'.$entry['pid'].'</td>';
echo '<td>'.format_si($entry['vsz']*1024).'</td>';
echo '<td>'.format_si($entry['rss']*1024).'</td>';
echo '<td>'.$entry['cputime'].'</td>';
echo '<td>'.$entry['user'].'</td>';
echo '<td>'.$entry['command'].'</td>';
echo '</tr>';
}
echo"</tbody></table></div>";
?>
+2
View File
@@ -585,4 +585,6 @@ $config['dateformat']['time'] = "H:i:s";
$config['enable_clear_discovery'] = 1;// Set this to 0 if you want to disable the web option to rediscover devices
$config['enable_footer'] = 1;// Set this to 0 if you want to disable the footer copyright in the web interface
?>
@@ -0,0 +1,79 @@
<?php
/* Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/**
* Bind9 Statistics
* @author Daniel Preussker <f0o@devilcode.org>
* @copyright 2015 f0o, LibreNMS
* @license GPL
* @package LibreNMS
* @subpackage Polling
*/
if( !empty($agent_data['app']['bind']) && $app['app_id'] > 0 ) {
echo " bind ";
$bind = $agent_data['app']['bind'];
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-bind-".$app['app_id'].".rrd";
$bind_parsed = array();
$prefix = "";
foreach( explode("\n",$bind) as $line ) {
$pattern = '/^\+\+ ([^+]+) \+\+$/';
preg_match($pattern, $line, $matches);
if( !empty($matches) ) {
$prefix = str_replace(" ","_",strtolower($matches[1]));
$view = $item = $cnt = "";
}
$pattern = '/^\[View: (\w+)(| .*)\]/';
preg_match($pattern, $line, $matches);
if( !empty($matches) ) {
if( $matches[1] == "default" ) {
continue;
} else {
$view = $matches[1];
}
}
$pattern = '/^\[(.*)\]$/';
preg_match($pattern, $line, $matches);
if( !empty($matches) ) {
$prefix = $matches[1];
}
$pattern = '/^\s+(\d+) ([^\n]+)/';
preg_match($pattern, $line, $matches);
if( !empty($matches) ) {
$cnt = str_replace(" ","_",strtolower($matches[1]));
$item = str_replace(" ","_",strtolower($matches[2]));
if( !empty($view) ) {
$bind_parsed[$prefix][$view][$item] = $cnt;
} else {
$bind_parsed[$prefix][$item] = $cnt;
}
}
}
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 \
DS:spf:COUNTER:600:0:125000000000 ".$config['rrd_rra']);
}
rrdtool_update($rrd_filename, "N:".((int) $bind_parsed['incoming_queries']['any']).":".((int) $bind_parsed['incoming_queries']['a']).":".((int) $bind_parsed['incoming_queries']['aaaa']).":".((int) $bind_parsed['incoming_queries']['cname']).":".((int) $bind_parsed['incoming_queries']['mx']).":".((int) $bind_parsed['incoming_queries']['ns']).":".((int) $bind_parsed['incoming_queries']['ptr']).":".((int) $bind_parsed['incoming_queries']['soa']).":".((int) $bind_parsed['incoming_queries']['srv']).":".((int) $bind_parsed['incoming_queries']['spf']));
}
?>
@@ -0,0 +1,53 @@
<?php
/* Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/**
* TinyDNS Statistics
* @author Daniel Preussker <f0o@devilcode.org>
* @copyright 2015 f0o, LibreNMS
* @license GPL
* @package LibreNMS
* @subpackage Polling
*/
if( !empty($agent_data['app']['tinydns']) && $app['app_id'] > 0 ) {
echo " tinydns ";
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-tinydns-".$app['app_id'].".rrd";
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 \
DS:noquery:COUNTER:600:0:125000000000 ".$config['rrd_rra']);
}
rrdtool_update($rrd_filename, "N:".$agent_data['app']['tinydns']);
}
?>
+8 -4
View File
@@ -43,6 +43,8 @@ if ($device['os_group'] == "unix")
if ($section == "apache") { $sa = "app"; $sb = "apache"; }
if ($section == "mysql") { $sa = "app"; $sb = "mysql"; }
if ($section == "nginx") { $sa = "app"; $sb = "nginx"; }
if ($section == "bind") { $sa = "app"; $sb = "bind"; }
if ($section == "tinydns") { $sa = "app"; $sb = "tinydns"; }
# if ($section == "drbd") { $sa = "app"; $sb = "drbd"; }
if (!empty($sa) && !empty($sb))
@@ -82,13 +84,15 @@ if ($device['os_group'] == "unix")
if (!empty($agent_data['ps']))
{
echo("Processes: ");
dbDelete('processes', 'device_id = ?', array($device['device_id']));
foreach (explode("\n", $agent_data['ps']) as $process)
{
$process = preg_replace("/\((.*),([0-9]*),([0-9]*),([0-9\.]*)\)\ (.*)/", "\\1|\\2|\\3|\\4|\\5", $process);
list($user, $vsz, $rss, $pcpu, $command) = explode("|", $process, 5);
$processlist[] = array('user' => $user, 'vsz' => $vsz, 'rss' => $rss, 'pcpu' => $pcpu, 'command' => $command);
$process = preg_replace("/\((.*),([0-9]*),([0-9]*),([0-9\:]*),([0-9]*)\)\ (.*)/", "\\1|\\2|\\3|\\4|\\5|\\6", $process);
list($user, $vsz, $rss, $cputime, $pid, $command) = explode("|", $process, 6);
if( !empty($command) ) {
dbInsert(array('device_id' => $device['device_id'], 'pid' => $pid, 'user' => $user, 'vsz' => $vsz, 'rss' => $rss, 'cputime' => $cputime, 'command' => $command), 'processes');
}
}
#print_r($processlist);
echo("\n");
}
+21
View File
@@ -0,0 +1,21 @@
#!/bin/bash
# (c) 2015, f0o@devilcode.org
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
stats="/etc/bind/named.stats"
echo "<<<bind>>>"
> $stats
rndc stats && cat $stats
+18
View File
@@ -0,0 +1,18 @@
#!/bin/bash
# (c) 2015, f0o@devilcode.org
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
echo "<<<tinydns>>>"
head -n1 /service/dns/log/main/tinystats/tinystats.out
+1
View File
@@ -0,0 +1 @@
CREATE TABLE IF NOT EXISTS `processes` ( `device_id` int(11) NOT NULL, `pid` int(255) NOT NULL, `vsz` int(255) NOT NULL, `rss` int(255) NOT NULL, `cputime` varchar(12) NOT NULL, `user` varchar(50) NOT NULL, `command` varchar(255) NOT NULL, KEY `device_id` (`device_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;