Solaris Server dectects EMC dead path and send mail immediately


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Solaris Server dectects EMC dead path and send mail immediately
# 1  
Old 10-05-2011
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 03:11 AM.. Reason: Please use code tags, thank you
# 2  
Old 10-06-2011
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 04:20 AM..
# 3  
Old 10-06-2011
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:
Mod Comment Video tutorial on how to use code tags in The UNIX and Linux Forums.

Last edited by vbe; 10-07-2011 at 08:47 AM..
# 4  
Old 10-06-2011
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

# 5  
Old 10-07-2011
Quote:
Originally Posted by orafup
#!/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.
# 6  
Old 10-07-2011
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 03:12 AM.. Reason: Please use code tags, thank you
# 7  
Old 10-08-2011
Quote:
Originally Posted by orafup
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.Smilie
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to send mail using PHP mail function On apache server.?

Hello, I am using centos-6.2 I have apache server,php5 on my system and I want to send mail using sendmail on my system. when I try to send mail from shell that time mail is succesfully sent to respective address() but when I try to send it through webbrowser I am not able to send it.... (1 Reply)
Discussion started by: Kiran ursal
1 Replies

2. UNIX for Advanced & Expert Users

How can I send a mail from my outlook or other mail accounts to UNIX server?

Hi all, I want to send a mail for my business needs from outlook account to an unix server (HP-UX) but I don't send any mail. While I can send from the unix server to my outlook account, I can't send from outlook to unix. How can I achieve this ? How can I send a mail from my outlook or other... (2 Replies)
Discussion started by: igelegin
2 Replies

3. Solaris

Removing Dead Paths And Unusable Path Solaris 9

Hi, One of our Solaris servers was peviously zoned and connected to 2 seperate arrays, one HP and the other EMC. The server is now only connected to the EMC. The sever has x2 single port HBA's. When running cfgadm I see the following: root@qwicprod /dev/rdsk]# cfgadm -al Ap_Id Type... (6 Replies)
Discussion started by: jamba1
6 Replies

4. UNIX for Advanced & Expert Users

need to configure mail setting to send mail to outlook mail server

i have sun machines having solaris 9 & 10 OS . Now i need to send mail from the machines to my outlook account . I have the ip adress of OUTLOOK mail server. Now what are the setting i need to do in solaris machines so that i can use mailx or sendmail. actually i am trying to automate the high... (2 Replies)
Discussion started by: amitranjansahu
2 Replies

5. Emergency UNIX and Linux Support

Send mail from dead.letter

Hi, Can someone pls tell me how do i mail the contents of my dead.letter to my mail id. The problem is that the content is a multi-part message in MIME format. How do i get the original message mailed to me. i used uuencode, but that does not work, says "uuencode not found" Any help... (7 Replies)
Discussion started by: raghu_shekar
7 Replies

6. UNIX for Advanced & Expert Users

send attachments using send mail in Solaris

Hi All, I have a requirement to send and email of body html with an attachment. concatinating uuencode output to the mail body with mailx command works, but as my Email body is of HTML type i use sendmail. my command to send HTML body is as below: export MAILTO="recipient@domain.com"... (1 Reply)
Discussion started by: mohan_kumarcs
1 Replies

7. Shell Programming and Scripting

script to monitor process running on server and posting a mail if any process is dead

Hello all, I would be happy if any one could help me with a shell script that would determine all the processes running on a Unix server and post a mail if any of the process is not running or aborted. Thanks in advance Regards, pradeep kulkarni. :mad: (13 Replies)
Discussion started by: pradeepmacha
13 Replies

8. UNIX for Dummies Questions & Answers

Can not send mail in solaris 5.9

Hi !! I'm trying to send myself a mail from my Solaris server, i had tryed with this commands: mail -s "test" irasela@yahoo.com < /monitoring/space/bitacora.txt mailx -s "test" irasela@yahoo.com < /monitoring/space/bitacora.txt sendmail -F "test" address "irasela.yahoo.com" -t... (1 Reply)
Discussion started by: irasela
1 Replies

9. Solaris

mail problems - how to send mail on solaris

Hello I am new user on solaris... I need to configure my solaris to be able to send mails... I know mailx command mailx -s hello address@address.com but I get an error... you have mail in /var/mail/root # hello... User unknown /dead.letter... Saved message in /dead.letter what... (10 Replies)
Discussion started by: amon
10 Replies

10. UNIX for Dummies Questions & Answers

can not send mail from unix server to company/yahoo mail

hi, Gurus, I need some help with sending mail out from my UNIX server: It is running Solaris 2.6 and the sendmail version is 8.8. Output of :/usr/lib/sendmail -d0.1 -bt < /dev/null Version 8.8.8+Sun Compiled with: LOG MATCHGECOS MIME7TO8 MIME8TO7 NAMED_BIND NDBM NETINET ... (5 Replies)
Discussion started by: b5fnpct
5 Replies
Login or Register to Ask a Question