09-29-2005
I added the color snippet, but only the red works on the failed pings (no green for the good pings). Is there a way to make the good pings green and the bad ones red? Have played around with the code and only get one color to show, either on the bad or good pings, but not both. Seems that the last argument is the only one to read the color code?
#!/bin/ksh
hosts='/etc/hosts'
while read ip host theRest
do
ping "${ip}" 1>/dev/null 2>&1
[[ "${?}" -eq 0 ]] && echo "${ip} is alive ${host} ${theRest}" || echo "${ip} IS DEAD!!! ${host} ${theRest}"
sed 's/.*IS DEAD!!!.*/[31;2m[0m/;s/.*is alive.*/[32;1m&[0m/'
done < "${hosts}"
Again, TIA.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
The line is simple, use " '{ print $1"]"$2"\"$3THE " NEEDS TO GO HERE$4 }'
I've tried \", "\, ^" and '"" but none of it works. What am I missing? Putting in the [ between $1 and $2 works fine, I just need to do the same with a ".
Thanks. (2 Replies)
Discussion started by: LordJezo
2 Replies
2. Shell Programming and Scripting
Actually I got a list of file end with *.txt
I want to use the same command apply to all the *.txt
Thus I try to find out the fastest way to write those same command in a script and then want to let them run automatics.
For example:
I got the file below:
file1.txt
file2.txt
file3.txt... (4 Replies)
Discussion started by: patrick87
4 Replies
3. Shell Programming and Scripting
Hey Guys,
First time posting here. I keep getting back here on my google searches to help me in my scripting quest.
Can i ask for some guidance please?
I acquired a script, from these forums in fact that pings a list of IPs/Hostnames. Works a treat. Echos results to a file with the value... (3 Replies)
Discussion started by: stacky69
3 Replies
4. Shell Programming and Scripting
Hi,
I am new to this world..
Using expect i loging to router and checking ping response to my links.
I need to genarate report using this output and that report contains only three file link name, packet loss, latency.
my output of script is like below:
-bash-3.00$ monmw/mwbkp... (2 Replies)
Discussion started by: jkmistry
2 Replies
5. Shell Programming and Scripting
Hi,
I develop simple animation ping script on Solaris Platform. It is like Cisco ping.
Examples and source code are below.
bash-3.00$ gokcell 152.155.180.8 30
Sending 30 Ping Packets to 152.155.180.8
!!!!!!!!!!!!!.!!!!!!!!!!!!!!!.
% 93.33 success... % 6.66 packet loss...... (1 Reply)
Discussion started by: gokcell
1 Replies
6. Shell Programming and Scripting
Hi,
I have the following input in a file & need output as mentioned below(need counter of every occurance of field which is to be increased by 1).
Input:
919143110065
919143110065
919143110052
918648846132
919143110012
918648873782
919143110152
919143110152
919143110152... (2 Replies)
Discussion started by: siramitsharma
2 Replies
7. Shell Programming and Scripting
Hi Team,
Need shell script to Telnet multiple node , Ping some IP and print output like pass or fail.
Need this script to check reachability of multiple nodes at same time.
Help me.
I use this but not working...
Eg.
in this script i need to telnet... (4 Replies)
Discussion started by: Ganesh Mankar
4 Replies
8. UNIX and Linux Applications
I need to ping a host website ...like facebook.com and out the seconds of delay for 5 websites ..I need help writing a script that will print the bold
PING facebook.com (173.252.90.36) 56(84) bytes of data.
64 bytes from edge-star-mini-shv-13-atn1.facebook.com (173.252.90.36): icmp_req=1... (1 Reply)
Discussion started by: 5sku5
1 Replies
9. Programming
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
10. Shell Programming and Scripting
I have a script that logs into a server and pings several other servers in order to verify IP path between servers.
The output can look like this, if good pings:
Response from 1.1.1.4;_id=0, vlan_prio=0): seq=0 time=91.547 ms.
Response from 1.1.1.4;_id=0, vlan_prio=0): seq=1 time=61.176 ms.... (7 Replies)
Discussion started by: he204035
7 Replies
LEARN ABOUT DEBIAN
smokeping_probes_tcpping
Smokeping_probes_TCPPing(3) SmokePing Smokeping_probes_TCPPing(3)
NAME
Smokeping::probes::TCPPing - TCPPing Probe for SmokePing
SYNOPSIS
*** Probes ***
+TCPPing
binary = /usr/bin/tcpping # mandatory
forks = 5
offset = 50%
step = 300
tcptraceroute = -e "sudo /bin/tcptraceroute"
timeout = 15
# The following variables can be overridden in each target section
pings = 5
port = 80
# [...]
*** Targets ***
probe = TCPPing # if this should be the default probe
# [...]
+ mytarget
# probe = TCPPing # if the default probe is something else
host = my.host
pings = 5
port = 80
DESCRIPTION
Integrates TCPPing as a probe into smokeping. The variable binary must point to your copy of the TCPPing program. If it is not installed on
your system yet, you can get it from http://www.vdberg.org/~richard/tcpping. You can also get it from
http://www.darkskies.za.net/~norman/scripts/tcpping.
The (optional) port option lets you configure the port for the pings sent. The TCPPing manpage has the following to say on this topic:
The problem is that with the widespread use of firewalls on the modern Internet, many of the packets that traceroute(8) sends out end up
being filtered, making it impossible to completely trace the path to the destination. However, in many cases, these firewalls will permit
inbound TCP packets to specific ports that hosts sitting behind the firewall are listening for connections on. By sending out TCP SYN
packets instead of UDP or ICMP ECHO packets, tcptraceroute is able to bypass the most common firewall filters.
It is worth noting that tcptraceroute never completely establishes a TCP connection with the destination host. If the host is not listening
for incoming connections, it will respond with an RST indicating that the port is closed. If the host instead responds with a SYN|ACK, the
port is known to be open, and an RST is sent by the kernel tcptraceroute is running on to tear down the connection without completing
three-way handshake. This is the same half-open scanning technique that nmap(1) uses when passed the -sS flag.
VARIABLES
Supported probe-specific variables:
binary
The location of your tcpping script.
Example value: /usr/bin/tcpping
This setting is mandatory.
forks
Run this many concurrent processes at maximum
Example value: 5
Default value: 5
offset
If you run many probes concurrently you may want to prevent them from hitting your network all at the same time. Using the probe-
specific offset parameter you can change the point in time when each probe will be run. Offset is specified in % of total interval, or
alternatively as 'random', and the offset from the 'General' section is used if nothing is specified here. Note that this does NOT
influence the rrds itself, it is just a matter of when data acqusition is initiated. (This variable is only applicable if the variable
'concurrentprobes' is set in the 'General' section.)
Example value: 50%
step
Duration of the base interval that this probe should use, if different from the one specified in the 'Database' section. Note that the
step in the RRD files is fixed when they are originally generated, and if you change the step parameter afterwards, you'll have to
delete the old RRD files or somehow convert them. (This variable is only applicable if the variable 'concurrentprobes' is set in the
'General' section.)
Example value: 300
tcptraceroute
tcptraceroute Options to pass to tcpping.
Example value: -e "sudo /bin/tcptraceroute"
timeout
How long a single 'ping' takes at maximum
Example value: 15
Default value: 5
Supported target-specific variables:
pings
How many pings should be sent to each target, if different from the global value specified in the Database section. Note that the
number of pings in the RRD files is fixed when they are originally generated, and if you change this parameter afterwards, you'll have
to delete the old RRD files or somehow convert them.
Example value: 5
port
The TCP port the probe should measure.
Example value: 80
AUTHORS
Norman Rasmussen <norman@rasmussen.co.za> Patched for Smokeping 2.x compatibility by Anton Chernev <maznio@doom.bg>
2.6.8 2013-03-17 Smokeping_probes_TCPPing(3)