I wanted to illustrate how to use fido with an example. Today we’re going to use it to count software downloads on this site. Exciting! This will be simple since we only have one data source. A few years ago, I move my software from an FTP repository onto this web server. To quantify software downloads, we can simply monitor the http access log.
Here’s our fido configuration for the log file:
/var/log/httpd/access_log { rules = downloads.conf action = /usr/local/bin/tally log = syslog }
This tells fido to monitor the access_log in real time. Its pattern match rules are in a file called downloads.conf
When fido finds a match, it will execute a program called tally
. Finally, the last directive tells fido to use syslog to log its activity.
In order to understand what we’re looking for, you should take a look at the software repository. It contains multiple versions and helpful links to the latest releases and betas. We want to match them all.
Let’s take a look at our downloads.conf file. Since we didn’t specify a full path to the file, fido knows to look for it under $sysconfdir/etc/fido/rules. If you configured it to use /etc, then the rules are found in /etc/fido/rules/downloads.conf. Here’s the file:
# # Track and count downloads from the website SIEGE: .*siege-.*tar.gz.* FIDO: .*fido-.*([rpm]|[tar.gz]).* WACKY: .*wackyd-.*tar.gz.* DICK: .*dick.*tar.gz.* SPROXY: .*sproxy-.*tar.gz.* CONFIG: .*JoeDog-Config.* STATS: .*JoeDog-Stats.* GETOPT: .*php-getopt.* WACKY: .*JoeDog-Wacky.* PBAR: .*JoeDog-ProgressBar.*
Each line begins with an optional label. If a label is present, fido will pass it (minus the colon) to the action program. In the example above, if the JoeDog-Config perl module is downloaded, then fido will run /usr/local/bin/tally CONFIG
. For more on labels, see the fido user’s manual.