I would like to reconfigure Nagios e-mail notification to send me information about largest files on a disk.

This is oneliner which shows me largest 20 files:

find / -type f -ls | sort -k 7 -r -n | head -20 |grep -v lastlog | awk '{ sum=$7 ; hum[1024**3]="Gb";hum[1024**2]="Mb";hum[1024]="Kb"; for (x=1024**3; x>=1024; x/=1024){ if (sum>=x) { printf "%.2f %s" " " $11 "\n",sum/x,hum[x];break;} }}'

I'd like Nagios to trigger this command on check_disk alert and to attach results in Nagios notification.

Could that be possible?



You probably want to use check_nrpe for this and add it as a separate check and give it the one liner as the remote command to be executed. You can't alter check_disk unless you edit the source code and recompile it.

The max output for chech_nrpe is 1024 chars, so you might need to cut it down a bit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.