Listing 1 This wrapper will add performance data output
to Nagios plug-ins that don't already have it.
#!/bin/sh
#a wrapper which adds perfdata functionality to any nagios plugin
#link pluginName_wrapper to this script for it to work
#for example, if you want to enable perfdata for check_mem
#you would 'ln -s check_wrapper_generic check_mem_wrapper'
#get rid of the 'wrapper' on the end of the name
NAME=`echo $0 | sed -e 's/_wrapper//'`
#call the plugin and capture it's output
OUTPUT=`${NAME} $@`
#capture it's return code too
CODE=$?
#parrot the plugin's output back to stdio twice, seperated with a pipe
echo "${OUTPUT}|${OUTPUT}"
#exit with the same code that plugin would have exited with
exit ${CODE}
|