Solaris Server dectects EMC dead path and send mail immediately | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Solaris Server dectects EMC dead path and send mail immediately

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-05-2011
orafup orafup is offline
Registered User
 
Join Date: Oct 2011
Last Activity: 29 June 2012, 2:33 PM EDT
Location: Los Angeles
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Solaris Server dectects EMC dead path and send mail immediately

taus-itcapp1#powermt display dev=all

Pseudo name=emcpower0a

CLARiiON ID=APM00105201788 [Sol_Taus_itcapp1]

Logical device ID=60060160B2202B001094F0E0AF5CE011 [SolDA_Taus_itcapp1_data]

state=alive; policy=CLAROpt; priority=0; queued-IOs=0;

Owner: default=SP A, current=SP A Array failover mode: 1

==============================================================================

--------------- Host --------------- - Stor - -- I/O Path -- -- Stats ---

### HW Path I/O Paths Interf. Mode State Q-IOs Errors

==============================================================================

3072 pci@1d,700000/SUNW,qlc@1/fp@0,0 c3t5006016446E01FEFd0s0 SP A4 active alive 0 0

3072 pci@1d,700000/SUNW,qlc@1/fp@0,0 c3t5006016C46E01FEFd0s0 SP B4 active dead 0 1

3073 pci@1e,600000/SUNW,qlc@3/fp@0,0 c4t5006016546E01FEFd0s0 SP A5 active alive 0 0

3073 pci@1e,600000/SUNW,qlc@3/fp@0,0 c4t5006016D46E01FEFd0s0 SP B5 active dead 0 1


The script is running every 10 mins to detect the ECM dead path ( see above) and sendind an email only when it detect the dead paths

The simple way is
10,20,30,40,50,59 * * * * /ect/powermt display dev=all|awk '{print $7}' |grep -i dead |mail orafup@mymail.com <---work perfect when there is a dead path

and the script

Code:
#!/bin/sh 
MYMAIL="orafup@mymail.com"
powermt display dev=all|awk '{print $7}' |grep -i dead|mail $MYMAIL
exit

the problem is there is no subject with the "mail" but if i am using the "mailx -s" , it will deliver a blank email even if there is no dead path detection.

I am trying to add an argument into the script but it seems not working 

