Results 1 to 10 of 10
  1. #1
    Join Date
    Mar 2007
    Posts
    35

    Unanswered: 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 11:37.

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

  3. #3
    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.

  4. #4
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

  5. #5
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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

  6. #6
    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 .

  7. #7
    Join Date
    Feb 2008
    Posts
    40
    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...........

  8. #8
    Join Date
    Dec 2011
    Posts
    2
    Thanks very much.

  9. #9
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    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
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

  10. #10
    Join Date
    Jan 2013
    Posts
    1

    Exclamation

    For normal daily monitoring, it's best just to use the -readfile flag by itself without specifying any specific file. DB2 is smart enough to use your DIAGPATH dbm parameter value by default.

    This goes double if you are using the DIAGSIZE parameter for automatic log rotation, otherwise it won't read the correct file after the next rotation.

    Enjoy the beeps!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •