LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-31-2016, 11:45 AM   #1
linuxmantra
Member
 
Registered: Dec 2013
Posts: 113

Rep: Reputation: Disabled
Script via Satellite


I have written script to check ntpstatus, if ntp service dead it will email to SA else it will email to SA team that script has been executed. I run script everyday at 8 AM via cron. I have 100s of system registered in satellite. Problem here is if script is executed, in 100s of system and no ntp service issue then 100s of email will comes up stating "script executed". I want only one email not 100s. here is my code. Any suggestion how can I modify my script.

#!/bin/bash
#
# NTP service check script
#

MAILTO="sa@exmaple.com"
/sbin/service ntpd status
OUT=$?
if [ $OUT -ne 0 ];
then
echo "Please check, ntp service is dead on $(hostname)" | mailx -s "NTP service dead in $(hostname)" $MAILTO
else
echo "No issue. ntp service check script executed on $(date)" | mailx -s "ntpstatus script executed" $MAILTO
fi
 
Old 03-31-2016, 12:00 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,689

Rep: Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972
Quote:
Originally Posted by linuxmantra View Post
I have written script to check ntpstatus, if ntp service dead it will email to SA else it will email to SA team that script has been executed. I run script everyday at 8 AM via cron. I have 100s of system registered in satellite. Problem here is if script is executed, in 100s of system and no ntp service issue then 100s of email will comes up stating "script executed". I want only one email not 100s. here is my code. Any suggestion how can I modify my script.
Code:
#!/bin/bash
#
# NTP service check script
#

MAILTO="sa@exmaple.com"
/sbin/service ntpd status
OUT=$?
if [ $OUT -ne 0 ];
then
        echo "Please check, ntp service is dead on $(hostname)" | mailx -s "NTP service dead in $(hostname)" $MAILTO
else
echo "No issue. ntp service check script executed on $(date)" | mailx -s "ntpstatus script executed" $MAILTO
fi
Please use CODE tags.

And if you're saying that you have this script on 100 machines now...you're STILL going to get 100 emails..whether they come in at exactly the same second or not won't matter.

If it was me, I'd write a script using snmpwalk, to cycle through the running processes on the systems listed in a file/database/whatever, and check for the process. Build a single email from that, and have it run one ONE system, to send out one email. You could even use passwordless-ssh and cycle through a simple command (such as "service check ntpd" or "ps -ef | grep ntp"), and parse the results to build that email.
 
Old 03-31-2016, 12:02 PM   #3
malekmustaq
Senior Member
 
Registered: Dec 2008
Location: root
Distribution: Slackware & BSD
Posts: 1,669

Rep: Reputation: 498Reputation: 498Reputation: 498Reputation: 498Reputation: 498
1. Change that MAILTO to a single flag packet addressed to your admin system IP; this way you will know which among the 100s reported a success or fail flag; or you can delimit reporting only those that failed.
2. Then you only run a local script to read the control record to identify which clients failed.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] use bios from Toshiba Satellite 3000 on a Satellite 2800-202? coyotl Linux - Hardware 4 12-13-2011 03:44 AM
satellite internet + VoIP or satellite internet + satellite phone rblampain Linux - Networking 2 08-27-2010 08:05 AM
Satellite on PC 12jewels Linux - Software 1 08-03-2007 03:01 PM
Toshiba Satellite bigredgiant1 Linux - Laptop and Netbook 1 08-29-2003 09:44 PM
Script for Netscape and satellite. marksstroud Programming 1 01-01-2002 09:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration