[CentOS] cat cron jobs crontab: SOLVED

Karl R. Balsmeier karl at klxsystems.net
Tue Mar 13 20:16:20 UTC 2007


Florin Andrei wrote:

> Karl R. Balsmeier wrote:
>
>>
>> #put in whatever cron checks you need, one by one...
>> echo "*/3 * * * *  
>> /usr/lib64/nagios/plugins/check_megaraid_passive.sh > /dev/null 2>&1" 
>> >> /var/spool/cron/root
>
>
> How are you going to remove or modify that line in a _safe_ and simple 
> fashion when you'll have to?
> Are you verifying if someone or something else has opened the 
> /var/spool/cron/root file for editing while you're messing with it?
>
> With a dedicated file (separate files for each task / purpose / 
> application / whatever) in /etc/cron.d changes or an altogether 
> removal are both trivial and safe.
>
I am the only user on the box, -this is all part of the %post element of 
a Kickstart file.  No one's on there, heh.  But I see what you mean.  If 
this were not the only cron job on the machine, i'd probably entertain 
the single-file/single-job tactic.

This particular question was aimed at adding the final line in a 
kickstart post-install script, e.g. modifying crontab in an automatic 
way to complete a given server build.  Specifically the local changes a 
system gets to make it ready for Nagios monitoring, prior, I needed to 
manually visit all the machines i'd built and crontab -e.  But then a 
phone rings, or a pager goes off, or a human appears, wanting something, 
heh.  Automatic is the way.

I'll be creatively using cat and echo to automate the builds with as 
little sysadmin intervention as possible, I like to have a 
production-ready server active within 20 minutes (I mean production as 
in our company's highly detailed linux build), so here's an example of 
just one of those 20+ 'moving parts', that if done manually, on 10 
machines, takes an hour or so at the very least, vs. 10 seconds max:
------------------snip----------------
# Megamake.sh <krb> 2007

###########################
# LSILOGIC RAID CARD TOOLS MEGARC
# This script assumes you already have nagios installed,
# and send_nsca.cfg, nrpe.cfg, and /etc/xinetd.d/nrpe set properly

mkdir -v /usr/local/bin/megaraid
cd /usr/local/bin/megaraid
# don't wget from public, get from kickstart source dir.
# wget 
http://www.lsilogic.com/files/support/rsa/utilities/megaconf/ut_linux_megarc_1.11.zip 

# wget 
http://my.kickstart.server.ip:/kickstart/sources/lsilogic/ut_linux_megarc_1.11.zip 
<http://www.lsilogic.com/files/support/rsa/utilities/megaconf/ut_linux_megarc_1.11.zip>

unzip ut_linux_megarc_1.11.zip
chmod +x megarc.bin
chmod +x megarc

# test the tool, -show the RAID level and how many disks you have, and 
their device ids:
echo "THIS IS YOUR BASIC RAID SETUP"
./megarc -ctlrInfo -a0

# Run this command on your nagios server to see plugin results in real 
time:
# tail -f /var/log/nagios/nagios.log

cd /usr/local/src
wget://my.kickstart.server.ip:/kickstart/src/nagios/plugins/check_megaraid_passive.sh 


cp check_megaraid_passive.sh /usr/lib64/nagios/plugins/
chmod +x /usr/lib64/nagios/plugins/check_megaraid_passive.sh

# run it, see if any errors pop up
/usr/lib64/nagios/plugins/check_megaraid_passive.sh

# open it in vi to edit, in case there are errors, if not just close it.
vi /usr/lib64/nagios/plugins/check_megaraid_passive.sh

# check the perms, if they match the other plugins
ls -al /usr/lib64/nagios/plugins/check_megaraid_passive.sh
# run it again
/usr/lib64/nagios/plugins/check_megaraid_passive.sh

# edit the cron job for this guy:
echo "*/3 * * * *  /usr/lib64/nagios/plugins/check_megaraid_passive.sh > 
/dev/null 2>&1" >> /var/spool/cron/root
# restart crond
service crond restart

# At this point your Nagios check for this one service should go "green" 
and you can hit the other 10 Nagios checks
# with your other scripts, and move on to Cacti adjustments.

--------------snip--------------

-karlski







More information about the CentOS mailing list