Java – Monitoring C++ applications

cjava

We're implementing a new centralized monitoring solution (Zenoss). Incorporating servers, networking, and Java programs is straightforward with SNMP and JMX.

The question, however, is what are the best practices for monitoring and managing custom C++ applications in large, heterogenous (Solaris x86, RHEL Linux, Windows) environments?

Possibilities I see are:

  1. Net SNMP
    • Advantages
      1. single, central daemon on each server
      2. well-known standard
      3. easy integration into monitoring solutions
      4. we run Net SNMP daemons on our servers already
    • Disadvantages:
      1. complex implementation (MIBs, Net SNMP library)
      2. new technology to introduce for the C++ developers
  2. rsyslog
    • Advantages
      1. single, central daemon on each server
      2. well-known standard
      3. unknown integration into monitoring solutions (I know they can do alerts based on text, but how well would it work for sending telemetry like memory usage, queue depths, thread capacity, etc)
      4. simple implementation
    • Disadvantages:
      1. possible integration issues
      2. somewhat new technology for C++ developers
      3. possible porting issues if we switch monitoring vendors
      4. probably involves coming up with an ad-hoc communication protocol (or using RFC5424 structured data; I don't know if Zenoss supports that without custom Zenpack coding)
  3. Embedded JMX (embed a JVM and use JNI)
    • Advantages
      1. consistent management interface for both Java and C++
      2. well-known standard
      3. easy integration into monitoring solutions
      4. somewhat simple implementation (we already do this today for other purposes)
    • Disadvantages:
      1. complexity (JNI, thunking layer between native C++ and Java, basically writing the management code twice)
      2. possible stability problems
      3. requires a JVM in each process, using considerably more memory
      4. JMX is new technology for C++ developers
      5. each process has it's own JMX port (we run a lot of processes on each machine)
  4. Local JMX daemon, processes connect to it
    • Advantages
      1. single, central daemon on each server
      2. consistent management interface for both Java and C++
      3. well-known standard
      4. easy integration into monitoring solutions
    • Disadvantages:
      1. complexity (basically writing the management code twice)
      2. need to find or write such a daemon
      3. need a protocol between the JMX daemon and the C++ process
      4. JMX is new technology for C++ developers
  5. CodeMesh JunC++ion
    • Advantages
      1. consistent management interface for both Java and C++
      2. well-known standard
      3. easy integration into monitoring solutions
      4. single, central daemon on each server when run in shared JVM mode
      5. somewhat simple implementation (requires code generation)
    • Disadvantages:
      1. complexity (code generation, requires a GUI and several rounds of tweaking to produce the proxied code)
      2. possible JNI stability problems
      3. requires a JVM in each process, using considerably more memory (in embedded mode)
      4. Does not support Solaris x86 (deal breaker)
      5. Even if it did support Solaris x86, there are possible compiler compatibility issues (we use an odd combination of STLPort and Forte on Solaris
      6. each process has it's own JMX port when run in embedded mode (we run a lot of processes on each machine)
      7. possibly precludes a shared JMX server for non-C++ processes (?)

Is there some reasonably standardized, simple solution I'm missing?

Given no other reasonable solutions, which of these solutions is typically used for custom C++ programs?

My gut feel is that Net SNMP is how people do this, but I'd like other's input and experience before I make a decision.

Best Answer

I'm not super familiar with Zenoss but when I used to used nagios for this sort of thing we'd make the c/c++ process listen on a socket and write a custom nagios plugin which would hand over diagnostic and status information.

First step is to choose the lib you want to use to make your process listen.. Something like C++ Socket Library will do for that. Nothing complicated there.. just make the process listen.

Then you have to define the response your process will send given a particular stimulus. This really meant (at least with nagios) defining the 'service' and then sending the process the signal that corresponded to that service. The simplest thing you can do is create a 'process ping' just see if you can successfully connect to the running process. If you do than the custom nagios plugin knows at least the process is still alive.

There's much more sophisticated stuff you can do but the idea is simple enough. You can write your own little lib of process listening code encapsulated within objects and pull it into your custom c++ stuff in a standardized manner whenever you build one (or all) your executables

My understanding is Zenoss can do this too.

Probably since Zenoss is python then you'll write your custom plugin for it using something like Twisted for connecting to your listening c++ executable.

Related Topic