Donnerstag, 20. Dezember 2012

Monitoring symfony2/swiftmailer spooling queue

If you want to monitor your email spooling queue and you are using symfony2 with swiftmailer, and if you are using Nagios or Icinga for your monitoring, I got a christmas present for you! Of course this only works when you use file spooling. Memory spooling sends mails on the end of each request, so there is not much to monitor.

I created a small shell script with no dependencies other than basic Linux tools (like find and wc) which counts the number of mails in the queue and let you thereby monitor them with Nagios/Icinga. For my example I'll use check_nrpe to execute the plugin remote on the application server.

First, here is the script. You need to save it executeable in your plugin directory on the remote machine, which in my case is /usr/lib/nagios/plugins. I saved it as check_spool:

Next you need to configure the plugin on your remote machine, adding the command to the nrpe commands in your nrpe.cfg:

command[check_spool]=/usr/lib/nagios/plugins/check_spool "/path/to/swiftmailer/spool" -w 5 -c 50

Mind the /path/to/swiftmailer/spool which should be replaced by the directory you keep your spooled files in. The -w and -c options are the Nagios/Icinga standard parameters for warning and critical threshhold. With this command registered, you can restart your nrpe server and add the check to the monitoring server:

define service{
    use                             generic-service
    host_name                       hostname
    service_description             Swiftmailer Spooling Queue
    check_command                   check_nrpe_1arg!check_spool
}


You can place this anywhere in your icinga/objects folder. Change the hostname for your defined hostname and restart Icinga. Maybe you need to change the check_nrpe_1arg for check_nrpe, depending on your Nagios/Icinga version.

Now, looking in your Nagios/Icinga frontend, you should see the service running without issues. To troubleshoot, you can execute the script on the remote server manually and see if any errors are thrown. Doublecheck the command in your nrpe.cfg if parameters are correct. If NRPE is working, this command should be no exception.

Happy monitoring!

Donnerstag, 6. Dezember 2012

Advanced git: Different ways to exclude files

When I started using git, I very fast learned about the local .gitignore file. It's one of those handy features that everybody knows about and which is used in almost every project. In there you find excludes for build files, temporary files, caching files and so on.

Working with the local .gitignore can lead to a few problems though:
  • If you want to add specific files for each commiter (different IDEs or so) or OS (like the windows thumbs.db or Unix ~ backup files), your gitignore gets really messy 
  • If you add your IDE and then use another one later, you have to change gitignore files in all your projects
  • If you want to contribute to an OOS project, you are not supposed to change the gitignore, so you either not add those files to git and have clutter around or find another way.
And that's why there are different files which all can be used to ignore files within your git repository.