[Nagiosplug-devel] process plugin

Gilles THOMAS gthomas at telemarket.fr
Fri Nov 15 05:44:02 CET 2002


First, excuse me for my english...

I made a plugin in perl, because I need to know if a particular process is
present if you are interresting with that I give you the code, I'm not a
perl expert so excuse me for the quality of the code, and the return is in
french, so sorry but you may translate :


# You need CPAN module "Proc-ProcessTable-0.37" from Dan Urist.
# You can found this module at http://www.cpan.org.
# This script allow you to see if a process is present.
# You may/can use this script with nrpe

use Proc::ProcessTable;
use Getopt::Long;

# Evaluation des paramètres passés à la commande
my $status = GetOptions(

usage() if ($status == 0 || ! ($process));

$i = 0;

$ref = new Proc::ProcessTable;

foreach $proc (@{$ref->table}) {
  if(@ARGV) {
    next unless grep {$_ == $proc->{pid}} @ARGV;

  if ($proc->{fname} =~ m/$process/i){

        printf "$proc->{cmndline} \n";


  if ($i > 0) {
        printf "Il y a $i process '$process' \n";

  printf ("Il n'y a pas de process '$process' en cours ! \n");

sub usage()

  printf "\n      check_process.pl Plugin for Nagios \n";
  printf "      Nagios : www.nagios.org \n";
  printf "\n Missing argument ! \n";
  printf "\n Ex : ./test_ps.pl -p nagios \n";
  printf "'nagios' is the name of the process \n\n";
  printf "it may be 'ping', 'smbd' or 'httpd', etc... \n\n";
  printf "-p : the name of the process you want to monitor \n\n";
  printf "\nCopyright (C) 2002 Gilles THOMAS 'tom\@persofrance.dyndns.org'
  printf "check_process.pl comes with ABSOLUTELY NO WARRANTY \n";
  printf "This programm is licensed under the terms of the ";
  printf "GNU General Public License\n(check source code for details) \n";
  printf "\n\n";



More information about the Devel mailing list