Java Code Examples for com.sun.jmx.snmp.SnmpOid

The following examples show how to use com.sun.jmx.snmp.SnmpOid. These examples are extracted from open source projects. 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 Project: jdk1.8-source-analysis   Author: raysonfang   File: AcmChecker.java    License: Apache License 2.0 6 votes vote down vote up
void checkCurrentOid() throws SnmpStatusException {
    if(model != null) {
        SnmpOid oid = new SnmpOid(l.toArray());
        if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
            SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(),
                    "checkCurrentOid", "Checking access for : " + oid);
        }
        model.checkAccess(version,
                          principal,
                          securityLevel,
                          pduType,
                          securityModel,
                          contextName,
                          oid);
    }
}
 
Example #2
Source Project: jdk8u-jdk   Author: frohoff   File: JvmRTClassPathTableMetaImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a table handler containing the Thread indexes.
 * Indexes are computed from the ThreadId.
 **/
protected SnmpCachedData updateCachedDatas(Object userData) {


    // We are getting all the input args
    final String[] path =
        JvmRuntimeImpl.getClassPath(userData);

    // Time stamp for the cache
    final long time = System.currentTimeMillis();
    final int len = path.length;

    SnmpOid indexes[] = new SnmpOid[len];

    for(int i = 0; i < len; i++) {
        indexes[i] = new SnmpOid(i + 1);
    }

    return new SnmpCachedData(time, indexes, path);
}
 
Example #3
Source Project: openjdk-8   Author: bpupadhyaya   File: SnmpAdaptorServer.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sends a trap using SNMP V1 trap format.
 * <BR>The trap is sent to the specified <CODE>SnmpPeer</CODE> destination.
 * The community string used is the one located in the
 * <CODE>SnmpPeer</CODE> parameters
 * (<CODE>SnmpParameters.getRdCommunity() </CODE>).
 *
 * @param peer The <CODE>SnmpPeer</CODE> destination of the trap.
 * @param agentAddr The agent address to be used for the trap.
 * @param enterpOid The enterprise OID to be used for the trap.
 * @param generic The generic number of the trap.
 * @param specific The specific number of the trap.
 * @param varBindList A list of <CODE>SnmpVarBind</CODE> instances or null.
 * @param time The time stamp (overwrite the current time).
 *
 * @exception IOException An I/O error occurred while sending the trap.
 * @exception SnmpStatusException If the trap exceeds the limit
 * defined by <CODE>bufferSize</CODE>.
 *
 * @since 1.5
 */
@Override
public void snmpV1Trap(SnmpPeer peer,
                       SnmpIpAddress agentAddr,
                       SnmpOid enterpOid,
                       int generic,
                       int specific,
                       SnmpVarBindList varBindList,
                       SnmpTimeticks time)
    throws IOException, SnmpStatusException {

    SnmpParameters p = (SnmpParameters) peer.getParams();
    snmpV1Trap(peer.getDestAddr(),
               peer.getDestPort(),
               agentAddr,
               p.getRdCommunity(),
               enterpOid,
               generic,
               specific,
               varBindList,
               time);
}
 
Example #4
Source Project: TencentKona-8   Author: Tencent   File: JvmRTClassPathTableMetaImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a table handler containing the Thread indexes.
 * Indexes are computed from the ThreadId.
 **/
protected SnmpCachedData updateCachedDatas(Object userData) {


    // We are getting all the input args
    final String[] path =
        JvmRuntimeImpl.getClassPath(userData);

    // Time stamp for the cache
    final long time = System.currentTimeMillis();
    final int len = path.length;

    SnmpOid indexes[] = new SnmpOid[len];

    for(int i = 0; i < len; i++) {
        indexes[i] = new SnmpOid(i + 1);
    }

    return new SnmpCachedData(time, indexes, path);
}
 
Example #5
Source Project: jdk8u-jdk   Author: frohoff   File: JvmRTBootClassPathTableMetaImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a table handler containing the Thread indexes.
 * Indexes are computed from the ThreadId.
 **/
