Just a quick not to mention that I’ve restarted work on jNag.  First order of business is to rewrite the server side code which, to be frank, is a quick and dirty job I hacked together just to get soemthing working at the time.  The rewrite will incorporate everything I’ve learned about development in the last couple of years and should be much easier to maintain and offer something that’s caused a few people grief with jNag in the past: version support.  On a basic level this means that jNag will be able to support all the different flavours of nagios that are out there by changing a configuration variable (there’s some detail about how this is done below, in case anyone’s interested)

This new version of the server will be backwards compatible with the current versions of the app, but once I’ve rewritten the server I’ll be moving onto the app.  First I’ll be updating the libraries that jNag uses (especially jQuery mobile, which has had a full production release and a point release since the version that shipped with current versions of jNag) and then hopefully adding features.

As a special bonus, here’s some bits of code that deal with loading in different vetrsions of Nagios.

First up, in the core framework class I have this bit of code:

include("includes/main/main_".$this->config->server_type.".php");    
$this->main = new main();

This ‘includes’ a file based on what’s set in the ‘server_type’ config key, and then instantiates the ‘main’ class from that file.

Our main class looks like this:

include("main.php");

/*
 * main class for the 'classic' server type

 */
class main extends main_base{
    function __construct(){
        
    }
    
    public function status(){
        $hosts = json_decode($this->run_query("GET columns\nOutputFormat: json\n\n"));
        echo "<table>";
        $last_table = "table";
        foreach($hosts as $host){
            if ($host[2] != $last_table)
            echo "<tr><td COLSPAN='4' ALIGN='middle' style='background-color:red;'>".$host[2]."</td></tr>";
            $last_table = $host[2];
            echo "<tr><td>".$host[0]."</td><td>".$host[1]."</td><td>".$host[2]."</td><td>".$host[3]."</td></tr>";
        }
        echo "</table>";        
    }

Obviously that’s just the first bit of it, the full class is a bit bigger… buut you can see how it implements the ‘Status’ method.  The full class implements all the methods that our old ‘returndata.php’ file in previous versions of jNag provided and, because the framework can be accessed from any index file we can access it through ‘returndata’ and maintain compatibility.

You’ll notice our ‘main’ class extends a ‘main_base’ class.  That looks something like this:

abstract class main_base{
    
    //show current system status
    abstract protected function status();
    
    //get items that are 'pinned' to the homescreen
    abstract protected function get_pinned();
    
    private function format_time($timestamp){
        if ($timestamp > 0){
            return date("d/m/Y-H:i",$timestamp);
        } else {
            return "Never";
        }
    }

And contains abstract functions for all the methods that our real main class has to implement.  So, once all this is in place all you have to do is create a ‘main’ class for your specific flavour of nagios, set the server_type correctly and jNag will work.

Refactoring this code has really shown how much I’ve learned since I wrote the original.  I’m particularly pleased with how the config class turned out.  It looks like this:

class config {
    
    /*
     * load all config information from $filename.
     * for each key = value in the file you end up with config->key = value;
     */
    public function __construct($filename){        
        $settings = file($filename,FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
        foreach($settings as $setting){
            $var_array = split("=",$setting);
            if (substr($var_array[0],0,2) != "//"){
                $var_array[0] = trim($var_array[0]);
                $var_array[1] = trim($var_array[1]);
                if (strtolower($var_array[1]) == "true")
                $var_array[1] = true;
                if (strtolower($var_array[1]) == "false")
                $var_array[1] = false;
                $variable = $var_array[0];                
                $this->$variable = $var_array[1];
            }
        }
         public function getValue($key){
            return $this->$key;
        }
}

 

And, as the comments say, you pass it a file with key / value pairs in the constructor like this:

$config = new config($myfile);

and then you can do something like this:

$foo = $config->getValue("foo");

Anyway, that’s it really… stay tuned for more news as the rewrite progresses.

 

So, jNag was recently listed by ‘Computerworlduk’ as one of the top 16 mobile applications for IT professionals:

http://mobile.computerworlduk.com/slideshow/applications/3352077/best-mobile-apps-for-it-pros/6/

And this has given me some motivation to restart development…. I need some sort of project to work on since giving up facebook (I deactivated my account last week in the hope of spurring some productivity) and revisiting jNag might be just what I’m looking for.

 

Feel free to comment if you’d like to see development restarted, and even shout out some features you’d like to see added if you like.

Note: I doubt I’ll be doing any work on the IOS version of jNag.  I don’t have an apple development platform at the moment, and don’t see me getting one for the foreseeable future (unless I switch jobs and get a new Air as part of my package.  Well, I can dream!) so any future development work will more than likely be android only.

As promised last week I’ve uploaded the IOS binary for jNag, so you can deploy it to a local device.  I’ve no idea how you go about doing this, and no-one’s gifted me a free Macbook yet so I can’t test this in any way.  Hopefully this helps out if you want to get jNag on your iDevice now it’s been removed from the App store.

enjoy

I’ve had a request that I make the IOS version of jNag available so that people can deploy it using a local provisioning server. I’m still trying to find the last build I did before losing access to my Mac platform, but once I dig it out of my backups I’ll upload it here. You can then do what you will with it. I’ve not looked into local deployment of IOS apps myself, but apparently you can do it…

I’ve just been notified that jNag for iPhone / iPad has been removed from the App store due to my apple developer subscription expiring. Since I no longer have access to a Mac development environment, I didn’t see the point of paying to renew my subscription. Since there’s no fees to pay to keep apps in the Android market, jNag for android will continue to be available.

If anyone wants to donate a Macbook pro / air for me to restart development on I’d be more than happy to oblige. Hell, I’ll even cover the apple developer subscription myself 😀

So, yeah I’ve sort of lost interest in jNag unfortunately.  It was a fun little project while it lasted but I’ve not updated it for a couple of months and to be honest I have no real interest in updating it any more.

Mostly this is down to a complete lack of time on my part, I recently accepted a promotion at work so I’m horrendously busy now.  Also, I’ve run out of fun things to do with it…the features that need adding aren’t particularly interesting and I don’t really fancy plugging away at boring stuff in my spare time.

I’ll be removing the paid android app from the appstore ASAP and moving the iPhone app to a free version sometime this week.  After that I probably won’t be making any more updates unless a) I get bored or b) someone offers me bucket loads of cash to update the code.

Just to clarify: the free versions of the app will continue to be available.

Sorry for any inconvenience, hope you got / continue to get some use from the released code.

Thought I might as well post something here, you never know who reads these things…

I am currently on the hunt for a job.  Ideally something in PHP / Web development that pays around £30k (or slightly less for the right role) and is based somewhere near Manchester (UK).  Working from home would be nice though if you’re based on the other side of the world.

email me for a CV if you have any opportunities that might fit the bill.

Just finished uploading the latest versions of the client, server and android apps.  The biggest change comes for the paid android app, which now supports (working) SSL connections.  The free app will have to wait a bit longer for that I’m afraid.  jQuery mobile has also been updated to Alpha 4 in this release. I’ll post a proper change log in the morning (tired now), just wanted to get them updated today. Enjoy…