monitoring oracle rac services

A

alfonsobaldaserra

hello,

i'm trying to develop a nagios plugin to monitor oracle rac services.

the command i'm using is crs_stat and i get the output as follows

NAME=ora.footest.footest1.inst
TYPE=application
TARGET=ONLINE
STATE=ONLINE on srv03

[snip]

NAME=ora.srv04.ASM2.asm
TYPE=application
TARGET=ONLINE
STATE=ONLINE on srv04

i need to monitor only specific services so we can pass the service
name as argument and check it's output.

the problem is i cannot relate NAME with STATE to check it's current
state, for example, if i do

$ crs_stat | grep -Ev '^TYPE|^TARGET' | sed -e 's/^NAME=//g' -e 's/
^STATE=//g' | sed -e 's/^ONLINE on //g'
ora.footest.footest1.inst
srv03

[snip]

ora.srv04.ASM2.asm
srv04

so if i want to monitor ora.srv04.ASM2.asm i could do
$ crs_stat | grep -Ev '^TYPE|^TARGET' | sed -e 's/^NAME=//g' -e 's/
^STATE=//g' | sed -e 's/^ONLINE on //g' | grep ora.srv04.ASM2.asm
and get only
ora.srv04.ASM2.asm
but could not figure out the state.

is that possible?

is there a better way to do that?

thanks
 
A

alfonsobaldaserra

i need to monitor only specific services so we can pass the service
name as argument and check it's output.

the problem is i cannot relate NAME with STATE to check it's current
state, for example, if i do

i guess i can load all the values in hash like

NAME=ora.srv04.ASM2.asm
TYPE=application
TARGET=ONLINE
STATE=ONLINE on srv04

my %services = (
NAME => ora.srv04.ASM2.asm,
TYPE => application,
TARGET => ONLINE
STATE => ONLINE on srv04
);

but i still cannot figure how to relate TYPE, TARGET and STATE for
argument NAME.
 
T

Tad J McClellan

alfonsobaldaserra said:
i guess i can load all the values in hash like

NAME=ora.srv04.ASM2.asm
TYPE=application
TARGET=ONLINE
STATE=ONLINE on srv04

my %services = (
NAME => ora.srv04.ASM2.asm,
TYPE => application,
TARGET => ONLINE
STATE => ONLINE on srv04
);

but i still cannot figure how to relate TYPE, TARGET and STATE for
argument NAME.


If you want to lookup by NAME, then NAME should be a hash key.

A HoH (hash of hashes, "perldoc perldsc") would seem to fit the bill:

my %services = (
'ora.srv04.ASM2.asm' => { TYPE => 'application',
TARGET => 'ONLINE',
STATE => 'ONLINE on srv04',
},
'ora.srv99.ASM2.asm' => { TYPE => 'application',
TARGET => 'ONLINE',
STATE => 'ONLINE on srv99',
},
);

my $NAME = 'ora.srv04.ASM2.asm';
my $state = $services{$NAME}{STATE}; # (ONLINE on srv04)
 
T

Ted Zlatanov

a> i guess i can load all the values in hash like

a> NAME=ora.srv04.ASM2.asm
a> TYPE=application
a> TARGET=ONLINE
a> STATE=ONLINE on srv04

a> my %services = (
a> NAME => ora.srv04.ASM2.asm,
a> TYPE => application,
a> TARGET => ONLINE
a> STATE => ONLINE on srv04
a> );

a> but i still cannot figure how to relate TYPE, TARGET and STATE for
a> argument NAME.

You can do this with a hash or with a nicer OO framework like Moose.
I'd recommend Moose, unless performance is an issue. Just get it from
CPAN, set up your rw fields named Type, Target, State, and Name. That's
it, you can start using those objects.

With a hash this is easy but inflexible:

my %services;

$services{'ora.src04.ASM2.asm'} = {
NAME => 'ora.srv04.ASM2.asm', # you don't need it, the key already has the name
TYPE => 'application',
TARGET => 'ONLINE',
STATE => 'ONLINE on srv04',
};

Ted
 
A

alfonsobaldaserra

    my %services = (
        'ora.srv04.ASM2.asm' => { TYPE   => 'application',
                                  TARGET => 'ONLINE',
                                  STATE  => 'ONLINE on srv04',
                                },
        'ora.srv99.ASM2.asm' => { TYPE   => 'application',
                                  TARGET => 'ONLINE',
                                  STATE  => 'ONLINE on srv99',
                                },
    );

    my $NAME = 'ora.srv04.ASM2.asm';
    my $state = $services{$NAME}{STATE};  # (ONLINE on srv04)

thank you all for your support.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top