protected SnmpCachedData updateCachedDatas(Object userData) {


    // We are getting all the input args
    final String[] path =
        JvmRuntimeImpl.getBootClassPath(userData);

    // Time stamp for the cache
    final long time = System.currentTimeMillis();
    final int len = path.length;

    SnmpOid indexes[] = new SnmpOid[len];

    for(int i = 0; i < len; i++) {
        indexes[i] = new SnmpOid(i + 1);
    }

    return new SnmpCachedData(time, indexes, path);
}
 
Example #6
Source Project: hottub   Author: dsrg-uoft   File: JvmThreadInstanceTableMetaImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
protected boolean contains(SnmpOid oid, Object userData) {

        // Get the handler.
        //
        SnmpTableHandler handler = getHandler(userData);

        // handler should never be null.
        //
        if (handler == null)
            return false;
        if(!handler.contains(oid))
            return false;

        JvmThreadInstanceEntryImpl inst = getJvmThreadInstance(userData, oid);
        return (inst != null);
    }
 
Example #7
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: SnmpNamedListTableCache.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Update cahed datas.
 * Obtains a {@link List} of raw datas by calling
 * {@link #getRawDatas(Map,String) getRawDatas((Map)context,getRawDatasKey())}.<br>
 * Then allocate a new {@link TreeMap} to serve as temporary map between
 * names and indexes, and call {@link #updateCachedDatas(Object,List)}
 * with that temporary map as context.<br>
 * Finally replaces the {@link #names} TreeMap by the temporary
 * TreeMap.
 * @param context The request contextual cache allocated by the
 *        {@link JvmContextFactory}.
 **/
protected SnmpCachedData updateCachedDatas(Object context) {

    final Map<Object, Object> userData =
        (context instanceof Map)?Util.<Map<Object, Object>>cast(context):null;

    // Look for memory manager list in request contextual cache.
    final List<?> rawDatas = getRawDatas(userData,getRawDatasKey());

    log.debug("updateCachedDatas","rawDatas.size()=" +
          ((rawDatas==null)?"<no data>":""+rawDatas.size()));

    TreeMap<String,SnmpOid> ctxt = new TreeMap<>();
    final SnmpCachedData result =
        super.updateCachedDatas(ctxt,rawDatas);
    names = ctxt;
    return result;
}
 
Example #8
Source Project: openjdk-8   Author: bpupadhyaya   File: JvmMemGCTableMeta.java    License: GNU General Public License v2.0 5 votes vote down vote up
public boolean skipEntryVariable( SnmpOid rowOid, long var, Object data, int pduVersion) {
    try {
        JvmMemGCEntryMBean entry = (JvmMemGCEntryMBean) getEntry(rowOid);
        synchronized (this) {
            node.setInstance(entry);
            return node.skipVariable(var, data, pduVersion);
        }
    } catch (SnmpStatusException x) {
        return false;
    }
}
 
Example #9
Source Project: jdk8u-jdk   Author: frohoff   File: JvmMemPoolTableMeta.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the arc of the next columnar object following "var".
 */
public long getNextVarEntryId( SnmpOid rowOid, long var, Object data )
    throws SnmpStatusException {
    long nextvar = node.getNextVarId(var, data);
    while (!isReadableEntryId(rowOid, nextvar, data))
        nextvar = node.getNextVarId(nextvar, data);
    return nextvar;
}
 
Example #10
Source Project: jdk8u-jdk   Author: lambdalab-mirror   File: JvmRTLibraryPathTableMeta.java    License: GNU General Public License v2.0 5 votes vote down vote up
public synchronized void addEntry(SnmpOid rowOid, ObjectName objname,
             Object entry)
    throws SnmpStatusException {
    if (! (entry instanceof JvmRTLibraryPathEntryMBean) )
        throw new ClassCastException("Entries for Table \"" +
                       "JvmRTLibraryPathTable" + "\" must implement the \"" +
                       "JvmRTLibraryPathEntryMBean" + "\" interface.");
    super.addEntry(rowOid, objname, entry);
}
 
Example #11
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: SnmpRequestTree.java    License: GNU General Public License v2.0 5 votes vote down vote up
public SnmpOid getEntryOid(int pos) {
    if (entryoids == null) return null;
    // if (pos == -1 || pos >= entryoids.size() ) return null;
    if (pos == -1 || pos >= entrycount ) return null;
    // return (SnmpOid) entryoids.get(pos);
    return entryoids[pos];
}
 
Example #12
Source Project: openjdk-8   Author: bpupadhyaya   File: JvmMemPoolTableMeta.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void createNewEntry(SnmpMibSubRequest req, SnmpOid rowOid, int depth)
    throws SnmpStatusException {
    if (factory != null)
        factory.createNewEntry(req, rowOid, depth, this);
    else
        throw new SnmpStatusException(
            SnmpStatusException.snmpRspNoAccess);
}
 
Example #13
Source Project: TencentKona-8   Author: Tencent   File: JvmMemMgrPoolRelTableMetaImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected SnmpOid getNextOid(SnmpOid oid, Object userData)
    throws SnmpStatusException {
    final boolean dbg = log.isDebugOn();
    if (dbg) log.debug("getNextOid", "previous=" + oid);


    // Get the data handler.
    //
    SnmpTableHandler handler = getHandler(userData);
    if (handler == null) {
        // This should never happen.
        // If we get here it's a bug.
        //
        if (dbg) log.debug("getNextOid", "handler is null!");
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    }

    // Get the next oid
    //
    final SnmpOid next = handler.getNext(oid);
    if (dbg) log.debug("getNextOid", "next=" + next);

    // if next is null: we reached the end of the table.
    //
    if (next == null)
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);

    return next;
}
 
Example #14
Source Project: hottub   Author: dsrg-uoft   File: JvmRTBootClassPathTableMetaImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected boolean contains(SnmpOid oid, Object userData) {

        // Get the handler.
        //
        SnmpTableHandler handler = getHandler(userData);

        // handler should never be null.
        //
        if (handler == null)
            return false;

        return handler.contains(oid);
    }
 
Example #15
Source Project: openjdk-8-source   Author: keerath   File: JvmThreadInstanceTableMetaImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
public Object getEntry(SnmpOid oid)
    throws SnmpStatusException {
    log.debug("*** **** **** **** getEntry", "oid [" + oid + "]");
    if (oid == null || oid.getLength() != 8) {
        log.debug("getEntry", "Invalid oid [" + oid + "]");
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
    }

    // Get the request contextual cache (userData).
    //
    final Map<Object,Object> m = JvmContextFactory.getUserData();

    // Get the handler.
    //
    SnmpTableHandler handler = getHandler(m);

    // handler should never be null.
    //
    if (handler == null || !handler.contains(oid))
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);

    final JvmThreadInstanceEntryImpl entry = getJvmThreadInstance(m,oid);

    if (entry == null)
        throw new SnmpStatusException(SnmpStatusException.noSuchInstance);

    return entry;
}
 
Example #16
Source Project: openjdk-8   Author: bpupadhyaya   File: JvmMemPoolTableMeta.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void get(SnmpMibSubRequest req, SnmpOid rowOid, int depth)
    throws SnmpStatusException {
    JvmMemPoolEntryMBean entry = (JvmMemPoolEntryMBean) getEntry(rowOid);
    synchronized (this) {
        node.setInstance(entry);
        node.get(req,depth);
    }
}
 
Example #17
Source Project: hottub   Author: dsrg-uoft   File: SnmpAdaptorServer.java    License: GNU General Public License v2.0 5 votes vote down vote up
private SnmpInformRequest snmpInformRequest(InetAddress addr,
                                            int port,
                                            String cs,
                                            SnmpInformHandler cb,
                                            SnmpOid trapOid,
                                            SnmpVarBindList varBindList)
    throws IllegalStateException, IOException, SnmpStatusException {

    if (!isActive()) {
        throw new IllegalStateException(
          "Start SNMP adaptor server before carrying out this operation");
    }
    if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) {
        SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag,
            "snmpInformRequest", "trapOid=" + trapOid);
    }

    // First, make an SNMP inform pdu:
    // We clone varBindList and insert sysUpTime and snmpTrapOid variables.
    //
    SnmpVarBindList fullVbl ;
    if (varBindList != null)
        fullVbl = varBindList.clone() ;
    else
        fullVbl = new SnmpVarBindList(2) ;
    SnmpTimeticks sysUpTimeValue = new SnmpTimeticks(getSysUpTime()) ;
    fullVbl.insertElementAt(new SnmpVarBind(snmpTrapOidOid, trapOid), 0) ;
    fullVbl.insertElementAt(new SnmpVarBind(sysUpTimeOid, sysUpTimeValue),
                            0);

    // Next, send the pdu to the specified destination
    //
    openInformSocketIfNeeded() ;
    return informSession.makeAsyncRequest(addr, cs, cb, fullVbl, port) ;
}
 
