Advertisement

05.08.2008 at 01:27PM PDT, ID: 23387559 | Points: 500
[x]
Attachment Details

Unix shell script for failed pings

Asked by dniven in Shell Scripting, Unix Systems Programming, Mac OS X

Tags: , ,

Hi Folks,

I use the following shell script to send extended pings to a host on a problematic network. What I'd like to do is have the script email me ONLY when the packet loss is anything but 0%.

Currently, my emailed results look like this:

** Automated System Status Report **

Thu May  8 13:03:33 PDT 2008

RESULTS: PING problemchild.example.com (192.168.1.5): 1470 data bytes

--- problemchild.example.com ---
100 packets transmitted, 100 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.775/0.823/1.310/0.066 ms


_______________________________________________


This script is /Users/hcs/bin/, and runs every 15 mins

Many thanks in advance for any suggestions, I'm a novice shell scripter.

Best, DougStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
#!/bin/sh
# This is a ping report 
(
echo "From: admin@example.com"
echo "To: netadmin@example.com"
echo "Subject: Ping Report"
echo ""
echo "** Automated System Status Report **"
echo
date
echo
echo -n "RESULTS: " ; /sbin/ping -s 1470  -c 100 -q problemchild.example.com
echo
echo
echo -n "_______________________________________________"
echo 
echo -n "This script is /Users/hcs/bin/, and runs every 15 mins"
) | /usr/sbin/sendmail -it
exit 0
fi
done
[+][-]05.08.2008 at 06:06PM PDT, ID: 21529743

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.08.2008 at 10:01PM PDT, ID: 21530471

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.09.2008 at 10:43AM PDT, ID: 21535044

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.09.2008 at 07:42PM PDT, ID: 21537639

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.09.2008 at 09:44PM PDT, ID: 21537879

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.11.2008 at 12:53AM PDT, ID: 21541756

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 07:15AM PDT, ID: 21573842

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 07:17AM PDT, ID: 21573869

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 07:44AM PDT, ID: 21574193

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628