per host custom macros
John P. Rouillard
rouilj at cs.umb.edu
Sat Jun 3 02:58:53 CEST 2006
I am coming into this a bit late, but maybe a method like this would
work. For each of my LDAP hosts I have a check_ldaps service defined
as:
$USER1$/check_ldaps -p 636 -H `$USER1$/ip2ldapCN $HOSTADDRESS$` $ARG1$
where ip2ldapCN is:
for i in auth1.example.com auth2.example.com auth3.example.com auth4.example.com auth4.example.com
do
addr=`dig +short $i`
if [ "$addr" = "$1" ]; then
echo $i
exit
fi
done
echo "Incorrect_address of ip2ldapCN $1"
This loops over all auth hosts and returns the auth host name
corresponding to the host address passed in. However a similar
mechanism could be used to represent any data.
Imagine a shell script that takes two arguments: attribute_name and host
this allows you to get any attribute value into a command.
So I could write:
$USER1$/check_ldaps -p 636 -H `$USER1$/attributes AUTHNAME $HOSTNAME$` $ARG1$
and then attributes runs:
sed -ne "s/.*$2-$1=(.*)/\1/p" /etc/nagios/hosts/*.cfg
to extract the attribute from the host config where the attribute
looks like:
# host1.example.com-AUTHNAME: auth1.example.com
With some perl you could check the mtime of the *.cfg files (or the
parent directory) and reparse the config files extracting all the keys
and values into a dbm file for faster lookup.
Yes, this is a hack but it might be a useful hack and can work for
any plugin.
-- rouilj
John Rouillard
===========================================================================
My employers don't acknowledge my existence much less my opinions.
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list