function nagios_status_page in Nagios Monitoring 5
Same name and namespace in other branches
- 6 nagios.module \nagios_status_page()
- 7 nagios.module \nagios_status_page()
Callback for the nagios status page
1 string reference to 'nagios_status_page'
- nagios_menu in ./
nagios.module - Implementation of hook_menu
File
- ./
nagios.module, line 127
Code
function nagios_status_page() {
$skip_invoke = FALSE;
header("Pragma: no-cache");
header("Expires: 0");
$codes = nagios_status();
// Check the unique ID string first
$ua = variable_get('nagios_ua', 'Nagios');
if ($_SERVER['HTTP_USER_AGENT'] != $ua) {
// This is not an authorized unique id, so do not send information out
$skip_invoke = TRUE;
$nagios_data = array(
'nagios' => array(
'DRUPAL' => array(
'status' => NAGIOS_STATUS_UNKNOWN,
'type' => 'state',
'text' => t('Unauthorized'),
),
),
);
}
if (!$skip_invoke) {
// Not authorized, so skipping calling other modules
$nagios_data = nagios_invoke_all('nagios');
}
// Find the highest level to be the overall status
$severity = NAGIOS_STATUS_OK;
foreach ($nagios_data as $module_name => $module_data) {
foreach ($module_data as $key => $value) {
$severity = max($severity, $value['status']);
}
}
// Identifier that we check on the other side
$output = "\n" . 'nagios=' . $codes[$severity] . ', ';
$output_state = array();
$output_perf = array();
foreach ($nagios_data as $module_name => $module_data) {
foreach ($module_data as $key => $value) {
switch ($value['type']) {
case 'state':
$tmp_state = $key . ':' . $codes[$value['status']];
if (!empty($value['text'])) {
$tmp_state .= '=' . $value['text'];
}
$output_state[] = $tmp_state;
break;
case 'perf':
$output_perf[] = $key . '=' . $value['text'];
break;
}
}
}
$output .= implode(', ', $output_state) . ' | ' . implode(';', $output_perf) . "\n";
// Print the output, so we test the theme
print theme('page', $output);
// Exit early so we do not cache the data, nor do we wrap the result in a theme
exit;
}