com.sun.jmx.snmp.SnmpValue Java Examples

The following examples show how to use com.sun.jmx.snmp.SnmpValue. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JvmCompilationMeta.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the value of a scalar variable
 */
public SnmpValue get(long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 3:
            return new SnmpInt(node.getJvmJITCompilerTimeMonitoring());

        case 2:
            return new SnmpCounter64(node.getJvmJITCompilerTimeMs());

        case 1:
            return new SnmpString(node.getJvmJITCompilerName());

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.noSuchObject);
}
 
Example #2
Source File: JvmMemManagerEntryMeta.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Set the value of a scalar variable
 */
public SnmpValue set(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
}
 
Example #3
Source File: JvmMemManagerEntryMeta.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check the value of a scalar variable
 */
public void check(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int) var) {
        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
    }
}
 
Example #4
Source File: JvmCompilationMeta.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Set the value of a scalar variable
 */
public SnmpValue set(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
}
 
Example #5
Source File: JvmCompilationMeta.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check the value of a scalar variable
 */
public void check(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int) var) {
        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
    }
}
 
Example #6
Source File: JvmOSMeta.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check the value of a scalar variable
 */
public void check(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int) var) {
        case 4:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
    }
}
 
Example #7
Source File: JvmOSMeta.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Set the value of a scalar variable
 */
public SnmpValue set(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 4:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
}
 
Example #8
Source File: JvmClassLoadingMeta.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the value of a scalar variable
 */
public SnmpValue get(long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 4:
            return new SnmpInt(node.getJvmClassesVerboseLevel());

        case 3:
            return new SnmpCounter64(node.getJvmClassesUnloadedCount());

        case 2:
            return new SnmpCounter64(node.getJvmClassesTotalLoadedCount());

        case 1:
            return new SnmpGauge(node.getJvmClassesLoadedCount());

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.noSuchObject);
}
 
Example #9
Source File: JvmOSMeta.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Set the value of a scalar variable
 */
public SnmpValue set(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 4:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
}
 
Example #10
Source File: JvmOSMeta.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check the value of a scalar variable
 */
public void check(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int) var) {
        case 4:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
    }
}
 
Example #11
Source File: JvmOSMeta.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the value of a scalar variable
 */
public SnmpValue get(long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 4:
            return new SnmpInt(node.getJvmOSProcessorCount());

        case 3:
            return new SnmpString(node.getJvmOSVersion());

        case 2:
            return new SnmpString(node.getJvmOSArch());

        case 1:
            return new SnmpString(node.getJvmOSName());

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.noSuchObject);
}
 
Example #12
Source File: JvmMemGCEntryMeta.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the value of a scalar variable
 */
public SnmpValue get(long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 3:
            return new SnmpCounter64(node.getJvmMemGCTimeMs());

        case 2:
            return new SnmpCounter64(node.getJvmMemGCCount());

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.noSuchObject);
}
 
Example #13
Source File: JvmRTInputArgsEntryMeta.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the value of a scalar variable
 */
public SnmpValue get(long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 2:
            return new SnmpString(node.getJvmRTInputArgsItem());

        case 1:
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.noSuchObject);
}
 
Example #14
Source File: JvmRTLibraryPathEntryMeta.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the value of a scalar variable
 */
public SnmpValue set(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
}
 
Example #15
Source File: JvmMemMgrPoolRelEntryMeta.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the value of a scalar variable
 */
public SnmpValue set(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
}
 
Example #16
Source File: JvmMemMgrPoolRelEntryMeta.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the value of a scalar variable
 */
public SnmpValue get(long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 3:
            return new SnmpString(node.getJvmMemMgrRelPoolName());

        case 2:
            return new SnmpString(node.getJvmMemMgrRelManagerName());

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.noSuchObject);
}
 
Example #17
Source File: JvmRTBootClassPathEntryMeta.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check the value of a scalar variable
 */
public void check(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int) var) {
        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
    }
}
 
Example #18
Source File: JvmRTBootClassPathEntryMeta.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the value of a scalar variable
 */
public SnmpValue set(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
}
 
Example #19
Source File: JvmRTLibraryPathEntryMeta.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the value of a scalar variable
 */
public SnmpValue get(long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 2:
            return new SnmpString(node.getJvmRTLibraryPathItem());

        case 1:
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.noSuchObject);
}
 
Example #20
Source File: JvmClassLoadingMeta.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the value of a scalar variable
 */
public SnmpValue set(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 4:
            if (x instanceof SnmpInt) {
                try  {
                    node.setJvmClassesVerboseLevel( new EnumJvmClassesVerboseLevel (((SnmpInt)x).toInteger()));
                } catch(IllegalArgumentException e)  {
                    throw new SnmpStatusException(SnmpStatusException.snmpRspWrongValue);
                }
                return new SnmpInt(node.getJvmClassesVerboseLevel());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }

        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
}
 
