cvs: pear /Net_Monitor/examples SMS.ini.php bg.ini.php complex.php config.ini.php ini_example.php simple.php

From: Date: Tue, 12 Apr 2005 18:05:02 +0000
Subject: cvs: pear /Net_Monitor/examples SMS.ini.php bg.ini.php complex.php config.ini.php ini_example.php simple.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-31120@lists.php.net to get a copy of this message
toggg Tue Apr 12 14:05:02 2005 EDT Added files: /pear/Net_Monitor/examples bg.ini.php complex.php config.ini.php ini_example.php simple.php SMS.ini.php Log: Usage examples for Net_Monitor http://cvs.php.net/co.php/pear/Net_Monitor/examples/bg.ini.php?r=1.1&p=1 Index: pear/Net_Monitor/examples/bg.ini.php +++ pear/Net_Monitor/examples/bg.ini.php ;<?PHP die(); /** @package Net_Monitor ; EDIT BELOW THIS LINE ; Services [services] www.toggg.com = SMTP, HTTP www.peakepro.com = HTTP, FTP, DNS ; Alerts ; Common SMTP server default localhost, port 25, no user, no auth [SMTP] host = smtp.tiscali.fr [bertrand] SMTP = bertrand@toggg.com [robert] SMTP = robert@peakepro.com ; Options [options] state_directory = /tmp/ state_file = Net_Monitor_State_bg subject_line = "Net_Monitor Alert" ; %h = host, %s = service, %m = message alert_line = "%h: %s: %m, confirm you got it please" notify_change = 1 notify_ok = 1 from_email = contact@toggg.com ; EDIT ABOVE THIS LINE ; */ ?> http://cvs.php.net/co.php/pear/Net_Monitor/examples/complex.php?r=1.1&p=1 Index: pear/Net_Monitor/examples/complex.php +++ pear/Net_Monitor/examples/complex.php <?php /** * * Example of use * * @package Net_Monitor */ /** * */ require_once('Net/Monitor.php'); error_reporting(E_ALL); //PEAR::setErrorHandling (PEAR_ERROR_DIE); $services = array('example.com'=>array('DNS','FTP','HTTPS')); $alerts = array( 'chine' => array('SMS' => array( 'SMS_provider' => 'sms2email_http', 'base_url' => 'horde.sms2email.com/horde/', 'ssl' => true, 'username' => 'xxxxx', 'password' => 'yyyyyyyy', 'phone_number' => '1234567890' )), 'bertrand' => array( 'SMS' => '9876543210', 'SMTP' => 'foo@bar.com')); $options = array('state_file' => 'Net_Monitor_TestSuite', 'SMS_default' => array( 'SMS_provider' => 'clickatell_http', 'username' => 'zzzzz', 'password' => 'yyyyy', 'api_id' => '123456' ), 'SMTP_default' => array( 'host' => 'smtp.example.com'), 'sms_debug' => false ); $monitor = new Net_Monitor($services,$alerts,$options); $monitor->resetState(); $monitor->checkAll(); $monitor->resetState(); ?> http://cvs.php.net/co.php/pear/Net_Monitor/examples/config.ini.php?r=1.1&p=1 Index: pear/Net_Monitor/examples/config.ini.php +++ pear/Net_Monitor/examples/config.ini.php ;<?PHP die(); /** @package Net_Monitor ; EDIT BELOW THIS LINE ; Services [services] foo.example.com = SMTP, DNS bar.example.com = HTTP, FTP, DNS ; Alerts ; Common SMTP server default localhost, port 25, no user, no auth [SMTP] host = smtp.example.com from = noreply@example.com port = 25 auth = true username = user2 password = supersecret ; Extra SMTP server(s) for alert about default one, host is the key [SMTP_Super] host = smtp.extra.com port = 25 auth = true username = user2' password = supersecret ; Common SMS server [SMS] SMS_provider = clickatell_http username = SMS_Subscriber password = supersecret api_id = x.y.z ; optionaly some extra SMS servers, SMS_provider is the key [commonUser] SMTP = common@example.com [extraUser] SMTP_Super = safety@demo.com SMS = 0123456789012 ; Options [options] state_directory = /tmp/ state_file = Net_Monitor_State subject_line = "Net_Monitor Alert" ; %h = host, %s = service, %m = message alert_line = "%h: %s: %m" notify_change = 1 notify_ok = 1 ; EDIT ABOVE THIS LINE ; */ ?> http://cvs.php.net/co.php/pear/Net_Monitor/examples/ini_example.php?r=1.1&p=1 Index: pear/Net_Monitor/examples/ini_example.php +++ pear/Net_Monitor/examples/ini_example.php <?PHP /** * * This file gives an example of configuring Net_Monitor using an INI file * * @package Net_Monitor * @see config.ini.php */ /** * */ require_once('Net/Monitor.php'); // what config file we use $cfg = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : 'config.ini.php'; $config = parse_ini_file($cfg,true); if (!($services = $config['services'])) { exit("You must at least have a section [services] !\n"); } unset( $config['services']); while(list($key,$value) = each($services)) { $value = explode(',',$value); $value = array_map('trim',$value); $services[$key] = $value; } $options = array(); if (isset($config['options'])) { $options = $config['options']; unset( $config['options']); } if (isset($config['SMTP'])) { $options['SMTP_default'] = $config['SMTP']; unset( $config['SMTP']); } if (isset($config['SMS'])) { $options['SMS_default'] = $config['SMS']; unset( $config['SMS']); } // proceed rest of sections for extra servers $SMTP = $SMS = array(); foreach ($config as $sec => $param) { if (isset($param['SMS_provider'])) { $SMS[$sec] = $param; unset( $config[$sec]); } if (isset($param['host'])) { $SMTP[$sec] = $param; unset( $config[$sec]); } } // users $alerts = array(); foreach ($config as $user => $param) { $alert = array(); if (isset($param['SMTP'])) { $alert['SMTP'] = $param['SMTP']; unset( $param['SMTP']); } if (isset($param['SMS'])) { $alert['SMS'] = $param['SMS']; unset( $param['SMS']); } foreach ($param as $server=>$extra) { if (isset($SMTP[$server])) { $alert['SMTP'] = $SMTP[$server]; $alert['SMTP']['email'] = $extra; } elseif (isset($SMS[$server])) { $alert['SMS'] = $SMS[$server]; $alert['SMS']['phone_number'] = $extra; } else { exit("Unknown server {$server} for user {$user} !\n"); } } if (!$alert) { exit("Empty for user {$user} !\n"); } $alerts[$user] = $alert; } print_r($services); print_r($alerts); print_r($options); $monitor = new Net_Monitor($services, $alerts, $options); $monitor->checkAll(); ?> http://cvs.php.net/co.php/pear/Net_Monitor/examples/simple.php?r=1.1&p=1 Index: pear/Net_Monitor/examples/simple.php +++ pear/Net_Monitor/examples/simple.php <?php require('Net/Monitor.php'); $monitor = new Net_Monitor(); $alerts = array('User1' => array('SMTP' => 'user1@example.com'), 'User2' => array('SMTP' => array('email'=>'user2@example.com', 'host' => 'example.com', 'port' => 25, 'auth' => true, 'username' => 'user2', 'password' => 'supersecret'))); $services = array('foo.example.com' => array('SMTP','DNS'), 'bar.example.com' => array('HTTP','FTP','DNS')); $monitor->setAlerts($alerts); $monitor->setServices($services); $monitor->checkAll(); ?> http://cvs.php.net/co.php/pear/Net_Monitor/examples/SMS.ini.php?r=1.1&p=1 Index: pear/Net_Monitor/examples/SMS.ini.php +++ pear/Net_Monitor/examples/SMS.ini.php ;<?PHP die(); /** @package Net_Monitor ; EDIT BELOW THIS LINE ; Services [services] www.toggg.com = SMTP, HTTP www.peakepro.com = HTTP, FTP, DNS ; Alerts ; Common SMS server: clickatell [SMS] SMS_provider = clickatell_http username = pique password = robert api_id = x.y.z ; Extra SMS server: sms2email [SMS1] SMS_provider = sms2email_http username = gruyere password = belletranche ; Extra SMS server: Vodafone Italy [SMS2] SMS_provider = vodafoneitaly_smtp username = italiano [bertrand] SMS = 1234567890 [robert] SMS1 = 2345678901 ; Options [options] state_directory = /tmp/ state_file = Net_Monitor_State_bg subject_line = "Net_Monitor Alert" ; %h = host, %s = service, %m = message alert_line = "%h: %s: %m, confirm you got it please" sms_line = "%h:%s->%c" notify_change = 1 notify_ok = 1 from_email = contact@toggg.com ; EDIT ABOVE THIS LINE ; */ ?>

« previous php.pear.cvs (#31120) next »