Net_Monitor
[ class tree: Net_Monitor ] [ index: Net_Monitor ] [ all elements ]

Class: Net_Monitor

Source Location: /Net_Monitor-0.2.5/Net/Monitor.php

Class Overview


class Net_Monitor


Author(s):

Methods


Inherited Variables

Inherited Methods


Class Details

[line 43]
class Net_Monitor


[ Top ]


Method Detail

Net_Monitor (Constructor)   [line 151]

void Net_Monitor( [array $services = array()], [array $alerts = array()], [array $options = array()])

function Net_Monitor
  • Access: public

Parameters:

array   $services     services to check 'url' => array('services') example: array('example.com' => array('SMTP', 'HTTP', 'HTTPS'), 'example.net' => array('DNS', 'FTP'))
array   $alerts     

alerts to be sent organized by alerter protocols as array('SMTP' => array(SMTP_adressees), 'SMS' => array(SMS_adressees)) If this array is empty, alerts will be only printed and nothing sent

SMTP_adressees is a simple string email, then $options['SMTP_default'] will be used to configure the SMTP sender, or can itself be an array of options for a prioritary adressee (useful to monitor SMTP itself) in this case, the adressee is the 'email' => 'email@adress.com' element. see Mail for these options

SMS_adressees is a simple string phone number, then $options['SMS_default'] will be used to configure the SMS sender, or can itself be an array of options for a prioritary adressee (useful to specify alternate provider) in this case, the adressee is the 'phone_number' => '0123456789' element. see Net_SMS for these options

array   $options     options to be used in the current monitoring session Options (default) are:
  • state_directory - the directory where the state file gets saved ('/tmp/')
  • state_file - the name of the state file ('Net_Monitor_State')
  • subject_line - the subject line of the alert message ('Net_Monitor Alert')
  • alert_line - the format string for the alert ('%h: %s: %m') where: %h = host %s = service %m = message %c = code
  • notify_change - send alerts only on state change (1)
  • notify_ok - send an alert when a service returns to a code 200 state (1)
  • smtp_debug - send debugging output to STDOUT for the SMTP alert (false)
  • from_email - who is the sender for the SMTP alert ('pear.Net_Monitor')
  • SMTP_default - array of options for Mail_SMTP used for normal adressees (array())
  • sms_debug - send debugging output to STDOUT for the SMS alert (false)
  • sms_from - who is the sender for the SMS alert, ('Net_Monitor')
  • SMS_default - array of options for Net_SMS used for normal adressees (array())

[ Top ]

check   [line 315]

mixed check( mixed $server, string $service)

function check

Check a single service ($service) on a single server ($server)

  • Access: public

Parameters:

mixed   $server     Host
string   $service     Service

[ Top ]

checkAll   [line 243]

void checkAll( )

function checkAll

Checks all services and sends all alerts.

  • Access: public

[ Top ]

getState   [line 479]

array getState( )

function getState

Retrieves previous state information from the directory specified in $_options['state_directory'] via a file named $_options['state_file']

  • Access: public

[ Top ]

loadAlerters   [line 355]

void loadAlerters( )

function loadAlerters

Load alert objects into Net_Monitor so that each type of alert is only used once.

  • Access: public

[ Top ]

loadClients   [line 330]

void loadClients( )

function loadClients

Load all clients into the Net_Monitor object so that each type of service client is only instantiated once.

  • Access: public

[ Top ]

printAlert   [line 645]

void printAlert( string $host, string $service, array $result)

function printAlert

Prints the alert for a host/service to STDOUT. Formats the alert according to $_options['alert_line'].

  • Access: public

Parameters:

string   $host     Host name
string   $service     Service
array   $result     (code, message)

[ Top ]

resetHostState   [line 610]

void resetHostState( string $host, [mixed $service = null])

function resetHostState

Resets the state for a single host ($host). Optionally takes in a second parameter, $service which maybe an array, whereby the function only resets the results for that/those particular host/service test.

  • Access: public

Parameters:

string   $host     Host
mixed   $service     Service

[ Top ]

resetState   [line 577]

boolean resetState( )

function resetState

Resets the results and results differential arrays and deletes the state file.

Returns true if the file has been deleted or never existed in the first place; false otherwise.

  • Access: public

[ Top ]

saveState   [line 442]

void saveState( [array $results = null])

function saveState

Saves the current $_results array to the directory specified in $_options['state_directory'] as a file named $_options['state_file'].

If an array ($results) is passed to the function, that array is saved as state, otherwise this function acts upon $_results.

  • Access: public

Parameters:

array   $results     Results

[ Top ]

setAlerts   [line 223]

void setAlerts( array $alerts)

function setAlerts

Sets the alerts for the class

Overwrites $_alerts with input array ($alerts)

Net_Monitor_Alerts are of the form:

 $alerts = array('User1' => array('SMTP'=>'user1@example.com'),
                 'User2' => array('SMTP'=>'user2@example.com'));


Parameters:

array   $alerts     Alerts

[ Top ]

setOptions   [line 180]

void setOptions( array $options)

function setOptions

Sets additional options for the class

Merges input array ($options) with $this->_options

  • Access: public

Parameters:

array   $options     Options to set

[ Top ]

setServices   [line 203]

void setServices( array $services)

function setServices

Sets the services to monitor for the class

Overwrites $_services with input array ($services)

Net_Monitor_Services are of the form:

 $services = array('foo.example.com'=>array('SMTP','DNS'),
                   'bar.example.com'=>array('HTTP','FTP','DNS'));

  • Access: public

Parameters:

array   $services     Services per domain

[ Top ]


Documentation generated on Mon, 20 Sep 2010 10:00:04 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.