function hook_nagios in Nagios Monitoring 7
Same name and namespace in other branches
- 8 nagios.api.php \hook_nagios()
Does the actual work of checking something.
Parameters
$id: Optional, an identifier which is the 2nd argument passed via the URL. this is useful when you just want nagios to check a single function. example: http://mysite.com/nagios/mymodule/myId.
"myId" would be send to mymodule_nagios.
http://mysite.com/nagios/mymodule would not send any id, but would not run hook_nagios for any other modules.
Return value
array The data returned is an associative array as follows:
array( 'key' => 'IDENTIFIER', 'data' => array( 'status' => STATUS_CODE, 'type => 'state', // Can be a 'state' for OK, Warning, Critical, Unknown) or can be 'perf', which does // Cause an alert, but can be processed later by custom programs 'text' => 'Text description for the problem', ), );
STATUS_CODE must be one of the following, defined in nagios.module:
NAGIOS_STATUS_OK NAGIOS_STATUS_UNKNOWN NAGIOS_STATUS_WARNING NAGIOS_STATUS_CRITICAL
Here is an example:
array
1 function implements hook_nagios()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- nagios_nagios in ./
nagios.module - Implements hook_nagios().
1 invocation of hook_nagios()
- nagios_status_page in ./
nagios.module - Callback for the nagios status page
File
- ./
nagios.api.php, line 57 - Document hooks provided by the Nagios Monitoring module.
Code
function hook_nagios(string $id) {
// Check something ...
$count = 10;
if (!$count) {
$data = [
'status' => NAGIOS_STATUS_WARNING,
'type' => 'state',
'text' => t('A very brief description of the warning'),
];
}
else {
$data = [
'status' => NAGIOS_STATUS_OK,
'type' => 'state',
'text' => '',
];
}
return [
'key' => 'IDENTIFIER',
// This identifier will appear on Nagios' monitoring pages and alerts.
'data' => $data,
];
}