- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script help please.
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
Forums
Discussions
Discussions
Discussions
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
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
02-18-2003 09:18 AM
02-18-2003 09:18 AM
script help please.
#!/usr/bin/ksh
##################################################################
# Declare variables
PATH=/usr/bin:/usr/local/bin
SERVERS="/home/xxx/xxxxx"
PAGE="/opt/apache/htdocs/testing/testing-$(date +%m-%d-%Y).html"
TODAY="/opt/apache/htdocs/testing/testing.html"
TMP_PAGE1="/tmp/testing1.html"
TMP_PAGE2="/tmp/testing2.html"
DATE=$(date)
COLOR=""
FAIL_CODE=""
END=""
# Make sure we start clean
/usr/bin/rm -f $TMP_PAGE1 $TMP_PAGE2 $TODAY
# Start the page
cat <<-EOF > $PAGE
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
Last updated: $DATE
NOTES:
Please notify Engineering if any backup fails.
EOF
# Start the table
cat <<-EOF >> $PAGE
EOF # Get the data for i in `cat $SERVERS` do # Get the start time ssh $i "grep -i "Starting" /var/sam/log/br_log 2> /dev/null | tail -1" > $TMP_PAGE2 echo " " >> $TMP_PAGE2 # Get the end time - will also use later for COLOR selection END=$(ssh $i "tail -2 /var/sam/log/br_log 2> /dev/null | grep -v -e 'Starting'") echo $END >> $TMP_PAGE2 echo " " >> $TMP_PAGE2 echo " | " >> $TMP_PAGE2 # Get the failure code and set the color FAIL_CODE=$(ssh $i "tail -2 /var/sam/log/br_log 2> /dev/null | grep -i 'Completed' | tail -1") case $FAIL_CODE in "Completed" ) COLOR="GREEN" ;; "ERROR" ) COLOR="RED" ;; * ) COLOR="RED" ;; esac # Also set the COLOR based on $END [ $(echo $END | grep -c ERROR) -eq 1 ] && COLOR="GREEN" # Build the first column - This is where we set the color echo " | ||
" > $TMP_PAGE1 echo "" >> $TMP_PAGE1 echo "$i | " >> $TMP_PAGE1 echo "" >> $TMP_PAGE1 echo " " >> $TMP_PAGE1 # Pull it together cat $TMP_PAGE1 $TMP_PAGE2 >> $PAGE done # end the table echo " |
echo "" >> $PAGE
#
Here is the log output from 2 systems.
01/30/03 02:01:05
01/30/03 02:01:05 Starting non-root full backup ...
01/30/03 03:25:18 Full Backup was successful
01/30/03 03:25:18 Full Backup Completed.
##################################################
# EXITING with 0 return code.... #
##################################################
systems2
01/28/03 12:00:34
01/28/03 12:00:34 Starting non-root full backup ...
01/28/03 12:01:17 ERROR: Full Backup FAILED !!! Contact System Admin
01/28/03 12:01:17 Exit with error !!!
##################################################
system1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2003 09:49 AM
02-18-2003 09:49 AM
Re: script help please.
...
esace
I think is your problem...
Change to-
if $(ssh $i "tail -2 /var/sam/log/br_log 2> /dev/null | grep -q -i 'Completed'") ; then
COLOR="GREEN"
else
COLOR="RED"
fi
The if will test the status of the last command (grep in this case) and if Completed is found, then set COLOR to GREEN.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2003 11:13 AM
02-18-2003 11:13 AM
Re: script help please.
Since there is no fixed field for the STATUS, you may want to use this code. You can extend the if statement further if you have other STATUS values in addition to "successful" and "FAILED".
Take out the case statement and replace it with the following
....
ssh $i "tail -2 /var/sam/log/br_log " |grep "successful" > /dev/null 2>&1
if [ $? = 0 ]
then
COLOR="GREEN"
else
COLOR="RED
fi
...
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2003 11:17 AM
02-18-2003 11:17 AM
Re: script help please.
I've worked in a similar case but ussing a custom script file, my logic have been the following:
fbackup -0 -v -i / -e /tmp -f /dev/rmt/0m 2> /tmp/fbackup.log
STATUS=$?
case in $STATUS
0) Your successful procedure
;;
4) Your warning procedure
;;
*) Your fail procedure
;;
esac
The main advantage of redirect the log file (/tmp/fbackup.log), is that you can manipulate it to extract the warning messages and send them in the case of a status 4.
Rgds.