Sie sind auf Seite 1von 7

Script for Monitoring iCAP Systems

icapreport.sh - a script for monitoring an iCAP system


Technical white paper Table of contents
Issue................................................................................................................................................... 2 Solution .............................................................................................................................................. 2 Script ................................................................................................................................................. 3 For more information ............................................................................................................................ 7 Call to action ...................................................................................................................................... 7

Issue
Sometimes a system administrator is unaware when there are problems with an iCAP system and the problems can persist for a long time before it becomes obvious that action is required. This can result in the following outcomes: Temporary Capacity (TiCAP) is consumed inadvertently, and possibly a negative TiCAP balance results. Cores allocated to vPars exceed the quantity of usage rights available, resulting in one or more vPars being unable to reboot. Communication problems between partitions might prevent other partitions from being able to allocate expected resources, and/or result in inadvertent TiCAP consumption.

Whitepapers are available that describe these problems and steps to take to prevent them. You can find them at the following locations:

Maintaining iCAP Compliance on HP Integrity & HP 9000 Mid-range & Superdome Servers Practices for maintaining compliance with iCAP on Superdome 2

Solution
A sample script has been written that can be used to have a summary of the status of an iCAP system mailed to the system administrator on a daily basis. The script is intended to be run from cron(1M). The entire script is included below in this document. It can be used as is, or modified to suit your specific needs. The script includes instructions for adding it to roots crontab(1). Use of this script will ensure that if there are problems with the iCAP system, the system administrator will be notified and be able to correct the situation before it escalates into a critical issue.

Script
#!/usr/bin/sh # set -x # # File: icapreport.sh # Purpose: This script is meant to be run as a cron job on a daily # basis for the purpose of notifying the system administrator # when certain iCAP issues need attention. # Instructions: # 1. Save this file in a directory such as /usr/local/bin. # 2. Modify the RECIPIENT variable to be either a user's e-mail # address to receive this report or an e-mail alias for a # distribution list. # 3. Add an entry to root's crontab -- see crontab(1). # An example crontab entry would be: # 00 03 * * * /usr/local/bin/icapreport.sh # That would generate a report every day at 03:00am # # Limitations: This script is compatible with versions 8.x, 9.x and 10.x # of the iCAP software. It explicitly does not work # with earlier versions of iCAP. # # (C) Copyright 2010 Hewlett-Packard Development Company, L.P. # # Disclaimer: This script is meant to be an example that should be # modified by the user to meet their specific needs. # # DISCLAIMER OF WARRANTY # The following software: icapreport.sh is experimental and is provided as # a courtesy, free of charge, "AS-IS" by Hewlett-Packard Company ("HP"). # HP shall have no obligation to maintain or support this software. # HP MAKES NO EXPRESS OR IMPLIED WARRANTY OF ANY KIND REGARDING THIS SOFTWARE # INCLUDING ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR # PURPOSE, TITLE OR NON-INFRINGEMENT. HP SHALL NOT BE LIABLE FOR ANY DIRECT, # INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, WHETHER BASED ON # CONTRACT, TORT OR ANY OTHER LEGAL THEORY, IN CONNECTION WITH OR ARISING # OUT OF THE FURNISHING, PERFORMANCE OR USE OF THIS SOFTWARE.

# Capture everything to be mailed in this file MSGFILE=`mktemp -d /tmp -p AAA` # Make sure that we are pointing to the actual mailx command. MAILX="/usr/bin/mailx" # Check that mailx command is present. if [[ ! -f "$MAILX" ]] then echo "Daily iCAP Status Report" echo "ERROR: mailx command not found: $MAILX" rm -f $MSGFILE exit 1 fi # Specify recipient to mail report to.

