Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #413 from f0o/issue-412
Added named/bind9 Application, Graphs, Check_MK-script
- Loading branch information
Showing
7 changed files
with
216 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>"; | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'])); | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|