Example #21
Source File: SnmpGenericObjectServer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the value of an SNMP variable.
 *
 * <p><b><i>
 * You should never need to use this method directly.
 * </i></b></p>
 *
 * @param meta  The impacted metadata object
 * @param name  The ObjectName of the impacted MBean
 * @param x     The new requested SnmpValue
 * @param id    The OID arc identifying the variable we're trying to set.
 * @param data  User contextual data allocated through the
 *        {@link com.sun.jmx.snmp.agent.SnmpUserDataFactory}
 *
 * @return The new value of the variable after the operation.
 *
 * @exception SnmpStatusException whenever an SNMP exception must be
 *      raised. Raising an exception will abort the request. <br>
 *      Exceptions should never be raised directly, but only by means of
 * <code>
 * req.registerSetException(<i>VariableId</i>,<i>SnmpStatusException</i>)
 * </code>
 **/
public SnmpValue set(SnmpGenericMetaServer meta, ObjectName name,
                     SnmpValue x, long id, Object data)
    throws SnmpStatusException {
    final String attname = meta.getAttributeName(id);
    final Object attvalue=
        meta.buildAttributeValue(id,x);
    final Attribute att = new Attribute(attname,attvalue);

    Object result = null;

    try {
        server.setAttribute(name,att);
        result = server.getAttribute(name,attname);
    } catch(InvalidAttributeValueException iv) {
        throw new
            SnmpStatusException(SnmpStatusException.snmpRspWrongValue);
    } catch (InstanceNotFoundException f) {
        throw new
            SnmpStatusException(SnmpStatusException.snmpRspInconsistentName);
    } catch (ReflectionException r) {
        throw new
            SnmpStatusException(SnmpStatusException.snmpRspInconsistentName);
    } catch (MBeanException m) {
        Exception t = m.getTargetException();
        if (t instanceof SnmpStatusException)
            throw (SnmpStatusException) t;
        throw new
            SnmpStatusException(SnmpStatusException.noAccess);
    } catch (Exception e) {
        throw new
            SnmpStatusException(SnmpStatusException.noAccess);
    }

    return meta.buildSnmpValue(id,result);
}
 
Example #22
Source File: JvmRTBootClassPathEntryMeta.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the value of a scalar variable
 */
public SnmpValue get(long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 2:
            return new SnmpString(node.getJvmRTBootClassPathItem());

        case 1:
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.noSuchObject);
}
 
Example #23
Source File: SnmpRequestHandler.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private SnmpPduPacket mergeNextResponses(SnmpPduRequest req) {
    int max= req.varBindList.length;
    SnmpVarBind[] result= new SnmpVarBind[max];

    // Go through the list of subrequests and concatenate.
    // Hopefully, by now all the sub-requests should be finished
    //
    for(Enumeration<SnmpSubRequestHandler> e= subs.elements(); e.hasMoreElements();) {
        SnmpSubRequestHandler sub= e.nextElement();
        sub.updateResult(result);
    }

    if (req.version == snmpVersionTwo) {
        return newValidResponsePdu(req,result);
    }

    // In v1 make sure there is no endOfMibView ...
    //
    for(int i=0; i < max; i++) {
        SnmpValue val= result[i].value;
        if (val == SnmpVarBind.endOfMibView)
            return newErrorResponsePdu(req,
                               SnmpDefinitions.snmpRspNoSuchName, i+1);
    }

    // So far so good ...
    //
    return newValidResponsePdu(req,result);
}
 
Example #24
Source File: JvmClassLoadingMeta.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the value of a scalar variable
 */
public SnmpValue set(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 4:
            if (x instanceof SnmpInt) {
                try  {
                    node.setJvmClassesVerboseLevel( new EnumJvmClassesVerboseLevel (((SnmpInt)x).toInteger()));
                } catch(IllegalArgumentException e)  {
                    throw new SnmpStatusException(SnmpStatusException.snmpRspWrongValue);
                }
                return new SnmpInt(node.getJvmClassesVerboseLevel());
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }

        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
}
 
Example #25
Source File: JvmRTInputArgsEntryMeta.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check the value of a scalar variable
 */
public void check(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int) var) {
        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
    }
}
 
Example #26
Source File: JvmRTInputArgsEntryMeta.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the value of a scalar variable
 */
public SnmpValue set(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
}
 
Example #27
Source File: JvmClassLoadingMeta.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check the value of a scalar variable
 */
public void check(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int) var) {
        case 4:
            if (x instanceof SnmpInt) {
                try  {
                    node.checkJvmClassesVerboseLevel( new EnumJvmClassesVerboseLevel (((SnmpInt)x).toInteger()));
                } catch(IllegalArgumentException e)  {
                    throw new SnmpStatusException(SnmpStatusException.snmpRspWrongValue);
                }
            } else {
                throw new SnmpStatusException(SnmpStatusException.snmpRspWrongType);
            }
            break;

        case 3:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
    }
}
 
Example #28
Source File: JvmRTClassPathEntryMeta.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the value of a scalar variable
 */
public SnmpValue set(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
}
 
Example #29
Source File: JvmRTClassPathEntryMeta.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check the value of a scalar variable
 */
public void check(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int) var) {
        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
    }
}
 
Example #30
Source File: JvmRTClassPathEntryMeta.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the value of a scalar variable
 */
public SnmpValue set(SnmpValue x, long var, Object data)
    throws SnmpStatusException {
    switch((int)var) {
        case 2:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        case 1:
            throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);

        default:
            break;
    }
    throw new SnmpStatusException(SnmpStatusException.snmpRspNotWritable);
}