|
From: Sasa M. <sa...@us...> - 2004-04-07 13:59:06
|
Update of /cvsroot/jrobin/src/org/jrobin/mrtg/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32462/org/jrobin/mrtg/server Modified Files: Poller.java RrdWriter.java Timer.java Log Message: MRTG: SNMP port on a router can be now different from default (161). THE CODE WILL NOT COMPILE WITHOUT PATCHED VERSION OF SNMP LIBRARY! Index: Poller.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/mrtg/server/Poller.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Poller.java 9 Dec 2003 12:22:04 -0000 1.1 --- Poller.java 7 Apr 2004 13:46:05 -0000 1.2 *************** *** 59,64 **** public Poller(String host, String community) throws IOException { ! InetAddress hostAddress = InetAddress.getByName(host); ! comm = new SNMPv1CommunicationInterface(0, hostAddress, community); comm.setSocketTimeout(SNMP_TIMEOUT * 1000); } --- 59,74 ---- public Poller(String host, String community) throws IOException { ! // check for port information ! String snmpHost = host; ! int snmpPort = SNMPv1CommunicationInterface.DEFAULT_SNMPPORT; ! int colonIndex = host.indexOf(":"); ! if(colonIndex != -1) { ! // port specified ! snmpHost = host.substring(0, colonIndex); ! String portStr = host.substring(colonIndex + 1); ! snmpPort = Integer.parseInt(portStr); ! } ! InetAddress snmpHostAddress = InetAddress.getByName(snmpHost); ! comm = new SNMPv1CommunicationInterface(0, snmpHostAddress, community, snmpPort); comm.setSocketTimeout(SNMP_TIMEOUT * 1000); } Index: Timer.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/mrtg/server/Timer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Timer.java 11 Mar 2004 13:54:26 -0000 1.2 --- Timer.java 7 Apr 2004 13:46:06 -0000 1.3 *************** *** 52,56 **** new SnmpReader(router, link).start(); try { ! sleep(SCHEDULER_DELAY); } catch (InterruptedException e) { e.printStackTrace(); --- 52,56 ---- new SnmpReader(router, link).start(); try { ! sleep((long)(1 + Math.random() * SCHEDULER_DELAY)); } catch (InterruptedException e) { e.printStackTrace(); Index: RrdWriter.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/mrtg/server/RrdWriter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RrdWriter.java 8 Mar 2004 13:14:39 -0000 1.2 --- RrdWriter.java 7 Apr 2004 13:46:05 -0000 1.3 *************** *** 119,123 **** static String getRrdFilename(String host, String ifDescr) { ! String filename = ifDescr.replaceAll("[^0-9a-zA-Z]", "_") + "@" + host + ".rrd"; return Config.getRrdDir() + filename; } --- 119,124 ---- static String getRrdFilename(String host, String ifDescr) { ! String filename = ifDescr.replaceAll("[^0-9a-zA-Z]", "_") + ! "@" + host.replaceFirst(":", "_") + ".rrd"; return Config.getRrdDir() + filename; } |