creating a perl Script to check service status

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

creating a perl Script to check service status

Postby camacho12th » Wed Oct 11, 2017 10:32 pm

Does anyone have a sample perl script for monitoring a service within /etc/int.d?

I've struggled to find one already made and now I must learn how to create one. This would really help me get my feet firmly on the ground.

Basically, I have an asterisk Service on a remote linux server that I want to make sure is running. If not, then generate a warning or critical.

Thank you greatly
camacho12th
 
Posts: 1
Joined: Wed Oct 11, 2017 7:47 pm

Re: creating a perl Script to check service status

Postby eloyd » Thu Oct 12, 2017 11:51 am

Just curious why you're not using the default "check_init_service" script to do that?
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
User avatar
eloyd
Cool Title Here
 
Posts: 1857
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY

Re: creating a perl Script to check service status

Postby tacolover101 » Thu Oct 12, 2017 1:05 pm

eloyd wrote:Just curious why you're not using the default "check_init_service" script to do that?


perl 4 lyfe. this is a good question though.

Code: Select all
$s=(`service $ARGV[0] status`);
if ($s =~ '(running)') {
   $val1="is";
   $val2=1;
   }
else {
   $val1="is not";
   $val2=0;
   }


you'll need to get creative with how you leverage $ARGV[0] in a print command to define ok / warning / etc. could be written better, but there's a framework. logic could be written better, too.
User avatar
tacolover101
 
Posts: 284
Joined: Mon Apr 10, 2017 11:55 am

Re: creating a perl Script to check service status

Postby kyang » Thu Oct 12, 2017 2:32 pm

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
kyang
 
Posts: 364
Joined: Tue Jul 25, 2017 3:35 pm


Return to Nagios Core

Who is online

Users browsing this forum: bengadsden and 15 guests