Thank you very much for your tips, guys!<div>I did the job using a passive service on Nagios that receives a message whenever a new instance is UP. This message contains information such as IP address and others. When Nagios get a message for this service, it calls an event handler that modifies properly the hosts definition file. Also I have a cronjob that checks if there's any modification in my config files, and if is there any, it uses "killall -HUP nagios" to reload the config files.</div>
<div><br></div><div>Thank you again,<br clear="all"><font><div><font><br></font></div><div><font>--</font></div> </font><font>Felipe Cecagno</font><div> Mconf Development Team</div><div> <a href="https://mconf.org/" target="_blank">https://mconf.org</a></div>
<br>
<br><br><div class="gmail_quote">On Sat, Feb 11, 2012 at 3:14 AM, Daniel Wittenberg <span dir="ltr"><<a href="mailto:daniel.wittenberg.r0ko@statefarm.com">daniel.wittenberg.r0ko@statefarm.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">That depends on your definition of dynamically. I would like to see it be able to add/remove hosts without requiring a restart of the service. I currently
use puppet, but it’s still just updating files and then you have to restart to pickup the changes.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Dan<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> ranjib dey [mailto:<a href="mailto:dey.ranjib@gmail.com" target="_blank">dey.ranjib@gmail.com</a>]
<br>
<b>Sent:</b> Friday, February 10, 2012 11:42 PM<br>
<b>To:</b> Nagios Users List<br>
<b>Subject:</b> Re: [Nagios-users] Dynamically add/remove hosts on Nagios<u></u><u></u></span></p><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<p>Have you considered using a configuration management tool like chef or puppet ? They address the exact usecase
<u></u><u></u></p>
<div>
<p class="MsoNormal">On Feb 10, 2012 7:08 AM, "Felipe Cecagno" <<a href="mailto:fcecagno@gmail.com" target="_blank">fcecagno@gmail.com</a>> wrote:<u></u><u></u></p>
<p class="MsoNormal">Hi everybody,<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">This is the first time I'm posting on this mailing list, so I'm sorry if my question was already discussed here - I tried to find information about it on the mailing list and also on Nagios documentation + googling, but couldn't find it.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Well, I'm setting up Nagios to monitor a group of servers in a cloud environment. I decided to use passive checks, so I will have one Nagios central monitor and all servers push statistics to Nagios using NSCA. Everything is OK so far.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">The problem is that I want to add and remove instances dynamically, I don't want to manually modify hosts.cfg on the central each time I change my infrastructure. So my idea was that when a new instance gets up, it will send to Nagios something
like (always using NSCA):<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">"localhost Server UP 0 <new instance IP>"<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">On Nagios I would create a new service on localhost to handle this passive check.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">I've created a Python script (that uses pynag) to modify the hosts.cfg file in order to add and remove host definitions. When Nagios receives this passive check, I would call the script to modify the hosts definition files, and a cron job
would execute every minute to look for modifications on hosts.cfg and make Nagios reload the definition files.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">My doubts are:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">- is there a smarter way to do that (dynamically add and remove hosts from Nagios)?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">- since my "Server UP" service uses passive checks only, how do I make Nagios call my script to modify hosts.cfg every time it receives the passive check?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Any thoughts/suggestions would be appreciated. :)<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Thank you in advance,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Best regards,<br clear="all">
<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">--<u></u><u></u></p>
</div>
<p class="MsoNormal"> Felipe Cecagno<u></u><u></u></p>
<div>
<p class="MsoNormal"> Mconf Development Team<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <a href="https://mconf.org/" target="_blank">https://mconf.org</a><u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal"><br>
------------------------------------------------------------------------------<br>
Virtualization & Cloud Management Using Capacity Planning<br>
Cloud computing makes use of virtualization - but cloud computing<br>
also focuses on allowing computing to be delivered as a service.<br>
<a href="http://www.accelacomm.com/jaw/sfnl/114/51521223/" target="_blank">http://www.accelacomm.com/jaw/sfnl/114/51521223/</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<u></u><u></u></p>
</div>
</div></div></div>
</div>
<br>------------------------------------------------------------------------------<br>
Virtualization & Cloud Management Using Capacity Planning<br>
Cloud computing makes use of virtualization - but cloud computing<br>
also focuses on allowing computing to be delivered as a service.<br>
<a href="http://www.accelacomm.com/jaw/sfnl/114/51521223/" target="_blank">http://www.accelacomm.com/jaw/sfnl/114/51521223/</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>