Example #18
Source Project: jdk8u60   Author: chenghanpeng   File: JvmMemManagerTableMeta.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void get(SnmpMibSubRequest req, SnmpOid rowOid, int depth)
    throws SnmpStatusException {
    JvmMemManagerEntryMBean entry = (JvmMemManagerEntryMBean) getEntry(rowOid);
    synchronized (this) {
        node.setInstance(entry);
        node.get(req,depth);
    }
}
 
Example #19
Source Project: TencentKona-8   Author: Tencent   File: JvmThreadInstanceTableMeta.java    License: GNU General Public License v2.0 5 votes vote down vote up
public boolean skipEntryVariable( SnmpOid rowOid, long var, Object data, int pduVersion) {
    try {
        JvmThreadInstanceEntryMBean entry = (JvmThreadInstanceEntryMBean) getEntry(rowOid);
        synchronized (this) {
            node.setInstance(entry);
            return node.skipVariable(var, data, pduVersion);
        }
    } catch (SnmpStatusException x) {
        return false;
    }
}
 
Example #20
Source Project: jdk8u-jdk   Author: frohoff   File: JvmRTInputArgsTableMeta.java    License: GNU General Public License v2.0 5 votes vote down vote up
public boolean skipEntryVariable( SnmpOid rowOid, long var, Object data, int pduVersion) {
    try {
        JvmRTInputArgsEntryMBean entry = (JvmRTInputArgsEntryMBean) getEntry(rowOid);
        synchronized (this) {
            node.setInstance(entry);
            return node.skipVariable(var, data, pduVersion);
        }
    } catch (SnmpStatusException x) {
        return false;
    }
}
 
