One of the many tasks I’m working on at the moment is taking some monitoring code from XRG and molding plugins out of each graph module. I want to make it easy for other developers to include monitors in their code, and I really believe that this is an evolutionary step in XRG’s development cycle. The resulting code is going to be called MTK, or the Monitoring Toolkit, and it will be the new foundation that XRG and Dash Monitors will be built on.

Just to give a little insight as to how MTK will work, each monitoring module will be a Cocoa plugin bundle. Right now I have completed plugins for CPU, Network, Disk, and Memory. The plugin is fairly simple, and at the moment must follow a simple protocol: the principal class must contain methods to return a plugin name, a plugin short name, and an NSDictionary of key-value data. The dictionary keys are the names of the data fields, and the values are, well, the values for those data fields. This gives developers a very generic interface to write their own MTK plugins to work with any application that uses the MTK protocol. Of course applications like XRG that do a lot of graphing or custom drawing can require plugins to implement other protocols to handle it’s view, preferences or other properties. I’m still working out the details of how to manage multiple protocols in a single plugin.

MTK plugins wouldn’t have any purpose if there wasn’t an application to use them, so when MTK is introduced there will be a command line application (mtk) that will make use of any MTK plugins. The app will simply take arguments to define the time interval between updates and a directory of MTK plugins, and will continually output data returned by the plugins in CSV format (the column names are just printed out once at the beginning of execution). Then, any app or script can parse this CSV output and do what they want with it. I’ve already opened some captured data in Excel and played around with it. Of course if you don’t want the overhead of running a separate executable to output CSV data, simply write some code to load MTK plugins in your own application. The mtk command line application will be open source, and it’s only a single class, so it should serve as a good example of how to use MTK in your own applications.

I’m pretty excited about the architecture, and I’m looking forward to having XRG completely migrated over to MTK. I would love to see other developers come up with their own modules and see where the project goes. I’m hoping to get the initial version out on the web sometime in the next week or two, but there are a lot of things going on right now so it might have to be put on hold for a bit.