[CentOS] Cacti/snmp question

Wed Jun 16 09:28:51 UTC 2010
John Doe <jdmls at yahoo.com>

From: Whit Blauvelt <whit at transpect.com>
> the PNP crew enhances their documentation with some working 
> examples, or I learn German

I was able to make some plugins without too much problems (even discovered perl in the process)...
http://nagiosplug.sourceforge.net/developer-guidelines.html#PLUGOUTPUT
Just copy/paste an existing plugin and adapt it.
The main thing to remember is the plugin returns on STDOUT:
SERVICE STATUS: Information text|'label1'=value[UOM];[warn];[crit];[min];[max] 'label2'=value[UOM];[warn];[crit];[min];[max] ...

Examples:
$ check_memory 
MEMORY OK - RAM Used: 37% (1127MB/3041MB), SWAP Used: 0% (0MB/2932MB)|RAM=1127MB;2736;2888;0;3041 SWAP=0MB;2902;2932;0;2932
$ check_netstat
NETSTAT OK - [LOC] = 24/0/0/8, [LAN] = 15/0/1/44, [WAN] = 0/0/0/0  (ES/SY/FW/TW)|LOC_ES=24;250;1000;0 LOC_SY=0;250;500;0 LOC_FW=0;150;300;0 LOC_TW=8;1500;3000;0 LAN_ES=15;250;1000;0 LAN_SY=0;250;500;0 LAN_FW=1;150;300;0 LAN_TW=44;1500;3000;0 WAN_ES=0;250;1000;0 WAN_SY=0;250;500;0 WAN_FW=0;150;300;0 WAN_TW=0;1500;3000;0
etc...

Then PNP will "automaticaly" plot these values... but yes, if you have n values, you will get n graphs...

> someone writes a Nagios plugin that captures per-core CPU load

/proc/stat gives
cpuX  <user_ticks> <nice_ticks> <system_ticks>
<idle_ticks> <uptime> <iowait> <irq>
<soft_irq>

What I did for disk perfs by example is save the stats plus a timestamp in a file, then (new_stats-old_stats)/(new_ts-old_ts)...
But, in some tricky cases (like /proc/net/dev), watch out for value rollovers and "bumps".

JD