public final ReturnValue execute ( final ICommandLine cl ) { if ( cl . hasOption ( ' ' ) ) { setUrl ( cl . getOptionValue ( ' ' ) ) ; } if ( cl . hasOption ( ' ' ) ) { setObject ( cl . getOptionValue ( ' ' ) ) ; } if ( cl . hasOption ( ' ' ) ) { setAttribute ( cl . getOptionValue ( ' ' ) ) ; } if ( cl . hasOption ( ' ' ) ) { setInfo_attribute ( cl . getOptionValue ( ' ' ) ) ; } if ( cl . hasOption ( ' ' ) ) { setInfo_key ( cl . getOptionValue ( ' ' ) ) ; } if ( cl . hasOption ( ' ' ) ) { setAttribute_key ( cl . getOptionValue ( ' ' ) ) ; } if ( cl . hasOption ( ' ' ) ) { setWarning ( cl . getOptionValue ( ' ' ) ) ; } if ( cl . hasOption ( ' ' ) ) { setCritical ( cl . getOptionValue ( ' ' ) ) ; } if ( cl . hasOption ( "username" ) ) { setUsername ( cl . getOptionValue ( "username" ) ) ; } if ( cl . hasOption ( "password" ) ) { setPassword ( cl . getOptionValue ( "password" ) ) ; } setVerbatim ( 2 ) ; // setVerbatim(4); try { connect ( ) ; execute ( ) ; ByteArrayOutputStream bout = new ByteArrayOutputStream ( ) ; PrintStream ps = new PrintStream ( bout ) ; Status status = report ( ps ) ; ps . flush ( ) ; ps . close ( ) ; return new ReturnValue ( status , new String ( bout . toByteArray ( ) ) ) ; } catch ( Exception ex ) { LOG . warn ( getContext ( ) , "An error has occurred during execution " + "of the CHECK_JMX plugin : " + ex . getMessage ( ) , ex ) ; ByteArrayOutputStream bout = new ByteArrayOutputStream ( ) ; PrintStream ps = new PrintStream ( bout ) ; Status status = report ( ex , ps ) ; ps . flush ( ) ; ps . close ( ) ; return new ReturnValue ( status , new String ( bout . toByteArray ( ) ) ) ; } finally { try { disconnect ( ) ; } catch ( IOException e ) { LOG . warn ( getContext ( ) , "An error has occurred during execution (disconnect) of the CHECK_JMX plugin : " + e . getMessage ( ) , e ) ; // ByteArrayOutputStream bout = new ByteArrayOutputStream(); // PrintStream ps = new PrintStream(bout); // // Status status = report(e, ps); // ps.flush(); // ps.close(); // return new ReturnValue(status, new String(bout.toByteArray())); } } }
Executes the plugin .