If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > checking db2diag.log for Severe error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-23-08, 10:23
jsmit jsmit is offline
Registered User
 
Join Date: Mar 2007
Posts: 35
checking db2diag.log for Severe error

Hi All
I am working with db2 v8.2 and aix 5.3

I am trying to write a shell script to check db2diag.log for Severe error and email to dba, I wrote as follow

#! /usr/bin/ksh
. /home/dba/.profile


SCRDIR=/home/dba
cd $SCRDIR

. ~insti1/sqllib/db2profile
TIMESTAMP=`date +%Y-%m-%d.%H:%M
LOGFILE="/home/dba/DBBOX-db2diag.$TIMESTAMP"
db2diag -g db:= -gi LEVEL=Severe >> $LOGFILE
cat $LOGFILE | mail -s "Checking error @ $( hostname ) --DBA@xxx.com $TIMESTAMP"

it works manually fine but when I put the job on crontab to check every 5 minutes and send email, always LOGFILE is empty

Please help I rid off this issue .

Thanks

Last edited by jsmit; 05-23-08 at 10:37.
Reply With Quote
  #2 (permalink)  
Old 05-26-08, 00:30
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Do you mean that the file on disk is empty or doesn't exist - or the email doesn't contain the respective details? If the file on disk is empty, you should verify under whose authority the cronjob is running. Maybe that user doesn't have the necessary privileges to create the file and write to it?
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 05-26-08, 14:44
jsmit jsmit is offline
Registered User
 
Join Date: Mar 2007
Posts: 35
Quote:
Originally Posted by stolze
Do you mean that the file on disk is empty or doesn't exist - or the email doesn't contain the respective details? If the file on disk is empty, you should verify under whose authority the cronjob is running. Maybe that user doesn't have the necessary privileges to create the file and write to it?
Hi Stolze,

I seems db2diag command does not work under crontab job and as result LOGFILE is empty, I created crontab job under "dba" i wrote other crontab jobs all works fine, it seems crontab can not read db2diag.log (because manually works fine).

I will try to resolve the problem , just in case could you please help me I write script and run manually (search for "severe" error every 5 min if found send email ).

Thank you in advance.
Reply With Quote
  #4 (permalink)  
Old 05-27-08, 00:12
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Have you verified that "db2diag" cannot be run from a cronjob? Have you verified that the cronjob is running as user "dba"? Try to write your LOGFILE to a file under /tmp/ to take privilege issues out of the picture. You should also write any error messages to a file under /tmp/ to see of something goes wrong there.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #5 (permalink)  
Old 05-27-08, 15:34
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
It works under cron if you use the -readfile option:

db2diag -l severe -H 12d -readfile $HOME/sqllib/db2dump/db2diag.log > $HOME/scripts/db2diag.report
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #6 (permalink)  
Old 05-27-08, 15:53
jsmit jsmit is offline
Registered User
 
Join Date: Mar 2007
Posts: 35
Quote:
Originally Posted by Marcus_A
It works under cron if you use the -readfile option:

db2diag -l severe -H 12d -readfile $HOME/sqllib/db2dump/db2diag.log > $HOME/scripts/db2diag.report
Marcus you are genius , it works fine , I was on this issue more than 3 days.

Thank you guys all .
Reply With Quote
  #7 (permalink)  
Old 05-20-10, 03:25
jayshah7 jayshah7 is offline
Registered User
 
Join Date: Feb 2008
Posts: 35
Hi guys,

In continuation wit the thread, I also have th same issue, where db2diag doesnt work under cronjob even after adding -readfile option, Here is the syntax used :

db2diag -l error -H 300m -readfile /db2inst1/dba/db2diag.log >> /db2inst1/script/sch_script/error_log.txt

Also, the user db2inst1 has r/w rights, but db2diag doesnt gets executed.

Please help...........
Reply With Quote
  #8 (permalink)  
Old 12-20-11, 22:58
suroot suroot is offline
Registered User
 
Join Date: Dec 2011
Posts: 2
Thanks very much.
Reply With Quote
  #9 (permalink)  
Old 12-21-11, 02:09
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
in crontab job : also execute the profile to set the path to sqllib...
otherwise you have to specify the complete path for db2diag executable
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On