- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Need a Shell Script to do this job. If anybody...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2006 06:01 AM
тАО01-23-2006 06:01 AM
We would like to do a simple monitoring script which can do a ping to all these servers and the package ips, if there is no resonse, it has to pages admins. Also once the machines which was not pingable for last five minutes is back up after a reboot or so, page saying that the machine is up.
Any help is appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2006 06:36 AM
тАО01-23-2006 06:36 AM
SolutionHosts.txt
----------------
host1 ip1
host2 ip2
etc ...
watch_net.sh
#!/usr/bin/sh
cat Hosts.txt |while read HOST IP;do
ping $IP -n 2 >/dev/null
if [ $? -ne 0 ]
mailx -s "$Host($IP) Not Pinging" support@domain.com
fi
done
Regards...bl.
- Tags:
- ping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2006 07:02 AM
тАО01-23-2006 07:02 AM
Re: Need a Shell Script to do this job. If anybody have it handy,let me know.
Here's a basic monitor script. Start it and it runs infinitly, waking up every 300-seconds. If a server is responsive to a 'ping' but was not in the previous pass, an email is generated. If a server isn't responsive but was before an email is also composed.
The list of servers can be by name and/or address, one per line in a file named '/tmp/servers'.
# cat monservers
#!/usr/bin/perl
#@(#) Simple server monitor - JRF
use strict;
use warnings;
my $hosts = "/tmp/servers";
my %servers;
my ($host, $state, $resp);
open ( FH, "<", "$hosts" ) or die "Can't open $hosts: $!";
while (
chomp;
$servers{$_} = 1;
}
while (1) {
foreach $host (keys %servers) {
$state = $servers{$host};
$resp = system("ping $host -n 1 > /dev/null 2>&1");
if ($resp == 0 && $state == 0) {
$servers{$host} = 1; #...server now up again...
`mailx -s "$host back up" root < /dev/null`
}
if ($resp != 0 && $state == 1) {
$servers{$host} = 0; #...server has gone down...
`mailx -s "$host is down" root < /dev/null`
}
}
sleep 300
}
1;
Regards!
...JRF...
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2006 08:09 AM
тАО01-23-2006 08:09 AM
Re: Need a Shell Script to do this job. If anybody have it handy,let me know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-23-2006 10:19 PM
тАО01-23-2006 10:19 PM
Re: Need a Shell Script to do this job. If anybody have it handy,let me know.
Set nagios up once with all your machines, and you'll even get nice emails, paging, hell even WML pages for your mobile phone with status messages..
Anyway ;)
I'm kinda a nagios fan now. I admit I only use it to monitor 25 systems, but it's pretty good for keeping track of things.