LinuxQuestions.org
Help answer threads with 0 replies.
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 09-29-2015, 09:29 AM   #1
linuxmantra
Member
 
Registered: Dec 2013
Posts: 112

Rep: Reputation: Disabled
Satellite and cron


I have a satellite server where around 500 systems are registered. I want to run a 'ntp status check' script daily. I want to put that script in satellite server and set a cronjob and want the script to run on all 500 system. I don't want script & cron to be placed in each individual machine. Script should remain in satellite server only so any time I can change or do what ever I like. Is there anyway this can be done via Red Hat Satellite server?

Last edited by linuxmantra; 09-29-2015 at 11:04 AM.
 
Old 09-29-2015, 11:10 PM   #2
Rinndalir
Member
 
Registered: Sep 2015
Posts: 733

Rep: Reputation: Disabled
Sounds like you would want your satellite server to be the time server and the 500 systems would sync time from the server.
Use ntp for this.
 
Old 09-30-2015, 02:02 PM   #3
linuxmantra
Member
 
Registered: Dec 2013
Posts: 112

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Rinndalir View Post
Sounds like you would want your satellite server to be the time server and the 500 systems would sync time from the server.
Use ntp for this.
Nope. I want to run simple ntpstat command in all servers and want to make sure ntp service is running well.

Well, I have figured out it can be done via spacecmd. Only thing i am stucked is how to mentione multiple host in a command

# spacecmd -s <server-name(s)> system_runscript -f /usr/local/bin/myscript.sh

Just wonderful how to list 500 servers in <server-name> space. Not sure if don't specify server name what it will take.
 
Old 09-30-2015, 08:29 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
Looking at the man page here http://linux.die.net/man/1/spacecmd it looks like if you don't specify a server, it contacts all the ones it knows about...
 
Old 10-01-2015, 03:35 PM   #5
linuxmantra
Member
 
Registered: Dec 2013
Posts: 112

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by chrism01 View Post
Looking at the man page here http://linux.die.net/man/1/spacecmd it looks like if you don't specify a server, it contacts all the ones it knows about...
root@rhel01:~# spacecmd -- system_runscript root:root -f /usr/local/bin/ntpstatus.sh
INFO: Connected to https://localhost/rpc/api as satadmin
WARNING: No systems selected

root@rhel01:/usr/local/bin# spacecmd -s txxdb01.domain.com -- system_runscript root:root -f /usr/local/bin/ntpstatus.sh
ERROR: Failed to connect to https://txxdb01.domain.com/rpc/api


huhhh...
 
Old 10-01-2015, 04:27 PM   #6
linuxmantra
Member
 
Registered: Dec 2013
Posts: 112

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by linuxmantra View Post
root@rhel01:~# spacecmd -- system_runscript root:root -f /usr/local/bin/ntpstatus.sh
INFO: Connected to https://localhost/rpc/api as satadmin
WARNING: No systems selected

root@rhel01:/usr/local/bin# spacecmd -s txxdb01.domain.com -- system_runscript root:root -f /usr/local/bin/ntpstatus.sh
ERROR: Failed to connect to https://txxdb01.domain.com/rpc/api


huhhh...
OK.. Here we go:

root@rhel01:~# spacecmd -- system_runscript txxdb01.domain.com root:root -f /usr/local/bin/ntpstatus.sh <---- This works percelty

BUT ... this is only for a single system txxdb01.domain.com. how to select all the system that has been registered in satellite. What options makes default as to take all the system...
 
Old 10-01-2015, 04:36 PM   #7
Rinndalir
Member
 
Registered: Sep 2015
Posts: 733

Rep: Reputation: Disabled
You can wrap that spacecmd in a bash script loop or perl or python or your favorite.

Or you can take a more passive approach and monitor which hosts have sync'd time and which have not.
You can use ntp logging or syslog.
 
Old 10-01-2015, 11:05 PM   #8
linuxmantra
Member
 
Registered: Dec 2013
Posts: 112

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Rinndalir View Post
You can wrap that spacecmd in a bash script loop or perl or python or your favorite.

Or you can take a more passive approach and monitor which hosts have sync'd time and which have not.
You can use ntp logging or syslog.
Thanks for the response. Yes, I will wrap spacecmd in bash script. Script would look like
SCRIPT 1:
#!/bin/bash
/usr/bin/bash/spacecmd -y --system_runscript txxdb01.domain.com -s root:root -f /usr/local/bin/ntpstatus.sh

