Nagios Variables

Ruslan Valiyev linuxoid at gmail.com
Thu Aug 2 13:18:11 CEST 2012


As I said, it's possible to extract the data from the variables you
mentioned.

*[root at bravura ~]# cat /usr/local/nagios/libexec/just_test*
#!/bin/bash
echo $NAGIOS_HOSTNAME

*Define a command:*
define command {
        command_name        just_test_cmd
        command_line        $USER1$/just_test > /tmp/test.txt
}

*Define a service:*
define service {
        name                 just_test_srv
        use                  local-service
        host_name            bravura.svc.unicc.org
        check_command        just_test_cmd
        service_description  Just test
}

After check is run, you will get your data.

*[root at bravura ~]# cat /tmp/test.txt*
bravura.svc.unicc.org

Hope it helps.


Ruslan

On Thu, Aug 2, 2012 at 12:49 PM, Bruno Martins <bmomartins at gmail.com> wrote:

> Hello there,
>
> Thanks for fast reply.
>
> I have that setting in my nagios.cfg file:
> enable_environment_macros=1
>
> Do you know how can I make this possible, if it is really possible...
>
> Best regards,
>
> Bruno
>
>
> On Thu, Aug 2, 2012 at 11:32 AM, Assaf Flatto <nagios at flatto.net> wrote:
>
>> **
>> The marco's are internal to nagios and will not be read from an external
>> text file .
>>
>> there is a way to make nagios macros available to external commands (
>> look for "macros" in the nagios.cfg file)
>>
>> But what you are trying to do with the message.txt file will fail to work
>> as the SendEmail script most likely do not have access to the nagios
>> internal macros and there for will not expand them .
>>
>>
>>
>> On 02/08/12 11:25, Bruno Martins wrote:
>>
>> Hello list,
>>
>> How can I access Nagios variables like $NOTIFICATIONTYPE$, $SHORTDATETIME$,
>> etc from a text file passed in a command?
>>
>> I have one command which is:
>> /usr/local/bin/sendEmail -o message-file=/etc/nagios/message.txt ... bla
>> bla bla
>>
>> And inside message.txt I have those variables. However when I am
>> notified, I am not getting variable's values, instead, it gives me the
>> plain string "$NOTIFICATIONTYPE$", etc.
>>
>> Googling didn't help too much.
>>
>> Thanks for all help on this!
>>
>> Best regards,
>>
>> Bruno
>>
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>>
>>
>> _______________________________________________
>> Nagios-users mailing listNagios-users at lists.sourceforge.nethttps://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
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> 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
>>
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20120802/dcfff080/attachment.html>
-------------- next part --------------
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
-------------- next part --------------
_______________________________________________
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