Class monitor

Description

The monitor class. This is the entity which contains the details of what is to be monitored, how it is to be monitored and what to do if a given condition arises.

Located in /monitor-defs.php (line 803)


	
			
Variable Summary
Method Summary
 monitor monitor ([string $name = ""], [string $emailto = ""], [string $emailfrom = ""], [string $emailpager = ""], [string $lockfilepath = ""])
 void add_monitor (object $monitor)
 void add_timeslot (mixed $start, mixed $end, string $name)
 void check ()
 void clear ()
 void notify ()
 void raise_condition (object $monitor)
 void set_condition_thresholds (integer $email_cond, integer $pager_cond)
 void set_emit_status ([boolean $mode = true])
 void set_stop_on_condition (int $cond)
Variables
mixed $condition = COND_OK (line 836)

Monitor highest priority condition

mixed $emailfrom = "" (line 810)

Address monitor messages come from

mixed $emailpager = "" (line 812)

Address to email SMS txt messages

mixed $emailto = "" (line 808)

Address to email monitor messages

mixed $email_condition_threshold = COND_WARNING (line 847)

Threshold condition for emailing

mixed $emit_status = false (line 817)

Whether to emit a status message to stdout. If true the monitor will emit the current status, plus the message associated with the highest priority (most severe) condition in the monitor. Format will be: 'CRITICAL: some message goes here'.

mixed $hostname = "" (line 824)

Local hostname we are running monitor on

mixed $locked = false (line 833)

True if we are locked via lockfile

mixed $lockfile (line 830)

Monitor lockfile object

mixed $lockfilepath = "" (line 819)

Monitor lockfile path

mixed $message = "" (line 838)

Monitor highest priority message

mixed $monitors = array() (line 863)

Array of monitors which do the work

mixed $name = "" (line 806)

The name of this monitor instance

mixed $pager_condition_threshold = COND_CRITICAL (line 850)

Threshold condition for paging

mixed $reportmsg = "" (line 841)

Report staging for email

mixed $schedule (line 860)

Schedule of named timeslots for this monitor

mixed $smstxtmsg = "" (line 844)

Report staging for SMS txt

mixed $stop_on_condition = COND_NONE (line 857)

Condition to stop on. If this condition is defined then we

mixed $tinow (line 853)

The current Unix timestamp

mixed $use_lockfile = true (line 827)

Whether to use a lockfile

Methods
Constructor monitor (line 874)

Create a new monitor object. This is the container for all of the monitors which you can define and use to monitor a complete system.

monitor monitor ([string $name = ""], [string $emailto = ""], [string $emailfrom = ""], [string $emailpager = ""], [string $lockfilepath = ""])
  • string $name: Name of this monitor instance (message prefix)
  • string $emailto: Email address to send monitor messages to
  • string $emailfrom: Email from-address for monitor messages
  • string $emailpager: Email address for pager TXT messages
  • string $lockfilepath: Path to lockfile (optional)
add_monitor (line 1185)

Add a new monitor. Eg. file_monitor, postgres_monitor etc. This just stuffs the object in an array ready to be checked.

void add_monitor (object $monitor)
  • object $monitor: New monitor object to add to our list
add_timeslot (line 1176)

Add a time slot to the schedule. This requires two times as per 24hr clock which define a time interval during the day, and gives it a name. You can define any number of these. Timeslots have to be in HH:MM format, separated by a dash "-", eg: '07:30-11:45'.

void add_timeslot (mixed $start, mixed $end, string $name)
  • mixed $start: Start time for timeslot, string datetime or Unix timestamp
  • mixed $end: End time for timeslot, string datetime or Unix timestamp
  • string $name: The name or ID associated with this timeslot.
check (line 1114)

Check all monitors. Just iterate through them and raise the conditions

contained in the reports each one returns. After collecting the details, we notify anyone which needs to know. If any condition returned from a check is CRITICAL, then the rule is we stop processing any further checks. Processing is done in order of definition of the monitors added, so put your critical ones first. NOTE: This method always performs a lock() before processing all the monitors, then performs an unlock() at the end.

void check ()
check_all_monitors (line 1091)

Iterate through all our monitors, checking in each case. Each monitor will implement its own kind of checking and set its condition afterward.

We also check to see if we have to abort monitor checking on a given monitor condition.

void check_all_monitors ()
clear (line 931)

Clear all the monitors.

void clear ()
notify (line 1059)

Method to send notification(s)..

void notify ()
raise_condition (line 1035)

Raise a condition. The single parameter to this method is a monitor object which will have had its check() method called. This contains the resulting condition and any messages to notify.

void raise_condition (object $monitor)
  • object $monitor: Monitor object which has had its check() method run
set_condition_thresholds (line 1015)

Sets the threshold at which we will send messages to email & pager.

Any conditions equal or worse than the threshold will be sent if the message is not nullstring.

void set_condition_thresholds (integer $email_cond, integer $pager_cond)
  • integer $email_cond: Conditions >= this will be reported via email
  • integer $pager_cond: Conditions >= this will be reported via pager
set_emit_status (line 944)

Control the emission of status and status message associated with the most sever monitor error. The monitor defaults to not doing this so you should call this method without parameters to turn it on.

void set_emit_status ([boolean $mode = true])
  • boolean $mode: If true then turn on status emission mode.
set_stop_on_condition (line 1025)

Set the condition to stop checking monitor on. If this is set to something other than COND_NONE, then the first time a monitor is raised to this condition the checking process is stopped.

void set_stop_on_condition (int $cond)
  • int $cond: Condition to stop the checking process on.

Documentation generated by phpDocumentor 1.3.0RC3