#!/bin/sh
HOSTNAME=`uname -a`
EMCSTATUS=`powermt display dev=all|awk '{print $7}' |grep -i dead
MYMAIL="orafup@mymail.com"
TEMPF=/tmp/prog$$
powermt display dev=all|awk '{print $7}' |grep -i dead |wc -l >$TEMPF
if [ ($TEMPF) -ne 0 ]
  then 
 echo " there is the dead path "
else 
  :
fi
mailx -s "Please check $HOSTNAME of $EMCSTATUS" $MYMAIL
exit

Please help me out.
Thanks!

Last edited by Franklin52; 10-06-2011 at 02:11 AM.. Reason: Please use code tags, thank you
Sponsored Links
    #2  
Old 10-06-2011
ygemici ygemici is offline Forum Advisor  
sed_shell@LNU
 
Join Date: Feb 2010
Last Activity: 17 April 2014, 11:04 AM EDT
Location: istanbul
Posts: 1,649
Thanks: 2
Thanked 280 Times in 273 Posts

Code:
#!/bin/sh
HOSTNAME=`uname -n`;MYMAIL='yourmail@yourdomain';TEMPF=/tmp/prog$$
powermt display dev=all|awk '/Pseudo name/{print substr($0,13,length($0))}'|
while read -r dev;do if [[ $(powermt display dev=$dev|grep -i dead) ]] ; then
powermt display dev=$dev>$TEMPF;mailx -s "There is a dead path(s) at the '$dev' device in $HOSTNAME" $MYMAIL<$TEMPF
fi; done


Last edited by ygemici; 10-06-2011 at 03:20 AM..
Sponsored Links
    #3  
Old 10-06-2011
orafup orafup is offline
Registered User
 
Join Date: Oct 2011
Last Activity: 29 June 2012, 2:33 PM EDT
Location: Los Angeles
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts

Code:
#!/bin/sh
HOSTNAME=`uname -n`;MYMAIL='yourmail@yourdomain';TEMPF=/tmp/prog$$
powermt display dev=all|awk '/Pseudo name/{print substr($0,13,length($0))}'|
while read -r dev;do if [[ $(powermt display dev=$dev|grep -i dead) ]] ; then
powermt display dev=$dev>$TEMPF;mailx -s "There is a dead path(s) at the '$dev' device in $HOSTNAME" $MYMAIL<$TEMPF
fi; done

I like your script . it is good for multi-luns but it dont think it work

Code:
#!/bin/sh
HOSTNAME=`uname -n`
MYMAIL="yourmail@yourdomain"
TEMPF=/tmp/prog$$
powermt display dev=all|awk '/Pseudo name/{print substr($0,13,length($0))}'|while read -r dev;
do
  echo $dev
  powermt display dev=$dev|grep -i dead
 if [[ $(powermt display dev=$dev|grep -c dead) -ne 0]] ;
 then
    powermt display dev=$dev>$TEMPF;
   
mailx -s "There is a dead path(s) at the '$dev' device i$HOSTNAME"$MYMAIL<$TEMPF
fi; 
done

but it is still not working. i am to send mail only when there is a dead path(s).
thanks!

Moderator's Comments:
Video tutorial on how to use code tags in The UNIX and Linux Forums.

Last edited by vbe; 10-07-2011 at 07:47 AM..
    #4  
Old 10-06-2011
rdcwayx rdcwayx is offline Forum Advisor  
Use nawk in Solaris
 
Join Date: Jun 2006
Last Activity: 22 March 2014, 12:27 PM EDT
Posts: 2,759
Thanks: 44
Thanked 418 Times in 406 Posts
How about this?


Code:
#!/bin/sh

HOSTNAME=`uname -a`
MYMAIL="orafup@mymail.com"
EMCSTATUS=/tmp/prog$$

powermt display dev=all|awk 'tolower($7)=="dead"'  > $EMCSTATUS

if [ `cat $EMCSTATUS |wc -l` -ne 0 ]
then 
 echo " there is the dead path "
 cat $EMCSTATUS |mailx -s "Please check $HOSTNAME on the dead path" $MYMAIL
 exit
fi

Sponsored Links
    #5  
Old 10-07-2011
ygemici ygemici is offline Forum Advisor  
sed_shell@LNU
 
Join Date: Feb 2010
Last Activity: 17 April 2014, 11:04 AM EDT
Location: istanbul
Posts: 1,649
Thanks: 2
Thanked 280 Times in 273 Posts
Quote:
Originally Posted by orafup View Post
#!/bin/sh
HOSTNAME=`uname -n`;MYMAIL='yourmail@yourdomain';TEMPF=/tmp/prog$$
powermt display dev=all|awk '/Pseudo name/{print substr($0,13,length($0))}'|
while read -r dev;do if [[ $(powermt display dev=$dev|grep -i dead) ]] ; then
powermt display dev=$dev>$TEMPF;mailx -s "There is a dead path(s) at the '$dev' device in $HOSTNAME" $MYMAIL<$TEMPF
fi; done


I like your script . it is good for multi-luns but it dont think it work

#!/bin/sh
HOSTNAME=`uname -n`
MYMAIL="yourmail@yourdomain"
TEMPF=/tmp/prog$$
powermt display dev=all|awk '/Pseudo name/{print substr($0,13,length($0))}'|while read -r dev;
do
echo $dev
powermt display dev=$dev|grep -i dead
if [[ $(powermt display dev=$dev|grep -c dead) -ne 0]] ;
then
powermt display dev=$dev>$TEMPF;

mailx -s "There is a dead path(s) at the '$dev' device i$HOSTNAME"$MYMAIL<$TEMPF
fi;
done

but it is still not working. i am to send mail only when there is a dead path(s).
thanks!
what is error?
i guess you has a typo!
this script already send to mail when matches dead of paths.
Sponsored Links
    #6  
Old 10-07-2011
orafup orafup is offline
Registered User
 
Join Date: Oct 2011
Last Activity: 29 June 2012, 2:33 PM EDT
Location: Los Angeles
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
i would like to change little bit. Please see below

Code:
#!/bin/sh

HOSTNAME=`uname -a`
MYMAIL="orafup@mymail.com"
EMCSTATUS=/tmp/prog$$

powermt display dev=all|awk ' {print $7}'|grep -c dead > $EMCSTATUS

if [ `cat $EMCSTATUS` -ne 0 ]
then 
 echo " there is the dead path "
 cat $EMCSTATUS |mailx -s "Please check $HOSTNAME on the dead path" $MYMAIL
 exit
fi
rm $EMCSTATUS
exit 0

---------- Post updated at 05:17 PM ---------- Previous update was at 05:16 PM ----------

YGEMICI,
It keeps looping , I have to kill it with control D

Last edited by Franklin52; 10-10-2011 at 02:12 AM.. Reason: Please use code tags, thank you
Sponsored Links
    #7  
Old 10-08-2011
ygemici ygemici is offline Forum Advisor  
sed_shell@LNU
 
Join Date: Feb 2010
Last Activity: 17 April 2014, 11:04 AM EDT
Location: istanbul
Posts: 1,649
Thanks: 2
Thanked 280 Times in 273 Posts
Quote:
Originally Posted by orafup View Post
YGEMICI,
It keeps looping , I have to kill it with control D
why do you use the sh ?
you must use
Code:
/usr/bin/bash


Code:
/bin/bash

.

and firstly glance , there is any error your script maybe except some corrections..
if you get any error with below script then write the output of below comd

Code:
powermt display dev=all

re-try this.

Code:
#!/bin/bash
HOSTNAME=`uname -n`
MYMAIL='yourmail@yourdomain'
TEMPF="/tmp/prog$$"
powermt display dev=all|awk '/Pseudo name/{print substr($0,13,length($0))}'|
while read -r dev 
 do 
  if [[ $(powermt display dev=$dev|grep -i dead) ]]
   then
   powermt display dev=$dev>$TEMPF
   mailx -s "There is a dead path(s) at the '$dev' device in $HOSTNAME" $MYMAIL<$TEMPF
  fi
 done

and your code might look like this.

Code:
#!/bin/bash
...........
mydeads=$(powermt display dev=all|awk ' {print $7}'|grep -c dead emc)
if [ $mydeads -ne 0 ]
.....
.......


regards
ygemici
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script to send mail with From and to address from specific mail server Dharv Shell Programming and Scripting 1 08-29-2011 11:10 AM
Removing Dead Paths And Unusable Path Solaris 9 jamba1 Solaris 6 08-02-2011 08:59 PM
need to configure mail setting to send mail to outlook mail server amitranjansahu UNIX for Advanced & Expert Users 2 02-18-2011 06:29 AM
Send mail from dead.letter raghu_shekar Emergency UNIX and Linux Support 7 09-17-2010 03:23 AM
can not send mail from unix server to company/yahoo mail b5fnpct UNIX for Dummies Questions & Answers 5 11-22-2002 08:24 PM



All times are GMT -4. The time now is 06:07 PM.