Having recently added some mysql replication slaves I wanted to be sure that the slaves are always running. In order to do this I’ve selected Monit though you could do this several different ways.
What I’ve done is put a quick little bash script together that runs every minute via cron.
What this does is grabs the Slave_IQ_Running and Slave_SQL_Running from a SHOW SLAVE STATUS and if they are both Yes indicating the replication is running smoothly then it touches the /opt/slave_running file.
This is my simple monit script, I drop this into /etc/monit/conf.d on an ubuntu system and it gets included by default. Just restart monit. Monit runs every 2min and if the /opt/slave_running is a couple minutes out of date I’m alerted to take a look.
I’ve seen this idea around on other blogs using python or ruby so I can’t take credit for the idea, just dropping in my notes for how I did it.
I recently wrote a post about setting up a new wordpress site using svn externals to include the wordpress core and optionally themes/plugins with a fresh svn repository. I’m now going through previously setup sites and changing them over to this new structure and thought it would be worth a quick post to take note of the steps I took to complete that.
a svn repo with wordpress installed in the trunk
a checked out working copy and you are currently inside this dir
Let’s start by adding the wordpress core as an external to the root of our current working copy
You’ll now have a wordpress dir with the core of wordpress.
With a new wordpress core we don’t need the original base of wordpress that we had so let’s remove the php files in root as well as the includes and admin folders. You need to keep your wp-content folder as that’s where all the custom wordpress stuff goes. You also need to keep your wp-config.php and the .htaccess (as well as any other non-wordpress files that you may have stored here).
svn commit -m 'replace wptouch plugin with a svn external copy tagged 1.9.29
This will only work with plugins that have svn repositories, such as ones available in the wordpress plugins repo or a third party provided repo. I’d recommend sticking with a tagged version and just changing the tag to the newest version as you see fit. If you prefer to stay on the bleeding edge you can easily use the trunk. The one thing to note about using the trunk is that you do need to run a ‘svn update’ in order to get the latest version from the trunk, it’s not pushed to you, so you are still in control.
I’ve read through a number of articles about using svn externals to setup a wordpress install and none of them were quite accurate or worked as written for myself (probably due to most being written previous to wordpress 3.0 but I haven’t verified and don’t wish to do so). I thought it was a good idea to log my instructions so that I could easily replicate it and if anyone else has troubles perhaps this will help you out.
you have a clean svn repository to start with
you are working from the root of your websites docroot
you are comfortable with wordpress and svn already
wordpress 3.1.3 is the latest release, we’ll initially start working with 3.1.2 to show the ease of upgrade to 3.1.3
Checkout your repository into a working copy:
svn co https://svn.example.com/example/trunk example
Enter your working copy and setup the wordpress core via externals
You will now see you have your wordpress core and a theme checked out from wordpress 3.1.2, next step is to setup the wordpress config. Copy the base wordpress config file, config the database connections and add additional content to setup for the new directory structure.
cp wordpress/wp-config-sample.php wp-config.php
Enter the following anywhere before the “/* That’s all, stop editing! Happy blogging. */” line and be sure to set all the other db settings etc as necessary:
You can now visit your site, fill in the details and complete the online install as normal. You will have to re-activate (or choose another) theme as the path to the default theme isn’t accurate because of the base install, so choose the delicate theme or any other theme of your choice in order to see the homepage after install.
Now the magic of running this through svn externals is that you can update the core or any themes plugins with a couple quick commands. For example to update the wordpress core to 3.1.3 you just have to change the externals value and do a svn up and you’re done like below:
All of this can be applied to the plugins/themes at anytime for adding and updating which makes things really fast and easy. It’s great in an environment where you work with a team and have developed some internal plugins or themes that you like to reuse you can link in any common required plugins and all your sites receive the updates together, no more merging in changes to separate projects.