SCRIPT 2 will be basically ntpstatus check script

And then I will set cronjob to invoke script 1.

But sole standing PROBLEM infront of me is: How do I make my Script 1 to take all the system that are registered in satellite server. What options is available in sapcecmd command? so in place -- system_runscript <?????> what should I use here <????> so that script get pushed on all the system.
 
Old 10-02-2015, 09:36 AM   #9
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060
Just a couple of thoughts.

You've got a bunch of servers, you want to know if they're on time. If I've got it right, you're serving time to them; NTP is running on all those servers, you're the time source and they all should be plus or minus no more than a second or two to you. If there is a server that's not within a few seconds, you want to take a harder look at it and see if NTP is running or not on that box.

So, why not compare your system date to "their" system date (keeping it really simple)?

If you, in a loop, get your system date as the number of seconds since the epoch date with
Code:
date +'s'
and execute the same on the target system then compare the two values (basically, subtract one from the other) to see how far out of time the target system may be, then, if it is out too far, execute, say,
Code:
ps -ef | grep ntpd
on the target which will tell you whether NTP is running on it (NTP synchronizes within milliseconds, so a couple of seconds out of synchronization would be an indication that you need to look further).

You'd want to ping the remotes to see if they're alive (if you're working from a list of addresses), you might want to remote execute ntpq on a questionable target, maybe a few other things to notify you (maybe with e-mail) that server XYZ has got a problem. You don't care if a system is on-time, you only care about one that is out.

Doing this will go likety-split fast but you'd want to execute the date command on both systems for every check, do a little shell arithmetic and that's pretty much that. Might take a little experimenting to learn the "best" difference value, system clocks do drift a little but not that much.

Hope this helps some.
 
Old 10-02-2015, 01:48 PM   #10
linuxmantra
Member
 
Registered: Dec 2013
Posts: 112

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by tronayne View Post
Just a couple of thoughts.

You've got a bunch of servers, you want to know if they're on time. If I've got it right, you're serving time to them; NTP is running on all those servers, you're the time source and they all should be plus or minus no more than a second or two to you. If there is a server that's not within a few seconds, you want to take a harder look at it and see if NTP is running or not on that box.

So, why not compare your system date to "their" system date (keeping it really simple)?

If you, in a loop, get your system date as the number of seconds since the epoch date with
Code:
date +'s'
and execute the same on the target system then compare the two values (basically, subtract one from the other) to see how far out of time the target system may be, then, if it is out too far, execute, say,
Code:
ps -ef | grep ntpd
on the target which will tell you whether NTP is running on it (NTP synchronizes within milliseconds, so a couple of seconds out of synchronization would be an indication that you need to look further).

You'd want to ping the remotes to see if they're alive (if you're working from a list of addresses), you might want to remote execute ntpq on a questionable target, maybe a few other things to notify you (maybe with e-mail) that server XYZ has got a problem. You don't care if a system is on-time, you only care about one that is out.

Doing this will go likety-split fast but you'd want to execute the date command on both systems for every check, do a little shell arithmetic and that's pretty much that. Might take a little experimenting to learn the "best" difference value, system clocks do drift a little but not that much.

Hope this helps some.
Thank you for your time and writing. My overall objective is I want to run # service ntpd status, to check whether service is running or not. We had ntp service dead issue many time. I want this to be get done by Satellite Server. I place script in satellite server and set the cron to invoke the script. This can be done by sapcecmd comand in satellite which I have test perfectly in one system and work great but problem is how to select all the server. see the command line below:
spacecmd -y -- system_runscript tqanrdmc01.bnqa.bn-dev.com -f /usr/local/bin/ntpstatus.sh

While reading some article I found that if we use ssm ( --system_runscript ssm -f /xx ) then I will take the system, but I want to confirm from any one who has the knowledge in satellite server.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 04:44 AM
Strange Cron directories: /var/spool/cron/cron.GfqqGO Woodsman Slackware 4 05-11-2011 03:37 PM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 09:16 AM
cron not working from crontab nor form /etc/cron/cron.d. What did SuSE change? JZL240I-U SUSE / openSUSE 11 01-04-2007 02:57 AM
Can any one plz explain why/what for cron.d, cron.daily, cron.weekly etc are there. mavinashbabu Linux - Newbie 4 09-21-2006 02:50 PM

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

All times are GMT -5. The time now is 04:15 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration