03 Nov

Monitoring WordPress with Nagios/Icinga

I have many WordPress installs on servers I maintain and the hardest part is making sure all the plugins, themes, and WordPress itself remain up to date.

I monitor my infrastructure with Icinga2 so I thought I’d try creating a plugin that can let me know when there are updates for WordPress core, themes, or plugins. It is written in Ruby and requires optparse, json, and active_support. The check uses WP CLI to query your WordPress install so that is required as well.

The check itself is pretty simple, though for my environment I have my different sites running as different users (instead of just the web server user) to sandbox them a bit. WP CLI will want the check run as the web server user so you need to pass in that user with the –wwwuser option. You also need to supply the document root, –docroot. Finally, in order to run the check as different users the script needs to run with sudo. You can do that by adding something like this to your sudoers file:

nagios ALL=(ALL) NOPASSWD: /usr/local/bin/check_wp.rb

This gives the nagios user permission to run get plugin without requiring a password.

An example of running the check from the command line would be:

sudo /usr/local/bin/check_wp.rb -u wpuser -d /var/www

Add –plugins or –themes to check for updates to them.

The code for the plugin is below, but it is part of the repository here: icinga_plugins

08 Feb

Young Women vs Hillary Clinton

From the New York Times:

Gloria Steinem and Madeleine Albright Rebuke Young Women Backing Bernie Sanders

I think this is one of the biggest problems I have with Clinton. Not that she is a woman, as an undecided progressive that is something that I count in her favor. The argument that because she is a woman, other women supporting the male candidate somehow are bad people. Madeleine Albright stating there is a special place in hell for women who do not support Clinton is pretty ridiculous. Does that mean her second choice candidate is Carly Fiorina? Clinton may have a record of supporting women, but she certainly wasn’t in the corner of Monica Lewinski, or any of the other women her husband harassed. I feel this charge to support women comes with some caveats, like by support women they mean support this specific woman.

Worse though is Gloria Steinem, stating “When you’re young, you’re thinking: ‘Where are the boys? The boys are with Bernie,’” referring to the majority of young women supporters Sanders has. What the hell is that? She’s a feminist pioneer and basically saying these women are boy crazy? She retracted the statement the next day, opologizing if the comments were misinterpreted. Seems like a non-apology though.

The possibility of a female president is a very big deal. Especially one calling for pay equality, paid family leave, and reproductve rights. Shaming women who choose not to support that candidate does seem like a winning move.

All that being said, women absolutely have to deal with a different set of standards, and Clinton has been a pro at navigating this. Clinton’s frustration at not having as much support with younger women is understandable. The optimism that draws young people to the big ideas of Sanders also likely leads them to believe sexism is something that they can end more easily. They haven’t had the experience dealing with institutionalized sexism for decades like the older supporters of Clinton.

31 Oct

Creating DHCP Static Maps for OS X Server in the Terminal

I was in the process of moving DNS and DHCP on my network at work to new Mac Mini servers. This is all much easier using a Linux server, but I had several Mac only applications I was planning on running on the servers as well, so I stuck with Macs. Apple has made working with DNS easy enough in 10.11 Server by allowing one to edit the host files for domains directly, and have everything still work if one wants to go through the Server app. DHCP isn’t so easy. I haven’t found a way to create static maps for DHCP clients by just editing a reservation file. It is possible to use the serveradmin command line utility however.

To create a DHCP static map a series of commands need to be entered through serveradmin. I could have made this even easier, but I’ve only got about 120 clients so I didn’t want to spend a ton of time getting something working. I keep all my client information in a spreadsheet so it was easy to pull a list of MAC addresses, IP addresses, and computer names. These three items need to be placed in to the script below. You can seen how they need to be formatted as a multidimensional array in the Python script on line 6.

After copying in the information, and running the script you are left with output like this:

dhcp:static_maps:_array_id:2d752303-4e67-438c-87c9-6594658bb761 = create
dhcp:static_maps:_array_id:2d752303-4e67-438c-87c9-6594658bb761:en_address:_array_index:0 = "xx:xx:xx:xx:xx:xx"
dhcp:static_maps:_array_id:2d752303-4e67-438c-87c9-6594658bb761:ip_address:_array_index:0 = "xxx.xxx.xxx.xxx"
dhcp:static_maps:_array_id:2d752303-4e67-438c-87c9-6594658bb761:name = "hostname"

There are four lines for each entry. To actually create the static maps run type the following in a terminal on your server:

$ sudo serveradmin settings

Paste your script output in to the terminal window then, and to leave the command block type control+D. If you are creating a large number of static maps the terminal may seem to pause for a moment. To check if your additions saved properly type:

$ sudo serveradmin settings dhcp:static_maps

Your new maps should also show up in the Server GUI application.