Ec (2); V. Example ServiceLogger process the following is an example ServiceLogger process. When a service is stopped, it sends an email to a standby person: classEmailMe_ServiceLoggerimplementsServiceLogger {publicfunctionlog_service_event (ServiceCheck $ service) script ec (2); script
5. ServiceLogger process example
The following is an example ServiceLogger process. When a service is stopped, it is responsible for sending an email to a standby person:
Class EmailMe_ServiceLogger implements ServiceLogger {
Public function log_service_event (ServiceCheck $ service)
{
If ($ service-> current_status = ServiceCheck: FAILURE ){
$ Message = "Problem with {$ service-> description ()} rn ";
Mail ('oncall @ example.com ', 'service event', $ message );
If ($ service-> consecutive_failures ()> 5 ){
Mail ('oncall _ backup@example.com ', 'service event', $ message );
}
}
}
Public function log_current_status (ServiceCheck $ service ){
Return;
}
}
If five consecutive failures occur, the process also sends a message to a backup address. Note that it does not implement a meaningful log_current_status () method.
Whenever you change the status of a service as follows, you should implement a ServiceLogger process written to the PHP Error Log:
Class ErrorLog_ServiceLogger implements ServiceLogger {
Public function log_service_event (ServiceCheck $ service)
{
If ($ service-> current_status ()! ==$ Service-> previus_status ()){
If ($ service-> current_status () === ServiceCheck: FAILURE ){
$ Status = 'low ';
}
Else {
$ Status = 'up ';
}
Error_log ("{$ service-> description ()} changed status to $ status ");
}
}
Public function log_current_status (ServiceCheck $ service)
{
Error_log ("{$ service-> description ()}: $ status ");
}
}
The log_current_status () method means that if the process sends a SIGUSR1 signal, it will copy its complete current status to your PHP error log.
The engine uses the following configuration file:
Errorlog
ErrorLog_ServiceLogger
Emailme
EmailMe_ServiceLogger
HTTP_ServiceCheck
OmniTI HTTP Check
Http://www.omniti.com
30
900
Errorlog
Emailme