I have a ping script I use on an old Open Step box (I guess its closely related to Mac OS X) and it runs fine, but now I built a system as a backup with Ubuntu 8.10 client and the script needs to be adapted a bit. Can anyone see where or how this needs to be done? The script starts and assigns the variables, but chokes on the ping portion of it which I think is syntax related
There are a few places where the end of the line is missing due to my copy and paste, but the main ping part that's broke is all there. I am hoping there is a substitution or something obvious I need to make throughout the script that will make it work again. Thanks!
[Make Server List To Ping]
#this is the server list, with IP's and IP of the router
echo making server list
cat<<_EOF > /tmp/$SCRIPTNAME.serverlist
Albany1 xx.xx.xx.xx xx.xx.xx.1
_EOF
## [function to send the email notification with high or low importance]
notify()
{
echo "\n\nThis message sent by cron script /admin/scripts/crons/ping_servers.s
h on mpt1a01" > /tmp/$SCRIPTNAME.serverlist.explain
echo "Subject: RCP server stats\nImportance: $1 \n\n" | cat - /tmp/$SCRIPTNAME
.serverlist.upagain /tmp/$SCRIPTNAME.serverlist.wentdown /tmp/$SCRIPTNAME.server
list.stilldown /tmp/$SCRIPTNAME.serverlist.explain | /usr/lib/sendmail sam.lman@sbcglobal.net
cat /tmp/$SCRIPTNAME.serverlist.upagain /tmp/$SCRIPTNAME.serverlist.wentdown |
logger -t "ping_servers.sh" -p local4.err
}
# [make a list of servers that were down last time this script was run]
touch /admin/scripts/crons/$SCRIPTNAME.serverlist.down /admin/scripts/crons/$SC
RIPTNAME.serverlist.downlastrun
cp /admin/scripts/crons/$SCRIPTNAME.serverlist.down /admin/scripts/crons/$SCRI
PTNAME.serverlist.downlastrun
# [ping all the servers and accumulate a retry list]
echo pinging all the servers and accumulating a retry list
>/tmp/$SCRIPTNAME.serverlist.retry
while read NAME IP ROUTER
do
sping $NAME $IP $ROUTER | grep "(down" >>/tmp/$SCRIPTNAME.serverlist.retry
done</tmp/$SCRIPTNAME.serverlist
# [wait before retrying the down servers]
if [ -s /tmp/$SCRIPTNAME.serverlist.retry ]; then
echo waiting before retrying the down servers
sleep 10
else
echo no servers down
exit
fi
# [ping all the down servers with more packets to make sure they are down]
echo retrying down servers with more packets
> /admin/scripts/crons/$SCRIPTNAME.serverlist.down
while read NAME IP ROUTER OTHER
do
sping $NAME $IP $ROUTER 5 | grep "(down" >> /admin/scripts/crons/$SCRIPTNAME.s
erverlist.down
done</tmp/$SCRIPTNAME.serverlist.retry
# [look for differences]
# in this section, we are looking for what servers just went down,
# which ones just came back up, and which ones are still down from before
echo lists of recent downs and returns, and servers that remain down
>/tmp/$SCRIPTNAME.serverlist.wentdown
>/tmp/$SCRIPTNAME.serverlist.stilldown
>/tmp/$SCRIPTNAME.serverlist.upagain
while read NAME IP ROUTER
do
WASDOWN=`grep -w $NAME /admin/scripts/crons/$SCRIPTNAME.serverlist.downlastrun`
ISDOWN=`grep -w $NAME /admin/scripts/crons/$SCRIPTNAME.serverlist.down`
if [ -n "$WASDOWN" -a -n "$ISDOWN" ]; then
echo "$ISDOWN (still down)" >>/tmp/$SCRIPTNAME.serverlist.stilldown
fi
if [ -n "$WASDOWN" -a -z "$ISDOWN" ]; then
echo "$NAME $IP $ROUTER (up again)" >>/tmp/$SCRIPTNAME.serverlist.upagain
fi
if [ -z "$WASDOWN" -a -n "$ISDOWN" ]; then
echo "$ISDOWN (just went down)" >>/tmp/$SCRIPTNAME.serverlist.wentdown
fi
done</tmp/$SCRIPTNAME.serverlist
# cat /tmp/$SCRIPTNAME.serverlist.upagain /tmp/$SCRIPTNAME.serverlist.wentdown /
tmp/$SCRIPTNAME.serverlist.stilldown
# [if there are servers that just went down or came back up, notify with high importance]
if [ -s /tmp/$SCRIPTNAME.serverlist.upagain -o -s /tmp/$SCRIPTNAME.serverlist.we
ntdown ]; then
echo notifying of servers that are up again or just now down
notify high
# [if there is no new news, but servers are still down from before,
# notify only once per day, with low importance]
elif [ -s /tmp/$SCRIPTNAME.serverlist.stilldown ]; then
if [ "`date | awk '{print $4}' | awk -F: '{print $1}'`" -eq 11 ]; then
if [ ! -f /tmp/$SCRIPTNAME.stilldownsent ]; then
touch /tmp/$SCRIPTNAME.stilldownsent
echo notifying once today of servers that are still down from before
notify low
fi
else
echo not time for daily notification of servers that are still down
if [ -f /tmp/$SCRIPTNAME.stilldownsent ]; then
rm /tmp/$SCRIPTNAME.stilldownsent
fi
fi
else
echo no notification to make
fi
Last edited by gbxfan; 04-13-2009 at 07:29 PM..
Reason: CODE TAG ADDED
I have a ping script I use on an old Open Step box (I guess its closely related to Mac OS X) and it runs fine, but now I built a system as a backup with Ubuntu 8.10 client and the script needs to be adapted a bit. Can anyone see where or how this needs to be done? The script starts and assigns the variables, but chokes on the ping portion of it which I think is syntax related
Have you read the man page for ping to see where its syntax differs from the Open Step version?
Quote:
There are a few places where the end of the line is missing due to my copy and paste,
Please edit your post and fix those places; you can't expect accurate help if we can't see exactly what you are doing.
While you're at it, please enclose the script in [code] tags.
Quote:
but the main ping part that's broke is all there.
Which part is that?
Have you tried just executing those parts (substituing reasonable values for the variables)?
Quote:
I am hoping there is a substitution or something obvious I need to make throughout the script that will make it work again. Thanks!
Thanks for your time. I have placed the entire script (minus a few clients) and have tried to add tags for each section (if I understood you correctly - I hope this makes it easier) and have also added space between the sections. I appreciate your time in looking at this. I'll have to review the man pages and see if something pops out at me. Dale
I hope I did this right, I have added the code tags - I thought they should be whereever processing is done? Please let me know. Thanks for your time. Dale
Hi All,
I am trying to print all the packages info in solaris 11 using below script.
#!/usr/bin/env bash
pkginfo -l | egrep '(BASEDIR|NAME|VERSION)' | awk '{print}' > /tmp/cp1
/usr/bin/nawk -F: '
{for (i=1; i<=NF; i++) {gsub (/^ *| *$/, "", $i)
... (5 Replies)
Here is a powershell script to use restful API to create ticket in our ticketing tool. Can anyone please convert it to a shell script sothat, I can run it in Unix servers,
below is the code:
$body = @{
Customer= ''test'
Summary= 'test summary'
Impact= '4-Minor/Localized'
... (2 Replies)
Hi All,
I have a small tool which is currently configured in batch scripts only. But my need is to run it on Linux platform, so I have been trying to convert a batch script to shell script.
below is the batch script:
@echo off
IF "%1"== "" GOTO ARGERR
REM UPDATE THESE PROPERTIES TO... (2 Replies)
Hi Guys
I am having a perl script that fetches exclude list from a unix client and I trying it to convert it to shell script but I am having issues please help me...
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Std;
# To turn on debuging (i.e. more information) specify... (29 Replies)
Hi
I have a file in the format with so many records
DB2 Universal JDBC Driver Provider,wdialdcsq,New JDBC Datasource,jdbc/wdialdcsq,,dcsqdb2n,cldrdgw1.is.chrysler.com,2998,DB2,10,1,180,0,1800
i need to convert all these into
<DataSource name="wdialODDC" maxConnection="10" minConnection="0 "... (1 Reply)
thanks for allowing me join your forum
i have an output of linux command "who"
which provides following details.....
CURRENT USER/ACCT INFO
17:31:36 up 4:49, 4 users, load average: 0.03, 0.04, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root :0 - 12:59 ?xdm? 4:54 0.02s /bin/sh /usr/bi... (1 Reply)
Can anyone provide me with a ksh or bash script which will accept a timestamp (format is YYYY-MM-DD-HH24.Mi.Ss) and time offset (in hours). The output will be (timestamp passed - time offset passed deducted from it) in the same YYYY-MM-DD-HH24.Mi.Ss format.
Basically I am trying to convert the... (1 Reply)
I have oracle 9i database installed with UTF-8 Encoding.
I want a perl script that converts unicode to utf8 before commiting in database and utf8 to unicode when retreiving from database
For example :
the word Ïntêrnatïônàlîzâtion has to be stored in database as Internationalization and when retreived... (6 Replies)
Hi,
I am a newbie and do not have much experience using unix. But I have been trying to understand it. I found the following unix script
typeset -i n=0
while
do
sleep 5
echo "${n}:Fluent is running...."
n=${n}+1
done
I have the following doubts:
1) In the first line - I am aware... (1 Reply)
My question is:
i have a script called getevent
to run i just call ./getevent
can i convert this to make it binary executable and not letting my clients open it and see the code.??:(
I am using Solaris 8. (3 Replies)