help with special character in check command

Rob Brown dtownrobbrown at gmail.com
Wed Nov 29 19:43:58 CET 2006


Since I did not receive any feedback on this, I ended up using this
rather simple workaround, in case anyone runs into this in the future:
I created a simple "wrapper" shell script with the community string
hard coded in it, then call the wrapper script instead of the
check_snmp command:
here is the one-line wrapper script: (I called it check_snmp_wrapper)
/usr/local/nagios/libexec/check_snmp -H $1 -o $2 -w $3 -c $4 -C xyz123!

then defined a new check command:
define command {
        command_name    check_snmp_wrapper
        command_line    $USER1$/check_snmp_wrapper $HOSTADDRESS$
$ARG1$ $ARG2$ $ARG3$
}

and defined my service:
define service {
        host_name                        myrouter
        service_description             check_connections
        use                                   workhours
        check_command                   check_snmp_wrapper![oid]!255000!260000
        notification_options            c,w,r,f
        contact_groups                  sysadmin
}

sometimes the answer is so simple, its staring you right in the face!

On 11/22/06, Rob Brown <dtownrobbrown at gmail.com> wrote:
> I am trying to use the check_snmp command to do a check against some
> network gear. The problem is that the community string is "xyz123!"
> (not really but example) and I cannot figure out how to get this to
> pass thru to the check command without it stripping the "!" character.
> For example:
> define command {
>         command_name    check_snmp
>         command_line    $USER1$/check_snmp -H $HOSTADDRESS$ -o $ARG1$
> -w $ARG2$ -c $ARG3$ -C $ARG4$
> }
> define service {
>         host_name                       myrouter
>         service_description           check_connections
>         useprod-                            workhours
>         check_command               check_snmp![myoid]!255000!260000!xyz123!
>         notification_options            c,w,r,f
>         contact_groups                  sysadmin
> }
> I have run the args thru a debug command and no matter what, the last
> ! in the comm string gets stripped off.
> I have tried:
> check_snmp![myoid]!255000!260000!xyz123!
> check_snmp![myoid]!255000!260000!xyz123\!
> check_snmp![myoid]!255000!260000!xyz123!!
>
> my nagios.cfg does have the following:
> illegal_object_name_chars=`~!$%^&*|'"<>?,()=
> but I tried taking the bang out and it still doesn't work.
>
> Any help here would be appreciated, as I cannot change the community string.
> There's got to be some trick to get this to work!
>
> PS: the command works fine when run from the command line.
>

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
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