nagios-dash
This commit is contained in:
parent
c55bee87fd
commit
dee322af88
|
@ -12,7 +12,7 @@ services:
|
||||||
build:
|
build:
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: nagios
|
container_name: nagios
|
||||||
image: docker-registry1.in.thelinuxpro.net:5000/tlp/nagios:241230.0.12
|
image: docker-registry1.in.thelinuxpro.net:5000/tlp/nagios:241230.0.13
|
||||||
networks:
|
networks:
|
||||||
infra_dev_net:
|
infra_dev_net:
|
||||||
ipv4_address: 10.99.23.36
|
ipv4_address: 10.99.23.36
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
$file = fopen("/var/cache/nagios3/status.dat", "r") or exit("Unable to open file!"); //path to nagios file
|
$file = fopen("/opt/nagios/var/status.dat", "r") or exit("Unable to open file!"); //path to nagios file
|
||||||
$refreshvalue = 10; //value in seconds to refresh page
|
$refreshvalue = 10; //value in seconds to refresh page
|
||||||
|
|
||||||
$collastcheck = true; //true/false to show last checked date column in table
|
$collastcheck = true; //true/false to show last checked date column in table
|
||||||
|
@ -12,7 +12,7 @@ $pagetitle = "Operations Nagios Dashboard";
|
||||||
$thedate = date('Y-m-d H:i:s');
|
$thedate = date('Y-m-d H:i:s');
|
||||||
$showthedate = false;
|
$showthedate = false;
|
||||||
?>
|
?>
|
||||||
<?php
|
<?php
|
||||||
//i may have missed some column displays here so add them in if you need them
|
//i may have missed some column displays here so add them in if you need them
|
||||||
if (($collastcheck == true) and ($colhost == true) and ($colstatusinfo == true) and ($colservice == false)) {
|
if (($collastcheck == true) and ($colhost == true) and ($colstatusinfo == true) and ($colservice == false)) {
|
||||||
echo("<table width=90% border=0 class=boldtable align=center>");
|
echo("<table width=90% border=0 class=boldtable align=center>");
|
||||||
|
@ -31,7 +31,7 @@ if (($collastcheck == true) and ($colhost == true) and ($colstatusinfo == true)
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<tr class="head">
|
<tr class="head">
|
||||||
<?php
|
<?php
|
||||||
if ($collastcheck == true) {
|
if ($collastcheck == true) {
|
||||||
echo("<th width=210>Last Checked</th>");
|
echo("<th width=210>Last Checked</th>");
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ if (($collastcheck == true) and ($colhost == true) and ($colstatusinfo == true)
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
function dashdisplay($dashline, $collastcheck, $colhost, $colstatusinfo, $colservice) { //function to display array data into table with colors/font etc
|
function dashdisplay($dashline, $collastcheck, $colhost, $colstatusinfo, $colservice) { //function to display array data into table with colors/font etc
|
||||||
|
|
||||||
$dashstatus = substr($dashline, 0, strpos($dashline, ','));
|
$dashstatus = substr($dashline, 0, strpos($dashline, ','));
|
||||||
|
@ -71,26 +71,26 @@ function dashdisplay($dashline, $collastcheck, $colhost, $colstatusinfo, $colser
|
||||||
}
|
}
|
||||||
$dashack = substr($dashline, 0, strpos($dashline, ','));
|
$dashack = substr($dashline, 0, strpos($dashline, ','));
|
||||||
$dashline = substr($dashline, strpos($dashline, ',') + 1, strlen($dashline));
|
$dashline = substr($dashline, strpos($dashline, ',') + 1, strlen($dashline));
|
||||||
|
|
||||||
if ($dashack == "") { //if somehow the acknowledgement state is blank, set it to 0 (acknowledged)
|
if ($dashack == "") { //if somehow the acknowledgement state is blank, set it to 0 (acknowledged)
|
||||||
$dashack = 0;
|
$dashack = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dashdate = substr($dashline, 0, strpos($dashline, ',') - 1);
|
$dashdate = substr($dashline, 0, strpos($dashline, ',') - 1);
|
||||||
$dashline = substr($dashline, strpos($dashline, ',') + 1, strlen($dashline));
|
$dashline = substr($dashline, strpos($dashline, ',') + 1, strlen($dashline));
|
||||||
|
|
||||||
$dashhost = substr($dashline, 0, strpos($dashline, ',') - 1);
|
$dashhost = substr($dashline, 0, strpos($dashline, ',') - 1);
|
||||||
$dashline = substr($dashline, strpos($dashline, ',') + 1, strlen($dashline));
|
$dashline = substr($dashline, strpos($dashline, ',') + 1, strlen($dashline));
|
||||||
|
|
||||||
$dashplugin = substr($dashline, 0, strrpos($dashline, ',') - 1);
|
$dashplugin = substr($dashline, 0, strrpos($dashline, ',') - 1);
|
||||||
$dashline = substr($dashline, strrpos($dashline, ',') + 1, strlen($dashline));
|
$dashline = substr($dashline, strrpos($dashline, ',') + 1, strlen($dashline));
|
||||||
|
|
||||||
$dashservice = $dashline;
|
$dashservice = $dashline;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<?php if($dashack == 0): ?>
|
<?php if($dashack == 0): ?>
|
||||||
<tr class="<?php print $trclass ?>">
|
<tr class="<?php print $trclass ?>">
|
||||||
<?php
|
<?php
|
||||||
if ($collastcheck == true) {
|
if ($collastcheck == true) {
|
||||||
echo("<td>".date("Y-m-d H:i:s", $dashdate)."</td>");
|
echo("<td>".date("Y-m-d H:i:s", $dashdate)."</td>");
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ function dashdisplay($dashline, $collastcheck, $colhost, $colstatusinfo, $colser
|
||||||
}
|
}
|
||||||
endif; ?>
|
endif; ?>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
} //end display function
|
} //end display function
|
||||||
|
|
||||||
//arrays for different fields in nagios status.dat
|
//arrays for different fields in nagios status.dat
|
||||||
|
@ -153,7 +153,7 @@ $critcount = 0;
|
||||||
|
|
||||||
while (!feof($file)) { //begin while through nagios status.dat
|
while (!feof($file)) { //begin while through nagios status.dat
|
||||||
$line = fgets($file);
|
$line = fgets($file);
|
||||||
|
|
||||||
//strpos to check for field line by line
|
//strpos to check for field line by line
|
||||||
$hostpos = strpos($line, $hostname);
|
$hostpos = strpos($line, $hostname);
|
||||||
$servicepos = strpos($line, $servicedes);
|
$servicepos = strpos($line, $servicedes);
|
||||||
|
@ -162,31 +162,31 @@ while (!feof($file)) { //begin while through nagios status.dat
|
||||||
$lastpos = strpos($line, $lastcheck);
|
$lastpos = strpos($line, $lastcheck);
|
||||||
$dispos = strpos($line, $discheck);
|
$dispos = strpos($line, $discheck);
|
||||||
$ackpos = strpos($line, $ackcheck);
|
$ackpos = strpos($line, $ackcheck);
|
||||||
|
|
||||||
if ($hostpos !== false) {
|
if ($hostpos !== false) {
|
||||||
$hostcount++;
|
$hostcount++;
|
||||||
$hostarray[$hostcount] = substr($line, strpos($line, '=') + 1, strlen($line));
|
$hostarray[$hostcount] = substr($line, strpos($line, '=') + 1, strlen($line));
|
||||||
$check = 1;
|
$check = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$check = 0;
|
$check = 0;
|
||||||
|
|
||||||
if ($servicepos !== false) {
|
if ($servicepos !== false) {
|
||||||
$servicecount++;
|
$servicecount++;
|
||||||
$servicearray[$servicecount] = substr($line, strpos($line, '=') + 1, strlen($line));
|
$servicearray[$servicecount] = substr($line, strpos($line, '=') + 1, strlen($line));
|
||||||
$check = 1;
|
$check = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$check = 0;
|
$check = 0;
|
||||||
|
|
||||||
if ($currpos !== false) {
|
if ($currpos !== false) {
|
||||||
$currcount++;
|
$currcount++;
|
||||||
$statearray[$currcount] = substr($line, strpos($line, '=') + 1, strlen($line));
|
$statearray[$currcount] = substr($line, strpos($line, '=') + 1, strlen($line));
|
||||||
$check = 1;
|
$check = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$check = 0;
|
$check = 0;
|
||||||
|
|
||||||
if ($plugpos !== false) {
|
if ($plugpos !== false) {
|
||||||
if (strpos($line, "long_plugin_output=") === false) {
|
if (strpos($line, "long_plugin_output=") === false) {
|
||||||
$plugcount++;
|
$plugcount++;
|
||||||
|
@ -194,33 +194,33 @@ while (!feof($file)) { //begin while through nagios status.dat
|
||||||
$check = 1;
|
$check = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$check = 0;
|
$check = 0;
|
||||||
|
|
||||||
if ($lastpos !== false) {
|
if ($lastpos !== false) {
|
||||||
$lastcount++;
|
$lastcount++;
|
||||||
$checkarray[$lastcount] = substr($line, strpos($line, '=') + 1, strlen($line));
|
$checkarray[$lastcount] = substr($line, strpos($line, '=') + 1, strlen($line));
|
||||||
$check = 1;
|
$check = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$check = 0;
|
$check = 0;
|
||||||
|
|
||||||
if ($servicearray[$servicecount] != "") { //if the host has a service being checked
|
if ($servicearray[$servicecount] != "") { //if the host has a service being checked
|
||||||
if ($dispos !== false) {
|
if ($dispos !== false) {
|
||||||
$discount++;
|
$discount++;
|
||||||
$disarray[$discount] = substr($line, strpos($line, '=') + 1, strlen($line));
|
$disarray[$discount] = substr($line, strpos($line, '=') + 1, strlen($line));
|
||||||
$check = 1;
|
$check = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$check = 0;
|
$check = 0;
|
||||||
|
|
||||||
if ($ackpos !== false) {
|
if ($ackpos !== false) {
|
||||||
$ackcount++;
|
$ackcount++;
|
||||||
$ackarray[$ackcount] = substr($line, strpos($line, '=') + 1, strlen($line));
|
$ackarray[$ackcount] = substr($line, strpos($line, '=') + 1, strlen($line));
|
||||||
$check = 1;
|
$check = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($servicearray[$servicecount] == "") { //if the host has no service being checked
|
if ($servicearray[$servicecount] == "") { //if the host has no service being checked
|
||||||
if ($ackpos !== false) {
|
if ($ackpos !== false) {
|
||||||
$ackcount++;
|
$ackcount++;
|
||||||
|
|
Loading…
Reference in New Issue