// Home | Go Back //
package agent.mib2;
import com.ireasoning.core.jmx.MBeanManager;
import java.io.*;
import java.util.*;
import com.ireasoning.util.*;
import com.ireasoning.protocol.snmp.*;
import javax.management.*;
public class AgentMib
{
private static MBeanManager _mgr = MBeanManager.getInstance();
private static OIDTreeNode _root;
public static void registerMBeans(MBeanServer server, OIDTreeNode root)
{
_root = root;
try
{
registerSnmpGroup();
registerSystemGroup();
registerAtTable();
registerTcpConnTable();
}
catch(Exception e)
{
Logger.error(e);
throw new SnmpException(e.toString());
}
}
public static void unregisterMBeans()
{
try
{
unregisterSnmpGroup();
unregisterSystemGroup();
unregisterAtTable();
unregisterTcpConnTable();
}
catch(Exception e)
{
Logger.error(e);
throw new SnmpException(e.toString());
}
}
public static void registerSnmpGroup() throws Exception
{
if ( _snmpGroup == null )
{
_snmpGroup = new SnmpGroup(_root, ".1.3.6.1.2.1.11", null);
}
ObjectName objName = new ObjectName("ireasoning:name=SnmpGroup,noPdu=true");
if(!_mgr.isRegistered(objName))
{
_mgr.registerMBean(_snmpGroup, objName);
}
}
public static void unregisterSnmpGroup() throws Exception
{
_mgr.unregisterMBean(new ObjectName("ireasoning:name=SnmpGroup,noPdu=true"));
_snmpGroup = null;
}
public static void registerSystemGroup() throws Exception
{
if ( _systemGroup == null )
{
_systemGroup = new SystemGroup(_root, ".1.3.6.1.2.1.1", null);
}
ObjectName objName = new ObjectName("ireasoning:name=SystemGroup,noPdu=true");
if(!_mgr.isRegistered(objName))
{
_mgr.registerMBean(_systemGroup, objName);
}
}
public static void unregisterSystemGroup() throws Exception
{
_mgr.unregisterMBean(new ObjectName("ireasoning:name=SystemGroup,noPdu=true"));
_systemGroup = null;
}
public static void registerAtTable() throws Exception
{
if ( _atTable == null )
{
_atTable = new AtTable(_root, ".1.3.6.1.2.1.3.1", null);
}
ObjectName objName = new ObjectName("ireasoning:name=AtTable,noPdu=true");
if(!_mgr.isRegistered(objName))
{
_mgr.registerMBean(_atTable, objName);
}
}
public static void unregisterAtTable() throws Exception
{
_mgr.unregisterMBean(new ObjectName("ireasoning:name=AtTable,noPdu=true"));
_atTable = null;
}
public static void registerTcpConnTable() throws Exception
{
if ( _tcpConnTable == null )
{
_tcpConnTable = new TcpConnTable(_root, ".1.3.6.1.2.1.6.13", null);
}
ObjectName objName = new ObjectName("ireasoning:name=TcpConnTable,noPdu=true");
if(!_mgr.isRegistered(objName))
{
_mgr.registerMBean(_tcpConnTable, objName);
}
}
public static void unregisterTcpConnTable() throws Exception
{
_mgr.unregisterMBean(new ObjectName("ireasoning:name=TcpConnTable,noPdu=true"));
_tcpConnTable = null;
}
public static SnmpGroup getSnmpGroup( )
{
if( _snmpGroup == null )
{
try
{
registerSnmpGroup();
}
catch(Exception e)
{
Logger.error(e);
}
}
return _snmpGroup;
}
public static SystemGroup getSystemGroup( )
{
if( _systemGroup == null )
{
try
{
registerSystemGroup();
}
catch(Exception e)
{
Logger.error(e);
}
}
return _systemGroup;
}
public static AtTable getAtTable( )
{
if( _atTable == null )
{
try
{
registerAtTable();
}
catch(Exception e)
{
Logger.error(e);
}
}
return _atTable;
}
public static TcpConnTable getTcpConnTable( )
{
if( _tcpConnTable == null )
{
try
{
registerTcpConnTable();
}
catch(Exception e)
{
Logger.error(e);
}
}
return _tcpConnTable;
}
static SnmpGroup _snmpGroup;
static SystemGroup _systemGroup;
static AtTable _atTable;
static TcpConnTable _tcpConnTable;
}