/* * Copyright (c) 2002-2003 iReasoning Inc. All Rights Reserved. * * This SOURCE CODE FILE, which has been provided by iReasoning Inc. as part * of an iReasoning Software product for use ONLY by licensed users of the product, * includes CONFIDENTIAL and PROPRIETARY information of iReasoning Inc. * * USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS * OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH * THE PRODUCT. * * IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD IREASONING SOFTWARE, ITS * RELATED COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY * CLAIMS OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR * DISTRIBUTION OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES * ARISING OUT OF OR RESULTING FROM THE USE, MODIFICATION, OR * DISTRIBUTION OF PROGRAMS OR FILES CREATED FROM, BASED ON, AND/OR * DERIVED FROM THIS SOURCE CODE FILE. */ package agent.mib2; import java.io.*; import java.util.*; import com.ireasoning.util.*; import com.ireasoning.protocol.snmp.*; import javax.management.*; /** * Class represents tcpConnTable MIB object in RFC1213_MIB */ public class TcpConnTable extends SnmpTable implements TcpConnTableMBean { /** * Constructor * @param root SnmpOID tree root * @param oid the SnmpOID of this table. For example, ".1.3.6.1.2.1.2.2" for IfTable in RFC1213 * @param args the objects passed from caller for Initialization purpose */ public TcpConnTable (OIDTreeNode root, String oid, Object[] args) { super(root, oid); // TODO: Add your implementation //New code , set update period to be 30 seconds update(); setUpdateInterval(30000);//set update interval to be 30 seconds. so the following update() method will get called if content is older than 30 seconds } //New code public void update() { super.update();//call super class' update method to update some internal variables in super class deleteAllRows();//delete all old rows, and we're going to create all rows again. ArrayList conns = null; if(Agent.isWindows()) { conns = Util.netstat(); } else { conns = Util.netstat_linux(); } int size = conns.size(); for (int i = 0; i < conns.size(); i++) { Connection conn = (Connection) conns.get(i); TcpConnEntry entry = new TcpConnEntry(this, conn.state, new SnmpIpAddress(conn.srcIp), conn.srcPort, new SnmpIpAddress(conn.destIp), conn.destPort); entry.addRow(); } } /** * Creates a new instance of table entry object */ public SnmpTableEntry newEntryInstance() { return new TcpConnEntry (this); } /** * Gets tcpConnState value * @param tcpConnEntry table entry object */ public int getTcpConnState(SnmpTableEntry tcpConnEntry) { synchronized (tcpConnEntry) { TcpConnEntry entry = (TcpConnEntry) tcpConnEntry; // TODO: Add your implementation return entry._tcpConnState; } } /** * Sets new tcpConnState value * @param tcpConnEntry table entry object * @param newValue new value to be set */ public void setTcpConnState(SnmpTableEntry tcpConnEntry, int newValue) { synchronized (tcpConnEntry) { TcpConnEntry entry = (TcpConnEntry) tcpConnEntry; entry._tcpConnState = newValue ; // TODO: Add your implementation } } /** * Gets tcpConnLocalAddress value * @param tcpConnEntry table entry object */ public SnmpIpAddress getTcpConnLocalAddress(SnmpTableEntry tcpConnEntry) { synchronized (tcpConnEntry) { TcpConnEntry entry = (TcpConnEntry) tcpConnEntry; // TODO: Add your implementation return entry._tcpConnLocalAddress; } } /** * Sets new tcpConnLocalAddress value * @param tcpConnEntry table entry object * @param newValue new value to be set */ public void setTcpConnLocalAddress(SnmpTableEntry tcpConnEntry, SnmpIpAddress newValue) { // This MIB node is not writeable, so TcpConnTableMBean does not have this method synchronized (tcpConnEntry) { TcpConnEntry entry = (TcpConnEntry) tcpConnEntry; entry._tcpConnLocalAddress = (SnmpIpAddress) newValue; // TODO: Add your implementation } } /** * Gets tcpConnLocalPort value * @param tcpConnEntry table entry object */ public int getTcpConnLocalPort(SnmpTableEntry tcpConnEntry) { synchronized (tcpConnEntry) { TcpConnEntry entry = (TcpConnEntry) tcpConnEntry; // TODO: Add your implementation return entry._tcpConnLocalPort; } } /** * Sets new tcpConnLocalPort value * @param tcpConnEntry table entry object * @param newValue new value to be set */ public void setTcpConnLocalPort(SnmpTableEntry tcpConnEntry, int newValue) { // This MIB node is not writeable, so TcpConnTableMBean does not have this method synchronized (tcpConnEntry) { TcpConnEntry entry = (TcpConnEntry) tcpConnEntry; entry._tcpConnLocalPort = newValue ; // TODO: Add your implementation } } /** * Gets tcpConnRemAddress value * @param tcpConnEntry table entry object */ public SnmpIpAddress getTcpConnRemAddress(SnmpTableEntry tcpConnEntry) { synchronized (tcpConnEntry) { TcpConnEntry entry = (TcpConnEntry) tcpConnEntry; // TODO: Add your implementation return entry._tcpConnRemAddress; } } /** * Sets new tcpConnRemAddress value * @param tcpConnEntry table entry object * @param newValue new value to be set */ public void setTcpConnRemAddress(SnmpTableEntry tcpConnEntry, SnmpIpAddress newValue) { // This MIB node is not writeable, so TcpConnTableMBean does not have this method synchronized (tcpConnEntry) { TcpConnEntry entry = (TcpConnEntry) tcpConnEntry; entry._tcpConnRemAddress = (SnmpIpAddress) newValue; // TODO: Add your implementation } } /** * Gets tcpConnRemPort value * @param tcpConnEntry table entry object */ public int getTcpConnRemPort(SnmpTableEntry tcpConnEntry) { synchronized (tcpConnEntry) { TcpConnEntry entry = (TcpConnEntry) tcpConnEntry; // TODO: Add your implementation return entry._tcpConnRemPort; } } /** * Sets new tcpConnRemPort value * @param tcpConnEntry table entry object * @param newValue new value to be set */ public void setTcpConnRemPort(SnmpTableEntry tcpConnEntry, int newValue) { // This MIB node is not writeable, so TcpConnTableMBean does not have this method synchronized (tcpConnEntry) { TcpConnEntry entry = (TcpConnEntry) tcpConnEntry; entry._tcpConnRemPort = newValue ; // TODO: Add your implementation } } }