INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Simple send Script

Simple send Script

(OP)
Hell All,

I am flabbergasted by Korn Shell's behavior.
I wrote a simple script as follows:
chk_sp_cop.sh:

CODE --> script

csp=`ps -ef | grep -v grep | grep sp_cop | wc -l`

if test $csp -ne 4
then
  mailx -s "SharePlex Configuration Processes(SPCP)" me@aol.com<<EOM
One or more SharePlex Configuration Processes are down on SERVER.
Please refer to the document - SharePlex Configuration Monitoring and Error Fixes.
Section:chk_sp_cop on how to fix this issue.
EOM
fi 

However, it still sends email, even when evaluation operation :
oracle::..ome/app/oracle-> ps -ef | grep -v grep | grep sp_cop | wc -l
4
oracle::..ome/app/oracle->
Please note I wrote a smilar script on the same server that is working perfectly.
Script Name: chk_eventmon.sh

CODE -->

c=`ps -ef | grep -v grep | grep sp_eventmon | wc -l`
#
if test $c -ne 2
then
mailx.........
..........
.......... 
I mainly copied from chk_eventmon.sh to chk_sp_cop.sh and modified the later.
I scheduled both on crontab:
55 * * * * /orahome/app/oracle/admin/scripts/chk_eventmon.sh
55 * * * * /orahome/app/oracle/admin/scripts/chk_sp_cop.sh

This is on Sunos BTW.

Again, chk_eventmon.sh is working as it should be, but chk_sp_cop.sh is not.

RE: Simple send Script

Hi

Quote (tekpr00)

I mainly copied from chk_eventmon.sh to chk_sp_cop.sh and modified the later.
I would say, you mainly copied its content, but changed its naming scheme :

CODE --> chk_sp_cop.sh ( fragment )

csp=`ps -ef | grep -v grep | grep sp_cop | wc -l`
# also matches script name :  chk_sp_cop.sh 

CODE --> chk_eventmon.sh ( fragment )

c=`ps -ef | grep -v grep | grep sp_eventmon | wc -l`
# not matches script name :    chk_eventmon.sh 
So when your chk_sp_cop.sh is running, there is one more process who's name is matched by grep sp_cop : the script itself.

Feherke.
feherke.ga

RE: Simple send Script

(OP)
Thanks, for pointing this out....
I changed the name of the script from chk_sp_cop.sh to chk_spcop.sh, and all is fine after that.
Again, thanks.

RE: Simple send Script

(OP)
Hello feherke:

Thanks for helping out the other time.
However, I will like to improve on the script.

Currently, my code chk_envemotn is as follow:

CODE --> script

csp=`ps -ef | grep -v grep | grep sp_sp_eventmon | wc -l`

if test $csp -ne 12
then
  mailx -s "SharePlex Configuration Processes(SPCP)" me@aol.com<<EOM
One or more SharePlex Configuration Processes are down on SERVER.
Please refer to the document - SharePlex Configuration Monitoring and Error Fixes.
Section:chk_sp_cop on how to fix this issue.
EOM
fi 

