iPhone Server Monitor

March 15th, 2008

I’ve built a couple of utilities to monitor my production web servers and a few select web applications. The server monitor polls the server on a 5 second 10 second interval and displays the goods. The web application monitor (not pictured) shows current work queue, number of users online, and other application-specific information both in textual data as well as graphical representation (3D pie, and histogram). Here is what the server monitor looks like:

Server Monitor

PHP Debugger/Profiler

March 5th, 2008

I’ve been using this debugger for 3 or 4 years now (and adding to it, making it better, etc., etc. for at least that long). I started working on it mostly because when I was doing some development work in Cold Fusion (blek!) I really liked the debugger, especially for looking at executed queries and profiling. So I took some of those ideas and built some plugins for ADODB, Memcache, an exception handler, and a profiler with multiple counter support. Here is what it looks like (image cropped, but the debugger is displayed inline after the footer of an HTML template):

PHP Debugger

eAccelerator for PHP

December 28th, 2007

I am a little surprised I had not heard of eAccelerator before. Turns out it is a fork of the older Turck MMCache (no longer under development). Anyhow I installed it on my development server and production server tonight - with very promising results.

PHP and the singleton

December 12th, 2007

Up until recently, most PHP webapps that I have developed have been designed for PHP4 and PHP5, mostly due to the fact that SO many hosting companies were so slow to adopt PHP5 (eh, what took so long?). But I have since started building only for PHP5, and now have started to re-tool some of my old code to use the more modern feature set and methodologies. One of those being singletons. LOVE IT. Using the singleton design pattern for a few choice things really cleans up the way thing work, especially for database connections and logging. Most classes I had used previously either subclassed a database provider or needed a db connection handle passed to them, and the same for logging. But now I don’t have to rely on that kludge, and have been able to simplify a lot of my PHP framework’s base level components.

PHP Framework

December 10th, 2007

I haven’t talked about my PHP framework in quite a while. One feature that I really like is the unit testing and functional testing components. Using the framework, you can easily write unit tests that automatically get run from the test harness, complete with output. The functional testing works using the Selenium web runner. If you aren’t familiar with Selenium, you should be! I use the Selenium IDE (FireFox extension) to record a given test and using the custom formatter it produces PHP code for use in the web runner. What you end up with in the framework is a complete automated testing facility.

I am also using the log4php logging mechanism in the framework. Anything Log4J can do, Log4PHP can do too. Even Chainsaw. I can fire up Chainsaw and get remote logging from my webapps, as well as remote logging/debugging within any JavaScript I am using. I wish I had the time to properly document, clean up, and package the framework for distribution. But then again, I guess it would be “Yet Another Framework”. Either way, it’s a better framework for me than any of the popular ones.

Cool Bug Reporting

November 29th, 2007

I cranked out a little library today for submitting bug reports in-line from a web app ajax style (probably am only going to use it for beta testing apps, but it could easily be left in for production use). Here’s the scoop: Trac has an XML-RPC plugin that enables some of it’s interfaces to an RPC server (which interfaces and permissions controlled by Trac WebAdmin of course). So I installed and configured that, and then added a hidden div to my UI template in a test project with a form for submitting a bug, which when POSTED, PHP shoots it directly into the Trac project with a description, the users $_SERVER array, and $_SESSION array. The bug reporting form is activated/made visible by pressing ctrl+alt+b from any page in the application (thanks MooTools!). Slick is all I’m going to say. Lot’s of possibilities for extending this. Maybe if I get some time I will package it up for use. If you are interested in it sooner, holla.

One of my new projects (mentioned here before) involves using Active Directory fairly extensively. One of the pitfalls of using AD, is that the data is hierarchical. This can (and will!) lead to an enormous number of queries against AD depending on what you are doing. In my application design, I decided to create a user table and store the attributes that I needed to use along with a few other bits and pieces specific to my application in order to lighten the load on the domain controller as well as the needless process of accessing data that changes infrequently. The problem then became keeping the data synchronized (which is why I am writing this post!). I built a synchronization utility that caches the AD queries on the application server for a specified time (3 hours in this case). When the cache expires, and the next time a page is hit that needs that data it kicks off the synch routine, updates everything, and then continues on it’s merry way (with a new cache valid for 3 more hours). All of my benchmarking and testing has been very successful. It is also nice to have the self-maintaining aspect of the utility function and not have to rely on a cron job or something similar.

It works something like this:


if($this->cacheAge() > CACHE_TIME) {

$this->synchronize();
return $this->record;

} else {

return $this->record;

}

Web Application Build Process

January 25th, 2007

Somebody asked me recently how I manage upgrades, etc. on web applications. Warning: this might seem like overkill to some people.

The short answer? ANT

That’s right I said it, ANT. I used to use ANT quite a bit when I was heavy into Java development and it quickly became my best friend. A couple of years have passed since I’ve used it, but once I set up my PHP build/deployment process I knew right where to go for some serious horsepower. So my system setup consists of:

  • ANT
  • ANT add-ons
  • JSPacker
  • Natural Docs

My build process differs from development to deployment (as it should). Things like optimization, etc. are left out of the development build. For deployment, I strip all comments out of the Javascript and CSS code, and run them through a compression utility to lighten the footprint up a bit. (BTW, I generally use gzip compression on the server to deliver those as well).

So my development involves editing files locally in either CVS or Subversion. When I’m ready to test, I fire up ANT and run a “dev” target which simply copies the files to the web server. When I’m ready to deploy, I use ANT to generate all of the documentation (Javascript and PHP), run the optimization targets (comment stripping and compression), build an archive (gzipped tar), do any necessary backups, run any necessary SQL update scripts, and deploy the new application or revision via FTP or SCP to the destination server. It’s all very automated and precise - a way of doing things that I geek out about and could not imagine doing any other way!

If you’re interested in more details or a sample build.xml file that I use, just ask.