Monitoring Linux Processes Using Metric Extensions
Monitoring Linux Processes Using Metric Extensions
$numArgs = $#ARGV + 1;
if ($numArgs==0)
{print "\nYou must provide the name of the Linux Process!\n";
exit 1;}
$syscmd = 'ps -elf | grep "' . $LinuxProcess . '" | grep -v grep | grep -v perl > "' .
$filename . '"';
system($syscmd);
$status=0; # Init
while(my $line = <$fh>) {
print $line;
if($line =~ m/$LinuxProcess/) {$status=1;}
}
close $fh;
print "em_result=$status";
The
creation
of
the
Metric
Extension
goes
as
follows:
From
the
Enterprise
menu
select
Monitoring
à
Metric
Extensions
From
the
Metric
Extension
page
click
[Create]
We
will
name
the
Metric
Extension
ME$Process_Status,
chose
for
Target
Type
‘Host’,
give
it
a
Display
Name
and
Description.
We
will
use
the
‘OS
Command
–
Multiple
Columns’
Adapter.
We
will
leave
the
Collection
Schedule
as
it
is
and
press
[Next]
At
the
Adapter
page
we
use
%perlBin%/perl
as
we
are
using
a
perl
script
to
be
executed
The
script
is
called
linuxprocess_collector.pl
and
is
uploaded
using
the
[+Add]
icon
Note
that
the
name
of
the
Linux
process
syslogd
is
entered
as
argument
to
the
script.
We
leave
the
delimiter
as
is
and
indicate
that
the
return
value
from
the
script
will
start
with
‘em_result=’.
When
you
check
the
perl
script
at
the
beginning
of
this
article
you
will
notice
that
this
is
the
case.
Press
[Next]
The
Metric
will
be
using
a
Column
to
communicate
the
Metric
result.
In
this
example
we
create
Column
process_status
that
will
be
used
as
Data
Column
of
type
Number.
We
select
‘=’
as
the
Comparison
Operator
for
this
Metric
and
enter
0
as
the
Critical
Threshold
value,
as
this
is
the
value
that
will
be
returned
by
the
script
in
case
the
process
is
not
found
running.
Notice
that
we
entered
‘Process
syslogd
is
down’
as
the
message
text
we
want
to
be
displayed
when
the
Metric
Extension
is
violated.
Press
[OK]
Press
[Next]
The
Metric
will
be
using
the
Default
Monitoring
Credentials
Press
[Next]
In
the
Test
page
we
add
a
Host
where
we
will
test
our
Metric
Extension
Press
[Run
Test]
and
as
you
will
notice
the
test
result
is
value
1
as
the
process
we
are
checking
syslogd,
is
actually
running.
To
make
sure
the
Metric
Extension
is
functioning
properly
to
do
a
‘negative’
test
by
changing
the
argument
to
the
name
of
a
process
we
know
is
not
running.
We
change
the
name
of
the
process
to
check
to
syslogdx
(or
any
other
name
of
a
non
existing
process)
and
proceed
to
the
Test
page
to
rerun
the
test
Notice
that
the
Metric
now
returns
value
0
as
the
given
process
is
not
found.
After
resetting
the
name
of
the
process
to
check
to
syslogd
we
precede
to
the
last
page:
After
being
sure
everything
was
entered
properly
we
press
[Finish]
to
complete
the
creation
of
the
Metric
Extension
To
allow
for
further
testing
we
will
save
the
Metric
as
a
Deployable
Draft
Just
select
Save
as
Deployable
Draft
from
the
Action
menu
Next
we
want
to
deploy
the
Metric
Extension
to
a
target
by
selecting
Deploy
To
Targets
from
the
Action
menu
By
pressing
[Add]
and
selecting
a
Host
and
pressing
[Submit]
we
schedule
the
deployment
to
the
Host
As
you
notice
the
deployment
of
the
Metric
Extension
is
scheduled
Next
we
navigate
to
the
Host
and
from
the
Target
menu
select
All
Metrics
At
the
left
side
pane
we
now
see
the
Metric
Extension
being
displayed
We
will
now
stop
the
syslogd
process
to
check
the
Metric
Extension
for
proper
functioning
After
just
some
seconds
waiting
the
Metric
shows
that
the
syslogd
process
is
down.