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)"
 
///////////////////////////////////////////////////////////////////////////////

Open Hand For more examples, see Samples.

 
Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software
Developer's Notes | Licensing | Authors | Pikt-Users | Pikt-Workers | Related Projects | Site Index | Privacy Policy | Contact Us
Page best viewed at 1024x768 or greater.   Page last updated 2008-03-27.   This site is PIKT® powered.
PIKT® is a registered trademark of the University of Chicago.   Copyright © 1998-2008 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
View sample
backup network
configuration
Pikt script