write cron jobs to check status
Posted in 2013
A user asked how to write a cron-driven script that checks Informix server status and emails someone. Respondents suggested running `onstat -` periodically (e.g. every 5 minutes) and either mailing its output directly or parsing it: Marcus Haarmann posted a sample sh script that exports INFORMIXSERVER/INFORMIXDIR/ONCONFIG, pipes `onstat -` through grep for "On-Line", and mails an alert if not found. Side notes: Solaris' standard grep lacks -q (the script works without it), onstat returns exit code 5 for an online stand-alone server, and single-user mode should be watched for. The poster thanked the group; no further detail given.
Auto-generated by DrWatson from the posts below — may be imperfect; read the full thread.
Topics: General Discussion
Hi, i need to write script and create cron job to check the informix server status and need to email it to some one's email any one can help me to do this Thanks
Hello.
You could easily get your Informix status from the output of "onstat -"
command.
Eg: in linux/unix boxes, you could check using:
onstat - |awk '{print $8}'
That should return "On-Line", in other case your system should not ready for
users sessions/applications.
http://pic.dhe.ibm.com/infocenter/informix/v121/topic/com.ibm.adref.doc/ids_adr_
0489.htm?resultof=%22%73%65%72%76%65%72%22%20%22%73%74%61%74%75%73%22%20%22%73%7
4%61%74%75%22%20
Pay attention to single-user mode, while the engine is running, but not
available for non-administrative users.
Hope it helps.
Regards.
Alexandre Marini
IBM Informix Certified Professional v10 / v11.50 / v11.70
IBM Information Management Informix Technical Professional
IBM Infosphere DataStage Technical Professional
Informix Senior DBA - Orizon Brasil
BRIUG website administrator
Informix independent consultant
> To: ids@iiug.org
> From: pushpa@cybersoft.lk
> Subject: write cron jobs to check status [30197]
> Date: Mon, 6 May 2013 05:49:21 -0400
>
> Hi,
>
> i need to write script and create cron job to check the informix server
status
> and need to email it to some one's email any one can help me to do this
>
> Thanks
>
>
>
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>
Hi, thanks for the reply, what will happen when it down and how could know whether it down or up and if down send a mail thanks
Have a 5 min cron rub
onstat - | mail <whoever>
Cheers
Paul
Paul Watson
+1 913-387-7529
www.oninit.com
On May 6, 2013, at 5:53, "PUSHPA KUMARA" <pushpa@cybersoft.lk> wrote:
> Hi,=20
>=20
> thanks for the reply, what will happen when it down and how could know whe=
ther=20
> it down or up and if down send a mail=20
>=20
> thanks=20
>=20
>=20
> **************************************************************************=
*****=20
> Forum Note: Use "Reply" to post a response in the discussion forum.=20
Hi,
something like:
#!/bin/sh
export INFORMIXSERVER=xxxx
export INFORMIXDIR=blabla
export ONCONFIG=onconfig.yyy
/opt/informix/bin/onstat - | grep -q On-Line
EXITSTATUS=$?
if [ ${EXITSTATUS} -gt 0 ]
then
echo "IDS is not online" | mail -s "IDS status" xyz@test.com
fi
Depends on your mail package how to send a text mail. This is an example from
a Linux system.
Hope this helps.
Marcus Haarmann
----- Ursprüngliche Mail -----
Von: "PUSHPA KUMARA" <pushpa@cybersoft.lk>
An: ids@iiug.org
Gesendet: Montag, 6. Mai 2013 12:53:03
Betreff: Re: RE: write cron jobs to check status [30199]
Hi,
thanks for the reply, what will happen when it down and how could know whether
it down or up and if down send a mail
thanks
*******************************************************************************
Forum Note: Use "Reply" to post a response in the discussion forum.
Careful with that "-q". Solaris, for one, does not support it in the =
standard grep, you have to use the xpg4 version of it.
j.
On May 6, 2013, at 7:16 AM, Marcus Haarmann wrote:
> Hi,=20
>=20
> something like:=20
>=20
> #!/bin/sh=20
>=20
> export INFORMIXSERVER=3Dxxxx=20
> export INFORMIXDIR=3Dblabla=20
> export ONCONFIG=3Donconfig.yyy=20>=20
> /opt/informix/bin/onstat - | grep -q On-Line=20
>=20
> EXITSTATUS=3D$?=20
>=20
> if [ ${EXITSTATUS} -gt 0 ]=20
> then=20
> echo "IDS is not online" | mail -s "IDS status" xyz@test.com=20
>=20
> fi=20
> Depends on your mail package how to send a text mail. This is an =
example from=20
> a Linux system.=20
>=20
> Hope this helps.=20
>=20
> Marcus Haarmann=20
>=20
> ----- Urspr=FCngliche Mail -----=20
>=20
> Von: "PUSHPA KUMARA" <pushpa@cybersoft.lk>=20
> An: ids@iiug.org=20
> Gesendet: Montag, 6. Mai 2013 12:53:03=20
> Betreff: Re: RE: write cron jobs to check status [30199]=20
>=20
> Hi,=20
>=20
> thanks for the reply, what will happen when it down and how could know =
whether=20
> it down or up and if down send a mail=20
>=20
> thanks=20
>=20
>=20
> =
**************************************************************************=
*****=20
> Forum Note: Use "Reply" to post a response in the discussion forum.=20
>=20
>=20
> =
**************************************************************************=
*****=20
> Forum Note: Use "Reply" to post a response in the discussion forum.=20=
>=20
Hi,
will work without -q, exitstatus is set either way.
Marcus Haarmann
----- Ursprüngliche Mail -----
Von: "Jack Parker" <jack.parker4@verizon.net>
An: ids@iiug.org
Gesendet: Montag, 6. Mai 2013 13:19:36
Betreff: Re: write cron jobs to check status [30204]
Careful with that "-q". Solaris, for one, does not support it in the =
standard grep, you have to use the xpg4 version of it.
j.
On May 6, 2013, at 7:16 AM, Marcus Haarmann wrote:
> Hi,=20
>=20
> something like:=20
>=20
> #!/bin/sh=20
>=20
> export INFORMIXSERVER=3Dxxxx=20
> export INFORMIXDIR=3Dblabla=20
> export ONCONFIG=3Donconfig.yyy=20>=20
> /opt/informix/bin/onstat - | grep -q On-Line=20
>=20
> EXITSTATUS=3D$?=20
>=20
> if [ ${EXITSTATUS} -gt 0 ]=20
> then=20
> echo "IDS is not online" | mail -s "IDS status" xyz@test.com=20
>=20
> fi=20
> Depends on your mail package how to send a text mail. This is an =
example from=20
> a Linux system.=20
>=20
> Hope this helps.=20
>=20
> Marcus Haarmann=20
>=20
> ----- Urspr=FCngliche Mail -----=20
>=20
> Von: "PUSHPA KUMARA" <pushpa@cybersoft.lk>=20
> An: ids@iiug.org=20
> Gesendet: Montag, 6. Mai 2013 12:53:03=20
> Betreff: Re: RE: write cron jobs to check status [30199]=20
>=20
> Hi,=20
>=20
> thanks for the reply, what will happen when it down and how could know =
whether=20
> it down or up and if down send a mail=20
>=20
> thanks=20
>=20
>=20
> =
**************************************************************************=
*****=20
> Forum Note: Use "Reply" to post a response in the discussion forum.=20
>=20
>=20
> =
**************************************************************************=
*****=20
> Forum Note: Use "Reply" to post a response in the discussion forum.=20=
>=20
*******************************************************************************
Forum Note: Use "Reply" to post a response in the discussion forum.
Also the return code from onstat is 5 when the server is online and stand
alone.
Art
On May 6, 2013 6:45 AM, "Alexandre Marini" <alexandre@briug.org> wrote:
> Hello.
> You could easily get your Informix status from the output of "onstat -"
> command.
> Eg: in linux/unix boxes, you could check using:
> onstat - |awk '{print $8}'
>
> That should return "On-Line", in other case your system should not ready
> for
> users sessions/applications.
>
>
>
>
http://pic.dhe.ibm.com/infocenter/informix/v121/topic/com.ibm.adref.doc/ids_adr_
0489.htm?resultof=%22%73%65%72%76%65%72%22%20%22%73%74%61%74%75%73%22%20%22%73%7
4%61%74%75%22%20
>
> Pay attention to single-user mode, while the engine is running, but not
> available for non-administrative users.
>
> Hope it helps.
> Regards.
>
> Alexandre Marini
> IBM Informix Certified Professional v10 / v11.50 / v11.70
>
> IBM Information Management Informix Technical Professional
>
> IBM Infosphere DataStage Technical Professional
> Informix Senior DBA - Orizon Brasil
> BRIUG website administrator
> Informix independent consultant
>
> > To: ids@iiug.org
> > From: pushpa@cybersoft.lk
> > Subject: write cron jobs to check status [30197]
> > Date: Mon, 6 May 2013 05:49:21 -0400
> >
> > Hi,
> >
> > i need to write script and create cron job to check the informix server
> status
> > and need to email it to some one's email any one can help me to do this
> >
> > Thanks
> >
> >
> >
>
>
*******************************************************************************
> > Forum Note: Use "Reply" to post a response in the discussion forum.
> >
>
>
>
>
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>
>
--047d7b342ba4f0167504dc0c6e2e
Hi ALL, thanks for all to help me Thanks