As I said, it's possible to extract the data from the variables you mentioned.<div><br></div><div><div><font face="courier new, monospace"><b>[root@bravura ~]# cat /usr/local/nagios/libexec/just_test</b></font></div><div>
<font face="courier new, monospace">#!/bin/bash</font></div><div><font face="courier new, monospace">echo $NAGIOS_HOSTNAME</font></div><div><font face="courier new, monospace"><br></font></div><div><b>Define a command:</b></div>
<div><div><font face="courier new, monospace">define command {</font></div><div><font face="courier new, monospace"> command_name just_test_cmd</font></div><div><font face="courier new, monospace"> command_line $USER1$/just_test > /tmp/test.txt</font></div>
<div><font face="courier new, monospace">}</font></div></div><div><font face="courier new, monospace"><br></font></div><div><b>Define a service:</b></div><div><div><font face="courier new, monospace">define service {</font></div>
<div><font face="courier new, monospace"> name just_test_srv</font></div><div><font face="courier new, monospace"> use local-service</font></div><div><font face="courier new, monospace"> host_name <a href="http://bravura.svc.unicc.org">bravura.svc.unicc.org</a></font></div>
<div><font face="courier new, monospace"> check_command just_test_cmd</font></div><div><font face="courier new, monospace"> service_description Just test</font></div><div><font face="courier new, monospace">}</font></div>
</div><div><br></div><div>After check is run, you will get your data.</div><div><br></div><div><div><font face="courier new, monospace"><b>[root@bravura ~]# cat /tmp/test.txt</b></font></div><div><font face="courier new, monospace"><a href="http://bravura.svc.unicc.org">bravura.svc.unicc.org</a></font></div>
</div><div><br></div><div>Hope it helps.</div><div><br></div><div><br></div><div>Ruslan</div><div><br><div class="gmail_quote">On Thu, Aug 2, 2012 at 12:49 PM, Bruno Martins <span dir="ltr"><<a href="mailto:bmomartins@gmail.com" target="_blank">bmomartins@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello there,<br><br>Thanks for fast reply.<br><br>I have that setting in my nagios.cfg file:<br>enable_environment_macros=1<br>
<br>Do you know how can I make this possible, if it is really possible...<br><br>Best regards,<br>
<br>Bruno<div class="HOEnZb"><div class="h5"><br><br><div class="gmail_quote">On Thu, Aug 2, 2012 at 11:32 AM, Assaf Flatto <span dir="ltr"><<a href="mailto:nagios@flatto.net" target="_blank">nagios@flatto.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<u></u>
<div bgcolor="#ffffff" text="#000000">
The marco's are internal to nagios and will not be read from an
external text file .<br>
<br>
there is a way to make nagios macros available to external commands
( look for "macros" in the nagios.cfg file)<br>
<br>
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 .<div><div><br>
<br>
<br>
On 02/08/12 11:25, Bruno Martins wrote:
</div></div><blockquote type="cite"><div><div>Hello list,<br>
<br>
How can I access Nagios variables like <span style="font-size:11pt;font-family:"Calibri","sans-serif"">$NOTIFICATIONTYPE$,
</span><span style="font-size:11pt;font-family:"Calibri","sans-serif"">$SHORTDATETIME$,
etc from a text file passed in a command?<br>
<br>
I have one command which is:<br>
/usr/local/bin/sendEmail -o message-file=/etc/nagios/message.txt
... bla bla bla<br>
<br>
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 "</span><span style="font-size:11pt;font-family:"Calibri","sans-serif"">$NOTIFICATIONTYPE$",
etc.<br>
<br>
Googling didn't help too much.<br>
<br>
Thanks for all help on this!<br>
<br>
Best regards,<br>
<br>
Bruno<br>
</span>
</div></div><pre><fieldset></fieldset>
------------------------------------------------------------------------------
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. <a href="http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/" target="_blank">http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/</a></pre>
<pre><fieldset></fieldset>
_______________________________________________
Nagios-users mailing list
<a href="mailto:Nagios-users@lists.sourceforge.net" target="_blank">Nagios-users@lists.sourceforge.net</a>
<a href="https://lists.sourceforge.net/lists/listinfo/nagios-users" target="_blank">https://lists.sourceforge.net/lists/listinfo/nagios-users</a>
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null</pre>
</blockquote>
<br>
</div>
<br>------------------------------------------------------------------------------<br>
Live Security Virtual Conference<br>
Exclusive live event will cover all the ways today's security and<br>
threat landscape has changed and how IT managers can respond. Discussions<br>
will include endpoint security, mobile security and the latest in malware<br>
threats. <a href="http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/" target="_blank">http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/</a><br>_______________________________________________<br>
Nagios-users mailing list<br>
<a href="mailto:Nagios-users@lists.sourceforge.net" target="_blank">Nagios-users@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/nagios-users" target="_blank">https://lists.sourceforge.net/lists/listinfo/nagios-users</a><br>
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.<br>
::: Messages without supporting info will risk being sent to /dev/null<br></blockquote></div><br>
</div></div><br>------------------------------------------------------------------------------<br>
Live Security Virtual Conference<br>
Exclusive live event will cover all the ways today's security and<br>
threat landscape has changed and how IT managers can respond. Discussions<br>
will include endpoint security, mobile security and the latest in malware<br>
threats. <a href="http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/" target="_blank">http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/</a><br>_______________________________________________<br>
Nagios-users mailing list<br>
<a href="mailto:Nagios-users@lists.sourceforge.net">Nagios-users@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/nagios-users" target="_blank">https://lists.sourceforge.net/lists/listinfo/nagios-users</a><br>
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.<br>
::: Messages without supporting info will risk being sent to /dev/null<br></blockquote></div><br></div></div>