Sponsored Content
Top Forums Shell Programming and Scripting help: infinant loop script - host ping test Post 302115209 by ghostdog74 on Monday 23rd of April 2007 06:11:56 AM
Old 04-23-2007
an awk example, not including infinite pinging.
Code:
#!/bin/bash
awk '	function pinger(count,ip) {
		command = "ping -c "count " " ip		
		while (( command | getline res )> 0 ) {	
			if ( res ~ /0 received|100% packet loss/ ) {
				close(command)
				return 100			 
			}
		}
	close(command)
	return 0
	}	
	BEGIN { 	
	IP="x.x.x.x"	
	if ( pinger(2,IP) == 100 ) {
		print IP " Not up"
		c = 0
		while ( c < 4 ) {			
			if ( pinger(2,IP) == 100 ) {
				print IP " Not up yet" 
			}
			c=c+1
		}
	} else { print IP " up" }
}'

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Unable to ping host

Hi, dear all, I am rather new to Unix and have this problem where I cant seem to ping from 1 host to another. The scenerio is as follows: - 1 QNX host->Eth->1 SCO host the SCO host is configured with it's IP the QNX host is configured with another IP both in the same domain, ie, 172.20.3.XX... (3 Replies)
Discussion started by: gavon
3 Replies

2. IP Networking

QNX host cannot ping SCO host, vice versa

The problem I am facing now is that the QNX host could not ping the SCO host and vice versa. They are in the same domain, ie, 172.20.3.xx. As I am very new to Unix, I guess I must have missed out some important steps. Pls help... Thanx alot (2 Replies)
Discussion started by: gavon
2 Replies

3. Shell Programming and Scripting

help to ping a host, is it alive or not ...

hello to everyone, i was wondering if you could help me with a script im working on, it's kind of simple but i dont have a lot experience on unix comands: well, here it is: you might apreciate the infinite while loop :D, it is supossed to be running on the server all day scaning it every 5... (12 Replies)
Discussion started by: sx3v1l_1n51de
12 Replies

4. Solaris

PING - Unknown host 127.0.0.1, Unknown host localhost - Solaris 10

Hello, I have a problem - I created a chrooted jail for one user. When I'm logged in as root, everything work fine, but when I'm logged in as a chrooted user - I have many problems: 1. When I execute the command ping, I get weird results: bash-3.00$ usr/sbin/ping localhost ... (4 Replies)
Discussion started by: Przemek
4 Replies

5. UNIX for Dummies Questions & Answers

PING to one host in one background process

Hi All, I'm doing one script on Juniper router where you have one FreeBSD Shell: Is pinging from time to time one ethernet port of othere router and in case of fail is blocking one port entering in CLI and doing some command: If I run this script all is working perfectly, but if I run in... (1 Reply)
Discussion started by: teigipo
1 Replies

6. Solaris

Unable to ping Solaris VM from Xp host

Hi All, I am using Vmware Workstation 6.0.3 build-80004. Guest OS: Solaris 10 Host OS : Win XP I am getting request time out when i am trying to ping from XP ( cmd line) to Solaris VM - I have assigned IP 192.168.50.5 in Solaris VM ( Hostname: Tower1) and it is in UP status. ... (4 Replies)
Discussion started by: saurabh84g
4 Replies

7. IP Networking

ping can not recognize host but host command can

Hi, I have a weird problem. when ever I do ping command like for example ping unix.comI get the following message: # ping unix.com ping: unknown host unix.com but when I use host the computer is able to know the host. # host unix.com unix.com has address 81.17.242.186 unix.com mail is... (2 Replies)
Discussion started by: programAngel
2 Replies

8. Shell Programming and Scripting

Ping Host Until it is up and email

Hi I am trying to write a script which runs until the host is up. i got it figured out that it needs to be in loop till it return $? = 0. Not getting it through though. I am not sure about the 6th line !!! #!/bin/sh HOSTS="host.txt" ping(){ for myhost in "$HOSTS" do ping -c -1 "$myhost"... (8 Replies)
Discussion started by: Antergen
8 Replies

