#!/bin/sh
#
# Filename: check_version_plugins
#
# print version of Nagios-Plugins via NRPE 
#
# Version of THIS script
OWN_VERSION=1.0
#
# used return codes of Nagios NRPE
#STATE_OK=0
#STATE_WARNING=1
#STATE_CRITICAL=2
#STATE_UNKNOWN=3
#STATE_DEPENDENT=4
#
# This script delivered by the Nagios plugins installation procedure
# contains the version
CHECK_UTILS=/usr/local/nagios/libexec/utils.sh
#
# optional: modify the script to your own needs
# to check version on an plugin or a system program (e.g. perl)
THE_PLUGIN=/usr/local/nagios/libexec/check_tcp
THE_PLUGIN_SHORT=check_tcp
#
# check if utils are available
#
if [ ! -r $CHECK_UTILS ]
then
   echo "check_version Error: $CHECK_UTILS not found"
   exit 3
fi

# Load the utils

. $CHECK_UTILS

# Call function printing Version of Plugins

print_revision check_version $OWN_VERSION | sed -n '1,1 p' | sed 's/(//g' | sed 's/)//g'|  awk ' { print "Nagios Plugins " $4 } '
exit 0

# optional

# select a plugin printing with option --version its Version
#if [ ! -x $THE_PLUGIN ]
#then
#   echo "check_version: State unknown"
#   exit 3
#fi

#$THE_PLUGIN --version | sed s/"$THE_PLUGIN_SHORT"//g | awk ' { print "Plugin $THE_PLUGIN_SHORT Version: " $0 } '
#exit 0
#
