ch.syabru.nagios
Class NagiosJmxPlugin

java.lang.Object
  extended by ch.syabru.nagios.NagiosJmxPlugin

public class NagiosJmxPlugin
extends Object

Nagios JMX plugin.

Author:
Felix Roethenbacher

Field Summary
static String PROP_ATTRIBUTE_KEY
          Attribute key system property.
static String PROP_ATTRIBUTE_NAME
          Attribute name system property.
static String PROP_HELP
          Help output.
static String PROP_OBJECT_NAME
          Object name system property.
static String PROP_OPERATION
          Operation to invoke on MBean.
static String PROP_PASSWORD
          Password system property.
static String PROP_SERVICE_URL
          Service URL system property.
static String PROP_THRESHOLD_CRITICAL
          Threshold critical level system property.
static String PROP_THRESHOLD_WARNING
          Threshold warning level system property.
static String PROP_UNITS
          Units system property.
static String PROP_USERNAME
          Username system property.
static String PROP_VERBOSE
          Verbose output.
 
Constructor Summary
NagiosJmxPlugin()
           
 
Method Summary
 void closeConnection(MBeanServerConnection connection)
          Close JMX connection.
 int execute(Properties args)
          Get system properties and execute query.
 ObjectName getObjectName(MBeanServerConnection connection, String objectName)
          Get object name object.
 void invoke(MBeanServerConnection connection, String objectName, String operationName)
          Invoke an operation on MBean.
static void main(String[] args)
          Main method.
 MBeanServerConnection openConnection(JMXServiceURL serviceUrl, String username, String password)
          Open a connection to a MBean server.
 Object query(MBeanServerConnection connection, String objectName, String attributeName, String attributeKey)
          Query MBean object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_USERNAME

public static final String PROP_USERNAME
Username system property.

See Also:
Constant Field Values

PROP_PASSWORD

public static final String PROP_PASSWORD
Password system property.

See Also:
Constant Field Values

PROP_OBJECT_NAME

public static final String PROP_OBJECT_NAME
Object name system property.

See Also:
Constant Field Values

PROP_ATTRIBUTE_NAME

public static final String PROP_ATTRIBUTE_NAME
Attribute name system property.

See Also:
Constant Field Values

PROP_ATTRIBUTE_KEY

public static final String PROP_ATTRIBUTE_KEY
Attribute key system property.

See Also:
Constant Field Values

PROP_SERVICE_URL

public static final String PROP_SERVICE_URL
Service URL system property.

See Also:
Constant Field Values

PROP_THRESHOLD_WARNING

public static final String PROP_THRESHOLD_WARNING
Threshold warning level system property. The number format of this property has to correspond to the type of the attribute object.

See Also:
Constant Field Values

PROP_THRESHOLD_CRITICAL

public static final String PROP_THRESHOLD_CRITICAL
Threshold critical level system property. The number format of this property has to correspond the type of the attribute object.

See Also:
Constant Field Values

PROP_UNITS

public static final String PROP_UNITS
Units system property.

See Also:
Constant Field Values

PROP_OPERATION

public static final String PROP_OPERATION
Operation to invoke on MBean.

See Also:
Constant Field Values

PROP_VERBOSE

public static final String PROP_VERBOSE
Verbose output.

See Also:
Constant Field Values

PROP_HELP

public static final String PROP_HELP
Help output.

See Also:
Constant Field Values
Constructor Detail

NagiosJmxPlugin

public NagiosJmxPlugin()
Method Detail

openConnection

public MBeanServerConnection openConnection(JMXServiceURL serviceUrl,
                                            String username,
                                            String password)
                                     throws IOException
Open a connection to a MBean server.

Parameters:
serviceUrl - Service URL, e.g. service:jmx:rmi://HOST:PORT/jndi/rmi://HOST:PORT/jmxrmi
username - Username
password - Password
Returns:
MBeanServerConnection if succesfull.
Throws:
IOException - XX

closeConnection

public void closeConnection(MBeanServerConnection connection)
                     throws IOException
Close JMX connection.

Parameters:
connection - Connection.
Throws:
IOException - XX.

getObjectName

public ObjectName getObjectName(MBeanServerConnection connection,
                                String objectName)
                         throws InstanceNotFoundException,
                                MalformedObjectNameException,
                                NagiosJmxPluginException,
                                IOException
Get object name object.

Parameters:
connection - MBean server connection.
objectName - Object name string.
Returns:
Object name object.
Throws:
InstanceNotFoundException - If object not found.
MalformedObjectNameException - If object name is malformed.
NagiosJmxPluginException - If object name is not unqiue.
IOException - In case of a communication error.

query

public Object query(MBeanServerConnection connection,
                    String objectName,
                    String attributeName,
                    String attributeKey)
             throws InstanceNotFoundException,
                    IntrospectionException,
                    ReflectionException,
                    IOException,
                    AttributeNotFoundException,
                    MBeanException,
                    MalformedObjectNameException,
                    NagiosJmxPluginException
Query MBean object.

Parameters:
connection - MBean server connection.
objectName - Object name.
attributeName - Attribute name.
attributeKey - Attribute key.
Returns:
Value.
Throws:
InstanceNotFoundException - XX
IntrospectionException - XX
ReflectionException - XX
IOException - XX
AttributeNotFoundException - XX
MBeanException - XX
MalformedObjectNameException - XX
NagiosJmxPluginException - XX

invoke

public void invoke(MBeanServerConnection connection,
                   String objectName,
                   String operationName)
            throws InstanceNotFoundException,
                   IOException,
                   MalformedObjectNameException,
                   MBeanException,
                   ReflectionException,
                   NagiosJmxPluginException
Invoke an operation on MBean.

Parameters:
connection - MBean server connection.
objectName - Object name.
operationName - Operation name.
Throws:
InstanceNotFoundException - XX
IOException - XX
MalformedObjectNameException - XX
MBeanException - XX
ReflectionException - XX
NagiosJmxPluginException - XX

execute

public int execute(Properties args)
            throws NagiosJmxPluginException
Get system properties and execute query.

Parameters:
args - Arguments as properties.
Returns:
Nagios exit code.
Throws:
NagiosJmxPluginException - XX

main

public static void main(String[] args)
Main method.

Parameters:
args - Command line arguments.


Copyright © 2009-2011 Syabru. All Rights Reserved.