WordPress as Alerts Database

As a companion to Nagios, OStatic has come up with a rather simple workaround to posting alerts in a database: your trusty blog platform, WordPress.

WordPress includes a script (wp-mail.php) that will check a pop3 inbox for mail, download the mail, and add the contents of the mail to a new blog post. To create the database, I simply added a new alert email address to all of our monitors. Then, I created a cron job that runs a curl command that calls the wp-mail.php script. By default, wp-mail.php will not post the contents of the email, but will instead add the post as a draft, and wait for manual intervention to publish it. I found that a single change to the php code removes this behavior, so that new alerts are immediately posted to the front page of the site. To make the change, look for $post_status and make sure that all settings say ‘publish’.