willixix / naglio-plugins

Monitoring Plugins by William Leibzon
http://william.leibzon.org/nagios/
77 stars 54 forks source link

Support bytes read/write per second in check_memcache.pl #44

Open thepaleone opened 10 years ago

thepaleone commented 10 years ago

It would be great to generate a bytes read / written per second similar to the way memcache-top does. I tried hacking around a bit but got stuck trying to figure out how to get the last time the check was run in order to do the calculations.

willixix commented 10 years ago

what plugin is this for? check_memcached.pl?

and I'm not familiar with memcache-top, you'll have to describe in more detail what it does.

in general something like read/write per second would be handled by rate code i.e. instead of checking variable you'd specify threshold for variable_rate. The library can handle all the necessary calculations for it.

thepaleone commented 10 years ago

Yes, it is for check_memcache.pl

memcache-top is a nice script for instant monitoring. It can be found at http://code.google.com/p/memcache-top/. basically the stats that I am talking about are teh READ/s and WRITE/s which simply records the bytes_read and bytes_written stats on each refresh (default 5 seconds). it then subtracts the current with the value from the last recycle and divides the result by the number of seconds in the refresh.

I will admit I didn't follow the variable_rate section very well so I wasn't sure if that was the right way to go. I'll dig into it a little more and see if I can put something together.

thepaleone commented 10 years ago

I've done a little more study of the docs, comments and such and it seems like the plugin might be able to do what I'm looking for already, but I'm having problems with coming up with the correct service definition. I've tried a few different combinations with no luck so far. Currently my command looks like this:

-H $HOSTADDRESS$ -p 11211 --rate_label=,_rate -a bytes_read_rate,bytes_written_rate -w ~,~ -c ~,~ -f -P "$SERVICEPERFDATA$"

The response I keep getting is:

Calculating rate variable such as &bytes_read requires previous performance data. Please add '-P $SERVICEPERFDATA$' to your nagios command line.

Am I on the right track? if so, what am I missing?

willixix commented 10 years ago

It should work the way you specified it. For some reason its not seeing perfdata coming back in at all. Try to run it manually from command line, i.e. run it first with empty data in -P, then in 5 minutes with data that was output first after |. Also I think you'd need to enter the variable as bytes_read_rate. You can also try specifying --debug potentially with a debug file name.

And what version of check_memcached.pl are you using? 0.8x all support long option --bytes_read_rate and --byte_write_rate which are essentially same as what you did. To use that you'd specify "--bytes_read_rate=DISPLAY:YES --bytes_written_rate=DISPLAY:YES" in place of "--rate_label=,rate -a bytes_read_rate,bytes_written_rate -w ~,~ -c ~,~"

thepaleone commented 10 years ago

I'm using 0.83 which I believe is the current stable release.

I'm not exactly sure how you pass data back in. When I run it with these options: --bytes_read_rate=DISPLAY:YES --bytes_written_rate=DISPLAY:YES -P ""

the response I get is MEMCACHE CRITICAL: bytes_written_rate data is missing, bytes_read_rate data is missing - memcached 1.4.4 on mc01:11211, up 17 days 32 minutes

Using the --debug option shows me that it's connecting and retrieving the stats properly, but that's about it.

willixix commented 10 years ago

add ",ABSENT:OK" after each DISPLAY

and right, you need previous performance data for plugin to do calculations. when you run it with "" that just tests that plugin works and recognizes all options. you can feed performance data manually from command line and then will see that it did the calculations.

but you need to find why it didn't do it properly from nagios from the macro and I'm not sure what's wrong there

thepaleone commented 10 years ago

The ABSENT:OK got rid of the error, but I still don't understand how to feed the data back in. What format does it need to be like? My output doesn't have anything that looks like I can feed it back to the -P parameter.

MEMCACHE OK: bytes_written_rate data is missing, bytes_read_rate data is missing - memcached 1.4.4 on mc01:11211, up 17 days 45 minutes

When I run it with --debug I do see that the stats I want are there,just not sure what to do with them to test it. Stats Data: misc(bytes_written) = 3288714880323 Stats Data: misc(bytes_read) = 1750952029928

willixix commented 10 years ago

if you run it manually you'd see it after "|" line in the output. Automatically it is collected in PERFDATA which in standard nagios interface you'll see if you click on the service. $SERVICEPERFDATA macro makes it available for next execution of the plugin.

thepaleone commented 10 years ago

I must be missing something simple but I cannot figure it out. When I try to use any sort of rate functionality I only get messages saying either the data is missong or that requires previous performance data. Here are various ways I've tried to do this followed immediately by their outputs.

./check_memcached.pl -H mc01 -p 11211 --rate_label=_rate -a bytes_read -w ~ -c ~ -f -P "bytes_read=1647493197c" MEMCACHE OK: memcached 1.4.4 on mc01:11211, up 15 minutes 30 seconds - bytes_read is 1668556899 | bytes_read=1668556899c

./check_memcached.pl -H mc01 -p 11211 -a "&bytes_read" -w ~ -c ~ -f -P "bytes_read=1647493197c" Calculating rate variable such as &bytes_read requires previous performance data. Please add '-P $SERVICEPERFDATA$' to your nagios command line.

./check_memcached.pl -H mc01 -p 11211 --bytes_read_rate=DISPLAY:YES,ABSENT:OK -f -P "bytes_read=1327412199c" MEMCACHE OK: memcached 1.4.4 on mc01:11211, up 14 minutes

./check_memcached.pl -H mc01 -p 11211 --bytes_read_rate=DISPLAY:YES,ABSENT:OK -f MEMCACHE OK: bytes_read_rate data is missing - memcached 1.4.4 on mc01:11211, up 22 minutes 24 seconds

./check_memcached.pl -H mc01 -p 11211 -a "&bytes_read" -w 100 -c 10000 -f -P "&bytes_read=1647493197c" Calculating rate variable such as &bytes_read requires previous performance data. Please add '-P $SERVICEPERFDATA$' to your nagios command line.

thepaleone commented 10 years ago

I'm still not able to get any sort of _rate variable working. They all tell me that there's no data, even when I pass data back in with the -P. Can anyone tell me what I'm doing wrong?

willixix commented 10 years ago

I will look into this and try what you're doing. But I've been very busy for last couple weeks. Probably next week I'll respond.

wu0407 commented 9 years ago

i have same issue, _rate variable not working