Working with PHP to control Nagios
<p>To monitor an host and some services with Nagios, we have to edit the text file with something like:</p>

<pre><code>define host{
use &lt;template&gt;
host_name &lt;name&gt;
alias &lt;alias&gt;
address &lt;IP&gt; }

define service{
use &lt;template&gt;
host_name &lt;name&gt;
service_description &lt;desc&gt;
check_command &lt;command&gt; }
</code></pre>

<p>I have an interface where I can do something like that with PHP language. I have 2 functions addServiceNagios($hostname, $service, $command) and addHostNagios($hostname, $hostIP) where the information is placed in the file. Now I have a big problem:</p>

<p>The information is always placed no matter what.. If the host already exists, or if the services are already assigned to hosts. What's the best approach to check if the host is already defined? And if the services are associated? And if I want to erase the services that are associated to the host? Thanks in advance.</p>
