public function NagiosCommands::check_updates in Nagios Monitoring 8
Allows querying Drupal's update status. Useful for NRPE.
It will respect the nagios.min_report_severity setting.
@command nagios-updates
Return value
int Defaults: NAGIOS_STATUS_OK: 0 NAGIOS_STATUS_WARNING: 1 NAGIOS_STATUS_CRITICAL: 2 NAGIOS_STATUS_UNKNOWN: 3
File
- src/
Commands/ NagiosCommands.php, line 122
Class
- NagiosCommands
- Drush command file for Nagios
Namespace
Drupal\nagios\CommandsCode
public function check_updates() {
$logger = $this->logger;
try {
$update_data = nagios_check_requirements()['data'];
$severity = $update_data['status'];
} catch (ServiceNotFoundException $e) {
$logger
->error(dt('This Drush command is only available if Core’s update module is enabled.'));
$logger
->error(dt('Run `drush en update` to enable it.'));
return NAGIOS_STATUS_UNKNOWN;
}
if ($severity == NAGIOS_STATUS_CRITICAL) {
$logger
->error($update_data['text']);
}
elseif ($severity == NAGIOS_STATUS_WARNING) {
$logger
->warning($update_data['text']);
}
else {
$logger
->notice($update_data['text']);
}
return $severity;
}