check_mk local FPS script

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
BiloxiGeek
Posts: 271
Joined: Tue Feb 11, 2014 2:04 pm

check_mk local FPS script

Post by BiloxiGeek »

If anyone is running a check_mk agent on their zm server here's a no frills script to monitor the frame rate from each configured monitor.

Code: Select all

#!/usr/bin/perl

# Get zoneminder monitor frame rates

push @camarray, ( 
	{ camname => "Back", 		camid   => "10" },
	{ camname => "Back-low",	camid   => "11" },
	{ camname => "Fence", 		camid   => "12" },
	{ camname => "Front",		camid   => "1" },
	{ camname => "Front-low",	camid   => "2" },
	{ camname => "Garage",		camid   => "5" },
	{ camname => "Garage-low",	camid   => "6" },
	{ camname => "Side",		camid   => "3" },
	{ camname => "Side-low",	camid   => "4" },
	{ camname => "Workshop",	camid   => "7" },
	{ camname => "Workshop-low",	camid   => "8" },
	{ camname => "Workshop-int",	camid   => "15" },
	{ camname => "Gates",		camid   => "14" },

);

foreach $cam (@camarray) {
	$fps = `zmu -m $cam->{camid} -f -Uusername -Ppassword`;
	chomp $fps;
	print "0 ZM_$cam->{camname} fps=$fps $cam->{camname} ($cam->{camid}) running at $fps FPS.\n";
}
You'll need to change the camera names and id #'s to fit your setup, and the login/password that zmu will use. Place it in /usr/lib/check_mk_agent/local/ or wherever your agent wants to see local scripts.

Probably not the best idea to put the username & password in there, if there's a way to get the info without that I'd be interested in a tip.
BiloxiGeek
Posts: 271
Joined: Tue Feb 11, 2014 2:04 pm

Re: check_mk local FPS script

Post by BiloxiGeek »

Added a zero padded camera ID field to the array. I just wanted the services in check_mk to show up in a specific order being the camera's ID #, that meant zero padding and it seemed easiest to hard code it into the array rather than change it by using more perl code.

One advantage here, is if I wanted to I could set the sorting order with the padid field to anything. Check_mk will alphbetically sort the services.

Code: Select all

#!/usr/bin/perl
# Get zoneminder monitor frame rates

push @camarray, ( 
	{ camname => "Back", 		camid   => "16" ,	padid	=> "16"},
	{ camname => "Back-low",	camid   => "17" ,	padid	=> "17"},
	{ camname => "Front",		camid   => "1" ,	padid	=> "01"},
	{ camname => "Front-low",	camid   => "2" ,	padid	=> "02"},
	{ camname => "Garage",	camid   => "5" ,	padid	=> "05"},
	{ camname => "Garage-low",	camid   => "6" ,	padid	=> "06"},
	{ camname => "Side",		camid   => "3" ,	padid	=> "03"},
	{ camname => "Side-low",	camid   => "4" ,	padid	=> "04"},
	{ camname => "Shop",		camid   => "7" ,	padid	=> "07"},
	{ camname => "Shop-low",	camid   => "8" ,	padid	=> "08"},
	{ camname => "Workshop-int",	camid   => "15" ,	padid	=> "15"},
	{ camname => "Gates",		camid   => "14" ,	padid	=> "14"},
	{ camname => "Penny-low",	camid   => "19" ,	padid	=> "19"},
	{ camname => "Penny",		camid   => "20",	padid	=> "20" },

);

foreach $cam (@camarray) {
	$fps = `zmu -m $cam->{camid} -f -Uusername -Ppassword`;
	chomp $fps;
	print "0 ZM_$cam->{padid}_$cam->{camname} fps=$fps $cam->{camname} ($cam->{camid}) running at $fps FPS.\n";
	
}
Post Reply