NAME
VBTK::Wrapper::Ping - System monitoring with 'ping'
SUPPORTED PLATFORMS
Solaris
SYNOPSIS
$obj = new VBTK::Wrapper::Ping( Host => 'myhost1');
$obj->addVBObj(VBObjName => '.myhost1.ping');
$obj = new VBTK::Wrapper::Ping( Host => 'myhost2');
$obj->addVBObj(VBObjName => '.myhost2.ping');
# Call this at the very end to start looping and checking everything
VBTK::runAll;
DESCRIPTION
This perl library is a front-end to the VBTK::Wrapper class. It supports the same public methods as the VBTK::Wrapper class, but with common defaults to simplify the setup of a 'ping' monitoring process.
METHODS
The following methods are supported
- $o = new VBTK::Wrapper::Vmstat (<parm1> => <val1>, <parm2> => <val2>, ...)
-
This method calls 'new VBTK::Wrapper' after defaulting the parameters to run and monitor the 'ping' command. For a detailed description of the parameters, see VBTK::Wrapper. Only 1 parameter 'Host' is required. The rest are defaulted appropriately, but if you don't like the defaults, you can override their settings.
- Required
-
This is the one parameter which must be specified! (Required)
Host => 'myhost1'
- Interval
-
Interval => 60,
- Execute
-
Defaults to run the 'ping' command with the parameters listed below. You may need to specify this instead, if your 'ping' is in a different location, or uses different parameters.
# Run the ping command once with a 56 bytes block size Execute => '/usr/sbin/ping -s <Host> 56 1',
- PreProcessor
-
Defaults to the following pre-processor subroutine. This parses through all the output of the 'ping' command, picking out the response time and packet loss values, and then replaces the whole array of output with a single row of host, ip, response-time, and packet loss.
PreProcessor => sub { my($data) = @_; my($respTime,$pktLoss,$host,$ip,$msg) = (0,100); foreach (@{$data}) { if(/bytes from (\S+) \(([\d\.]+)\): icmp_seq=\d+.+time=(\d+)/) { ($host,$ip,$respTime) = ($1,$2,$3); next; } if (/(\d+)\% packet loss/) { $pktLoss = $1; next; } if (/PING|^\s*$|^round-trip/) { next; } } # Now replace everything in the $data array with a single line @{$data} = ([ $host, $ip, $respTime, $pktLoss ]); };
- VBServerURI
-
A URI which specifies which VB Server to report results to. Defaults to the environment variable $VBURI.
VBServerURI => $VBURI,
- VBHeader
-
VBHeader => [ ' Resp Pkt', 'Time HostName IP Time (ms) Loss (%)', '------------------ -------------------------- --------------- --------- --------' ],
- VBDetail
-
VBDetail => [ '@<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<< @>>>>>>>> @>>>>>>>', '$time, @data[0..3]' ],
- LogHeader
-
Same as VBHeader
- LogDetail
-
Same as VBDetail
- Timeout
-
Timeout => 15,
- TimeoutStatus
-
TimeoutStatus => 'Warn',
- NonZeroExitStatus
-
NonZeroExitStatus => 'Warn',
- DebugHeader
-
DebugHeader => 'Ping <Host>',
- $vbObj = $o->addVBObj(<parm1> => <val1>, <parm2> => <val2>, ...)
-
This method calls VBTK::Wrapper::addVBObj after defaulting unspecified parameters to best monitor the 'ping' command. For a detailed description of the addVBObj parameters, see VBTK::Parser. The defaults are as follows. If you like all the defaults then you don't have to pass in any parms
- VBObjName
-
VBObjName => ".<Host>.cpu",
- TextHistoryLimit
-
TextHistoryLimit => 30,
- ReverseText
-
ReverseText => 1,
- Rules
-
If the response time > 250 or packet loss > 0, then set to Warning.
Rules => { '(($data[2] > 250)||($data[3] > 0))' => 'Warn' },
- StatusHistoryLimit
-
StatusHistoryLimit => 30,
- StatusUpgradeRules
-
StatusUpgradeRules => 'Upgrade to Failed if Warning occurs 2 times in (<Interval> * 3) sec',
- ExpireAfter
-
ExpireAfter => (<Interval> * 3) seconds
- Description
-
Description = qq( This object uses the 'ping' command to monitor '<Host>'. It will set the status to 'Warning' if the ping command loses any packets or if the response time is greater than 250ms. );
- RrdColumns
-
Store the response time and packet loss in the rrd library.
RrdColumns => [ '$data[2]', '$data[3]' ],
- RrdMin
-
RrdMin => 0,
In addition to passing these defaults on in a call to VBTK::Wrapper::addVBObj, this method captures the resulting VBTK::ClientObject pointer ($vbObj) and makes the following calls to '$vbObj->addGraphGroup':
$vbObj->addGraphGroup ( GroupNumber => 1, DataSourceList => ':0', Labels => 'Response Time (ms)', Title => "Ping <Host>", ); $vbObj->addGraphGroup ( GroupNumber => 2, DataSourceList => ':1', Labels => 'Packet Loss %', Title => "Ping <Host>", );
This defines two graphGroups for the VBObject. See VBTK::ClientObject for details on the 'addGraphGroup' method.
SEE ALSO
VBTK, VBTK::Wrapper, VBTK::Parser, VBTK::ClientObject, VBTK::Server
AUTHOR
Brent Henry, vbtoolkit@yahoo.com
COPYRIGHT
Copyright (C) 1996-2002 Brent Henry
This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation available at: http://http://www.gnu.org/copyleft/gpl.html
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.