Posts tagged bash
HP Array Configuration Utility RAID Controller Checker Script
2hpacucli-check.sh is a bash shell script that checks the status of the logical drives on a HP Server with hpacu (HP Array Configuration Utility Client) installed, syslogging and sending an email with errors to administrators.
Tested ona HP Proliant DL580 G5 Server with Debian Lenny and HP Array Configuration Utility Installed, this software is available from the “HP ProLiant Support Pack CD for Debian GNU/Linux 5.0 (“lenny”) and Ubuntu 9.04 (“jaunty”) x86 and AMD64/EM64T” downloadable from the HP Support Web Site.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #!/bin/bash ### # FILE: hpacucli-check.sh (2010-11-05) # LICENCIA: GNU/GPL v3.0 # USAGE: Check the status of the logical drives on a HP Server # with hpacu (HP Array Configuration Utility Client) # installed, syslog and send an email with errors. # AUTHOR: Olaf Reitmaier Veracierta <olafrv@gmail.com> / www.olafrv.com ## MAIL=root@localhost HPACUCLI=`which hpacucli` HPACUCLI_TMP=/tmp/hpacucli.log hpacucli ctrl all show | grep "Slot " | while read line1 do slot=`expr match "$line1" '.*Slot \([0-9]\).*'` echo "Searching controller in slot #$slot..." hpacucli ctrl slot=$slot array all show | grep array | while read line2 do array=`expr match "$line2" '.*array \([a-Z]\).*'` echo "Searching array $array..." hpacucli ctrl slot=$slot array $array logicaldrive all show | grep logicaldrive | while read line3 do logicaldrive=`expr match "$line3" '.*logicaldrive \([0-9]\).*'` echo "Searching logical drive #$logicaldrive..." if [ `hpacucli ctrl slot=$slot array $array logicaldrive $logicaldrive show | grep "Status: OK$" | wc -l` -lt 2 ] then msg="RAID Controller Error Slot #$slot Array $array Logical Drive #$logicaldrive" echo $msg logger -p syslog.error -t RAID "$msg" $HPACUCLI ctrl slot=$slot show config detail > $HPACUCLI_TMP mail -s "$HOSTNAME [ERROR] - $msg" "$MAIL" < $HPACUCLI_TMP rm -f $HPACUCLI_TMP fi done done done |
See Also: http://wiki.debian.org/HP/ProLiant
How to capitalize letters on bash shell script
1It’s easy just use the tr command to lower, upper or capital case.
Here is an example…
1 2 3 4 5 6 7 8 9 | function toCapital { for x in $* do echo -n ${x:0:1} | tr '[a-z]' '[A-Z]' | xargs echo -n echo -n ${x:1} | tr '[A-Z]' '[a-z]' | xargs echo -n echo -n " " done } |
To test the function just call it:
1 | toCapital yuCa aMigo |
The output is:
Yuca Amigo
Hope it’s useful.