public function run() { $needs_alert = false; $data = get_from_cache('events', 'SessionStart'); /* if the session didn't start we store the information; admin will * receive the alert only once. */ if ($data == NULL) { $data = array(); } $user = $this->ev->user->getAttribute('login'); if (isset($data[$user]) && $this->ev->ok) { unset($data[$user]); } if (!isset($data[$user]) && !$this->ev->ok) { $needs_alert = true; $data[$user] = false; } set_cache($data, 'events', 'SessionStart'); if ($needs_alert) { Logger::debug('main', 'SessionStartMail: sending alert'); $subject = sprintf(_('OVD Session alert: %s couldn\'t log in'), $user); if (isset($this->ev->error)) { $message = _("The following error happened:\n") . $this->ev->error; } else { $message = _('No error given'); } send_alert_mail($subject, $message); } return true; }
public function run() { $needs_alert = false; $data = get_from_cache('events', 'SqlFailure'); if ($data == NULL) { $data[$this->ev->host] = $this->ev->status; if ($this->ev->status < 0) { $needs_alert = true; } } else { if (isset($data[$this->ev->host]) && $data[$this->ev->host] != $this->ev->status) { $data[$this->ev->host] = $this->ev->status; $needs_alert = true; } } if ($needs_alert) { set_cache($data, 'events', 'SqlFailure'); Logger::debug('main', 'SqlFailureMail: sending alert'); if ($this->ev->status < 0) { $subject = sprintf(_('OVD Alert: MySQL %s is offline'), $this->ev->host); } else { $subject = sprintf(_('OVD End Alert: MySQL %s is up again'), $this->ev->host); } send_alert_mail($subject, ''); } return true; }
public function run() { $needs_alert = false; $data = get_from_cache('events', 'ServerStatusChanged'); if ($data == NULL) { $data[$this->ev->fqdn] = $this->ev->status; if ($this->ev->status == ServerStatusChanged::$OFFLINE) { $needs_alert = true; } } else { if (isset($data[$this->ev->fqdn]) && $data[$this->ev->fqdn] != $this->ev->status) { $data[$this->ev->fqdn] = $this->ev->status; $needs_alert = true; } } if ($needs_alert) { Logger::debug('main', 'ServerStatusChangedMail: sending alert'); set_cache($data, 'events', 'ServerStatusChanged'); if ($this->ev->status == ServerStatusChanged::$OFFLINE) { $subject = sprintf(_('OVD Alert: %s is offline'), $this->ev->fqdn); } else { $subject = sprintf(_('OVD End Alert: %s is up again'), $this->ev->fqdn); } send_alert_mail($subject, ''); } return true; }