9. Shell Programming and Scripting

Ping Response from the host name

Hi All, I have the requirement where am pinging the server and matching the IP address with the existing IP address. Below code is returning me the IP address and my requirement is i have to see that also whether it is pinging or not PING useipapd01 (172.22.32.87) 56(84) bytes of data. 64... (1 Reply)
Discussion started by: sharsour
1 Replies

10. Programming

Ping test sends mail when ping fails

help with bash script! im am working on this script to make sure my server will stay online, so i made this script.. HOSTS="192.168.138.155" COUNT=4 pingtest(){ for myhost in "$@" do ping -c "$COUNT" "$myhost" &&return 1 done return 0 } if pingtest $HOSTS #100% failed... (4 Replies)
Discussion started by: mort3924
4 Replies
HOBBITPING(1)						      General Commands Manual						     HOBBITPING(1)

NAME
hobbitping - Xymon ping tool SYNOPSIS
hobbitping [--retries=N] [--timeout=N] [IP-adresses] DESCRIPTION
hobbitping(1) is used for ping testing of the hosts monitored by the xymon(7) monitoring system. It reads a list of IP adresses from stdin, and performs a "ping" check to see if these hosts are alive. It is normally invoked by the bbtest-net(1) utility, which performs all of the Xymon network tests. Optionally, if a list of IP-adresses is passed as commandline arguments, it will ping those IP's instead of reading them from stdin. hobbitping only handles IP-adresses, not hostnames. hobbitping was inspired by the fping(1) tool, but has been written from scratch to implement a fast ping tester without much of the over- head found in other such utilities. The output from hobbitping is similar to that of "fping -Ae". hobbitping probes multiple systems in parallel, and the runtime is therefore mostly dependant on the timeout-setting and the number of retries. With the default options, hobbitping takes approximately 18 seconds to ping all hosts (tested with an input set of 1500 IP adresses). SUID-ROOT INSTALLATION REQUIRED hobbitping needs to be installed with suid-root privileges, since it requires a "raw socket" to send and receive ICMP Echo (ping) packets. hobbitping is implemented such that it immediately drops the root privileges, and only regains them to perform two operations: Obtaining the raw socket, and optionally binding it to a specific source address. These operations are performed as root, the rest of the time hob- bitping runs with normal user privileges. Specifically, no user-supplied data or network data is used while running with root privileges. Therefore it should be safe to provide hobbitping with the necessary suid-root privileges. OPTIONS
--retries=N Sets the number of retries for hosts that fail to respond to the initial ping, i.e. the number of ping probes sent in addition to the initial probe. The default is --retries=2, to ping a host 3 times before concluding that it is not responding. --timeout=N Determines the timeout (in seconds) for ping probes. If a host does not respond within N seconds, it is regarded as unavailable, unless it responds to one of the retries. The default is --timeout=5. --responses=N hobbitping normally stops pinging a host after receiving a single response, and uses that to determine the round-trip time. If the first response takes longer to arrive - e.g. because of additional network overhead when first determining the route to the target host - it may skew the round-trip-time reports. You can then use this option to require N responses, and hobbitping will calculate the round-trip time as the average of all of responsetimes. --max-pps=N Maximum number of packets per second. This limits the number of ICMP packets hobbitping will send per second, by enforcing a brief delay after each packet is sent. The default setting is to send a maximum of 50 packets per second. Note that increasing this may cause flooding of the network, and since ICMP packets can be discarded by routers and other network equipment, this can cause erratic behaviour with hosts recorded as not responding when they are in fact OK. --source=ADDRESS Use ADDRESS as the source IP address of the ping packets sent. On multi-homed systems, allows you to select the source IP of the hosts going out, which might be necessary for ping to work. --debug Enable debug output. This prints out all packets sent and received. SEE ALSO
xymon(7), bbtest-net(1), fping(1) Xymon Version 4.2.3: 4 Feb 2009 HOBBITPING(1)
All times are GMT -4. The time now is 02:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy