[smokeping-users] creating a smokeping like www.dslreports.com/smokeping

Peter Kristolaitis alter3d at alter3d.ca
Fri Aug 10 00:16:21 CEST 2007


Hi Peter;

There's no way 'out-of-the-box' to accomplish what you want, as far as I 
know, but it wouldn't be terribly difficult to roll your own solution.

There are a few approaches that come to mind, depending on the volume of 
traffic you expect your site to get, since the simpler solution can run 
into concurrency problems.  All of them, however, involve re-writing 
config files on the fly.  With a decent scripting language (my choice 
here would be Perl, YMMV), this is /very/ straightforward.

I would recommend keeping a 'master' config file with e.g. your probe 
and alert configurations, and then have one file as an 'include', which 
gets rewritten on-the-fly, as below.

The general 'lifecycle' of a simple solution would be something like:
1) Accept new IPs as input.
2) Append new 'host' entry in your config file;  use a 
specially-formatted comment line to indicate expiration time.
3) Restart SmokePing daemon.
4) In a separate scheduled process (say, once every 4 hours), scan the 
config file for expired entries and remove them.
4a) While removing the entries, remove the .rrd files at the same time.

With a little forward-thinking, step (4) is trivial.  If you were to 
format your file (and each host in the file) in a specific manner (as it 
would have to be, being machine-generated), something like:

###BEGINHOST {insert_expiry_time_here} ###
+smokepinghostname
host = xx.xx.xx.xx
menu = Foo
title = Foo (xx.xx.xx.xx)

then it becomes trivial to remove expired entries... as you're reading 
each line of the file, check to see if the line matches the regex 
/^###BEGINHOST/, parse out the expiry time and compare it to the current 
time.  If it has indeed expired, skip all lines of input until 
/^###BEGINHOST/ matches again.  If it hasn't expired, then read those 
lines and just re-output them into the new config file.

The above solution can run into concurrency problems if your site is 
very busy, since you may end up with multiple processes trying to write 
to the file at the same time.

A slightly more advanced solution would follow a workflow something like:
1) Accept new IP as input.
2) Enter new IP request into submission queue (e.g. an RDBMS).  
Timestamp entries for submission and/or expiration times.
3) Periodically (say, every 5 minutes), run a script that reads the 
database, deletes (or disables) expired entries, and re-creates the 
config file with the non-expired entries.
3a) Stop SmokePing.
3a) Delete .rrd files for expired hosts.
3c) Start SmokePing.

This solution has many, many advantages -- for example, no need to write 
metadata (e.g. expiry time) into the config file, since it's all in the 
database.  Also, the use of a database is MUCH more web-friendly in 
terms of your PHP/CGI/etc scripts.  You also won't run into concurrency 
problems since there's only a single process writing to the file (the 
multiple-writes are moved to the RDMBS system, which is designed for that).

There are more tricks you could play to increase efficiency for a very 
large system (e.g. 256 include files, with entries sorted based on the 
mask 0.0.0.255 (NOT 255.0.0.0 since distribution on that set is heavily 
biased)... you would only have to update changed files between cycles.  
On very very large data sets, it could provide a performance boost 
during the update cycle by allowing parallelism and not updating 
unchanged data.  I somehow get the feeling that this isn't the case for 
you, however.

There are many, many ways to implement the actual coding of all this, 
depending on your environment, available scripting or programming 
languages, and any defined requirements for the system.  However, if you 
use a reasonable language (Perl! :), it's actually very, very 
straight-forward.

Hope that helps!
- Peter


peter Mistich wrote:
> Hello all,
>
> I'm new to smoke ping and have been trying to recreate the smokeping 
> on dslreports so you can enter a ip address and it auto adds it to the 
> smokeping config and runs it for one day.
>
> I have made several attempts but have failed. the issue I keep running 
> into is the config file you cannot include a directory of config files 
> just the config files itself.
>
> if it would allow me to read a directory of configs I could write a 
> seprate config for each ip and then reload smokeping.
>
> one note I'd like to be able to do this with out modfying smokeping 
> its self so that in futher updates I do not have to modfiy each version.
>
> any suggestions,
> Pete
> ------------------------------------------------------------------------
>
> _______________________________________________
> smokeping-users mailing list
> smokeping-users at lists.oetiker.ch
> https://lists.oetiker.ch/cgi-bin/listinfo/smokeping-users
>   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.oetiker.ch/pipermail/smokeping-users/attachments/20070809/6dde2c5e/attachment-0001.html 


More information about the smokeping-users mailing list