script to check status of dbspaces & chunks
Answered: green (solid confidence) — Asker explicitly confirms 'It worked for me' after Art Kagel's cleaned-up monitoring script; a follow-on edge case (temp dbspace down, error 229) then gets a working alternative (IBM's DBAmon script) pointed to by the end of the thread.
Advisory only.
Posted in 2014
A DBA asked how to script monitoring of dbspace/chunk status and email alerts. Jack Parker and Art Kagel posted a shell script that runs a dbaccess query against sysmaster's syschunks for is_offline/is_recovering/is_inconsistent, unloads to a temp file and formats alerts with awk. It worked, but when the poster joined sysdbspaces to also show dbspace names, the query failed with error 229 (could not open or create a temporary file) because the temp dbspace was down. Suggested workarounds: use the older DBAmon script from the IIUG software archive (http://www.iiug.org/software/index_DBA.html), which uses onstat -d instead of SQL, or configure ALARMPROGRAM with IBM's alarmprogram.sh in $INFORMIXDIR/etc. No confirmation that the poster got it working.
Auto-generated by DrWatson from the posts below — may be imperfect; read the full thread.
Topics: Storage & Space Management
Hi All, I need to write a shell script to check the status of all dbspaces & all chunks of an instance & send an email if any of dbspaces/chunks got corrupted/dropped/inconsistent etc Can any body help me in this regards? Regards
Something I wrote a while back. You can mail yourself the output.
dbaccess sysmaster - 2>/dev/null <<EOF
unload to /tmp/DBAmon.tmp=20
select fname, is_offline, is_recovering, is_inconsistent
from syschunks
where is_offline !=3D 0
or is_recovering !=3D 0
or is_inconsistent !=3D 0;
EOF
rnm=3D`wc -w /tmp/DBAmon.tmp | awk '{print $1}'`
if [ rnm -gt 0 ]
then
log "CHUNKS IN ABNORMAL STATUS:"
awk -F"|" '{
printf("Chunk: %s\\
",$1)=20
if ($2!=3D0) printf(" Offline\\
")=20
if ($3!=3D0) printf(" Recovering\\
")=20
if ($4!=3D0) printf(" Inconsistent\\
")=20
}' /tmp/DBAmon.tmp >> $LOGFILE
fi
rm -f /tmp/DBAmon.tmp
On Jan 2, 2014, at 6:15 AM, MUHAMMAD SHAKEEL AZEEM <mazeem@i2cinc.com> =
wrote:
> Hi All,=20
>=20
> I need to write a shell script to check the status of all dbspaces & =
all=20
> chunks of an instance & send an email if any of dbspaces/chunks got=20
> corrupted/dropped/inconsistent etc=20
>=20
> Can any body help me in this regards?=20
>=20
> Regards=20
>=20
>=20
> =
**************************************************************************=
*****=20
> Forum Note: Use "Reply" to post a response in the discussion forum.=20=
>=20
D*mn mail program.
Attaching it as a file.
j.
On Jan 2, 2014, at 8:42 AM, Jack Parker <jack.parker4@verizon.net> =
wrote:
> Something I wrote a while back. You can mail yourself the output.=20
>=20
> dbaccess sysmaster - 2>/dev/null <<EOF=20
> unload to /tmp/DBAmon.tmp=3D20=20
> select fname, is_offline, is_recovering, is_inconsistent=20
> from syschunks=20
> where is_offline !=3D3D 0=20>=20
> or is_recovering !=3D3D 0=20
>=20
> or is_inconsistent !=3D3D 0;=20
> EOF=20
>=20
> rnm=3D3D`wc -w /tmp/DBAmon.tmp | awk '{print $1}'`=20
> if [ rnm -gt 0 ]=20
> then=20
>=20
> log "CHUNKS IN ABNORMAL STATUS:"=20
>=20
> awk -F"|" '{=20
>=20
> printf("Chunk: %s\\
",$1)=3D20=20
>=20
> if ($2!=3D3D0) printf(" Offline\\
")=3D20=20
>=20
> if ($3!=3D3D0) printf(" Recovering\\
")=3D20=20
>=20
> if ($4!=3D3D0) printf(" Inconsistent\\
")=3D20=20
>=20
> }' /tmp/DBAmon.tmp >> $LOGFILE=20
> fi=20
> rm -f /tmp/DBAmon.tmp=20
>=20
> On Jan 2, 2014, at 6:15 AM, MUHAMMAD SHAKEEL AZEEM <mazeem@i2cinc.com> =
=3D=20
> wrote:=20
>=20
>> Hi All,=3D20=20
>> =3D20=20
>> I need to write a shell script to check the status of all dbspaces & =
=3D=20
> all=3D20=20
>> chunks of an instance & send an email if any of dbspaces/chunks =
got=3D20=20
>> corrupted/dropped/inconsistent etc=3D20=20
>> =3D20=20
>> Can any body help me in this regards?=3D20=20
>> =3D20=20
>> Regards=3D20=20
>> =3D20=20
>> =3D20=20
>> =3D=20
> =
**************************************************************************=
=3D=20
> *****=3D20=20
>> Forum Note: Use "Reply" to post a response in the discussion =
forum.=3D20=3D=20
>=20
>> =3D20=20
>=20
>=20
> =
**************************************************************************=
*****=20
> Forum Note: Use "Reply" to post a response in the discussion forum.=20=
>=20
Attachments don't work on the forums Jack. Here, cleaned it up for you:
dbaccess sysmaster - 2>/dev/null <<EOF
unload to /tmp/DBAmon.tmp
select fname, is_offline, is_recovering, is_inconsistent
from syschunks
where is_offline != 0
or is_recovering != 0
or is_inconsistent != 0;
EOF
rnm=`wc -w /tmp/DBAmon.tmp | awk '{print $1}'`
if [ rnm -gt 0 ]
then
log "CHUNKS IN ABNORMAL STATUS:"
awk -F"|" '{
printf("Chunk: %s\\
",$1)
if ($2!=0) printf(" Offline\\
")
if ($3!=0) printf(" Recovering\\
")
if ($4!=0) printf(" Inconsistent\\
")
}' /tmp/DBAmon.tmp >> $LOGFILE
fi
rm -f /tmp/DBAmon.tmp
Art
Art S. Kagel, Principal Consultant
Advanced DataTools (www.advancedatatools.com)
Blog: http://informix-myview.blogspot.com/
Disclaimer: Please keep in mind that my own opinions are my own opinions
and do not reflect on the IIUG, nor any other organization with which I am
associated either explicitly, implicitly, or by inference. Neither do
those opinions reflect those of other individuals affiliated with any
entity with which I am affiliated nor those of the entities themselves.
On Thu, Jan 2, 2014 at 8:52 AM, Jack Parker <jack.parker4@verizon.net>wrote:
> D*mn mail program.
>
> Attaching it as a file.
>
> j.
>
> On Jan 2, 2014, at 8:42 AM, Jack Parker <jack.parker4@verizon.net> =
> wrote:
>
> > Something I wrote a while back. You can mail yourself the output.=20
> >=20
> > dbaccess sysmaster - 2>/dev/null <<EOF=20
> > unload to /tmp/DBAmon.tmp=3D20=20
> > select fname, is_offline, is_recovering, is_inconsistent=20
> > from syschunks=20
> > where is_offline !=3D3D 0=20> >=20
> > or is_recovering !=3D3D 0=20
> >=20
> > or is_inconsistent !=3D3D 0;=20
> > EOF=20
> >=20
> > rnm=3D3D`wc -w /tmp/DBAmon.tmp | awk '{print $1}'`=20
> > if [ rnm -gt 0 ]=20
> > then=20
> >=20
> > log "CHUNKS IN ABNORMAL STATUS:"=20
> >=20
> > awk -F"|" '{=20
> >=20
> > printf("Chunk: %s\\
",$1)=3D20=20
> >=20
> > if ($2!=3D3D0) printf(" Offline\\
")=3D20=20
> >=20
> > if ($3!=3D3D0) printf(" Recovering\\
")=3D20=20
> >=20
> > if ($4!=3D3D0) printf(" Inconsistent\\
")=3D20=20
> >=20
> > }' /tmp/DBAmon.tmp >> $LOGFILE=20
> > fi=20
> > rm -f /tmp/DBAmon.tmp=20
> >=20
> > On Jan 2, 2014, at 6:15 AM, MUHAMMAD SHAKEEL AZEEM <mazeem@i2cinc.com> =
> =3D=20
> > wrote:=20
> >=20
> >> Hi All,=3D20=20
> >> =3D20=20
> >> I need to write a shell script to check the status of all dbspaces & =
> =3D=20
> > all=3D20=20
> >> chunks of an instance & send an email if any of dbspaces/chunks =
> got=3D20=20
> >> corrupted/dropped/inconsistent etc=3D20=20
> >> =3D20=20
> >> Can any body help me in this regards?=3D20=20
> >> =3D20=20
> >> Regards=3D20=20
> >> =3D20=20
> >> =3D20=20
> >> =3D=20
> > =
> **************************************************************************=
> =3D=20
> > *****=3D20=20
> >> Forum Note: Use "Reply" to post a response in the discussion =
> forum.=3D20=3D=20
> >=20
> >> =3D20=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.
>
>
--001a11c268a4cba18d04eefd376e
Thanks Kagel & Parker
It worked for me but i can't query the sysmaster db if temporary dbspaces got
corrupted/down/inconsistent
I got the following error while running query on sysmaster
229: Could not open or create a temporary file.
-bash-3.00$ onstat -d
IBM Informix Dynamic Server Version 11.50.FC7 -- Read-Only (Sec) -- Up 2 days
21:28:17 -- 322560 Kbytes
Dbspaces
address number flags fchunk nchunks pgsize flags owner name
10e69d028 1 0x60801 1 1 2048 NL B informix rootdbs_mcp19
10e69de50 2 0x60801 2 1 2048 NL B informix datadbs_mcp19
10f811028 3 0x42005 3 1 2048 NDTB informix tempdbs_mcp19
10f8111c0 4 0x60801 4 1 2048 NL B informix logdbs_mcp19
4 active, 2047 maximum
Chunks
address chunk/dbs offset size free bpages flags pathname
10e69d1c0 1 1 0 102400 52917 PI-B- /data/ids_space/rootdbs_mcp19
10f811358 2 2 0 51200 49945 PI-B- /data/ids_space/datadbs_mcp19
10f811548 3 3 0 51200 0 PD-B- /data/ids_space/tempdbs_mcp19
10f811738 4 4 0 51200 43467 PI-B- /data/ids_space/logdbs_mcp19
4 active, 32766 maximum
I am able to execute the query you provided even if the temp dbspace is down
But actually i need to display dbspace name as well,so i am using the
following query which gave the error
select name,fname,is_offline,is_recovering,is_inconsistent
from sysdbspaces dbs, syschunks chk
where dbs.dbsnum=chk.dbsnum
and (is_offline != 0 or is_recovering != 0 or is_inconsistent != 0);
229: Could not open or create a temporary file
Kindly suggest how to deal with this scenario
Regards,
Azeem
If you go to the iiug website, in the software archives is the original =
DBAmon which was written before sys master existed. That did the same =
check, but used onstat -d and should solve your problem.
Regards,
Jack Parker
On Jan 4, 2014, at 5:28 AM, MUHAMMAD SHAKEEL AZEEM <mazeem@i2cinc.com> =
wrote:
> I am able to execute the query you provided even if the temp dbspace =
is down=20
>=20
> But actually i need to display dbspace name as well,so i am using the=20=
> following query which gave the error=20
>=20
> select name,fname,is_offline,is_recovering,is_inconsistent=20
> from sysdbspaces dbs, syschunks chk=20
> where dbs.dbsnum=3Dchk.dbsnum=20
> and (is_offline !=3D 0 or is_recovering !=3D 0 or is_inconsistent !=3D =0);=20
>=20
> 229: Could not open or create a temporary file=20
>=20> Kindly suggest how to deal with this scenario=20
>=20
> Regards,=20
> Azeem=20
>=20
>=20
> =
**************************************************************************=
*****=20
> Forum Note: Use "Reply" to post a response in the discussion forum.=20=
>=20
I would use the IBM provided script alarmprogram.sh in onconfig ALARMPROGRAM /opt/informix/etc/alarmprogram.sh
unable to find the old script,kindly share the script or share the exact path Hope you won't mind it Thanks & regards,
It should be in $INFORMIXDIR/etc directory. From: "MUHAMMAD SHAKEEL AZEEM" <mazeem@i2cinc.com> Sent: Tue, 07 Jan 2014 10:28:29 To: ids@iiug.org Subject: Re: script to check status of dbspaces & chunks [32179] unable to find the old script,kindly share the script or share the exact path Hope you won't mind it Thanks & regards, ******************************************************************************* Forum Note: Use "Reply" to post a response in the discussion forum.
i was talking about DBAmon script which Jack mentioned that this script can be found at iiug website Regards,
Can anyone please share DBmon (with onstat -d) script ?
Here is the link to the repository http://www.iiug.org/software/index_DBA.html
Related threads
- IDS 10 table-level restore
- Informix Development Webinar December 11, 2007
- ontape -p/r with changed ROOTPATH
- Migrate from HP PA-RISC to HP ITANIUM by ontape