PDA

View Full Version : Keeping track of swapout rates in Linux and Solaris


helixblue
16-02-2005, 21:04
I find it important to track the swapout rates of my UNIX machines, almost as much as it is to track the total swap. Thankfully, vmstat returns these results quite nicely. Linux and Solaris 10 use two different columns (8 and 9 respectively), hence the two different versions:

UserParameter=linuxswap[rate5s],vmstat 5 2 | awk '{ print $8 }' | tail -1
UserParameter=linuxswap[rateavg],vmstat | awk '{ print $8 }' | tail -1

UserParameter=solswap[rate5s],vmstat 5 2 | awk '{ print $9 }' | tail -1
UserParameter=solswap[rateavg],vmstat | awk '{ print $9 }' | tail -1

The rateavg is the average swapout rate since your machine last booted, at least according to the vmstat documentation. Enjoy! :)

Alexei
16-02-2005, 22:23
Thanks for your messages! I'm sure they will be useful for many ZABBIX users.

Just a small note. I wouldn't recommend use of commands which require long execution time as UserParameters. For example, the "vmstat 5 2" needs 2 seconds to return result back to ZABBIX server. It means, that one of ZABBIX sucker processes will block for 2 seconds. At least, this is how it works in 1.0.

helixblue
17-02-2005, 22:46
I try to avoid long-running UserParameter scripts if I can, but I don't know of any other way to go about monitoring these objects. I'm okay with blocking the process for a single test, as it's better to slow things down then ignore possible problems.

My web performance script sometimes takes over a minute to execute. It seems to work for the most part, though I had to change the Zabbix source to allow execution of up to 120 second.s

Thanks for the great product!

Alexei
17-02-2005, 22:58
My web performance script sometimes takes over a minute to execute. It seems to work for the most part, though I had to change the Zabbix source to allow execution of up to 120 seconds. Consider use of combination of crontab+zabbix_sender+zabbix_trapperd for long running parameters. This will not hurt performance and responsiveness of ZABBIX server.

Note that if UserParameter timeouts, ZABBIX agent does not kill executed processes. It may lead to situations when same UserParameter is executed several times, and, in some extreme cases, hundreds of times. Why? Because ZABBIX server does not give up in case of timeout and tries to get value of the parameter over and over again. Very dangerous!

bbrendon
12-02-2007, 08:31
This seems like a slightly better solution.
UserParameter=pagesswappedout,vmstat -s|grep 'swapped out' |awk '{ print $1 }'

clahti
12-02-2007, 19:46
Consider use of combination of crontab+zabbix_sender+zabbix_trapperd for long running parameters. This will not hurt performance and responsiveness of ZABBIX server.

Note that if UserParameter timeouts, ZABBIX agent does not kill executed processes. It may lead to situations when same UserParameter is executed several times, and, in some extreme cases, hundreds of times. Why? Because ZABBIX server does not give up in case of timeout and tries to get value of the parameter over and over again. Very dangerous!

I am writing three perl wrapper scripts for iostat, vmstat and mpstat that alarms properly (timeout) etc, and I wish to use them with zabbix_sender but this does not work in the current 1.3.2 beta version. I will be happy to post these once I verify they actually work, but until zabbix_sender is fixed in 1.3.x series I am pretty dead in the water. I will be providing templates as well in the cookbook when I post these. I actually will avoid the crontab approach and use a UserParameter in the agent to actually fire the script which will then zabbix_send back multiple items, I have this pretty much ready to go but zabbix_sender is the bottleneck to releasing these...:(


/Chris