# A best practice would be to establish an e-mail alias to receive # this report. RECIPIENT="root@localhost" # Run everything in a sub-shell to mail complete output ( # For safety, use a minimum $PATH for generic commnds. export PATH="/usr/bin:/usr/sbin:" # Create temporary file to capture stderr ERRFILE=`mktemp -d /tmp -p AAA` # Get current date/time DATE=`date 2>>$ERRFILE` RC=$? if [[ $RC -ne 0 ]] then echo "Daily iCAP Status Report" echo "ERROR: Unable to run date command" cat $ERRFILE rm -f $ERRFILE exit $RC fi # Report header echo "Daily iCAP Status Report for: $DATE" echo "" # Make sure that we are pointing to the actual icapstatus command. ICAPSTATUS="/usr/sbin/icapstatus" # Check that icapstatus command is present. if [[ ! -f "$ICAPSTATUS" ]] then echo "ERROR: icapstatus command not found: $ICAPSTATUS" cat $ERRFILE rm -f $ERRFILE exit 1 fi # Run icapstatus command once and capture output. ICAPOUT=`$ICAPSTATUS 2>>$ERRFILE` RC=$? if [[ $RC -ne 0 ]] then echo "ERROR: Unable to run $ICAPSTATUS" cat $ERRFILE rm -f $ERRFILE exit $RC fi IFS=" " EXCEPTIONSTATE=No typeset -i WARNINGS=0 typeset -i ERRORS=0 echo "$ICAPOUT" | while read TOK1 TOK2 TOK3 TOK4 TOK5 TOK6 TOK7 TOK8 TOK9

do case "$TOK1" in "") ;; # Ignore blank lines System) # Check if System contact e-mail is set if [[ "$TOK3" = "e-mail:" ]] then if [[ "$TOK4" = "Not" ]] then echo "WARNING: System contact e-mail is not set." echo " Use icapmodify(1M) -c option to set." let WARNINGS=$WARNINGS+1 fi fi ;; Exception) # Check for exceptions if [[ "$TOK3" != "No" ]] then echo "ERROR: iCAP Complex is in an exception status:" echo " $TOK3 $TOK4 $TOK5 $TOK6 $TOK7 $TOK8 $TOK9" let ERRORS=$ERRORS+1 EXCEPTIONSTATE=Yes else EXCEPTIONSTATE=No fi ;; Local|Member) # Determine when list of exceptions has stopped if [[ "$EXCEPTIONSTATE" = "Yes" ]] then EXCEPTIONSTATE=No fi ;; Number) # Check if TiCAP is being consumed if [[ "$TOK5" = "temporary" && "$TOK7" != "0" ]] then echo "WARNING: Temporary Capacity is being consumed:" echo " $TOK1 $TOK2 $TOK3 $TOK4 $TOK5 $TOK6 $TOK7 $TOK8 $TOK9" let WARNINGS=$WARNINGS+1 fi ;; Temporary) # Check TiCAP balance is negative if [[ "$TOK4" = "(negative)" ]] then echo "ERROR: Negative temporary capacity balance:" echo " $TOK1 $TOK2 $TOK3 $TOK4 $TOK5 $TOK6 $TOK7 $TOK8 $TOK9" let ERRORS=$ERRORS+1 fi ;; Projected) # Check if TiCAP is about to expire, or has already expired case "$TOK5" in N/A) ;; # Ignore Expired) echo "ERROR: Temporary capacity has expired." let ERRORS=$ERRORS+1 ;; *) echo "WARNING: Temporary Capacity is about to expire:" echo " $TOK1 $TOK2 $TOK3 $TOK4 $TOK5 $TOK6 $TOK7 $TOK8 $TOK9" let WARNINGS=$WARNINGS+1

;; esac ;; *) # Catch additional exceptions after first one if [[ "$EXCEPTIONSTATE" = "Yes" ]] then echo " $TOK1 $TOK2 $TOK3 $TOK4 $TOK5 $TOK6 $TOK7 $TOK8 $TOK9" fi ;; esac done # Summarize results if [[ -s $ERRFILE ]] then echo "ERRORS encountered while running script:" cat $ERRFILE fi if [[ $WARNINGS -gt 0 || $ERRORS -gt 0 ]] then echo "" fi echo "WARNINGS found: $WARNINGS" echo "ERRORS found: $ERRORS" rm -f $ERRFILE ) > $MSGFILE # Mail final report to recipient $MAILX -s "iCAP Daily Status Report" $RECIPIENT < $MSGFILE rm -f $MSGFILE exit 0

For more information


To get access to more technical documentation on iCAP such as user guides, release notes and technical whitepapers go to www.hp.com/go/hp-icap-docs

Call to action
If you want to know more about the HP Utility Pricing Solutions offering called HP Instant Capacity, please contact your HP representative or visit: www.hp.com/go/icap

Share with colleagues

Copyright 2010 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. The only warranties for HP products and services are set forth in the express warranty statements accompanying such products and services. Nothing herein should be construed as constituting an additional warranty. HP shall not be liable for technical or editorial errors or omissions contained herein.

4AA2-7787ENW, Created August 2010

Das könnte Ihnen auch gefallen