<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
I do a similar thing where I dynamically change the service check
definitions configured into Nagios. You've almost got to this solution
but say "and couldn't just
". Not sure why you say that but I'll briefly cover what I did. You
will need some programming/scripting.<br>
<br>
First up in the nagios.cfg file configure either a specific
configuration file or directory where you will define your dynamic
service checks<br>
eg cfg_dir=/etc/nagios/dynamic_services or <br>
cfg_file=/etc/nagios/dynamic_services.cfg<br>
<br>
Using a file/directory will be dependent on exactly how you need to
generate your checks.<br>
<br>
Then at the point where you know what the service checks will be
generate the appropriate nagios config file based on what is in the
database into either your single config file or into one file each in
the dynamic directory.<br>
<br>
You will then need to reload the nagios config and make sure it
syntaxes ok.<br>
<br>
We do this quite sucessfully. When customers add/delete servers we just
regenerate the config to match and reload Nagios.<br>
<br>
David Rosenstrauch wrote:
<blockquote cite="mid:4A5D04EF.5080601@darose.net" type="cite">
  <pre wrap="">Scratching my head as to how it might be possible to accomplish a 
monitoring task I need to do:

We have a database table of tags.  For each tag we have a process that 
generates a Javascript file and pushes it out to a CDN.  I've 
successfully created a service check to monitor that the process runs 
successfully (by using check_mysql_query to verify that a "pushed" date 
gets updated on the database table).  But we also need to monitor that 
each of the files exists - and in the correct version - over at the CDN, 
and here's where I'm hitting a wall.

What I'm envisioning is a way whereby I could dynamically generate a 
whole bunch of service checks - one for each tag in the database table. 
  Each service check would then go and download its corresponding file 
from the CDN, parse it, and verify the version number.  In this way, if 
any particular file was missing or the wrong version, we would get a 
Nagios alert on that tag/file.

However, I don't see any clear way to approach this with Nagios.  Near 
as I can tell there doesn't seem to be any way to dynamically generate 
service checks.  From my reading of the docs, every service need to be 
explicitly listed in the config files beforehand.

I was thinking that perhaps having a cron job that generates passive 
checks might be a solution here, but again it looks like I would still 
need to have the service checks defined beforehand in the nagios config 
files, and couldn't just generate them on-the-fly based on the contents 
of the database table.


Anyone have any ideas on how I could accomplish this file monitoring in 
a dynamic fashion?  (Note that alerting on a file-by-file basis is 
needed here; it would not be sufficient to have a single service check 
that monitors and alerts on all of the files.)

TIA,

DR

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: <a class="moz-txt-link-freetext" href="http://p.sf.net/sfu/Challenge">http://p.sf.net/sfu/Challenge</a>
_______________________________________________
Nagios-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Nagios-users@lists.sourceforge.net">Nagios-users@lists.sourceforge.net</a>
<a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/nagios-users">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 class="moz-signature">-- <br>
<font size="2"><font face="Verdana">
<a href="http://www.smartmon.com.au">Smartmon System Monitoring</a><br>
<a class="moz-txt-link-abbreviated" href="http://www.smartmon.com.au">www.smartmon.com.au</a>
</font></font></div>
</body>
</html>