Network Service Test Macros
The macros in the sample network_service_test_macros.cfg configuration file below are for testing whether a network service--for example, RPC, SSH, SMTP, HTTP--is available or not.
///////////////////////////////////////////////////////////////////////////////
//
// network_service_test_macros.cfg
//
///////////////////////////////////////////////////////////////////////////////
pingfail(H, R, T)
// test if system doesn't respond to ping, where
// (H) is the host, (R) is the retries, (T) is timeout
$command("=ping -c (R) -w (T) (H) | =tail -n 2 | =head -n 1")
=~ "100% packet loss"
///////////////////////////////////////////////////////////////////////////////
rpcfail(H)
// test if system doesn't respond to a rpcinfo request,
// where (H) is the host
$command("=rpcinfo -p (H) 2>/dev/null | =head -n 2 | =tail -n 1")
!~~ "100000.+tcp.+111.+portmapper"
///////////////////////////////////////////////////////////////////////////////
// if system is down, the $command() returns:
// telnet: connect to address : No route to host
// if service is down, the $command() returns:
// ssh: connect to port 22: Connection refused
sshfail(H)
// test if can't connect to system's port 22,
// where (H) is the host
$command("=echo '.close' | =telnet -e . -a (H) 22 | =tail -n +3 | =head -n 1")
!~~ "connected to (H)"
smtpfail(H)
// test if can't connect to system's port 25,
// where (H) is the host
$command("=echo '.close' | =telnet -e . -a (H) 25 | =tail -n +3 | =head -n 1")
!~~ "connected to (H)"
httpfail(H)
// test if can't connect to system's port 80,
// where (H) is the host
$command("=echo '.close' | =telnet -e . -a (H) 80 | =tail -n +3 | =head -n 1")
!~~ "connected to (H)"
///////////////////////////////////////////////////////////////////////////////
For more examples, see Samples.