Example #21
Source Project: jdk8u-jdk   Author: lambdalab-mirror   File: SnmpCachedData.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a new instance of SnmpCachedData. Instances are
 * immutable.
 * @param lastUpdated Time stamp as returned by
 *        {@link System#currentTimeMillis System.currentTimeMillis()}
 * @param indexMap The table indexed table data, sorted in ascending
 *                 order by {@link #oidComparator}. The keys must be
 *                 instances of {@link SnmpOid}.
 **/
public SnmpCachedData(long lastUpdated, TreeMap<SnmpOid, Object> indexMap,
                      boolean b) {

    final int size = indexMap.size();
    this.lastUpdated = lastUpdated;
    this.indexes     = new SnmpOid[size];
    this.datas       = new Object[size];

    if(b) {
        indexMap.keySet().toArray(this.indexes);
        indexMap.values().toArray(this.datas);
    } else
        indexMap.values().toArray(this.datas);
}
 
Example #22
Source Project: jdk8u60   Author: chenghanpeng   File: JvmRTBootClassPathTableMeta.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void set(SnmpMibSubRequest req, SnmpOid rowOid, int depth)
    throws SnmpStatusException {
    if (req.getSize() == 0) return;

    JvmRTBootClassPathEntryMBean entry = (JvmRTBootClassPathEntryMBean) getEntry(rowOid);
    synchronized (this) {
        node.setInstance(entry);
        node.set(req,depth);
    }
}
 
Example #23
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: JvmMemPoolTableMeta.java    License: GNU General Public License v2.0 5 votes vote down vote up
public synchronized void addEntry(SnmpOid rowOid, ObjectName objname,
             Object entry)
    throws SnmpStatusException {
    if (! (entry instanceof JvmMemPoolEntryMBean) )
        throw new ClassCastException("Entries for Table \"" +
                       "JvmMemPoolTable" + "\" must implement the \"" +
                       "JvmMemPoolEntryMBean" + "\" interface.");
    super.addEntry(rowOid, objname, entry);
}
 
Example #24
Source Project: hottub   Author: dsrg-uoft   File: JvmRTLibraryPathTableMetaImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected boolean contains(SnmpOid oid, Object userData) {

        // Get the handler.
        //
        SnmpTableHandler handler = getHandler(userData);

        // handler should never be null.
        //
        if (handler == null)
            return false;

        return handler.contains(oid);
    }
 
Example #25
Source Project: hottub   Author: dsrg-uoft   File: JvmRTBootClassPathTableMeta.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the arc of the next columnar object following "var".
 */
public long getNextVarEntryId( SnmpOid rowOid, long var, Object data )
    throws SnmpStatusException {
    long nextvar = node.getNextVarId(var, data);
    while (!isReadableEntryId(rowOid, nextvar, data))
        nextvar = node.getNextVarId(nextvar, data);
    return nextvar;
}
 
Example #26
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: JvmRTBootClassPathTableMeta.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the arc of the next columnar object following "var".
 */
public long getNextVarEntryId( SnmpOid rowOid, long var, Object data )
    throws SnmpStatusException {
    long nextvar = node.getNextVarId(var, data);
    while (!isReadableEntryId(rowOid, nextvar, data))
        nextvar = node.getNextVarId(nextvar, data);
    return nextvar;
}
 
Example #27
Source Project: jdk8u-jdk   Author: frohoff   File: JVM_MANAGEMENT_MIB_IMPL.java    License: GNU General Public License v2.0 5 votes vote down vote up
private synchronized void sendTrap(SnmpOid trap, SnmpVarBindList list) {
    final Iterator<NotificationTarget> iterator = notificationTargets.iterator();
    final SnmpAdaptorServer adaptor =
        (SnmpAdaptorServer) getSnmpAdaptor();

    if (adaptor == null) {
        log.error("sendTrap", "Cannot send trap: adaptor is null.");
        return;
    }

    if (!adaptor.isActive()) {
        log.config("sendTrap", "Adaptor is not active: trap not sent.");
        return;
    }

    while(iterator.hasNext()) {
        NotificationTarget target = null;
        try {
            target = iterator.next();
            SnmpPeer peer =
                new SnmpPeer(target.getAddress(), target.getPort());
            SnmpParameters p = new SnmpParameters();
            p.setRdCommunity(target.getCommunity());
            peer.setParams(p);
            log.debug("handleNotification", "Sending trap to " +
                      target.getAddress() + ":" + target.getPort());
            adaptor.snmpV2Trap(peer, trap, list, null);
        }catch(Exception e) {
            log.error("sendTrap",
                      "Exception occurred while sending trap to [" +
                      target + "]. Exception : " + e);
            log.debug("sendTrap",e);
        }
    }
}
 
Example #28
Source Project: dragonwell8_jdk   Author: alibaba   File: JvmMemManagerTableMetaImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected boolean contains(SnmpOid oid, Object userData) {

        // Get the handler.
        //
        SnmpTableHandler handler = getHandler(userData);

        // handler should never be null.
        //
        if (handler == null)
            return false;

        return handler.contains(oid);
    }
 
Example #29
Source Project: jdk8u60   Author: chenghanpeng   File: JvmRTLibraryPathTableMeta.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void check(SnmpMibSubRequest req, SnmpOid rowOid, int depth)
    throws SnmpStatusException {
    if (req.getSize() == 0) return;

    JvmRTLibraryPathEntryMBean entry = (JvmRTLibraryPathEntryMBean) getEntry(rowOid);
    synchronized (this) {
        node.setInstance(entry);
        node.check(req,depth);
    }
}
 
Example #30
Source Project: jdk8u-jdk   Author: frohoff   File: SnmpCachedData.java    License: GNU General Public License v2.0 5 votes vote down vote up
public  SnmpOid getNext(SnmpOid index) {
    if (index == null) {
        if (indexes.length>0) return indexes[0];
        else return null;
    }
    final int pos = find(index);
    if (pos > -1) {
        if (pos < (indexes.length -1) ) return indexes[pos+1];
        else return null;
    }
    final int insertion = -pos -1;
    if ((insertion > -1) && (insertion < indexes.length))
        return indexes[insertion];
    else return null;
}