Osgish

Posted on March 2nd, 2010 by roland

osgish [os-gish] is based on a Perl shell on the client side which communicates via HTTP/JSON to a special agent bundled deployed on the target platform. Beside standard features provided by the various existing OSGi shells outside it provides some unique features to make life easiers when dealing with a lot of OSGi bundles:

  • GNU Readline support with

    • History saved accross sessions
    • context sensitive command line completion
    • Emacs key bindings ;-)
  • Consistent syntax highlighting (switchable) with color theme support

  • Remote operation via HTTP(S) including a upload facility for bundles to install/update

  • Configurable via a configuration file like shortcuts for known server URLs.

  • Wildcard support for query and lifecycle operations

  • Support for bulk operations (e.g. starting multiple bundles at once)

  • Command groups which can be traversed like directories

  • Extensible by command plugins

But have a look on your own in this 4:30 minutes walkthrough:

(The fine remix “Revolve” by hisboyelroy released under the Creative Commons NonCommercial Sampling Plus 1.0 License is used for the background music)

How does it work

Osgish's architecture

An agent bundle exporting an administrative HTTP Rest interface via Jmx4Perl and Aries JMX. The only dependency for now is on an OSGi HttpService implementation as specified in the OSGi Compendium Specification 4.2 (e.g. Pax Web)

A local Perl based shell using several external Perl modules, all available on CPAN. Readline support will use Term::ReadLine::Gnu if available and falls back to the pure Perl version Term::ReadLine::Perl if not.

“Why on earth are you using Perl for bridging to a pure Java based technology like OSGi ?”

Well, as the setup might seem quite complex (an in fact, it is confessly more work than installing a bunch of OSGi bundles) it has some unique advantages. Perl is known for its premium level text manipulation capabilities and its tight system integration. The richness of CPAN modules is still unmatched in the Java world so far. Goodies like Term::ProgressBar or Term::ShellUI are probably missing on the Java side for quite some time to come. Thanks to its pure HTTP communication it works nicely across firewall boundaries. And don’t forget Perl’s excellent performance characterisics for this sort of applications. Last but not least, it is a perfect use case for jmx4perl, which has a story on its own ;-). IMO it is the perfect mix, where each language plays out its strength.

Ok, enough praise, there are of course some drawbacks, too: Installing Perl modules can be a pain especially if one is uncomfortable with cpan or Perl at a whole. Especially installing Term::ReadLine::Gnu on Windows or OS X can give major headaches (although is possible, and there is a fallback, too). It is easy to shoot oneself in the foot when manipulating the lifecycle of the agent bundle or it’s dependencies with osgish. Network latency and traffic can become an issue since all communication is remotely per se.

At the end it is up to you to judge wheter osgish fits for you. I would be more than happy if you would give it a try. For me it helps me at my OSGi development and administration tasks every day.

Even if you are not planning to use osgish, I’m curious about your opinion on this setup. Comments are highly appreciated ;-)

Although this is the initial release and there are in fact some rough edges it is already very useful and I use it on a daily basis. You can download osgish from CPAN, installation instructions included. The source is also available from GitHub.

4 Responses to “Osgish”

  1. ConSol* Labs » Blog Archive » Jmx4Perl 0.65 Says:
    March 30th, 2010 at 20:12

    […] for interactive access to remote JMX MBeans. It will reuse the experience gained while developing osgish, my little OSGi remote […]

  2. Jmx4Perl 0.70 – ConSol* Labs Says:
    July 10th, 2010 at 12:21

    […] the same spirit as osgish (my litte OSGi shell) j4psh provides interactive access to remote MBeans which are exposed with via […]

  3. Janu Says:
    December 14th, 2011 at 12:24

    Hi,

    firstly, thanks for all the hard work You put in this project. It seems really powerful and of course useful :) Unfortunately I’m having some problems getting it all working, I managed to build and install osgish according to instructions in README file and install agent bundle in my local glassfish 3.1.1 server thru remote osgi shell (the agent is installed and started). Now when I try to connect to glassfish osgi using osgish I get:

    osgish –server http://localhost:8080/osgi/j4p Use of qw(…) as parentheses is deprecated at /root/perl5/lib/perl5/OSGi/Osgish/ServerHandler.pm line 150. Server Error: javax.management.RuntimeMBeanException: java.lang.IllegalArgumentException: Illegal value: 4)”.

    Trying to connect to different address gives another error:

    osgish –server http://localhost:8080/j4p Use of qw(…) as parentheses is deprecated at /root/perl5/lib/perl5/OSGi/Osgish/ServerHandler.pm line 150. No agent running [Not found: osgi.core:type=bundleState,version=1.5,listBundles].

    This would suggest that the agent is up and running (at /osgi/j4p) and the problem is somewhere in MBeans configuration. I’ll try to debug this on my own, but I’d greatly appreciate if You could point me in the right direction. As I had no experience with Perl, something might be wrong with my local perl installation.

    Regards, Janu

    [Reply]

    roland Reply:

    @Janu, osgish hasn’t been updated for a while, so chances are high that something broke with the newest Jolokia releases. I will look at it ASAP and release a new version of osgish working with the latest Jolokia releases.

    [Reply]

Leave a Reply