change order, report name, add svc status filter

master
Bryan Heden 4 years ago
parent eda2466c6e
commit 42a5481441

@ -0,0 +1,14 @@
# 0.0.1
> 08 Aug 2021
* Change name of report to "Day-Night No Transition"
* Add `$filter_services` global variable in `index.php` to allow for matching service statuses to be filtered against
* With default value of "plugin timed out" (anything matching this text will be filtered out of the final services)
* Change order of report
# 0.0.0
> 31 Jul 2021
* Initial version

@ -10,6 +10,8 @@ check_authentication(false);
generate_report();
$filter_services = array("plugin timed out");
function generate_report()
{
@ -24,6 +26,9 @@ Light Mode Night
The report would show:
Host Name, Host Address, Service Description, Status Information, and Duration (hours)
Addendum:
We would need the services that have "CRITICAL - Plugin timed out while executing system call" as the status to be filtered out
*/
$default_services = "
Day Mode
@ -43,7 +48,6 @@ Host Name, Host Address, Service Description, Status Information, and Duration (
$service_array = array_map(function($el) { return trim($el); }, $service_array);
$service_array = array_filter($service_array, function($el) { return !empty($el); });
do_page_start(array("page_title" => "Non-OK Services Report"), true);
echo '
<form method="get">
@ -98,6 +102,7 @@ Host Name, Host Address, Service Description, Status Information, and Duration (
function get_objects_down_services($services, $hours, $return_headers = true)
{
$arr = array();
global $filter_services;
if (!is_array($services)) {
echo "passed variable to get_objects_down_services() must be an array of service names\n";
@ -138,6 +143,16 @@ function get_objects_down_services($services, $hours, $return_headers = true)
$svc_arr['svc_desc'] = (string) $svc->name;
$svc_arr['svc_status'] = (string) $svc->status_text;
$match_filter = false;
foreach ($filter_services as $filter) {
if (strpos(strtolower($svc_arr["svc_status"]), strtolower($filter)) !== false) {
$match_filter = true;
}
}
if ($match_filter == true) {
continue;
}
$state_change_time = strtotime($svc->last_state_change);
// something went wrong with strtotime..

@ -17,8 +17,8 @@ function report_non_ok_svc_init()
COMPONENT_AUTHOR => "hedenface",
COMPONENT_DESCRIPTION => $desc,
COMPONENT_TITLE => "Services Non-OK Report",
COMPONENT_VERSION => "0.0.0",
COMPONENT_DATE => "31/07/2021",
COMPONENT_VERSION => "0.0.1",
COMPONENT_DATE => "08/08/2021",
)
);
@ -52,14 +52,14 @@ function report_non_ok_svc_component_addmenu()
}
$order = grab_array_var($menu_section, "order", "");
$new_order = $order + 0.1;
$new_order = $order + 0.2;
if ($new_order < 0) {
return false;
}
add_menu_item(MENU_REPORTS, array(
"type" => "link",
"title" => "Non-OK Services",
"title" => "Day-Night No Transition",
"id" => "menu-report-non-ok",
"order" => $new_order,
"opts" => array(

Loading…
Cancel
Save