0% found this document useful (0 votes)
41 views

Monitoring Linux Processes Using Metric Extensions

This document describes how to create a Metric Extension in EM12c to monitor the status of Linux processes. It involves: 1. Creating a Metric Extension called ME$Process_Status that uses a Perl script to check if a process is running on a Linux host 2. The script returns a status of 1 if the process is found, 0 if not 3. The Metric Extension defines a column to store the result and thresholds to trigger alerts 4. It is tested on a host, and then deployed to allow monitoring the status of Linux processes from the EM12c interface.

Uploaded by

wojiaolifu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Monitoring Linux Processes Using Metric Extensions

This document describes how to create a Metric Extension in EM12c to monitor the status of Linux processes. It involves: 1. Creating a Metric Extension called ME$Process_Status that uses a Perl script to check if a process is running on a Linux host 2. The script returns a status of 1 if the process is found, 0 if not 3. The Metric Extension defines a column to store the result and thresholds to trigger alerts 4. It is tested on a host, and then deployed to allow monitoring the status of Linux processes from the EM12c interface.

Uploaded by

wojiaolifu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Monitoring

 Linux  processes  using    


Metric  Extensions  in  EM12c  
Date:  Feb  1 st  2014  
Author:  Rob  Zoeteweij    
http://oemgc.wordpress.com  
 
EM12c  come  with  many  Out  of  the  Box  metrics  that  can  be  used  to  monitor  events  
within  your  datacentre  or  application  landscape.  
 
You  might  however  run  into  situations  that  are  not  fully  covered  by  these  Out  of  Box  
Metrics.  I  situation  I  run  into  recently  was  the  demand  to  monitor  the  presence  of  a  
certain  OS  process  on  Linux.  
 
This  article  gives  a  description  of  how  to  create  a  Metric  Extension  for  this.  
 
We  will  create  a  Metric  Extension  called  ME$Process_Status  that  uses  the  following  perl  
script:  
 
#!/usr/local/bin/perl
#
# linuxprocess_collector.pl
#
# NAME
# linuxprocess_collector.pl - Script to get Linux Process state up/down
#
# DESCRIPTION
# This script returns the up/down status of a Linux Process
#
# NOTES
# -
# MODIFIED (MM/DD/YY)
# robztw 09/03/11
#
use File::Temp qw/ tempfile tempdir /;
my $status;

$numArgs = $#ARGV + 1;
if ($numArgs==0)
{print "\nYou must provide the name of the Linux Process!\n";
exit 1;}

foreach $argnum (0 .. $#ARGV) {

if ($argnum > 0) {$WinService = $WinService . " "};

$LinuxProcess = $LinuxProcess . $ARGV[$argnum];


}

my ($fh, $filename) = tempfile();

$syscmd = 'ps -elf | grep "' . $LinuxProcess . '" | grep -v grep | grep -v perl > "' .
$filename . '"';

open($fh, $filename) or die("Can't open $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.  
 
 
 

You might also like