Re: [Nagios-devel] BUG: servicegroup and (Return code of 127 is out
Posted: Tue May 10, 2011 6:31 am
On 05/09/2011 09:10 PM, Roberto Oppedisano wrote:
> AFAIK we don't use environment variables (and grepping for NAGIOS in th=
e
> config file led me only to commented out strings).
(FWIW, it would be the executables (!) spawned from Nagios - plugins,
event handlers, yadda yadda - who would (try to) retrieve data from
their environment. The *Nagios config* only determines whether Nagios
(the executable) should go ahead and fill the environment for them or
not, so you won't find any individual env vars there. As an example,
here's the beginning of a notification-sending shell script which I
initially had read the env vars, and later had to modify to accept the
data from the command line instead:
> [root@nagios ~]# head -26 /usr/local/nagios/libexec/notify-hostonly-ove=
rride.mailx
> #!/bin/sh
>=20
> # How to log. Note that Nagios is hardcoded (!) to user.info ...
> LOGGER=3D"logger -t `basename $0` -p user"
>=20
> # These are the env vars controlling our actions
> SLA=3D"$NAGIOS__HOSTSLA"
> SRV=3D"$NAGIOS__SERVICEIMPORTANT"
>=20
> # If you have the env vars disabled, you can pass the data via command
> # line, as follows:
> # --explicit-params "$HOSTNAME$" "$SERVICEDESC$" "$_HOSTSLA$ "$_SERVICE=
IMPORTANT$"
> # Note that this needs to *precede all* params passed to the mail comma=
nd.
> if [ "$1" =3D "--explicit-params" ]; then
> HNAME=3D"$2"
> SRVDESC=3D"$3"
> SLA=3D"$4"
> SRV=3D"$5"
> shift 5
> elif [ "$NAGIOS_HOSTNAME" =3D "" -o "$NAGIOS_HOSTNAME" =3D '$' ]; then
> # Try to catch someone calling us manually ...
> echo "This script should NOT be called manually ..." > /dev/stderr
> else
> HNAME=3D"$NAGIOS_HOSTNAME"
> SRVDESC=3D"$NAGIOS_SERVICEDESC"
> fi
Kind regards,
J. Bern)
--=20
Jochen Bern, Systemingenieur --- LINworks GmbH
Postfach 100121, 64201 Darmstadt | Robert-Koch-Str. 9, 64331 Weiterstadt
PGP (1024D/4096g) FP =3D D18B 41B1 16C0 11BA 7F8C DCF7 E1D5 FAF4 444E 1C2=
7
Tel. +49 6151 9067-231, Zentr. -0, Fax -299 - Amtsg. Darmstadt HRB 85202
Unternehmenssitz Weiterstadt, Gesch=E4ftsf=FChrer Metin Dogan, Oliver Mic=
hel
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
> AFAIK we don't use environment variables (and grepping for NAGIOS in th=
e
> config file led me only to commented out strings).
(FWIW, it would be the executables (!) spawned from Nagios - plugins,
event handlers, yadda yadda - who would (try to) retrieve data from
their environment. The *Nagios config* only determines whether Nagios
(the executable) should go ahead and fill the environment for them or
not, so you won't find any individual env vars there. As an example,
here's the beginning of a notification-sending shell script which I
initially had read the env vars, and later had to modify to accept the
data from the command line instead:
> [root@nagios ~]# head -26 /usr/local/nagios/libexec/notify-hostonly-ove=
rride.mailx
> #!/bin/sh
>=20
> # How to log. Note that Nagios is hardcoded (!) to user.info ...
> LOGGER=3D"logger -t `basename $0` -p user"
>=20
> # These are the env vars controlling our actions
> SLA=3D"$NAGIOS__HOSTSLA"
> SRV=3D"$NAGIOS__SERVICEIMPORTANT"
>=20
> # If you have the env vars disabled, you can pass the data via command
> # line, as follows:
> # --explicit-params "$HOSTNAME$" "$SERVICEDESC$" "$_HOSTSLA$ "$_SERVICE=
IMPORTANT$"
> # Note that this needs to *precede all* params passed to the mail comma=
nd.
> if [ "$1" =3D "--explicit-params" ]; then
> HNAME=3D"$2"
> SRVDESC=3D"$3"
> SLA=3D"$4"
> SRV=3D"$5"
> shift 5
> elif [ "$NAGIOS_HOSTNAME" =3D "" -o "$NAGIOS_HOSTNAME" =3D '$' ]; then
> # Try to catch someone calling us manually ...
> echo "This script should NOT be called manually ..." > /dev/stderr
> else
> HNAME=3D"$NAGIOS_HOSTNAME"
> SRVDESC=3D"$NAGIOS_SERVICEDESC"
> fi
Kind regards,
J. Bern)
--=20
Jochen Bern, Systemingenieur --- LINworks GmbH
Postfach 100121, 64201 Darmstadt | Robert-Koch-Str. 9, 64331 Weiterstadt
PGP (1024D/4096g) FP =3D D18B 41B1 16C0 11BA 7F8C DCF7 E1D5 FAF4 444E 1C2=
7
Tel. +49 6151 9067-231, Zentr. -0, Fax -299 - Amtsg. Darmstadt HRB 85202
Unternehmenssitz Weiterstadt, Gesch=E4ftsf=FChrer Metin Dogan, Oliver Mic=
hel
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]