Posts Tagged ‘automation’

Automatically update iptables rules for Pingdom monitors.

March 14th, 2012 4 comments

Pingdom is an awesome service that tracks the uptime, downtime, and performance of websites (you can see an example of the public stats of this server here). If you have a firewall running on your system, you need to whitelist Pingdom’s servers or else their monitors will fail. As their servers may change at any given time, it is better to automate this whitelisting by realistically and responsibly polling the RSS feed of their monitoring servers.

It’s been done before, but this is how I have chosen to do it.

First, a little php helper script to extract the Active IP addresses of the monitors. For this example, let’s save it as alongside our bash script which will be executed by cron.


echo implode("\n", $ips[1]);

Then, our bash script which is called from cron:

for ip in $(/usr/bin/php; do
    $IPTABLES -A INPUT -s $ip -p icmp -j ACCEPT

Of course, this is just an example and you will need to modify the firewall rule(s) according to your needs.

Automatically download and merge multiple PDF files with a Unix shell.

June 14th, 2011 No comments

This is a simple little script which I wrote to download multiple parts of some weekly newspapers and then merge them all up into one PDF file. I have no idea why they post these broken up into many pieces instead of just one and it’s a pain to close and open multiple files just to read the paper.

To use this script, you must know the exact filenames of the PDFs you want to download and you need pdfmerge, installable with yum ($ sudo yum install pdfmerge) from the updates repo.

Read more…