Shell program to accept multiple request at the same time


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell program to accept multiple request at the same time
# 1  
Old 06-04-2008
Question Shell program to accept multiple request at the same time

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
# 2  
Old 06-05-2008
Show us the code.
# 3  
Old 06-05-2008
Quote:
Originally Posted by era
Show us the code.

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"
# 4  
Old 06-05-2008
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)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell program request to download .pdf files

Hello, Would you suggest me a shell program that would launch the given url and if there is login we have enter the credentials. If the credentials are correct it would be redirected to home page of that url, the program will check if there are any PDF'S found automatically the PDF'S have... (5 Replies)
Discussion started by: pandu19
5 Replies

2. Shell Programming and Scripting

Shell program request

Hello, I'm requesting the shell program to compare 2 .csv files which will have large data. Can any one help me with this linux shell program Thanks in advance. Thanks and regards Ramanjaneya. K (1 Reply)
Discussion started by: pandu19
1 Replies

3. Shell Programming and Scripting

Passing multiple C program output into a shell

Hi I have the following C code # cat test.c #include <stdio.h> main() { printf ("The output is : Power\n"); printf ("The output is : No Power\n"); } The output of this C code is # ./test The output is : Power The output is : No Power Now i need to pass this outputs into a shell... (4 Replies)
Discussion started by: Priya Amaresh
4 Replies

4. Programming

C program multiple definition error during linking time

Hi, I have the following files: // file.hvoid foo(); int i = 5; // should be just declared as extern int i; // file1.c#include <stdio.h> #include "file.h" void foo() { i = 10; printf("%d\n", i); } // file2.c#include <stdio.h> #include "file.h" int main() { foo(); (9 Replies)
Discussion started by: royalibrahim
9 Replies

5. UNIX for Dummies Questions & Answers

Using Shell Script To Loop Program Through Multiple Text Files

Hello, So I have approximately 300 files of raw data (.txt) files that I am using to perform statistical analysis. I have been able to construct a Fortran program that is able to perform my statistical analysis on a file by file basis. However, I now want to be able to loop program through... (19 Replies)
Discussion started by: Jimmyd24
19 Replies

6. Programming

How to accept multiple lines input from User in C?

Hi I want to accept multiple lines input with spaces from User and i have a working code like this. char sRes; char sReq; printf("Please enter request:"); scanf("%",sReq); /* Accept the input from user */ printf("\nPlease enter response:"); scanf("%",sRes); but the... (4 Replies)
Discussion started by: AAKhan
4 Replies

7. Cybersecurity

configure apache to accept request form specific IP

Hi, What should I change in the httpd.conf so that the apache will accept request from page from specific IP and deny all the rest IP. I am reading the document of the apache but it is very long (700 pages) and I searched but I could not find something about this. So if someone can explain... (0 Replies)
Discussion started by: programAngel
0 Replies

8. Shell Programming and Scripting

Shell script to run a python program on multiple entries in a file

Hello I am trying to run a python program using shell script, which takes a single argument from a file. This file has one entry per line : 1aaa 2bbb 3ccc 4ddd 5eee ... ... ... My shell script runs the program, only for the last entry : #!/bin/sh IFS=$'\n' for line in $(cat... (2 Replies)
Discussion started by: ad23
2 Replies

9. Shell Programming and Scripting

How to accept multiple input in a same variable

Hi All, I am trying to write a script in which I need to accept multiple value in the same variable. The case Is that I have put a FOR loop and inside the FOR loop I am accepting a variable value. And I require all the values which gets inputted in the variable. To be... (5 Replies)
Discussion started by: rahulmittal87
5 Replies

10. Shell Programming and Scripting

problem accessing Multiple Variables from C Program to a Shell script

program name--test #!/bin/bash output1=`/home/user/a.c` output2=`/home/user/a.c` k=`$output1 + 1` m=`$output2 + 1` echo $k echo $m --------------------------------------------------------------------------- prgram name--a.c #include<stdio.h> int main() (1 Reply)
Discussion started by: sameworld1980
1 Replies
Login or Register to Ask a Question