Hi All,
Is it possible to create custom plugin using Perl in checking if the some services like asterisk are running; same as running this command service asterisk status.
Please help. Can you help me to have sample plugin codes regarding to my concern.
Thank you so much.
Custom Nagios Plugin - Service Status
Re: Custom Nagios Plugin - Service Status
Plugins can absolutely be custom-made, and Perl is in my opinion a great language to use! Unfortunately, giving a Perl tutorial is a bit out of scope for this forum, but there are tons of resources online. What I can give you is our plugin development guidelines:
https://nagios-plugins.org/doc/guidelines.html
That page has just about everything you need to know about writing a plugin properly. If you have specific questions we can certainly help!
https://nagios-plugins.org/doc/guidelines.html
That page has just about everything you need to know about writing a plugin properly. If you have specific questions we can certainly help!
Former Nagios employee
Re: Custom Nagios Plugin - Service Status
I'm not saying its the best script ever, but I think it might work
Code: Select all
#! /usr/bin/perl -w
use strict;
use Getopt::Long;
use vars qw($opt_V $opt_h $opt_H $opt_p $procs $check $PROGNAME);
use lib "/usr/lib/nagios/plugins/" ;
use utils qw(%ERRORS &print_revision &support &usage);
$PROGNAME = "check_proc-status";
sub print_help ();
sub print_usage ();
$ENV{'PATH'}='';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
Getopt::Long::Configure('bundling');
GetOptions
("V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"H=s" => \$opt_H, "hostname=s" => \$opt_H,
"p=s" => \$opt_p, "process=s" => \$opt_p);
if ($opt_V) {
print_revision($PROGNAME,'$Revision: 0.1 $');
exit $ERRORS{'OK'};
}
if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
($opt_H) || usage("Host name/address not specified\n");
my $host = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/);
($host) || usage("Invalid host: $opt_H\n");
($opt_p) || usage("Process name not specified\n");
my $proc = $1 if ($opt_p =~ /([-.A-Za-z0-9_]+)/);
($proc) || usage("Invalid process: $opt_p\n");
$check=`/sbin/service $proc status`;
#print $check;
#print $?;
if ($? == 0){
print "OK - $proc"; exit $ERRORS{'OK'}};
print "CRITICAL"; exit $ERRORS{'CRITICAL'} ;
sub print_usage () {
print "Usage: $PROGNAME -H <host> [-C community] -w <warn> -c <crit>\n";
}
sub print_help () {
print_revision($PROGNAME,'$Revision: 0.1 $');
print "Copyright (c) 2015 Rob Hassing
This plugin reports the usage of a Netapp Storage volume
";
print_usage();
print "
-H, --hostname=HOST
Name or IP address of host to check
-p, --proc=Process
Name of the process to check
";
# support();
}
Rob Hassing
-
- Posts: 5
- Joined: Wed Sep 16, 2015 6:16 pm
Re: Custom Nagios Plugin - Service Status
Hi guys,
Thank you for your help. This is a great help for me as NEW in Nagios.
And if i still have any issues or concern regarding nagios hope you still help me
GOD BLESS to ALL of you.
Thank you for your help. This is a great help for me as NEW in Nagios.
And if i still have any issues or concern regarding nagios hope you still help me
GOD BLESS to ALL of you.
Re: Custom Nagios Plugin - Service Status
Great! I'll go ahead and lock this one to keep it nice and tidy. Please post and let us know if there is anything else we can do for you.
Former Nagios Employee.
me.
me.