![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Request to modify script to list multiple parameters for V_fieldid variable | Sammy | Shell Programming and Scripting | 0 | 03-30-2008 09:08 PM |
| kill multiple instances of the same program | ipzig | Shell Programming and Scripting | 12 | 12-17-2007 02:42 AM |
| Perl program to read from multiple files | jyotipg | Shell Programming and Scripting | 1 | 07-19-2006 10:26 PM |
| running a program for a specified time | prosputko | High Level Programming | 3 | 07-06-2005 02:39 PM |
| time clock program | Ben070371 | UNIX for Dummies Questions & Answers | 5 | 12-05-2003 07:57 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi,
I got a script which sends the Email to the user based on certain variables received from Tivoli Server Monitoring 6.1. Now to keep track of the mails I have wrote a stored procedure in DB2 as we use DB2 UDB as back end which take the variables that were used to send the mail and store it in the table. I am calling this store procedure from a Shell program and for every mail sent using the script i call the shell program by passing the variables that is used to send the mails,which in turn is passed to DB2 stored procedure. I also have a Log file which will store timestamp and other information of all mails that were successfully sent. It’s working perfectly fine. But my problem is when i tally the data from the DB and the data in the log file my DB always have a lesser number as compared to the log file. I am sure the log file is not having any duplicates. When I compared the log file data and the Data in the Database I found that if Multiple request are coming at the same time, shell program is unable to process all of them. That is if I get 5 requests at same time shell file is able to only process 1 request or max 2 or 3 request it is dropping other 3 or 2 requests. How do I fix this. How can I make my shell program process multiple requests. Thanks in advance. Regards Praveen |
|
||||
|
Hi the code is as following #!/bin/sh #WORKDIR='X:/Tivoli/bin/w32-ix86/TME/TEC/TCS_ACTIVE/TECTASK' email_id=`perl X:/Tivoli/bin/w32-ix86/TME/TEC/TCS_ACTIVE/TECTASK/ip_mail.pl $hostname` echo "|$email_id|\n" #echo "|$branch|\n" #echo "|$location|\n" branch=`echo $email_id|cut -d ";" -f 1` location=`echo $email_id|cut -d ";" -f 2` email=`echo $email_id|cut -d ";" -f 3` to_email_id=`echo $email|cut -d ":" -f 1` cc_email_id=`echo $email|cut -d ":" -f 2` alias_name=`echo $email|cut -d ":" -f 3` TO=$to_email_id CC=$cc_email_id MAIL_MESSAGE=" Dear Administrator,\n Tivoli Monitoring event received with the following information :\n \n HostName : $hostname\n IP_Address : $origin\n SITUATION : $situation_name \n Severity : $severity\n Cause : $situation_displayitem\n Occurence : $situation_time\n \n The details of the event are as below :\n \n Message : The Logical VOlume $situation_displayitem on the server $hostname is $pct__used % full. Currently the free space is $free_megabytes MB.\n \n To view the current status of the server, log on to \n http://XX.XX.XX.XX///cnp/kdh/lib/cnp.html \n Note: This is a auto generated email please do not reply back.\n In case of any queries please contact local Tivoli Coordinators.\n \n \n SUBJECT="The Situation $situation_name triggered on the server $hostname " X="$(X:/sendEmail -f tivoli.monitoring@tcs.com -t $TO -cc $CC -u $SUBJECT -m "$MAIL_MESSAGE" -s XX.XX.XX.XX)" echo "$branch;$location;$hostname;$situation_name;$X to $TO " >>X:/mail.log echo "$branch;$location;$hostname;$situation_name;$timestamp;$msg;$TO;$X" >>X:/event.log X:/count/disk_mail.sh $cms_hostname $situation_name $situation_origin $origin $adapter_host $timestamp $TO $CC The last line in bold is where i am calling the db2 stored procedure from the shell file disk_mail.sh. All the above code is ment for sending the email based on the parameters recived from Tivoli. Db2 stored procedure is inside X:/count/disk_mail.sh and this has the following code. db2cmd /w /i << EOF echo "--------------------------------------------------------------------------------------------------------" >> "X:/reports/track_disk.txt" db2 connect to XXXX User XXXX using XXXX db2 call ITMUSER.MAIL_TRACK_SP('$1','$2','$3',current_timestamp,'$4','$5','$6','$7','$8') >> "X:/reports/track_disk.txt" EOF echo "inserted values sucessfully $2 $3" >> "X:/reports/track_disk.txt" echo "---------------------------------------------------------------------------------------------------------" >> "X:/reports/track_disk.txt" |
|
||||
|
I'm not familiar with db2, but if it's not allowing you to run multiple db2cmd instances at the same time, you will have to serialize them somehow. A common technique is to create a "lock" file in a shared location, and remove it when finished. If the file already exists when you want to create it, back off (maybe sleep for a few seconds) and try again later. How exactly to create a lock file safely depends on your platform etc, but google around for "lock file". If you have Procmail, it comes with a lockfile utility. Maybe db2 already has something similar, actually.
(I thought databases were supposed to solve this problem, though. You can't allow concurrent writes to the same record but some databases allow you to lock just the record(s) you want to write to, and allow another process to write to other records at the same time. Googling for db2 lock brings up some vaguely promising links.) PS. You might want to go back and edit out the live email link to your Tivoli admin account. I imagine you would not like for it to start receiving spam (maybe it's too late already) |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|