In addition to counting the number of lines as above, I will like it to identify missing instance and suggest ways to restart it.
The output of the line - ps -ef | grep -v grep | grep sp_sp_eventmon:
oracle/11.2.0.4 - ctxa)/orahome/app/SharePlex/11g/prod/bin> ps -ef | grep -v grep | grep sp_eventmon
oracle 23696 1 0 Feb 27 ? 1:54 /bin/ksh /orahome/app/SharePlex/11g/prod/.app-modules/sp_eventmon -s -u2350_etx
oracle 4604 1 0 Feb 27 ? 1:53 /bin/ksh /orahome/app/SharePlex/10g/prod/.app-modules/sp_eventmon -s -u2150_sfg
oracle 27614 1 0 Feb 27 ? 1:58 /bin/ksh /orahome/app/SharePlex/11g/prod/.app-modules/sp_eventmon -s -u2100_ctx
oracle 14185 1 0 Mar 01 ? 1:01 /bin/ksh /orahome/app/SharePlex/11g/prod/.app-modules/sp_eventmon -s -u2500_ctx
oracle 666 1 0 Feb 27 ? 1:57 /bin/ksh /orahome/app/SharePlex/10g/prod/.app-modules/sp_eventmon -s -u2100_sfg
oracle 27499 1 0 Feb 27 ? 1:55 /bin/ksh /orahome/app/SharePlex/11g/prod/.app-modules/sp_eventmon -s -u2150_ctx
oracle 6368 1 0 Feb 27 ? 1:55 /bin/ksh /orahome/app/SharePlex/10g/prod/.app-modules/sp_eventmon -s -u2250_sfg
oracle 15824 1 0 Feb 27 ? 1:57 /bin/ksh /orahome/app/SharePlex/11g/prod/.app-modules/sp_eventmon -s -u2250_ctx
oracle 6307 1 0 Feb 27 ? 2:23 /bin/ksh /orahome/app/SharePlex/11g/prod/.app-modules/sp_eventmon -s -u2200_ctx
oracle 21974 1 0 Feb 27 ? 1:55 /bin/ksh /orahome/app/SharePlex/11g/prod/.app-modules/sp_eventmon -s -u2300_etx
oracle 22738 1 0 Feb 27 ? 1:52 /bin/ksh /orahome/app/SharePlex/11g/prod/.app-modules/sp_eventmon -s -u2450_etx
oracle 26662 21995 0 08:59:23 pts/7 0:07 /bin/ksh /orahome/app/SharePlex/11g/prod/.app-modules/sp_eventmon -s -u2400_etx

First, this command: ps -ef | grep -v grep | grep sp_sp_eventmon has a glitch of missing the last character in the output. Maybe because I am using SunOS, not sure.
THe Output should be like:
oracle 23696 1 0 Feb 27 ? 1:54 /bin/ksh /orahome/app/SharePlex/11g/prod/.app-modules/sp_eventmon -s -u2350_etxe
But sorry for digressing.

I will like to modify script abouve to compare a field in the ouput records (u2350_etxe) to my exisiting active_instance_field.txt file, and send email advising the recipient to restart the mising instance.

Content of my active_instance_field.txt:
2150_ctxi
2250_ctxs
2100_sfgd
2250_sfgm
2300_etxd
2350_etxs
2400_etxa
2100_ctxd
2200_ctxa
2150_sfgi
2450_etxi
2200_sfga

Here is attempt:

CODE --> script

csp=`ps -ef | grep -v grep | grep sp_sp_eventmon | wc -l`

if test $csp -ne 12
then
  mailx -s "SharePlex Configuration Processes(SPCP)" me@aol.com<<EOM
One or more SharePlex Configuration Processes are down on SERVER.
cspa=`ps -ef | grep -v grep | grep sp_sp_eventmon` > current_active_inst.txt
#extract field 2350_etxe from line /orahome/app/SharePlex/11g/prod/.app-modules/sp_eventmon -s -u2350_etxe
for active_inst in `cat current_active_inst.txt|\Efrep ‘sp_eventmon -s -u2150_sfge’ | grep –v \*|cut –fi –d’ sp_eventmon -s -u’`
compare variable active_inst to each record in the file active_instance_field.txt
if not present
Please evaluate the reason for the cracsh of $active_inst and restart with the follwoing example
nohup ./sp_eventmon -s '-u2350_etxse' -t 30 -p /orahome/app/SharePlex/11g/var2350_etxe -m /dev/null &
EOM fi

RE: Simple send Script

Hi

Not really sure what exactly you tried to put in the last code, but personally I would start with something like this :

CODE --> shell

ps -C sp_eventmon hocmd | # list processes with command name sp_eventmon, do not display list header, display only cmd column
sed 's/.*-u//' | # keep only the part after -u
grep -v -f - active_instance_field.txt | # from that file output those not listed by ps
sed 's!.*!nohup ./sp_eventmon -s -u& -t 30 -p /orahome/app/SharePlex/11g/var& -m /dev/null \&!' # format the list as shell commands 

See whether your ps accepts any of those options. Also check whether it accepts column width specifier like ps -C sp_eventmon hocmd:256. I think the truncating things comes from ps's formatting. If nothing helps, maybe you could reverse the options to have that -u 1st to not get it truncated.

Feherke.
feherke.ga

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close