You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
(927) |
Apr
(419) |
May
(352) |
Jun
(431) |
Jul
(463) |
Aug
(345) |
Sep
(304) |
Oct
(596) |
Nov
(466) |
Dec
(414) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(348) |
Feb
(313) |
Mar
(665) |
Apr
(688) |
May
(434) |
Jun
(311) |
Jul
(540) |
Aug
(554) |
Sep
(467) |
Oct
(341) |
Nov
(365) |
Dec
(272) |
2009 |
Jan
(386) |
Feb
(293) |
Mar
(279) |
Apr
(239) |
May
(229) |
Jun
(199) |
Jul
(186) |
Aug
(111) |
Sep
(196) |
Oct
(146) |
Nov
(116) |
Dec
(140) |
2010 |
Jan
(170) |
Feb
(159) |
Mar
(151) |
Apr
(161) |
May
(90) |
Jun
(56) |
Jul
(28) |
Aug
(22) |
Sep
(5) |
Oct
|
Nov
(23) |
Dec
(12) |
2011 |
Jan
(8) |
Feb
(8) |
Mar
(22) |
Apr
(24) |
May
(4) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2012 |
Jan
(5) |
Feb
(1) |
Mar
|
Apr
(1) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <tr...@hy...> - 2010-01-06 20:09:05
|
Author: trader Date: 2010-01-06 12:08:56 -0800 (Wed, 06 Jan 2010) New Revision: 14148 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14148 Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/IfTableCollector.java Log: Same as revision 9972, reformatted with project settings Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/IfTableCollector.java =================================================================== --- trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/IfTableCollector.java 2010-01-06 20:08:11 UTC (rev 14147) +++ trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/IfTableCollector.java 2010-01-06 20:08:56 UTC (rev 14148) @@ -1,30 +1,19 @@ -/* - * 'IfTableCollector.java' - * - * - * NOTE: This copyright does *not* cover user programs that use HQ - * program services by normal system calls through the application - * program interfaces provided as part of the Hyperic Plug-in Development - * Kit or the Hyperic Client Development Kit - this is merely considered - * normal use of the program, and does *not* fall under the heading of - * "derived work". - * - * Copyright (C) [2004, 2005, 2006, 2007, 2008, 2009], Hyperic, Inc. - * This file is part of HQ. - * - * HQ is free software; you can redistribute it and/or modify - * it under the terms version 2 of the GNU General Public License as - * published by the Free Software Foundation. This program is distributed - * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - */ +/* + * NOTE: This copyright does *not* cover user programs that use HQ program + * services by normal system calls through the application program interfaces + * provided as part of the Hyperic Plug-in Development Kit or the Hyperic Client + * Development Kit - this is merely considered normal use of the program, and + * does *not* fall under the heading of "derived work". Copyright (C) [2004, + * 2005, 2006], Hyperic, Inc. This file is part of HQ. HQ is free software; you + * can redistribute it and/or modify it under the terms version 2 of the GNU + * General Public License as published by the Free Software Foundation. This + * program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA. + */ package org.hyperic.hq.plugin.netdevice; @@ -36,85 +25,64 @@ import org.hyperic.snmp.SNMPException; import org.hyperic.snmp.SNMPSession; -public class IfTableCollector extends SNMPCollector +public class IfTableCollector + extends SNMPCollector { - private boolean _isVersion1; - private String _columnName; + private boolean _isVersion1; + private String _columnName; - private static HashMap counter64 = new HashMap ( ); - - // - // Conditionally use Counter64 versions of IF-MIB metrics. - // These metrics are not supported when using SNMPv1. - // Not all devices support the 64 bit versions, regardless. - // - static - { - counter64.put ( "ifInOctets", "ifHCInOctets" ); - counter64.put ( "ifOutOctets", "ifHCOutOctets" ); - counter64.put ( "ifInUcastPkts", "ifHCInUcastPkts" ); - counter64.put ( "ifOutUcastPkts", "ifHCOutUcastPkts" ); - counter64.put ( "ifInNUcastPkts", "ifInMulticastPkts" ); - counter64.put ( "ifOutNUcastPkts", "ifOutMulticastPkts" ); - } + private static HashMap counter64 = new HashMap(); - protected String getColumnName ( ) - { - return _columnName; - } + // Conditionally use Counter64 versions of IF-MIB metrics. + // These metrics are not supported when using snmp v1. + // Not all devices support the 64 bit versions regardless. + static { + counter64.put("ifInOctets", "ifHCInOctets"); + counter64.put("ifOutOctets", "ifHCOutOctets"); - protected void init ( SNMPSession session ) throws PluginException - { - _isVersion1 = "v1".equals ( _props.getProperty ( SNMPClient.PROP_VERSION ) ); + counter64.put("ifInUcastPkts", "ifHCInUcastPkts"); + counter64.put("ifOutUcastPkts", "ifHCOutUcastPkts"); - _columnName = super.getColumnName ( ); + counter64.put("ifInNUcastPkts", "ifInMulticastPkts"); + counter64.put("ifOutNUcastPkts", "ifOutMulticastPkts"); + } - if ( _columnName == null ) - { - throw new PluginException ( PROP_COLUMN + " not defined: " + getProperties ( ) + " (stale template?)" ); - } - - if ( _isVersion1 ) - { - return; - } - - String name = (String)counter64.get ( _columnName ); - - if ( name != null ) - { - List list64 = null; - - try - { - list64 = session.getBulk ( name ); - } - catch ( SNMPException e ) - { - } - - if ( isEmpty ( list64, name ) ) - { - getLog().debug ( getInfo ( ) + " does not support Counter64: " + name ); - } - else - { - getLog().debug ( "Switching to 64 bit counter: " + _columnName + "->" + name + ": " + getInfo ( ) ); - - _columnName = name; - } - } - - setSource ( _columnName + "@" + getInfo ( ) ); - } + protected String getColumnName() { + return _columnName; + } - protected boolean isTotalCounter ( String name ) - { - return name.endsWith ( "Octets" ); - } + protected void init(SNMPSession session) throws PluginException { + _isVersion1 = "v1".equals(_props.getProperty(SNMPClient.PROP_VERSION)); + _columnName = super.getColumnName(); - public void collect ( ) - { - collectIndexedColumn ( ); - } + if (_columnName == null) { + throw new PluginException(PROP_COLUMN + " not defined: " + getProperties() + " (stale template?)"); + } + if (_isVersion1) { + return; + } + String name = (String) counter64.get(_columnName); + if (name != null) { + List list64 = null; + try { + list64 = session.getBulk(name); + } catch (SNMPException e) { + } + if (isEmpty(list64, name)) { + getLog().debug(getInfo() + " does not support Counter64: " + name); + } else { + getLog().debug("Switching to 64 bit counter: " + _columnName + "->" + name + ": " + getInfo()); + _columnName = name; + } + } + setSource(_columnName + "@" + getInfo()); + } + + protected boolean isTotalCounter(String name) { + return name.endsWith("Octets"); + } + + public void collect() { + collectIndexedColumn(); + } } |
From: <tr...@hy...> - 2010-01-06 20:08:19
|
Author: trader Date: 2010-01-06 12:08:11 -0800 (Wed, 06 Jan 2010) New Revision: 14147 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14147 Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiverPlugin.java Log: Same as revision 14087, reformatted with project settings Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiverPlugin.java =================================================================== --- trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiverPlugin.java 2010-01-06 20:07:33 UTC (rev 14146) +++ trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiverPlugin.java 2010-01-06 20:08:11 UTC (rev 14147) @@ -1,3 +1,32 @@ +/* + * 'SNMPTrapReceiverPlugin.java' + * + * + * NOTE: This copyright does *not* cover user programs that use HQ + * program services by normal system calls through the application + * program interfaces provided as part of the Hyperic Plug-in Development + * Kit or the Hyperic Client Development Kit - this is merely considered + * normal use of the program, and does *not* fall under the heading of + * "derived work". + * + * Copyright (C) [2004, 2005, 2006, 2007, 2008, 2009], Hyperic, Inc. + * This file is part of HQ. + * + * HQ is free software; you can redistribute it and/or modify + * it under the terms version 2 of the GNU General Public License as + * published by the Free Software Foundation. This program is distributed + * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + */ + + package org.hyperic.hq.plugin.netdevice; import java.io.IOException; @@ -10,24 +39,29 @@ public class SNMPTrapReceiverPlugin extends LogTrackPlugin { - private SNMPTrapReceiver getReceiver() throws IOException { + SNMPTrapReceiver receiver = SNMPTrapReceiver.getInstance(getManager().getProperties()); - SNMPTrapReceiver receiver = SNMPTrapReceiver.getInstance(getManager().getProperties()); receiver.setPluginManager(getManager()); + return receiver; } public void init(PluginManager manager) throws PluginException { super.init(manager); + if (SNMPTrapReceiver.hasInstance()) { return; } + String listen = manager.getProperty(SNMPTrapReceiver.PROP_LISTEN_ADDRESS); + if (listen == null) { return; } + getLog().debug("Configuring default listener: " + listen); + try { getReceiver(); } catch (Exception e) { |
From: <tr...@hy...> - 2010-01-06 20:07:42
|
Author: trader Date: 2010-01-06 12:07:33 -0800 (Wed, 06 Jan 2010) New Revision: 14146 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14146 Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiverPlugin.java Log: Same as revision 9991, reformatted with project settings Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiverPlugin.java =================================================================== --- trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiverPlugin.java 2010-01-06 19:58:55 UTC (rev 14145) +++ trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiverPlugin.java 2010-01-06 20:07:33 UTC (rev 14146) @@ -1,32 +1,3 @@ -/* - * 'SNMPTrapReceiverPlugin.java' - * - * - * NOTE: This copyright does *not* cover user programs that use HQ - * program services by normal system calls through the application - * program interfaces provided as part of the Hyperic Plug-in Development - * Kit or the Hyperic Client Development Kit - this is merely considered - * normal use of the program, and does *not* fall under the heading of - * "derived work". - * - * Copyright (C) [2004, 2005, 2006, 2007, 2008, 2009], Hyperic, Inc. - * This file is part of HQ. - * - * HQ is free software; you can redistribute it and/or modify - * it under the terms version 2 of the GNU General Public License as - * published by the Free Software Foundation. This program is distributed - * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - */ - - package org.hyperic.hq.plugin.netdevice; import java.io.IOException; @@ -36,63 +7,47 @@ import org.hyperic.hq.product.PluginManager; import org.hyperic.util.config.ConfigResponse; -public class SNMPTrapReceiverPlugin extends LogTrackPlugin +public class SNMPTrapReceiverPlugin + extends LogTrackPlugin { - private SNMPTrapReceiver getReceiver ( ) throws IOException - { - SNMPTrapReceiver receiver = SNMPTrapReceiver.getInstance ( getManager().getProperties ( ) ); - receiver.setPluginManager ( getManager ( ) ); + private SNMPTrapReceiver getReceiver() throws IOException { - return receiver; - } + SNMPTrapReceiver receiver = SNMPTrapReceiver.getInstance(getManager().getProperties()); + receiver.setPluginManager(getManager()); + return receiver; + } - public void init ( PluginManager manager ) throws PluginException - { - super.init ( manager ); + public void init(PluginManager manager) throws PluginException { + super.init(manager); + if (SNMPTrapReceiver.hasInstance()) { + return; + } + String listen = manager.getProperty(SNMPTrapReceiver.PROP_LISTEN_ADDRESS); + if (listen == null) { + return; + } + getLog().debug("Configuring default listener: " + listen); + try { + getReceiver(); + } catch (Exception e) { + throw new PluginException(e.getMessage(), e); + } + } - if ( SNMPTrapReceiver.hasInstance ( ) ) - { - return; - } + public void configure(ConfigResponse config) throws PluginException { + super.configure(config); - String listen = manager.getProperty ( SNMPTrapReceiver.PROP_LISTEN_ADDRESS ); + try { + getReceiver().add(this); + } catch (IOException e) { + throw new PluginException(e.getMessage(), e); + } + } - if ( listen == null ) - { - return; - } + public void shutdown() throws PluginException { + super.shutdown(); - getLog().debug ( "Configuring default listener: " + listen ); - - try - { - getReceiver ( ); - } - catch ( Exception e ) - { - throw new PluginException ( e.getMessage ( ), e ); - } - } - - public void configure ( ConfigResponse config ) throws PluginException - { - super.configure ( config ); - - try - { - getReceiver().add ( this ); - } - catch ( IOException e ) - { - throw new PluginException ( e.getMessage ( ), e ); - } - } - - public void shutdown ( ) throws PluginException - { - super.shutdown ( ); - - SNMPTrapReceiver.remove ( this ); - } + SNMPTrapReceiver.remove(this); + } } |
From: <tr...@hy...> - 2010-01-06 19:59:05
|
Author: trader Date: 2010-01-06 11:58:55 -0800 (Wed, 06 Jan 2010) New Revision: 14145 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14145 Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDeviceDetector.java Log: Same as revision 14087, reformatted with project settings Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDeviceDetector.java =================================================================== --- trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDeviceDetector.java 2010-01-06 19:58:10 UTC (rev 14144) +++ trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDeviceDetector.java 2010-01-06 19:58:55 UTC (rev 14145) @@ -1,17 +1,18 @@ /* - * NOTE: This copyright does *not* cover user programs that use HQ program - * services by normal system calls through the application program interfaces - * provided as part of the Hyperic Plug-in Development Kit or the Hyperic Client - * Development Kit - this is merely considered normal use of the program, and - * does *not* fall under the heading of "derived work". Copyright (C) [2004, - * 2005, 2006], Hyperic, Inc. This file is part of HQ. HQ is free software; you - * can redistribute it and/or modify it under the terms version 2 of the GNU - * General Public License as published by the Free Software Foundation. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * 'NetworkDeviceDetector.java' NOTE: This copyright does *not* cover user + * programs that use HQ program services by normal system calls through the + * application program interfaces provided as part of the Hyperic Plug-in + * Development Kit or the Hyperic Client Development Kit - this is merely + * considered normal use of the program, and does *not* fall under the heading + * of "derived work". Copyright (C) [2004, 2005, 2006, 2007, 2008, 2009], + * Hyperic, Inc. This file is part of HQ. HQ is free software; you can + * redistribute it and/or modify it under the terms version 2 of the GNU General + * Public License as published by the Free Software Foundation. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. You + * should have received a copy of the GNU General Public License along with this + * program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place, Suite 330, Boston, MA 02111-1307 USA. */ @@ -46,7 +47,6 @@ public class NetworkDeviceDetector extends PlatformServiceDetector { - private static final String SVC_NAME = "Interface"; private static final String PROP_IF = SVC_NAME.toLowerCase(); static final String PROP_IF_IX = PROP_IF + ".index"; @@ -55,7 +55,6 @@ private static final String IF_MAC = "ifPhysAddress"; private static final String IP_IF_IX = "ipAdEntIfIndex"; private static final String IP_NETMASK = "ipAdEntNetMask"; - private static final String PROP_IP = "ipaddress"; private static final String PROP_NETMASK = "netmask"; private static final String[] FILTER_PROPS = { PROP_IP, PROP_NETMASK }; @@ -63,7 +62,6 @@ private SNMPSession session; public List discoverServices(ConfigResponse serverConfig) throws PluginException { - Log log = getLog(); List services = new ArrayList(); @@ -86,37 +84,45 @@ protected boolean hasInterfaceService() { String type = getServiceTypeName(SVC_NAME); + ProductPluginManager manager = (ProductPluginManager) getManager().getParent(); + MeasurementPlugin plugin = manager.getMeasurementPlugin(type); + if (plugin == null) { - // Interface service is not defined + // Interface service is not defined... return false; } else { // Check that ifMtu cprop exists, if so assume standard IF-MIB - // interface + // interface... return plugin.getCustomPropertiesSchema().getOption("ifMtu") != null; } } protected List discoverInterfaces(ConfigResponse serverConfig) throws PluginException { + Log log = getLog(); - Log log = getLog(); List services = new ArrayList(); String type = getServiceTypeName(SVC_NAME); if (!hasInterfaceService()) { log.debug("Skipping discovery of " + type); + return services; } String[] keys = getCustomPropertiesSchema(type).getOptionNames(); + HashMap cpropColumns = new HashMap(); + for (int i = 0; i < keys.length; i++) { String key = keys[i]; + if (Arrays.binarySearch(FILTER_PROPS, key) != -1) { continue; } + try { cpropColumns.put(key, getIfColumn(key)); } catch (PluginException e) { @@ -125,40 +131,54 @@ } String columnName = serverConfig.getValue(PROP_IF_IX); + if (columnName == null) { columnName = IF_DESCR; } + Map interfaces = getIfColumn(columnName); + log.debug("Found " + interfaces.size() + " interfaces using " + columnName); String descrColumn = columnName.equals(IF_DESCR) ? IF_NAME : IF_DESCR; + Map descriptions; try { descriptions = getIfColumn(descrColumn); } catch (PluginException e) { descriptions = new HashMap(); + String msg = "Error getting descriptions from " + descrColumn + ": " + e; + log.warn(msg); } List ip_if_ix = getColumn(IP_IF_IX); + HashMap ips = new HashMap(); + HashMap netmasks = new HashMap(); + final String IF_IX_OID = SNMPClient.getOID(IP_IF_IX) + "."; final String NETMASK_OID = SNMPClient.getOID(IP_NETMASK) + "."; + String ip, netmask; for (int i = 0; i < ip_if_ix.size(); i++) { SNMPValue value = (SNMPValue) ip_if_ix.get(i); + String oid = value.getOID(); + String ix = value.toString(); - String ix = value.toString(); if (oid.startsWith(IF_IX_OID)) { ip = oid.substring(IF_IX_OID.length()); + ips.put(ix, ip); + try { netmask = this.session.getSingleValue(NETMASK_OID + ip).toString(); + netmasks.put(ix, netmask); } catch (SNMPException e) { log.debug("Failed to get netmask for " + ip); @@ -169,7 +189,9 @@ for (Iterator it = interfaces.entrySet().iterator(); it.hasNext();) { ConfigResponse config = new ConfigResponse(); ConfigResponse cprops = new ConfigResponse(); + Map.Entry entry = (Map.Entry) it.next(); + String ix = (String) entry.getKey(); String name = (String) entry.getValue(); String mac = null; @@ -179,49 +201,65 @@ config.setValue(PROP_IF, name); config.setValue(PROP_IF_IX, columnName); service.setProductConfig(config); + // required to auto-enable metric service.setMeasurementConfig(); for (int j = 0; j < keys.length; j++) { String key = keys[j]; + Map data = (Map) cpropColumns.get(key); + if (data == null) { continue; } + String val = (String) data.get(ix); + if (val == null) { continue; } + cprops.setValue(key, val); + if (key.equals(IF_MAC)) { mac = val; } } ip = (String) ips.get(ix); + netmask = (String) netmasks.get(ix); + if (ip == null) { ip = "0.0.0.0"; } + if (netmask == null) { netmask = "0.0.0.0"; } + cprops.setValue(PROP_IP, ip); cprops.setValue(PROP_NETMASK, netmask); service.setCustomProperties(cprops); - // might be more than 1 interface w/ the same name - // so append the mac address to make it unique + // Might be more than 1 interface w/ the same name, + // so append the mac address to make it unique... name = name + " " + SVC_NAME; + if ((mac != null) && !mac.equals("0:0:0:0:0:0")) { name += " (" + mac + ")"; } + service.setServiceName(name); + Object obj = descriptions.get(ix); + if (obj != null) { service.setDescription(obj.toString()); } + services.add(service); } @@ -229,7 +267,6 @@ } static SNMPSession getSession(ConfigResponse config) throws PluginException { - try { return new SNMPClient().getSession(config); } catch (SNMPException e) { @@ -237,7 +274,7 @@ } } - // XXX these could be in a base class of some sort + // These could be in a base class of some sort... protected void openSession(ConfigResponse config) throws PluginException { this.session = getSession(config); } @@ -248,24 +285,32 @@ private String getIfIndex(SNMPValue val) { String oid = val.getOID(); + int last = oid.lastIndexOf('.'); + return oid.substring(last + 1); } protected Map getIfColumn(String name) throws PluginException { Map map = new LinkedHashMap(); + List column = getColumn(name); + for (int i = 0; i < column.size(); i++) { SNMPValue ent = (SNMPValue) column.get(i); + String ix = getIfIndex(ent); String val; + if (name.equals(IF_MAC)) { val = ent.toPhysAddressString(); } else { val = ent.toString().trim(); } + map.put(ix, val); } + return map; } @@ -277,30 +322,39 @@ } } - // use platform.name instead of the generic type name + // Use platform.name instead of the generic type name... protected String getServerName(ConfigResponse config) { String fqdn = config.getValue(ProductPlugin.PROP_PLATFORM_FQDN); String name = config.getValue(ProductPlugin.PROP_PLATFORM_NAME); + return fqdn + " " + name; } public List getServerResources(ConfigResponse config) { Log log = getLog(); + if (log.isDebugEnabled()) { log.debug("Testing snmp config=" + config); } + if (config.getValue(SNMPClient.PROP_IP) == null) { log.debug("snmp config incomplete, defering server creation"); + return null; } + try { getSession(config).getSingleValue("sysName"); + } catch (Exception e) { - // wait till we have valid snmp config at the platform level + // Wait till we have valid snmp config at the platform level... log.debug("snmp config invalid, defering server creation"); + return null; } + log.debug("snmp config valid, creating server"); + return super.getServerResources(config); } |
From: <tr...@hy...> - 2010-01-06 19:58:24
|
Author: trader Date: 2010-01-06 11:58:10 -0800 (Wed, 06 Jan 2010) New Revision: 14144 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14144 Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDeviceDetector.java Log: Same as revision 9848, reformatted with project settings Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDeviceDetector.java =================================================================== --- trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDeviceDetector.java 2010-01-06 19:56:13 UTC (rev 14143) +++ trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDeviceDetector.java 2010-01-06 19:58:10 UTC (rev 14144) @@ -1,29 +1,18 @@ /* - * 'NetworkDeviceDetector.java' - * - * - * NOTE: This copyright does *not* cover user programs that use HQ - * program services by normal system calls through the application - * program interfaces provided as part of the Hyperic Plug-in Development - * Kit or the Hyperic Client Development Kit - this is merely considered - * normal use of the program, and does *not* fall under the heading of - * "derived work". - * - * Copyright (C) [2004, 2005, 2006, 2007, 2008, 2009], Hyperic, Inc. - * This file is part of HQ. - * - * HQ is free software; you can redistribute it and/or modify - * it under the terms version 2 of the GNU General Public License as - * published by the Free Software Foundation. This program is distributed - * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. + * NOTE: This copyright does *not* cover user programs that use HQ program + * services by normal system calls through the application program interfaces + * provided as part of the Hyperic Plug-in Development Kit or the Hyperic Client + * Development Kit - this is merely considered normal use of the program, and + * does *not* fall under the heading of "derived work". Copyright (C) [2004, + * 2005, 2006], Hyperic, Inc. This file is part of HQ. HQ is free software; you + * can redistribute it and/or modify it under the terms version 2 of the GNU + * General Public License as published by the Free Software Foundation. This + * program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA. */ package org.hyperic.hq.plugin.netdevice; @@ -54,380 +43,272 @@ import org.hyperic.util.config.ConfigResponse; -public class NetworkDeviceDetector extends PlatformServiceDetector +public class NetworkDeviceDetector + extends PlatformServiceDetector { - private static final String SVC_NAME = "Interface"; - private static final String PROP_IF = SVC_NAME.toLowerCase ( ); - static final String PROP_IF_IX = PROP_IF + ".index"; - static final String IF_DESCR = "ifDescr"; - static final String IF_NAME = "ifName"; - private static final String IF_MAC = "ifPhysAddress"; - private static final String IP_IF_IX = "ipAdEntIfIndex"; - private static final String IP_NETMASK = "ipAdEntNetMask"; - private static final String PROP_IP = "ipaddress"; - private static final String PROP_NETMASK = "netmask"; - private static final String[] FILTER_PROPS = { PROP_IP, PROP_NETMASK }; - private SNMPSession session; + private static final String SVC_NAME = "Interface"; + private static final String PROP_IF = SVC_NAME.toLowerCase(); + static final String PROP_IF_IX = PROP_IF + ".index"; + static final String IF_DESCR = "ifDescr"; + static final String IF_NAME = "ifName"; + private static final String IF_MAC = "ifPhysAddress"; + private static final String IP_IF_IX = "ipAdEntIfIndex"; + private static final String IP_NETMASK = "ipAdEntNetMask"; - public List discoverServices ( ConfigResponse serverConfig ) throws PluginException - { - Log log = getLog ( ); + private static final String PROP_IP = "ipaddress"; + private static final String PROP_NETMASK = "netmask"; + private static final String[] FILTER_PROPS = { PROP_IP, PROP_NETMASK }; - List services = new ArrayList ( ); + private SNMPSession session; - openSession ( serverConfig ); + public List discoverServices(ConfigResponse serverConfig) throws PluginException { - if ( log.isDebugEnabled ( ) ) - { - log.debug ( "Using snmp config=" + serverConfig ); - } + Log log = getLog(); - services.addAll ( discoverInterfaces ( serverConfig ) ); + List services = new ArrayList(); - List extServices = SNMPDetector.discoverServices ( this, - serverConfig, - this.session ); - services.addAll ( extServices ); + openSession(serverConfig); - closeSession ( ); + if (log.isDebugEnabled()) { + log.debug("Using snmp config=" + serverConfig); + } - return services; - } + services.addAll(discoverInterfaces(serverConfig)); - protected boolean hasInterfaceService ( ) - { - String type = getServiceTypeName ( SVC_NAME ); + List extServices = SNMPDetector.discoverServices(this, serverConfig, this.session); + services.addAll(extServices); - ProductPluginManager manager = (ProductPluginManager)getManager().getParent ( ); + closeSession(); - MeasurementPlugin plugin = manager.getMeasurementPlugin ( type ); + return services; + } - if ( plugin == null ) - { - // Interface service is not defined... - return false; - } - else - { - // Check that ifMtu cprop exists, if so assume standard IF-MIB interface... - return plugin.getCustomPropertiesSchema().getOption("ifMtu") != null; - } - } + protected boolean hasInterfaceService() { + String type = getServiceTypeName(SVC_NAME); + ProductPluginManager manager = (ProductPluginManager) getManager().getParent(); + MeasurementPlugin plugin = manager.getMeasurementPlugin(type); + if (plugin == null) { + // Interface service is not defined + return false; + } else { + // Check that ifMtu cprop exists, if so assume standard IF-MIB + // interface + return plugin.getCustomPropertiesSchema().getOption("ifMtu") != null; + } + } - protected List discoverInterfaces(ConfigResponse serverConfig ) throws PluginException - { - Log log = getLog ( ); + protected List discoverInterfaces(ConfigResponse serverConfig) throws PluginException { - List services = new ArrayList ( ); + Log log = getLog(); + List services = new ArrayList(); - String type = getServiceTypeName ( SVC_NAME ); + String type = getServiceTypeName(SVC_NAME); - if ( !hasInterfaceService ( ) ) - { - log.debug ( "Skipping discovery of " + type ); + if (!hasInterfaceService()) { + log.debug("Skipping discovery of " + type); + return services; + } - return services; - } + String[] keys = getCustomPropertiesSchema(type).getOptionNames(); + HashMap cpropColumns = new HashMap(); + for (int i = 0; i < keys.length; i++) { + String key = keys[i]; + if (Arrays.binarySearch(FILTER_PROPS, key) != -1) { + continue; + } + try { + cpropColumns.put(key, getIfColumn(key)); + } catch (PluginException e) { + log.warn("Error getting '" + key + "': " + e.getMessage()); + } + } - String[] keys = getCustomPropertiesSchema(type).getOptionNames ( ); + String columnName = serverConfig.getValue(PROP_IF_IX); + if (columnName == null) { + columnName = IF_DESCR; + } + Map interfaces = getIfColumn(columnName); + log.debug("Found " + interfaces.size() + " interfaces using " + columnName); - HashMap cpropColumns = new HashMap ( ); + String descrColumn = columnName.equals(IF_DESCR) ? IF_NAME : IF_DESCR; + Map descriptions; - for ( int i = 0; i < keys.length; i++ ) - { - String key = keys[i]; + try { + descriptions = getIfColumn(descrColumn); + } catch (PluginException e) { + descriptions = new HashMap(); + String msg = "Error getting descriptions from " + descrColumn + ": " + e; + log.warn(msg); + } - if ( Arrays.binarySearch ( FILTER_PROPS, key ) != -1 ) - { - continue; - } - - try - { - cpropColumns.put ( key, getIfColumn ( key ) ); - } - catch ( PluginException e ) - { - log.warn ( "Error getting '" + key + "': " + e.getMessage ( ) ); - } - } + List ip_if_ix = getColumn(IP_IF_IX); + HashMap ips = new HashMap(); + HashMap netmasks = new HashMap(); + final String IF_IX_OID = SNMPClient.getOID(IP_IF_IX) + "."; + final String NETMASK_OID = SNMPClient.getOID(IP_NETMASK) + "."; + String ip, netmask; - String columnName = serverConfig.getValue ( PROP_IF_IX ); + for (int i = 0; i < ip_if_ix.size(); i++) { + SNMPValue value = (SNMPValue) ip_if_ix.get(i); + String oid = value.getOID(); - if ( columnName == null ) - { - columnName = IF_DESCR; - } + String ix = value.toString(); + if (oid.startsWith(IF_IX_OID)) { + ip = oid.substring(IF_IX_OID.length()); + ips.put(ix, ip); + try { + netmask = this.session.getSingleValue(NETMASK_OID + ip).toString(); + netmasks.put(ix, netmask); + } catch (SNMPException e) { + log.debug("Failed to get netmask for " + ip); + } + } + } - Map interfaces = getIfColumn ( columnName ); + for (Iterator it = interfaces.entrySet().iterator(); it.hasNext();) { + ConfigResponse config = new ConfigResponse(); + ConfigResponse cprops = new ConfigResponse(); + Map.Entry entry = (Map.Entry) it.next(); + String ix = (String) entry.getKey(); + String name = (String) entry.getValue(); + String mac = null; - log.debug ( "Found " + interfaces.size ( ) + " interfaces using " + columnName ); + ServiceResource service = createServiceResource(SVC_NAME); - String descrColumn = columnName.equals ( IF_DESCR ) ? IF_NAME : IF_DESCR; + config.setValue(PROP_IF, name); + config.setValue(PROP_IF_IX, columnName); + service.setProductConfig(config); + // required to auto-enable metric + service.setMeasurementConfig(); - Map descriptions; + for (int j = 0; j < keys.length; j++) { + String key = keys[j]; + Map data = (Map) cpropColumns.get(key); + if (data == null) { + continue; + } + String val = (String) data.get(ix); + if (val == null) { + continue; + } + cprops.setValue(key, val); + if (key.equals(IF_MAC)) { + mac = val; + } + } - try - { - descriptions = getIfColumn ( descrColumn ); - } - catch ( PluginException e ) - { - descriptions = new HashMap(); - - String msg = "Error getting descriptions from " + descrColumn + ": " + e; - - log.warn ( msg ); - } - - List ip_if_ix = getColumn ( IP_IF_IX ); - - HashMap ips = new HashMap ( ); - - HashMap netmasks = new HashMap ( ); - - final String IF_IX_OID = SNMPClient.getOID ( IP_IF_IX ) + "."; - final String NETMASK_OID = SNMPClient.getOID ( IP_NETMASK) + "."; - - String ip, netmask; - - for ( int i = 0; i < ip_if_ix.size ( ); i++ ) - { - SNMPValue value = (SNMPValue)ip_if_ix.get ( i ); - - String oid = value.getOID ( ); - String ix = value.toString ( ); - - if ( oid.startsWith ( IF_IX_OID ) ) - { - ip = oid.substring ( IF_IX_OID.length ( ) ); - - ips.put ( ix, ip ); - - try - { - netmask = this.session.getSingleValue ( NETMASK_OID + ip ).toString ( ); - - netmasks.put ( ix, netmask ); + ip = (String) ips.get(ix); + netmask = (String) netmasks.get(ix); + if (ip == null) { + ip = "0.0.0.0"; } - catch ( SNMPException e ) - { - log.debug ( "Failed to get netmask for " + ip ); + if (netmask == null) { + netmask = "0.0.0.0"; } - } - } + cprops.setValue(PROP_IP, ip); + cprops.setValue(PROP_NETMASK, netmask); - for ( Iterator it = interfaces.entrySet().iterator ( ); it.hasNext ( ); ) - { - ConfigResponse config = new ConfigResponse ( ); - ConfigResponse cprops = new ConfigResponse ( ); + service.setCustomProperties(cprops); - Map.Entry entry = (Map.Entry)it.next ( ); - - String ix = (String)entry.getKey ( ); - String name = (String)entry.getValue ( ); - String mac = null; - - ServiceResource service = createServiceResource ( SVC_NAME ); - - config.setValue ( PROP_IF, name ); - config.setValue ( PROP_IF_IX, columnName ); - service.setProductConfig ( config ); - - //required to auto-enable metric - service.setMeasurementConfig ( ); - - for ( int j = 0; j < keys.length; j++ ) - { - String key = keys[j]; - - Map data = (Map)cpropColumns.get ( key ); - - if ( data == null ) - { - continue; + // might be more than 1 interface w/ the same name + // so append the mac address to make it unique + name = name + " " + SVC_NAME; + if ((mac != null) && !mac.equals("0:0:0:0:0:0")) { + name += " (" + mac + ")"; } - - String val = (String)data.get ( ix ); - - if ( val == null ) - { - continue; + service.setServiceName(name); + Object obj = descriptions.get(ix); + if (obj != null) { + service.setDescription(obj.toString()); } + services.add(service); + } - cprops.setValue ( key, val ); + return services; + } - if ( key.equals ( IF_MAC ) ) - { - mac = val; - } - } + static SNMPSession getSession(ConfigResponse config) throws PluginException { - ip = (String)ips.get ( ix ); + try { + return new SNMPClient().getSession(config); + } catch (SNMPException e) { + throw new PluginException("Error getting SNMP session: " + e.getMessage(), e); + } + } - netmask = (String)netmasks.get ( ix ); + // XXX these could be in a base class of some sort + protected void openSession(ConfigResponse config) throws PluginException { + this.session = getSession(config); + } - if ( ip == null ) - { - ip = "0.0.0.0"; - } + protected void closeSession() { + this.session = null; + } - if ( netmask == null ) - { - netmask = "0.0.0.0"; - } + private String getIfIndex(SNMPValue val) { + String oid = val.getOID(); + int last = oid.lastIndexOf('.'); + return oid.substring(last + 1); + } - cprops.setValue ( PROP_IP, ip ); - cprops.setValue ( PROP_NETMASK, netmask ); + protected Map getIfColumn(String name) throws PluginException { + Map map = new LinkedHashMap(); + List column = getColumn(name); + for (int i = 0; i < column.size(); i++) { + SNMPValue ent = (SNMPValue) column.get(i); + String ix = getIfIndex(ent); + String val; + if (name.equals(IF_MAC)) { + val = ent.toPhysAddressString(); + } else { + val = ent.toString().trim(); + } + map.put(ix, val); + } + return map; + } - service.setCustomProperties ( cprops ); + protected List getColumn(String name) throws PluginException { + try { + return this.session.getColumn(name); + } catch (SNMPException e) { + throw new PluginException("Error getting SNMP column: " + name + ":" + e, e); + } + } - // Might be more than 1 interface w/ the same name, - // so append the mac address to make it unique... - name = name + " " + SVC_NAME; + // use platform.name instead of the generic type name + protected String getServerName(ConfigResponse config) { + String fqdn = config.getValue(ProductPlugin.PROP_PLATFORM_FQDN); + String name = config.getValue(ProductPlugin.PROP_PLATFORM_NAME); + return fqdn + " " + name; + } - if ( ( mac != null ) && !mac.equals ( "0:0:0:0:0:0" ) ) - { - name += " (" + mac + ")"; - } + public List getServerResources(ConfigResponse config) { + Log log = getLog(); + if (log.isDebugEnabled()) { + log.debug("Testing snmp config=" + config); + } + if (config.getValue(SNMPClient.PROP_IP) == null) { + log.debug("snmp config incomplete, defering server creation"); + return null; + } + try { + getSession(config).getSingleValue("sysName"); + } catch (Exception e) { + // wait till we have valid snmp config at the platform level + log.debug("snmp config invalid, defering server creation"); + return null; + } + log.debug("snmp config valid, creating server"); + return super.getServerResources(config); + } - service.setServiceName ( name ); + protected ServerResource getServer(ConfigResponse config) { + ServerResource server = super.getServer(config); - Object obj = descriptions.get ( ix ); + server.setName(getServerName(config)); - if ( obj != null ) - { - service.setDescription ( obj.toString ( ) ); - } - - services.add(service); - } - - return services; - } - - static SNMPSession getSession ( ConfigResponse config ) throws PluginException - { - try - { - return new SNMPClient().getSession ( config ); - } - catch ( SNMPException e ) - { - throw new PluginException ( "Error getting SNMP session: " + e.getMessage ( ), e ); - } - } - - // These could be in a base class of some sort... - protected void openSession ( ConfigResponse config ) throws PluginException - { - this.session = getSession ( config ); - } - - protected void closeSession ( ) - { - this.session = null; - } - - private String getIfIndex ( SNMPValue val ) - { - String oid = val.getOID(); - - int last = oid.lastIndexOf ( '.' ); - - return oid.substring ( last + 1 ); - } - - protected Map getIfColumn ( String name ) throws PluginException - { - Map map = new LinkedHashMap ( ); - - List column = getColumn ( name ); - - for ( int i = 0; i < column.size ( ); i++ ) - { - SNMPValue ent = (SNMPValue)column.get ( i ); - - String ix = getIfIndex ( ent ); - String val; - - if ( name.equals ( IF_MAC ) ) - { - val = ent.toPhysAddressString ( ); - } - else - { - val = ent.toString().trim ( ); - } - - map.put ( ix, val ); - } - - return map; - } - - protected List getColumn ( String name ) throws PluginException - { - try - { - return this.session.getColumn ( name ); - } - catch ( SNMPException e ) - { - throw new PluginException ( "Error getting SNMP column: " + name+ ":" + e, e ); - } - } - - // Use platform.name instead of the generic type name... - protected String getServerName ( ConfigResponse config ) - { - String fqdn = config.getValue ( ProductPlugin.PROP_PLATFORM_FQDN ); - String name = config.getValue ( ProductPlugin.PROP_PLATFORM_NAME ); - - return fqdn + " " + name; - } - - public List getServerResources ( ConfigResponse config ) - { - Log log = getLog ( ); - - if ( log.isDebugEnabled ( ) ) - { - log.debug ( "Testing snmp config=" + config ); - } - - if ( config.getValue ( SNMPClient.PROP_IP ) == null ) - { - log.debug ( "snmp config incomplete, defering server creation" ); - - return null; - } - - try - { - getSession ( config ).getSingleValue ( "sysName" ); - - } - catch ( Exception e ) - { - // Wait till we have valid snmp config at the platform level... - log.debug ( "snmp config invalid, defering server creation" ); - - return null; - } - - log.debug ( "snmp config valid, creating server" ); - - return super.getServerResources ( config ); - } - - protected ServerResource getServer ( ConfigResponse config ) - { - ServerResource server = super.getServer ( config ); - - server.setName ( getServerName ( config ) ); - - return server; - } + return server; + } } |
From: <tr...@hy...> - 2010-01-06 19:56:22
|
Author: trader Date: 2010-01-06 11:56:13 -0800 (Wed, 06 Jan 2010) New Revision: 14143 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14143 Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDeviceProductPlugin.java Log: Same as revision 14087, reformatted with project settings Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDeviceProductPlugin.java =================================================================== --- trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDeviceProductPlugin.java 2010-01-06 19:55:42 UTC (rev 14142) +++ trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDeviceProductPlugin.java 2010-01-06 19:56:13 UTC (rev 14143) @@ -1,17 +1,18 @@ /* - * NOTE: This copyright does *not* cover user programs that use HQ program - * services by normal system calls through the application program interfaces - * provided as part of the Hyperic Plug-in Development Kit or the Hyperic Client - * Development Kit - this is merely considered normal use of the program, and - * does *not* fall under the heading of "derived work". Copyright (C) [2004, - * 2005, 2006], Hyperic, Inc. This file is part of HQ. HQ is free software; you - * can redistribute it and/or modify it under the terms version 2 of the GNU - * General Public License as published by the Free Software Foundation. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * 'NetworkDeviceProductPlugin.java' NOTE: This copyright does *not* cover user + * programs that use HQ program services by normal system calls through the + * application program interfaces provided as part of the Hyperic Plug-in + * Development Kit or the Hyperic Client Development Kit - this is merely + * considered normal use of the program, and does *not* fall under the heading + * of "derived work". Copyright (C) [2004, 2005, 2006, 2007, 2008, 2009], + * Hyperic, Inc. This file is part of HQ. HQ is free software; you can + * redistribute it and/or modify it under the terms version 2 of the GNU General + * Public License as published by the Free Software Foundation. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. You + * should have received a copy of the GNU General Public License along with this + * program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place, Suite 330, Boston, MA 02111-1307 USA. */ @@ -25,7 +26,6 @@ public class NetworkDeviceProductPlugin extends ProductPlugin { - public void shutdown() throws PluginException { super.shutdown(); |
From: <tr...@hy...> - 2010-01-06 19:55:50
|
Author: trader Date: 2010-01-06 11:55:42 -0800 (Wed, 06 Jan 2010) New Revision: 14142 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14142 Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDeviceProductPlugin.java Log: Same as revision 3331, reformatted with project settings Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDeviceProductPlugin.java =================================================================== --- trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDeviceProductPlugin.java 2010-01-06 19:54:09 UTC (rev 14141) +++ trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDeviceProductPlugin.java 2010-01-06 19:55:42 UTC (rev 14142) @@ -1,29 +1,18 @@ /* - * 'NetworkDeviceProductPlugin.java' - * - * - * NOTE: This copyright does *not* cover user programs that use HQ - * program services by normal system calls through the application - * program interfaces provided as part of the Hyperic Plug-in Development - * Kit or the Hyperic Client Development Kit - this is merely considered - * normal use of the program, and does *not* fall under the heading of - * "derived work". - * - * Copyright (C) [2004, 2005, 2006, 2007, 2008, 2009], Hyperic, Inc. - * This file is part of HQ. - * - * HQ is free software; you can redistribute it and/or modify - * it under the terms version 2 of the GNU General Public License as - * published by the Free Software Foundation. This program is distributed - * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. + * NOTE: This copyright does *not* cover user programs that use HQ program + * services by normal system calls through the application program interfaces + * provided as part of the Hyperic Plug-in Development Kit or the Hyperic Client + * Development Kit - this is merely considered normal use of the program, and + * does *not* fall under the heading of "derived work". Copyright (C) [2004, + * 2005, 2006], Hyperic, Inc. This file is part of HQ. HQ is free software; you + * can redistribute it and/or modify it under the terms version 2 of the GNU + * General Public License as published by the Free Software Foundation. This + * program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA. */ package org.hyperic.hq.plugin.netdevice; @@ -33,19 +22,17 @@ import org.hyperic.hq.product.PluginException; import org.hyperic.hq.product.ProductPlugin; -public class NetworkDeviceProductPlugin extends ProductPlugin +public class NetworkDeviceProductPlugin + extends ProductPlugin { - public void shutdown ( ) throws PluginException - { - super.shutdown ( ); - try - { - SNMPTrapReceiver.shutdown ( ); - } - catch ( IOException e ) - { - getLog().error ( e.getMessage ( ), e ); - } - } + public void shutdown() throws PluginException { + super.shutdown(); + + try { + SNMPTrapReceiver.shutdown(); + } catch (IOException e) { + getLog().error(e.getMessage(), e); + } + } } |
From: <tr...@hy...> - 2010-01-06 19:53:34
|
Author: trader Date: 2010-01-06 11:53:23 -0800 (Wed, 06 Jan 2010) New Revision: 14140 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14140 Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkHostDetector.java Log: Same as revision 8886, reformatted with project settings Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkHostDetector.java =================================================================== --- trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkHostDetector.java 2010-01-06 19:52:07 UTC (rev 14139) +++ trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkHostDetector.java 2010-01-06 19:53:23 UTC (rev 14140) @@ -1,29 +1,18 @@ /* - * 'NetworkHostDetector.java' - * - * - * NOTE: This copyright does *not* cover user programs that use HQ - * program services by normal system calls through the application - * program interfaces provided as part of the Hyperic Plug-in Development - * Kit or the Hyperic Client Development Kit - this is merely considered - * normal use of the program, and does *not* fall under the heading of - * "derived work". - * - * Copyright (C) [2004, 2005, 2006, 2007, 2008, 2009], Hyperic, Inc. - * This file is part of HQ. - * - * HQ is free software; you can redistribute it and/or modify - * it under the terms version 2 of the GNU General Public License as - * published by the Free Software Foundation. This program is distributed - * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. + * NOTE: This copyright does *not* cover user programs that use HQ program + * services by normal system calls through the application program interfaces + * provided as part of the Hyperic Plug-in Development Kit or the Hyperic Client + * Development Kit - this is merely considered normal use of the program, and + * does *not* fall under the heading of "derived work". Copyright (C) [2004, + * 2005, 2006], Hyperic, Inc. This file is part of HQ. HQ is free software; you + * can redistribute it and/or modify it under the terms version 2 of the GNU + * General Public License as published by the Free Software Foundation. This + * program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA. */ package org.hyperic.hq.plugin.netdevice; @@ -34,42 +23,40 @@ import org.hyperic.hq.product.ServiceResource; import org.hyperic.util.config.ConfigResponse; -public class NetworkHostDetector extends NetworkDeviceDetector +public class NetworkHostDetector + extends NetworkDeviceDetector { - private static final String STORAGE_NAME = "Storage"; - private static final String PROP_STORAGE = STORAGE_NAME.toLowerCase ( ); - private static final String STORAGE_COLUMN = "hrStorageDescr"; - - public List discoverServices ( ConfigResponse serverConfig ) throws PluginException - { - List services = super.discoverServices ( serverConfig ); - openSession ( serverConfig ); + private static final String STORAGE_NAME = "Storage"; + private static final String PROP_STORAGE = STORAGE_NAME.toLowerCase(); + private static final String STORAGE_COLUMN = "hrStorageDescr"; - List storageDesc = getColumn ( STORAGE_COLUMN ); + public List discoverServices(ConfigResponse serverConfig) throws PluginException { - for ( int i = 0; i < storageDesc.size ( ); i++ ) - { - ConfigResponse config = new ConfigResponse ( ); + List services = super.discoverServices(serverConfig); - String name = storageDesc.get(i).toString().trim ( ); + openSession(serverConfig); - ServiceResource service = createServiceResource ( STORAGE_NAME ); + List storageDesc = getColumn(STORAGE_COLUMN); - config.setValue ( PROP_STORAGE, name ); + for (int i = 0; i < storageDesc.size(); i++) { + ConfigResponse config = new ConfigResponse(); + String name = storageDesc.get(i).toString().trim(); - service.setProductConfig ( config ); + ServiceResource service = createServiceResource(STORAGE_NAME); - // Required to auto-enable metric... - service.setMeasurementConfig ( ); - - service.setServiceName ( name + " " + STORAGE_NAME ); + config.setValue(PROP_STORAGE, name); + service.setProductConfig(config); + // required to auto-enable metric + service.setMeasurementConfig(); - services.add ( service ); - } + service.setServiceName(name + " " + STORAGE_NAME); - closeSession ( ); + services.add(service); + } - return services; - } + closeSession(); + + return services; + } } |
From: <tr...@hy...> - 2010-01-06 19:52:16
|
Author: trader Date: 2010-01-06 11:52:07 -0800 (Wed, 06 Jan 2010) New Revision: 14139 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14139 Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDevicePlatformDetector.java Log: Same as revision 14087, reformatted with project settings Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDevicePlatformDetector.java =================================================================== --- trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDevicePlatformDetector.java 2010-01-06 19:50:57 UTC (rev 14138) +++ trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDevicePlatformDetector.java 2010-01-06 19:52:07 UTC (rev 14139) @@ -1,26 +1,19 @@ /* - * NOTE: This copyright does *not* cover user programs that use HQ - * program services by normal system calls through the application - * program interfaces provided as part of the Hyperic Plug-in Development - * Kit or the Hyperic Client Development Kit - this is merely considered - * normal use of the program, and does *not* fall under the heading of - * "derived work". - * - * Copyright (C) [2004, 2005, 2006], Hyperic, Inc. - * This file is part of HQ. - * - * HQ is free software; you can redistribute it and/or modify - * it under the terms version 2 of the GNU General Public License as - * published by the Free Software Foundation. This program is distributed - * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. + * 'NetworkDevicePlatformDetector.java' NOTE: This copyright does *not* cover + * user programs that use HQ program services by normal system calls through the + * application program interfaces provided as part of the Hyperic Plug-in + * Development Kit or the Hyperic Client Development Kit - this is merely + * considered normal use of the program, and does *not* fall under the heading + * of "derived work". Copyright (C) [2004, 2005, 2006, 2007, 2008, 2009], + * Hyperic, Inc. This file is part of HQ. HQ is free software; you can + * redistribute it and/or modify it under the terms version 2 of the GNU General + * Public License as published by the Free Software Foundation. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. You + * should have received a copy of the GNU General Public License along with this + * program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA. */ package org.hyperic.hq.plugin.netdevice; @@ -43,7 +36,6 @@ public class NetworkDevicePlatformDetector extends PlatformDetector { - private static final String PROP_VERSION = "Version"; private Properties props; @@ -51,10 +43,13 @@ public void init(PluginManager manager) throws PluginException { super.init(manager); + this.props = manager.getProperties(); + this.autoDefaults = "true".equals(this.props.getProperty("snmp.autoDefaults")); + if (!this.autoDefaults) { - // command-line -DsnmpCommunity=public + // Command-line -DsnmpCommunity=public... this.autoDefaults = this.props.getProperty(SNMPClient.PROP_COMMUNITY) != null; } } @@ -64,6 +59,7 @@ return NetworkDeviceDetector.getSession(config); } catch (PluginException e) { getLog().error(e.getMessage(), e); + return null; } } @@ -71,59 +67,75 @@ private String getString(SNMPSession session, String oid) { try { Object obj = session.getSingleValue(oid); + if (obj == null) { return null; } + String value = obj.toString(); - // XXX cisco has \r\n in description, strip out? + + // Cisco has \r\n in description, strip out? return value; } catch (SNMPException e) { getLog().warn("Error getting '" + oid + "': " + e.getMessage()); + return null; } } - // allow defaults to be configure in agent.properties like so: - // snmpCommunity.192.168.1.102=MyCommunity - // snmpVersion.192.168.1.102=v1 - // snmpPort.192.168.1.102=1611 + // + // Allow defaults to be configure in agent.properties, e.g. + // + // snmpCommunity.192.168.1.102 = MyCommunity + // snmpVersion.192.168.1.102 = v1 + // snmpPort.192.168.1.102 = 1611 + // private String getIpProp(String key, String ip, String defVal) { String propDefault = this.props.getProperty(key, defVal); + return this.props.getProperty(key + "." + ip, propDefault); } public PlatformResource getPlatformResource(ConfigResponse config) throws PluginException { + String platformIp = config.getValue(ProductPlugin.PROP_PLATFORM_IP); - String platformIp = config.getValue(ProductPlugin.PROP_PLATFORM_IP); - // for command-line -DsnmpIp=x.x.x.x usage + // For command-line -DsnmpIp=x.x.x.x usage... platformIp = getIpProp(SNMPClient.PROP_IP, platformIp, platformIp); String defaultVersion = getIpProp(SNMPClient.PROP_VERSION, platformIp, SNMPClient.VALID_VERSIONS[1]); // v2c + String fallbackVersion = SNMPClient.VALID_VERSIONS[0]; // v1 PlatformResource platform = super.getPlatformResource(config); Log log = getLog(); + ConfigResponse metricConfig; + boolean hasConfig = config.getValue(SNMPClient.PROP_IP) != null; if (hasConfig) { - // we've already been here + // We've already been here... metricConfig = config; + if (log.isDebugEnabled()) { log.debug("Using approved snmp config=" + metricConfig); } } else if (this.autoDefaults) { - // platform was just created, attempt to auto-configure + // Platform was just created, attempt to auto-configure... metricConfig = new ConfigResponse(); + metricConfig.setValue(SNMPClient.PROP_IP, platformIp); metricConfig.setValue(SNMPClient.PROP_VERSION, defaultVersion); + metricConfig.setValue(SNMPClient.PROP_COMMUNITY, getIpProp(SNMPClient.PROP_COMMUNITY, platformIp, SNMPClient.DEFAULT_COMMUNITY)); + metricConfig.setValue(SNMPClient.PROP_PORT, getIpProp(SNMPClient.PROP_PORT, platformIp, SNMPClient.DEFAULT_PORT_STRING)); + metricConfig.setValue(NetworkDeviceDetector.PROP_IF_IX, getIpProp(NetworkDeviceDetector.PROP_IF_IX, platformIp, NetworkDeviceDetector.IF_DESCR)); @@ -134,6 +146,7 @@ if (log.isDebugEnabled()) { log.debug("Need user input for snmp config=" + config); } + return platform; } @@ -149,7 +162,9 @@ session.getSingleValue("sysName"); } catch (SNMPException e) { getLog().debug("Unable to connect using " + defaultVersion + ", trying version " + fallbackVersion); + metricConfig.setValue(SNMPClient.PROP_VERSION, fallbackVersion); + if ((session = getSession(metricConfig)) == null) { return platform; } @@ -159,40 +174,51 @@ for (int i = 0; i < keys.length; i++) { String key = keys[i]; + if (Character.isUpperCase(key.charAt(0))) { - continue; // not a mib name + continue; // Not a MIB name } + String val = getString(session, key); + if (val == null) { log.debug("'" + key + "'==null"); + continue; } + cprops.setValue(key, val); } if (!hasConfig) { - // should only happen when the platform is created + // Should only happen when the platform is created... config.merge(metricConfig, false); + platform.setProductConfig(config); platform.setMeasurementConfig(new ConfigResponse()); + log.debug("Setting measurement config=" + metricConfig); } String description = getString(session, "sysDescr"); + if (description != null) { platform.setDescription(description); boolean hasVersionCprop = getCustomPropertiesSchema().getOption(PROP_VERSION) != null; if (hasVersionCprop) { - // this works for Cisco IOS at least + // This works for Cisco IOS at least... StringTokenizer tok = new StringTokenizer(description, " ,"); while (tok.hasMoreTokens()) { String s = tok.nextToken(); + if (s.equalsIgnoreCase(PROP_VERSION) && tok.hasMoreTokens()) { String version = tok.nextToken(); + cprops.setValue(PROP_VERSION, version); + break; } } |
From: <tr...@hy...> - 2010-01-06 19:51:08
|
Author: trader Date: 2010-01-06 11:50:57 -0800 (Wed, 06 Jan 2010) New Revision: 14138 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14138 Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDevicePlatformDetector.java Log: Same as revision 4450, reformatted with project settings Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDevicePlatformDetector.java =================================================================== --- trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDevicePlatformDetector.java 2010-01-06 19:45:53 UTC (rev 14137) +++ trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/NetworkDevicePlatformDetector.java 2010-01-06 19:50:57 UTC (rev 14138) @@ -1,7 +1,4 @@ /* - * 'NetworkDevicePlatformDetector.java' - * - * * NOTE: This copyright does *not* cover user programs that use HQ * program services by normal system calls through the application * program interfaces provided as part of the Hyperic Plug-in Development @@ -9,7 +6,7 @@ * normal use of the program, and does *not* fall under the heading of * "derived work". * - * Copyright (C) [2004, 2005, 2006, 2007, 2008, 2009], Hyperic, Inc. + * Copyright (C) [2004, 2005, 2006], Hyperic, Inc. * This file is part of HQ. * * HQ is free software; you can redistribute it and/or modify @@ -43,238 +40,167 @@ import org.hyperic.snmp.SNMPSession; import org.hyperic.util.config.ConfigResponse; -public class NetworkDevicePlatformDetector extends PlatformDetector +public class NetworkDevicePlatformDetector + extends PlatformDetector { - private static final String PROP_VERSION = "Version"; - private Properties props; - private boolean autoDefaults; + private static final String PROP_VERSION = "Version"; - public void init ( PluginManager manager ) throws PluginException - { - super.init ( manager ); + private Properties props; + private boolean autoDefaults; - this.props = manager.getProperties ( ); + public void init(PluginManager manager) throws PluginException { + super.init(manager); + this.props = manager.getProperties(); + this.autoDefaults = "true".equals(this.props.getProperty("snmp.autoDefaults")); + if (!this.autoDefaults) { + // command-line -DsnmpCommunity=public + this.autoDefaults = this.props.getProperty(SNMPClient.PROP_COMMUNITY) != null; + } + } - this.autoDefaults = "true".equals ( this.props.getProperty ( "snmp.autoDefaults" ) ); + private SNMPSession getSession(ConfigResponse config) { + try { + return NetworkDeviceDetector.getSession(config); + } catch (PluginException e) { + getLog().error(e.getMessage(), e); + return null; + } + } - if ( !this.autoDefaults ) - { - // Command-line -DsnmpCommunity=public... - this.autoDefaults = this.props.getProperty ( SNMPClient.PROP_COMMUNITY ) != null; - } - } - - private SNMPSession getSession ( ConfigResponse config ) - { - try - { - return NetworkDeviceDetector.getSession ( config ); - } - catch ( PluginException e ) - { - getLog().error ( e.getMessage ( ), e ); - - return null; - } - } - - private String getString ( SNMPSession session, - String oid ) - { - try - { - Object obj = session.getSingleValue ( oid ); - - if ( obj == null ) - { + private String getString(SNMPSession session, String oid) { + try { + Object obj = session.getSingleValue(oid); + if (obj == null) { + return null; + } + String value = obj.toString(); + // XXX cisco has \r\n in description, strip out? + return value; + } catch (SNMPException e) { + getLog().warn("Error getting '" + oid + "': " + e.getMessage()); return null; - } + } + } - String value = obj.toString ( ); + // allow defaults to be configure in agent.properties like so: + // snmpCommunity.192.168.1.102=MyCommunity + // snmpVersion.192.168.1.102=v1 + // snmpPort.192.168.1.102=1611 + private String getIpProp(String key, String ip, String defVal) { + String propDefault = this.props.getProperty(key, defVal); + return this.props.getProperty(key + "." + ip, propDefault); + } - // Cisco has \r\n in description, strip out? - return value; - } - catch ( SNMPException e ) - { - getLog().warn ( "Error getting '" + oid+ "': " + e.getMessage ( ) ); + public PlatformResource getPlatformResource(ConfigResponse config) throws PluginException { - return null; - } - } + String platformIp = config.getValue(ProductPlugin.PROP_PLATFORM_IP); + // for command-line -DsnmpIp=x.x.x.x usage + platformIp = getIpProp(SNMPClient.PROP_IP, platformIp, platformIp); - // - // Allow defaults to be configure in agent.properties, e.g. - // - // snmpCommunity.192.168.1.102 = MyCommunity - // snmpVersion.192.168.1.102 = v1 - // snmpPort.192.168.1.102 = 1611 - // - private String getIpProp ( String key, - String ip, - String defVal ) - { - String propDefault = this.props.getProperty ( key, defVal ); + String defaultVersion = getIpProp(SNMPClient.PROP_VERSION, platformIp, SNMPClient.VALID_VERSIONS[1]); // v2c + String fallbackVersion = SNMPClient.VALID_VERSIONS[0]; // v1 - return this.props.getProperty ( key + "." + ip, propDefault ); - } + PlatformResource platform = super.getPlatformResource(config); - public PlatformResource getPlatformResource ( ConfigResponse config ) throws PluginException - { - String platformIp = config.getValue ( ProductPlugin.PROP_PLATFORM_IP ); + Log log = getLog(); + ConfigResponse metricConfig; + boolean hasConfig = config.getValue(SNMPClient.PROP_IP) != null; - // For command-line -DsnmpIp=x.x.x.x usage... - platformIp = getIpProp ( SNMPClient.PROP_IP, platformIp, platformIp ); + if (hasConfig) { + // we've already been here + metricConfig = config; + if (log.isDebugEnabled()) { + log.debug("Using approved snmp config=" + metricConfig); + } + } else if (this.autoDefaults) { + // platform was just created, attempt to auto-configure + metricConfig = new ConfigResponse(); + metricConfig.setValue(SNMPClient.PROP_IP, platformIp); + metricConfig.setValue(SNMPClient.PROP_VERSION, defaultVersion); + metricConfig.setValue(SNMPClient.PROP_COMMUNITY, getIpProp(SNMPClient.PROP_COMMUNITY, + platformIp, + SNMPClient.DEFAULT_COMMUNITY)); + metricConfig.setValue(SNMPClient.PROP_PORT, getIpProp(SNMPClient.PROP_PORT, + platformIp, + SNMPClient.DEFAULT_PORT_STRING)); + metricConfig.setValue(NetworkDeviceDetector.PROP_IF_IX, getIpProp(NetworkDeviceDetector.PROP_IF_IX, + platformIp, + NetworkDeviceDetector.IF_DESCR)); + if (log.isDebugEnabled()) { + log.debug("Using default snmp config=" + metricConfig); + } + } else { + if (log.isDebugEnabled()) { + log.debug("Need user input for snmp config=" + config); + } + return platform; + } - String defaultVersion = getIpProp ( SNMPClient.PROP_VERSION, - platformIp, - SNMPClient.VALID_VERSIONS[1] ); // v2c + ConfigResponse cprops = new ConfigResponse(); - String fallbackVersion = SNMPClient.VALID_VERSIONS[0]; // v1 + SNMPSession session; - PlatformResource platform = super.getPlatformResource ( config ); - - Log log = getLog ( ); - - ConfigResponse metricConfig; - - boolean hasConfig = config.getValue ( SNMPClient.PROP_IP ) != null; - - if ( hasConfig ) - { - // We've already been here... - metricConfig = config; - - if ( log.isDebugEnabled ( ) ) - { - log.debug ( "Using approved snmp config=" + metricConfig ); - } - } - else if ( this.autoDefaults ) - { - // Platform was just created, attempt to auto-configure... - metricConfig = new ConfigResponse(); - - metricConfig.setValue ( SNMPClient.PROP_IP, platformIp ); - metricConfig.setValue ( SNMPClient.PROP_VERSION, defaultVersion ); - - metricConfig.setValue ( SNMPClient.PROP_COMMUNITY, getIpProp ( SNMPClient.PROP_COMMUNITY, - platformIp, - SNMPClient.DEFAULT_COMMUNITY ) ); - - metricConfig.setValue ( SNMPClient.PROP_PORT, getIpProp ( SNMPClient.PROP_PORT, - platformIp, - SNMPClient.DEFAULT_PORT_STRING ) ); - - metricConfig.setValue ( NetworkDeviceDetector.PROP_IF_IX, getIpProp ( NetworkDeviceDetector.PROP_IF_IX, - platformIp, - NetworkDeviceDetector.IF_DESCR ) ); - if ( log.isDebugEnabled ( ) ) - { - log.debug ( "Using default snmp config=" + metricConfig ); - } - } - else - { - if ( log.isDebugEnabled ( ) ) - { - log.debug ( "Need user input for snmp config=" + config ); - } - - return platform; - } - - ConfigResponse cprops = new ConfigResponse ( ); - - SNMPSession session; - - if ( ( session = getSession ( metricConfig ) ) == null ) - { - return platform; - } - - try - { - session.getSingleValue ( "sysName" ); - } - catch ( SNMPException e ) - { - getLog().debug ( "Unable to connect using " + defaultVersion + ", trying version " + fallbackVersion ); - - metricConfig.setValue ( SNMPClient.PROP_VERSION, fallbackVersion ); - - if ( ( session = getSession ( metricConfig ) ) == null ) - { + if ((session = getSession(metricConfig)) == null) { return platform; - } - } + } - String[] keys = getCustomPropertiesSchema().getOptionNames ( ); + try { + session.getSingleValue("sysName"); + } catch (SNMPException e) { + getLog().debug("Unable to connect using " + defaultVersion + ", trying version " + fallbackVersion); + metricConfig.setValue(SNMPClient.PROP_VERSION, fallbackVersion); + if ((session = getSession(metricConfig)) == null) { + return platform; + } + } - for ( int i = 0; i < keys.length; i++ ) - { - String key = keys[i]; + String[] keys = getCustomPropertiesSchema().getOptionNames(); - if ( Character.isUpperCase ( key.charAt ( 0 ) ) ) - { - continue; // Not a MIB name - } + for (int i = 0; i < keys.length; i++) { + String key = keys[i]; + if (Character.isUpperCase(key.charAt(0))) { + continue; // not a mib name + } + String val = getString(session, key); + if (val == null) { + log.debug("'" + key + "'==null"); + continue; + } + cprops.setValue(key, val); + } - String val = getString ( session, key ); + if (!hasConfig) { + // should only happen when the platform is created + config.merge(metricConfig, false); + platform.setProductConfig(config); + platform.setMeasurementConfig(new ConfigResponse()); + log.debug("Setting measurement config=" + metricConfig); + } - if ( val == null ) - { - log.debug ( "'" + key + "'==null" ); + String description = getString(session, "sysDescr"); + if (description != null) { + platform.setDescription(description); - continue; - } - - cprops.setValue(key, val); - } + boolean hasVersionCprop = getCustomPropertiesSchema().getOption(PROP_VERSION) != null; - if ( !hasConfig ) - { - // Should only happen when the platform is created... - config.merge ( metricConfig, false ); + if (hasVersionCprop) { + // this works for Cisco IOS at least + StringTokenizer tok = new StringTokenizer(description, " ,"); - platform.setProductConfig ( config ); - platform.setMeasurementConfig ( new ConfigResponse ( ) ); - - log.debug ( "Setting measurement config=" + metricConfig ); - } - - String description = getString ( session, "sysDescr" ); - - if ( description != null ) - { - platform.setDescription ( description ); - - boolean hasVersionCprop = getCustomPropertiesSchema().getOption ( PROP_VERSION ) != null; - - if ( hasVersionCprop ) - { - // This works for Cisco IOS at least... - StringTokenizer tok = new StringTokenizer ( description, " ," ); - - while ( tok.hasMoreTokens ( ) ) - { - String s = tok.nextToken ( ); - - if ( s.equalsIgnoreCase ( PROP_VERSION ) && tok.hasMoreTokens ( ) ) - { - String version = tok.nextToken ( ); - - cprops.setValue ( PROP_VERSION, version ); - - break; - } + while (tok.hasMoreTokens()) { + String s = tok.nextToken(); + if (s.equalsIgnoreCase(PROP_VERSION) && tok.hasMoreTokens()) { + String version = tok.nextToken(); + cprops.setValue(PROP_VERSION, version); + break; + } + } } - } - } + } - platform.setCustomProperties ( cprops ); + platform.setCustomProperties(cprops); - return platform; - } + return platform; + } } |
From: <tr...@hy...> - 2010-01-06 19:46:05
|
Author: trader Date: 2010-01-06 11:45:53 -0800 (Wed, 06 Jan 2010) New Revision: 14137 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14137 Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPCollector.java Log: Same as revision 14087, reformatted with project settings Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPCollector.java =================================================================== --- trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPCollector.java 2010-01-06 19:44:57 UTC (rev 14136) +++ trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPCollector.java 2010-01-06 19:45:53 UTC (rev 14137) @@ -1,241 +1,278 @@ -/* - * NOTE: This copyright does *not* cover user programs that use HQ program - * services by normal system calls through the application program interfaces - * provided as part of the Hyperic Plug-in Development Kit or the Hyperic Client - * Development Kit - this is merely considered normal use of the program, and - * does *not* fall under the heading of "derived work". Copyright (C) [2004, - * 2005, 2006], Hyperic, Inc. This file is part of HQ. HQ is free software; you - * can redistribute it and/or modify it under the terms version 2 of the GNU - * General Public License as published by the Free Software Foundation. This - * program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package org.hyperic.hq.plugin.netdevice; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.hyperic.hq.product.Collector; -import org.hyperic.hq.product.Metric; -import org.hyperic.hq.product.MetricValue; -import org.hyperic.hq.product.PluginException; -import org.hyperic.hq.product.SNMPMeasurementPlugin; -import org.hyperic.snmp.SNMPClient; -import org.hyperic.snmp.SNMPException; -import org.hyperic.snmp.SNMPSession; -import org.hyperic.snmp.SNMPValue; - -public class SNMPCollector - extends Collector -{ - protected static final String PROP_COLUMN = "snmpColumn"; - protected Properties _props; - protected SNMPClient _client; - - private static final String[][] DEFAULT_PROPS = { { SNMPClient.PROP_IP, SNMPClient.DEFAULT_IP }, - { SNMPClient.PROP_PORT, SNMPClient.DEFAULT_PORT_STRING }, - { SNMPClient.PROP_VERSION, SNMPClient.VALID_VERSIONS[1] }, - { SNMPClient.PROP_COMMUNITY, SNMPClient.DEFAULT_COMMUNITY } }; - - protected Log getLog() { - return LogFactory.getLog(getClass().getName()); - } - - protected String getInfo() { - String info = _props.getProperty(SNMPClient.PROP_IP) + ":" + _props.getProperty(SNMPClient.PROP_PORT) + " " + - _props.getProperty(SNMPClient.PROP_VERSION) + "," + _props.getProperty(SNMPClient.PROP_COMMUNITY); - return info; - } - - protected boolean isEmpty(List list, String name) { - boolean isEmpty; - if (list == null) { - isEmpty = true; - } else { - isEmpty = list.isEmpty(); - } - if (isEmpty) { - setErrorMessage("No data returned for: " + name); - } - return isEmpty; - } - - protected boolean isEmpty(Map map, String name) { - boolean isEmpty; - if (map == null) { - isEmpty = true; - } else { - isEmpty = map.isEmpty(); - } - if (isEmpty) { - setErrorMessage("No data returned for: " + name); - } - return isEmpty; - } - - protected boolean isAvailability() { - String availName = getPlugin().getTypeProperty(Metric.ATTR_AVAIL); - if (availName == null) { - return false; - } - return getCounterName().equals(availName); - } - - protected String getColumnName() { - return _props.getProperty(PROP_COLUMN); - } - - protected String getCounterName() { - return _props.getProperty(PROP_COLUMN); - } - - protected String getIndexName() { - return _props.getProperty(SNMPMeasurementPlugin.PROP_INDEX_NAME); - } - - protected String getColumnIndex(SNMPValue val) { - String oid = val.getOID(); - int last = oid.lastIndexOf('.'); - return oid.substring(last + 1); - } - - protected Map getIndexedColumn(SNMPSession session, String name) throws SNMPException { - - return getIndexedColumn(session, name, true); - } - - protected Map getIndexedColumn(SNMPSession session, String name, boolean asString) throws SNMPException { - // XXX expose walk() in SNMPClient - List column; - Map values = new HashMap(); - try { - column = session.getBulk(name); - if (isEmpty(column, name)) { - return values; - } - for (int i = 0; i < column.size(); i++) { - SNMPValue val = (SNMPValue) column.get(i); - String ix = getColumnIndex(val); - Object obj; - if (asString) { - obj = val.toString().trim(); - } else { - obj = val; - } - values.put(ix, obj); - } - } catch (Exception e) { - getLog().error("getBulk(" + name + "): " + e); - return null; - } - return values; - } - - public interface ColumnValueConverter { - public double convert(String index, SNMPValue value) throws Exception; - } - - public static class GenericColumnValueConverter implements ColumnValueConverter { - - public double convert(String index, SNMPValue value) throws Exception { - return value.toLong(); - } - } - - protected SNMPSession getSession() throws Exception { - try { - return _client.getSession(_props); - } catch (Exception e) { - setErrorMessage(e.getMessage()); - throw e; - } - } - - protected boolean isTotalCounter(String name) { - return false; - } - - protected void collectIndexedColumn() { - collectIndexedColumn(new GenericColumnValueConverter()); - } - - protected void collectIndexedColumn(ColumnValueConverter converter) { - String indexName = getIndexName(); - String columnName = getColumnName(); - String counterName = getCounterName(); - boolean isAvail = isAvailability(); - SNMPSession session; - List column; - Map indexNames; - boolean doTotal = isTotalCounter(counterName); - double total = 0.0; - - try { - session = getSession(); - indexNames = getIndexedColumn(session, indexName); - column = session.getBulk(columnName); - } catch (Exception e) { - return; - } - if (isEmpty(column, columnName) || isEmpty(indexNames, indexName)) { - return; - } - - for (int i = 0; i < column.size(); i++) { - SNMPValue val = (SNMPValue) column.get(i); - String ix = getColumnIndex(val); - String name = (String) indexNames.get(ix); - try { - double value = converter.convert(ix, val); - if (doTotal && (value > 0.0) && (value != MetricValue.VALUE_NONE)) { - total += value; - } - setValue(name + "." + counterName, value); - } catch (Exception e) { - getLog().warn(columnName + ".convert failed for " + name + "@" + getInfo()); - } - if (isAvail) { - setValue(name + "." + Metric.ATTR_AVAIL, Metric.AVAIL_UP); - } - } - if (doTotal) { - setValue("_TOTAL_" + "." + counterName, total); - } - } - - public void init() throws PluginException { - _client = new SNMPClient(); - _props = getProperties(); - for (int i = 0; i < DEFAULT_PROPS.length; i++) { - String key = DEFAULT_PROPS[i][0]; - String val = DEFAULT_PROPS[i][1]; - if (_props.getProperty(key) == null) { - _props.setProperty(key, val); - } - } - setSource(getInfo()); - try { - init(_client.getSession(_props)); - } catch (SNMPException e) { - throw new PluginException(getInfo() + ": " + e.getMessage()); - } - } - - protected void init(SNMPSession session) throws PluginException { - - } - - public void collect() { - - } -} +/* + * 'SNMPCollector.java' NOTE: This copyright does *not* cover user programs that + * use HQ program services by normal system calls through the application + * program interfaces provided as part of the Hyperic Plug-in Development Kit or + * the Hyperic Client Development Kit - this is merely considered normal use of + * the program, and does *not* fall under the heading of "derived work". + * Copyright (C) [2004, 2005, 2006, 2007, 2008, 2009], Hyperic, Inc. This file + * is part of HQ. HQ is free software; you can redistribute it and/or modify it + * under the terms version 2 of the GNU General Public License as published by + * the Free Software Foundation. This program is distributed in the hope that it + * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. You should have received a copy of the GNU + * General Public License along with this program; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + */ + +package org.hyperic.hq.plugin.netdevice; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.hyperic.hq.product.Collector; +import org.hyperic.hq.product.Metric; +import org.hyperic.hq.product.MetricValue; +import org.hyperic.hq.product.PluginException; +import org.hyperic.hq.product.SNMPMeasurementPlugin; +import org.hyperic.snmp.SNMPClient; +import org.hyperic.snmp.SNMPException; +import org.hyperic.snmp.SNMPSession; +import org.hyperic.snmp.SNMPValue; + +public class SNMPCollector + extends Collector +{ + protected static final String PROP_COLUMN = "snmpColumn"; + protected Properties _props; + protected SNMPClient _client; + + private static final String[][] DEFAULT_PROPS = { { SNMPClient.PROP_IP, SNMPClient.DEFAULT_IP }, + { SNMPClient.PROP_PORT, SNMPClient.DEFAULT_PORT_STRING }, + { SNMPClient.PROP_VERSION, SNMPClient.VALID_VERSIONS[1] }, + { SNMPClient.PROP_COMMUNITY, SNMPClient.DEFAULT_COMMUNITY } }; + + protected Log getLog() { + return LogFactory.getLog(getClass().getName()); + } + + protected String getInfo() { + String info = _props.getProperty(SNMPClient.PROP_IP) + ":" + _props.getProperty(SNMPClient.PROP_PORT) + " " + + _props.getProperty(SNMPClient.PROP_VERSION) + "," + _props.getProperty(SNMPClient.PROP_COMMUNITY); + + return info; + } + + protected boolean isEmpty(List list, String name) { + boolean isEmpty; + + if (list == null) { + isEmpty = true; + } else { + isEmpty = list.isEmpty(); + } + if (isEmpty) { + setErrorMessage("No data returned for: " + name); + } + + return isEmpty; + } + + protected boolean isEmpty(Map map, String name) { + boolean isEmpty; + + if (map == null) { + isEmpty = true; + } else { + isEmpty = map.isEmpty(); + } + + if (isEmpty) { + setErrorMessage("No data returned for: " + name); + } + + return isEmpty; + } + + protected boolean isAvailability() { + String availName = getPlugin().getTypeProperty(Metric.ATTR_AVAIL); + + if (availName == null) { + return false; + } + + return getCounterName().equals(availName); + } + + protected String getColumnName() { + return _props.getProperty(PROP_COLUMN); + } + + protected String getCounterName() { + return _props.getProperty(PROP_COLUMN); + } + + protected String getIndexName() { + return _props.getProperty(SNMPMeasurementPlugin.PROP_INDEX_NAME); + } + + protected String getColumnIndex(SNMPValue val) { + String oid = val.getOID(); + + int last = oid.lastIndexOf('.'); + + return oid.substring(last + 1); + } + + protected Map getIndexedColumn(SNMPSession session, String name) throws SNMPException { + return getIndexedColumn(session, name, true); + } + + protected Map getIndexedColumn(SNMPSession session, String name, boolean asString) throws SNMPException { + // Expose walk() in SNMPClient... + List column; + + Map values = new HashMap(); + + try { + column = session.getBulk(name); + + if (isEmpty(column, name)) { + return values; + } + + for (int i = 0; i < column.size(); i++) { + SNMPValue val = (SNMPValue) column.get(i); + + String ix = getColumnIndex(val); + + Object obj; + + if (asString) { + obj = val.toString().trim(); + } else { + obj = val; + } + + values.put(ix, obj); + } + } catch (Exception e) { + getLog().error("getBulk ( " + name + " ): " + e); + + return null; + } + + return values; + } + + public interface ColumnValueConverter { + public double convert(String index, SNMPValue value) throws Exception; + } + + public static class GenericColumnValueConverter implements ColumnValueConverter { + public double convert(String index, SNMPValue value) throws Exception { + return value.toLong(); + } + } + + protected SNMPSession getSession() throws Exception { + try { + return _client.getSession(_props); + } catch (Exception e) { + setErrorMessage(e.getMessage()); + throw e; + } + } + + protected boolean isTotalCounter(String name) { + return false; + } + + protected void collectIndexedColumn() { + collectIndexedColumn(new GenericColumnValueConverter()); + } + + protected void collectIndexedColumn(ColumnValueConverter converter) { + String indexName = getIndexName(); + String columnName = getColumnName(); + String counterName = getCounterName(); + + boolean isAvail = isAvailability(); + + SNMPSession session; + + List column; + + Map indexNames; + + boolean doTotal = isTotalCounter(counterName); + + double total = 0.0; + + try { + session = getSession(); + + indexNames = getIndexedColumn(session, indexName); + + column = session.getBulk(columnName); + } catch (Exception e) { + return; + } + + if (isEmpty(column, columnName) || isEmpty(indexNames, indexName)) { + return; + } + + for (int i = 0; i < column.size(); i++) { + SNMPValue val = (SNMPValue) column.get(i); + + String ix = getColumnIndex(val); + String name = (String) indexNames.get(ix); + + try { + double value = converter.convert(ix, val); + + if (doTotal && (value > 0.0) && (value != MetricValue.VALUE_NONE)) { + total += value; + } + + setValue(name + "." + counterName, value); + } catch (Exception e) { + getLog().warn(columnName + ".convert failed for " + name + "@" + getInfo()); + } + + if (isAvail) { + setValue(name + "." + Metric.ATTR_AVAIL, Metric.AVAIL_UP); + } + } + + if (doTotal) { + setValue("_TOTAL_" + "." + counterName, total); + } + } + + public void init() throws PluginException { + _client = new SNMPClient(); + + _props = getProperties(); + + for (int i = 0; i < DEFAULT_PROPS.length; i++) { + String key = DEFAULT_PROPS[i][0]; + String val = DEFAULT_PROPS[i][1]; + + if (_props.getProperty(key) == null) { + _props.setProperty(key, val); + } + } + + setSource(getInfo()); + + try { + init(_client.getSession(_props)); + } catch (SNMPException e) { + throw new PluginException(getInfo() + ": " + e.getMessage()); + } + } + + protected void init(SNMPSession session) throws PluginException { + } + + public void collect() { + } +} |
From: <tr...@hy...> - 2010-01-06 19:45:06
|
Author: trader Date: 2010-01-06 11:44:57 -0800 (Wed, 06 Jan 2010) New Revision: 14136 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14136 Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPCollector.java Log: Same as revision 9972, reformatted with project settings Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPCollector.java =================================================================== --- trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPCollector.java 2010-01-06 19:36:44 UTC (rev 14135) +++ trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPCollector.java 2010-01-06 19:44:57 UTC (rev 14136) @@ -1,30 +1,19 @@ -/* - * 'SNMPCollector.java' - * - * - * NOTE: This copyright does *not* cover user programs that use HQ - * program services by normal system calls through the application - * program interfaces provided as part of the Hyperic Plug-in Development - * Kit or the Hyperic Client Development Kit - this is merely considered - * normal use of the program, and does *not* fall under the heading of - * "derived work". - * - * Copyright (C) [2004, 2005, 2006, 2007, 2008, 2009], Hyperic, Inc. - * This file is part of HQ. - * - * HQ is free software; you can redistribute it and/or modify - * it under the terms version 2 of the GNU General Public License as - * published by the Free Software Foundation. This program is distributed - * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - */ +/* + * NOTE: This copyright does *not* cover user programs that use HQ program + * services by normal system calls through the application program interfaces + * provided as part of the Hyperic Plug-in Development Kit or the Hyperic Client + * Development Kit - this is merely considered normal use of the program, and + * does *not* fall under the heading of "derived work". Copyright (C) [2004, + * 2005, 2006], Hyperic, Inc. This file is part of HQ. HQ is free software; you + * can redistribute it and/or modify it under the terms version 2 of the GNU + * General Public License as published by the Free Software Foundation. This + * program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place, Suite 330, Boston, MA 02111-1307 USA. + */ package org.hyperic.hq.plugin.netdevice; @@ -46,309 +35,207 @@ import org.hyperic.snmp.SNMPSession; import org.hyperic.snmp.SNMPValue; -public class SNMPCollector extends Collector +public class SNMPCollector + extends Collector { - protected static final String PROP_COLUMN = "snmpColumn"; - protected Properties _props; - protected SNMPClient _client; + protected static final String PROP_COLUMN = "snmpColumn"; + protected Properties _props; + protected SNMPClient _client; - private static final String[][] DEFAULT_PROPS = - { - { SNMPClient.PROP_IP, SNMPClient.DEFAULT_IP }, - { SNMPClient.PROP_PORT, SNMPClient.DEFAULT_PORT_STRING }, - { SNMPClient.PROP_VERSION, SNMPClient.VALID_VERSIONS[1] }, - { SNMPClient.PROP_COMMUNITY, SNMPClient.DEFAULT_COMMUNITY } - }; + private static final String[][] DEFAULT_PROPS = { { SNMPClient.PROP_IP, SNMPClient.DEFAULT_IP }, + { SNMPClient.PROP_PORT, SNMPClient.DEFAULT_PORT_STRING }, + { SNMPClient.PROP_VERSION, SNMPClient.VALID_VERSIONS[1] }, + { SNMPClient.PROP_COMMUNITY, SNMPClient.DEFAULT_COMMUNITY } }; - protected Log getLog ( ) - { - return LogFactory.getLog ( getClass().getName ( ) ); - } - - protected String getInfo ( ) - { - String info = _props.getProperty ( SNMPClient.PROP_IP ) + ":" + - _props.getProperty ( SNMPClient.PROP_PORT ) + " " + - _props.getProperty ( SNMPClient.PROP_VERSION ) + "," + - _props.getProperty ( SNMPClient.PROP_COMMUNITY ); - - return info; - } + protected Log getLog() { + return LogFactory.getLog(getClass().getName()); + } - protected boolean isEmpty ( List list, - String name) - { - boolean isEmpty; + protected String getInfo() { + String info = _props.getProperty(SNMPClient.PROP_IP) + ":" + _props.getProperty(SNMPClient.PROP_PORT) + " " + + _props.getProperty(SNMPClient.PROP_VERSION) + "," + _props.getProperty(SNMPClient.PROP_COMMUNITY); + return info; + } - if ( list == null ) - { - isEmpty = true; - } - else - { - isEmpty = list.isEmpty ( ); - } - if ( isEmpty ) - { - setErrorMessage ( "No data returned for: " + name ); - } - - return isEmpty; - } + protected boolean isEmpty(List list, String name) { + boolean isEmpty; + if (list == null) { + isEmpty = true; + } else { + isEmpty = list.isEmpty(); + } + if (isEmpty) { + setErrorMessage("No data returned for: " + name); + } + return isEmpty; + } - protected boolean isEmpty ( Map map, - String name) - { - boolean isEmpty; - - if ( map == null ) - { - isEmpty = true; - } - else - { - isEmpty = map.isEmpty ( ); - } - - if ( isEmpty ) - { - setErrorMessage ( "No data returned for: " + name ); - } - - return isEmpty; - } - - protected boolean isAvailability ( ) - { - String availName = getPlugin().getTypeProperty ( Metric.ATTR_AVAIL ); + protected boolean isEmpty(Map map, String name) { + boolean isEmpty; + if (map == null) { + isEmpty = true; + } else { + isEmpty = map.isEmpty(); + } + if (isEmpty) { + setErrorMessage("No data returned for: " + name); + } + return isEmpty; + } - if ( availName == null ) - { - return false; - } - - return getCounterName().equals ( availName ); - } + protected boolean isAvailability() { + String availName = getPlugin().getTypeProperty(Metric.ATTR_AVAIL); + if (availName == null) { + return false; + } + return getCounterName().equals(availName); + } - protected String getColumnName ( ) - { - return _props.getProperty ( PROP_COLUMN ); - } + protected String getColumnName() { + return _props.getProperty(PROP_COLUMN); + } - protected String getCounterName ( ) - { - return _props.getProperty ( PROP_COLUMN ); - } + protected String getCounterName() { + return _props.getProperty(PROP_COLUMN); + } - protected String getIndexName ( ) - { - return _props.getProperty ( SNMPMeasurementPlugin.PROP_INDEX_NAME ); - } + protected String getIndexName() { + return _props.getProperty(SNMPMeasurementPlugin.PROP_INDEX_NAME); + } - protected String getColumnIndex ( SNMPValue val ) - { - String oid = val.getOID ( ); - - int last = oid.lastIndexOf ( '.' ); - - return oid.substring ( last + 1 ); - } + protected String getColumnIndex(SNMPValue val) { + String oid = val.getOID(); + int last = oid.lastIndexOf('.'); + return oid.substring(last + 1); + } - protected Map getIndexedColumn ( SNMPSession session, - String name ) throws SNMPException - { - return getIndexedColumn ( session, name, true ); - } + protected Map getIndexedColumn(SNMPSession session, String name) throws SNMPException { - protected Map getIndexedColumn ( SNMPSession session, - String name, - boolean asString ) throws SNMPException - { - // Expose walk() in SNMPClient... - List column; - - Map values = new HashMap ( ); - - try - { - column = session.getBulk ( name ); + return getIndexedColumn(session, name, true); + } - if ( isEmpty ( column, name ) ) - { - return values; - } - - for ( int i = 0; i < column.size ( ); i++ ) - { - SNMPValue val = (SNMPValue)column.get ( i ); - - String ix = getColumnIndex ( val ); - - Object obj; - - if ( asString ) - { - obj = val.toString().trim ( ); + protected Map getIndexedColumn(SNMPSession session, String name, boolean asString) throws SNMPException { + // XXX expose walk() in SNMPClient + List column; + Map values = new HashMap(); + try { + column = session.getBulk(name); + if (isEmpty(column, name)) { + return values; } - else - { - obj = val; + for (int i = 0; i < column.size(); i++) { + SNMPValue val = (SNMPValue) column.get(i); + String ix = getColumnIndex(val); + Object obj; + if (asString) { + obj = val.toString().trim(); + } else { + obj = val; + } + values.put(ix, obj); } - - values.put ( ix, obj ); - } - } - catch ( Exception e ) - { - getLog().error ( "getBulk ( " + name + " ): " + e ); - - return null; - } - - return values; - } + } catch (Exception e) { + getLog().error("getBulk(" + name + "): " + e); + return null; + } + return values; + } - public interface ColumnValueConverter - { - public double convert ( String index, - SNMPValue value ) throws Exception; - } + public interface ColumnValueConverter { + public double convert(String index, SNMPValue value) throws Exception; + } - public static class GenericColumnValueConverter implements ColumnValueConverter - { - public double convert ( String index, - SNMPValue value ) throws Exception - { - return value.toLong ( ); - } - } + public static class GenericColumnValueConverter implements ColumnValueConverter { - protected SNMPSession getSession ( ) throws Exception - { - try - { - return _client.getSession ( _props ); - } - catch ( Exception e ) - { - setErrorMessage ( e.getMessage ( ) ); - throw e; - } - } + public double convert(String index, SNMPValue value) throws Exception { + return value.toLong(); + } + } - protected boolean isTotalCounter ( String name ) - { - return false; - } + protected SNMPSession getSession() throws Exception { + try { + return _client.getSession(_props); + } catch (Exception e) { + setErrorMessage(e.getMessage()); + throw e; + } + } - protected void collectIndexedColumn ( ) - { - collectIndexedColumn ( new GenericColumnValueConverter ( ) ); - } + protected boolean isTotalCounter(String name) { + return false; + } - protected void collectIndexedColumn ( ColumnValueConverter converter ) - { - String indexName = getIndexName ( ); - String columnName = getColumnName ( ); - String counterName = getCounterName ( ); + protected void collectIndexedColumn() { + collectIndexedColumn(new GenericColumnValueConverter()); + } - boolean isAvail = isAvailability ( ); - - SNMPSession session; - - List column; - - Map indexNames; - - boolean doTotal = isTotalCounter ( counterName ); - - double total = 0.0; + protected void collectIndexedColumn(ColumnValueConverter converter) { + String indexName = getIndexName(); + String columnName = getColumnName(); + String counterName = getCounterName(); + boolean isAvail = isAvailability(); + SNMPSession session; + List column; + Map indexNames; + boolean doTotal = isTotalCounter(counterName); + double total = 0.0; - try - { - session = getSession ( ); - - indexNames = getIndexedColumn ( session, indexName ); - - column = session.getBulk ( columnName ); - } - catch ( Exception e ) - { - return; - } - - if ( isEmpty ( column, columnName ) || isEmpty ( indexNames, indexName ) ) - { - return; - } + try { + session = getSession(); + indexNames = getIndexedColumn(session, indexName); + column = session.getBulk(columnName); + } catch (Exception e) { + return; + } + if (isEmpty(column, columnName) || isEmpty(indexNames, indexName)) { + return; + } - for ( int i = 0; i < column.size ( ); i++ ) - { - SNMPValue val = (SNMPValue)column.get ( i ); - - String ix = getColumnIndex ( val ); - String name = (String)indexNames.get ( ix ); - - try - { - double value = converter.convert ( ix, val ); + for (int i = 0; i < column.size(); i++) { + SNMPValue val = (SNMPValue) column.get(i); + String ix = getColumnIndex(val); + String name = (String) indexNames.get(ix); + try { + double value = converter.convert(ix, val); + if (doTotal && (value > 0.0) && (value != MetricValue.VALUE_NONE)) { + total += value; + } + setValue(name + "." + counterName, value); + } catch (Exception e) { + getLog().warn(columnName + ".convert failed for " + name + "@" + getInfo()); + } + if (isAvail) { + setValue(name + "." + Metric.ATTR_AVAIL, Metric.AVAIL_UP); + } + } + if (doTotal) { + setValue("_TOTAL_" + "." + counterName, total); + } + } - if ( doTotal && ( value > 0.0 ) && ( value != MetricValue.VALUE_NONE ) ) - { - total += value; + public void init() throws PluginException { + _client = new SNMPClient(); + _props = getProperties(); + for (int i = 0; i < DEFAULT_PROPS.length; i++) { + String key = DEFAULT_PROPS[i][0]; + String val = DEFAULT_PROPS[i][1]; + if (_props.getProperty(key) == null) { + _props.setProperty(key, val); } - - setValue ( name + "." + counterName, value ); - } - catch ( Exception e ) - { - getLog().warn ( columnName + ".convert failed for " + name + "@" + getInfo ( ) ); - } - - if ( isAvail ) - { - setValue ( name + "." + Metric.ATTR_AVAIL, Metric.AVAIL_UP ); - } - } + } + setSource(getInfo()); + try { + init(_client.getSession(_props)); + } catch (SNMPException e) { + throw new PluginException(getInfo() + ": " + e.getMessage()); + } + } - if ( doTotal ) - { - setValue ( "_TOTAL_" + "." + counterName, total ); - } - } + protected void init(SNMPSession session) throws PluginException { - public void init ( ) throws PluginException - { - _client = new SNMPClient ( ); + } - _props = getProperties ( ); - - for ( int i = 0; i < DEFAULT_PROPS.length; i++ ) - { - String key = DEFAULT_PROPS[i][0]; - String val = DEFAULT_PROPS[i][1]; + public void collect() { - if ( _props.getProperty ( key ) == null ) - { - _props.setProperty ( key, val ); - } - } - - setSource ( getInfo ( ) ); - - try - { - init ( _client.getSession ( _props ) ); - } - catch ( SNMPException e ) - { - throw new PluginException ( getInfo ( ) + ": " + e.getMessage ( ) ); - } - } - - protected void init ( SNMPSession session ) throws PluginException - { } - - public void collect ( ) - { } + } } |
From: <tr...@hy...> - 2010-01-06 19:36:56
|
Author: trader Date: 2010-01-06 11:36:44 -0800 (Wed, 06 Jan 2010) New Revision: 14135 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14135 Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiver.java Log: Same as revision 14133 (ALSO 14087, NOT 10487!), reformatted with project settings Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiver.java =================================================================== --- trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiver.java 2010-01-06 19:34:18 UTC (rev 14134) +++ trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiver.java 2010-01-06 19:36:44 UTC (rev 14135) @@ -1,3 +1,21 @@ +/* + * 'SNMPTrapReceiver.java' NOTE: This copyright does *not* cover user programs + * that use HQ program services by normal system calls through the application + * program interfaces provided as part of the Hyperic Plug-in Development Kit or + * the Hyperic Client Development Kit - this is merely considered normal use of + * the program, and does *not* fall under the heading of "derived work". + * Copyright (C) [2004, 2005, 2006, 2007, 2008, 2009], Hyperic, Inc. This file + * is part of HQ. HQ is free software; you can redistribute it and/or modify it + * under the terms version 2 of the GNU General Public License as published by + * the Free Software Foundation. This program is distributed in the hope that it + * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. You should have received a copy of the GNU + * General Public License along with this program; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + */ + package org.hyperic.hq.plugin.netdevice; import java.io.IOException; @@ -36,11 +54,11 @@ import org.snmp4j.util.ThreadPool; public class SNMPTrapReceiver implements CommandResponder { - static final String PROP_LISTEN_ADDRESS = "snmpTrapReceiver.listenAddress"; static final String DEFAULT_LISTEN_ADDRESS = "udp:0.0.0.0/162"; private static SNMPTrapReceiver instance = null; + private static final Log log = LogFactory.getLog(SNMPTrapReceiver.class.getName()); private MultiThreadedMessageDispatcher _dispatcher; @@ -48,6 +66,7 @@ private Address _listenAddress; private ThreadPool _threadPool; private Map _plugins = new HashMap(); + LogTrackPluginManager _manager; private int _received = 0; @@ -57,7 +76,6 @@ } public static SNMPTrapReceiver getInstance(Properties props) throws IOException { - if (!hasInstance()) { instance = new SNMPTrapReceiver(); instance.init(props); @@ -67,15 +85,16 @@ } public static void start(Properties props) throws IOException { - getInstance(props); } public static void shutdown() throws IOException { if (hasInstance()) { log.debug("Shutdown instance"); + instance._threadPool.cancel(); instance._snmp.close(); + instance = null; } } @@ -85,10 +104,10 @@ } private static String getConfig(LogTrackPlugin plugin, String key, String def) { + String value = plugin.getConfig(key); - String value = plugin.getConfig(key); if (value == null) { - // commandline-testing + // Commandline-testing... return plugin.getManager().getProperty(key, def); } else { return value; @@ -105,13 +124,15 @@ private LogTrackPlugin getPlugin(String address, String community) { String key = getPluginKey(address, community); + return (LogTrackPlugin) _plugins.get(key); } public void add(LogTrackPlugin plugin) throws IOException { + String key = getPluginKey(plugin); - String key = getPluginKey(plugin); log.debug("Add " + plugin.getName() + " for " + key); + _plugins.put(key, plugin); } @@ -119,8 +140,11 @@ if (!hasInstance()) { return; } + String key = getPluginKey(plugin); + log.debug("Remove " + plugin.getName() + " for " + key); + instance._plugins.remove(key); } @@ -128,7 +152,6 @@ } private void init(Properties props) throws IOException { - String address = props.getProperty(PROP_LISTEN_ADDRESS, DEFAULT_LISTEN_ADDRESS).trim(); String numThreads = props.getProperty("snmpTrapReceiver.numThreads", "1"); @@ -139,6 +162,7 @@ try { _listenAddress = GenericAddress.parse(address); + if (!_listenAddress.isValid()) { throw new IllegalArgumentException(); } @@ -149,6 +173,7 @@ log.debug(PROP_LISTEN_ADDRESS + "=" + address); TransportMapping transport; + if (_listenAddress instanceof UdpAddress) { transport = new DefaultUdpTransportMapping((UdpAddress) _listenAddress); } else { @@ -156,11 +181,13 @@ } _snmp = new Snmp(_dispatcher, transport); + _snmp.getMessageDispatcher().addMessageProcessingModel(new MPv1()); _snmp.getMessageDispatcher().addMessageProcessingModel(new MPv2c()); _snmp.getMessageDispatcher().addMessageProcessingModel(new MPv3()); USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0); + SecurityModels.getInstance().addSecurityModel(usm); _snmp.addCommandResponder(this); @@ -175,10 +202,14 @@ StringBuffer msg = new StringBuffer(); Vector vars = event.getPDU().getVariableBindings(); + int size = vars.size(); + for (int i = 0; i < size; i++) { VariableBinding var = (VariableBinding) vars.get(i); + msg.append(var.getVariable().toString().trim()); + if (i < size - 1) { msg.append(", "); } @@ -188,9 +219,11 @@ } private LogTrackPlugin getPlatformPlugin() { - // XXX return _manager.getDefaultPlatformPlugin() + // return _manager.getDefaultPlatformPlugin ( ) final String prop = LogTrackPluginManager.DEFAULT_PLATFORM_PLUGIN; + String name = _manager.getProperty(prop); + return _manager.getLogTrackPlugin(name); } @@ -202,13 +235,16 @@ _received++; Address peer = event.getPeerAddress(); + InetAddress peerAddress; + if (peer instanceof UdpAddress) { peerAddress = ((UdpAddress) peer).getInetAddress(); } else if (peer instanceof TcpAddress) { peerAddress = ((TcpAddress) peer).getInetAddress(); } else { log.debug("Unsupported transport: " + peer.getClass().getName()); + return; } @@ -217,23 +253,28 @@ String community = new OctetString(event.getSecurityName()).toString(); LogTrackPlugin plugin = getPlugin(address, community); + if (plugin == null) { plugin = getPlatformPlugin(); + if (plugin != null) { if (log.isDebugEnabled()) { log.debug("No plugin for " + address + ", routing to default platform: " + plugin.getName()); } } } + if (plugin == null) { if (log.isDebugEnabled()) { log.debug("No plugin for " + address + ", msg=" + getMessage(event)); } } else { String msg = getMessage(event); + if (log.isDebugEnabled()) { log.debug("Msg=" + msg); } + plugin.reportEvent(System.currentTimeMillis(), LogTrackPlugin.LOGLEVEL_ERROR, address, msg); } } @@ -244,7 +285,9 @@ System.out.println("Ready"); System.in.read(); System.out.print("Shutting down..."); + SNMPTrapReceiver.shutdown(); + System.out.println("done"); } } |
From: <tr...@hy...> - 2010-01-06 19:34:26
|
Author: trader Date: 2010-01-06 11:34:18 -0800 (Wed, 06 Jan 2010) New Revision: 14134 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14134 Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiver.java Log: Same as revision 14132, reformatted with project settings Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiver.java =================================================================== --- trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiver.java 2010-01-06 19:28:46 UTC (rev 14133) +++ trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiver.java 2010-01-06 19:34:18 UTC (rev 14134) @@ -1,32 +1,3 @@ -/* - * 'SNMPTrapReceiver.java' - * - * - * NOTE: This copyright does *not* cover user programs that use HQ - * program services by normal system calls through the application - * program interfaces provided as part of the Hyperic Plug-in Development - * Kit or the Hyperic Client Development Kit - this is merely considered - * normal use of the program, and does *not* fall under the heading of - * "derived work". - * - * Copyright (C) [2004, 2005, 2006, 2007, 2008, 2009], Hyperic, Inc. - * This file is part of HQ. - * - * HQ is free software; you can redistribute it and/or modify - * it under the terms version 2 of the GNU General Public License as - * published by the Free Software Foundation. This program is distributed - * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - */ - - package org.hyperic.hq.plugin.netdevice; import java.io.IOException; @@ -64,304 +35,216 @@ import org.snmp4j.util.MultiThreadedMessageDispatcher; import org.snmp4j.util.ThreadPool; -public class SNMPTrapReceiver implements CommandResponder -{ - static final String PROP_LISTEN_ADDRESS = "snmpTrapReceiver.listenAddress"; +public class SNMPTrapReceiver implements CommandResponder { + + static final String PROP_LISTEN_ADDRESS = "snmpTrapReceiver.listenAddress"; static final String DEFAULT_LISTEN_ADDRESS = "udp:0.0.0.0/162"; private static SNMPTrapReceiver instance = null; + private static final Log log = LogFactory.getLog(SNMPTrapReceiver.class.getName()); - private static final Log log = LogFactory.getLog ( SNMPTrapReceiver.class.getName ( ) ); - private MultiThreadedMessageDispatcher _dispatcher; private Snmp _snmp; private Address _listenAddress; private ThreadPool _threadPool; - private Map _plugins = new HashMap ( ); - + private Map _plugins = new HashMap(); LogTrackPluginManager _manager; private int _received = 0; - static boolean hasInstance ( ) - { + static boolean hasInstance() { return instance != null; } - public static SNMPTrapReceiver getInstance ( Properties props ) throws IOException - { - if ( !hasInstance ( ) ) - { - instance = new SNMPTrapReceiver ( ); - instance.init ( props ); + public static SNMPTrapReceiver getInstance(Properties props) throws IOException { + + if (!hasInstance()) { + instance = new SNMPTrapReceiver(); + instance.init(props); } return instance; } - public static void start(Properties props) throws IOException - { - getInstance ( props ); + public static void start(Properties props) throws IOException { + + getInstance(props); } - public static void shutdown ( ) throws IOException - { - if ( hasInstance ( ) ) - { - log.debug ( "Shutdown instance" ); - - instance._threadPool.cancel ( ); - instance._snmp.close ( ); - + public static void shutdown() throws IOException { + if (hasInstance()) { + log.debug("Shutdown instance"); + instance._threadPool.cancel(); + instance._snmp.close(); instance = null; } } - private static String getPluginKey ( String address, - String community ) - { - return address + "-" + community; + private static String getPluginKey(String address, String community) { + return address + "-" + community; } - private static String getConfig ( LogTrackPlugin plugin, - String key, - String def ) - { - String value = plugin.getConfig ( key ); + private static String getConfig(LogTrackPlugin plugin, String key, String def) { - if ( value == null ) - { - // Commandline-testing... - return plugin.getManager().getProperty ( key, def ); - } - else - { + String value = plugin.getConfig(key); + if (value == null) { + // commandline-testing + return plugin.getManager().getProperty(key, def); + } else { return value; } } - private static String getPluginKey ( LogTrackPlugin plugin ) - { - String address = getConfig ( plugin, - SNMPClient.PROP_IP, - SNMPClient.DEFAULT_IP ); + private static String getPluginKey(LogTrackPlugin plugin) { + String address = getConfig(plugin, SNMPClient.PROP_IP, SNMPClient.DEFAULT_IP); - String community = getConfig ( plugin, - SNMPClient.PROP_COMMUNITY, - SNMPClient.DEFAULT_COMMUNITY ); + String community = getConfig(plugin, SNMPClient.PROP_COMMUNITY, SNMPClient.DEFAULT_COMMUNITY); - return getPluginKey ( address, community ); + return getPluginKey(address, community); } - private LogTrackPlugin getPlugin ( String address, String community ) - { - String key = getPluginKey ( address, community ); - - return (LogTrackPlugin)_plugins.get ( key ); + private LogTrackPlugin getPlugin(String address, String community) { + String key = getPluginKey(address, community); + return (LogTrackPlugin) _plugins.get(key); } - public void add ( LogTrackPlugin plugin ) throws IOException - { - String key = getPluginKey ( plugin ); + public void add(LogTrackPlugin plugin) throws IOException { - log.debug ( "Add " + plugin.getName ( ) + " for " + key ); - - _plugins.put ( key, plugin ); + String key = getPluginKey(plugin); + log.debug("Add " + plugin.getName() + " for " + key); + _plugins.put(key, plugin); } - public static void remove ( LogTrackPlugin plugin ) - { - if ( !hasInstance ( ) ) - { + public static void remove(LogTrackPlugin plugin) { + if (!hasInstance()) { return; } + String key = getPluginKey(plugin); + log.debug("Remove " + plugin.getName() + " for " + key); + instance._plugins.remove(key); + } - String key = getPluginKey ( plugin ); - - log.debug ( "Remove " + plugin.getName ( ) + " for " + key ); - - instance._plugins.remove ( key ); + private SNMPTrapReceiver() { } - private SNMPTrapReceiver ( ) - { } + private void init(Properties props) throws IOException { - private void init ( Properties props ) throws IOException - { - String address = props.getProperty ( PROP_LISTEN_ADDRESS, - DEFAULT_LISTEN_ADDRESS ).trim ( ); + String address = props.getProperty(PROP_LISTEN_ADDRESS, DEFAULT_LISTEN_ADDRESS).trim(); - String numThreads = props.getProperty ( "snmpTrapReceiver.numThreads", - "1" ); + String numThreads = props.getProperty("snmpTrapReceiver.numThreads", "1"); - _threadPool = ThreadPool.create ( "SNMPTrapReceiver", - Integer.parseInt ( numThreads ) ); + _threadPool = ThreadPool.create("SNMPTrapReceiver", Integer.parseInt(numThreads)); - _dispatcher = new MultiThreadedMessageDispatcher ( _threadPool, - new MessageDispatcherImpl ( ) ); + _dispatcher = new MultiThreadedMessageDispatcher(_threadPool, new MessageDispatcherImpl()); - try - { - _listenAddress = GenericAddress.parse ( address ); - - if ( !_listenAddress.isValid ( ) ) - { - throw new IllegalArgumentException ( ); + try { + _listenAddress = GenericAddress.parse(address); + if (!_listenAddress.isValid()) { + throw new IllegalArgumentException(); } + } catch (Exception e) { + throw new IOException("Invalid " + PROP_LISTEN_ADDRESS + "=" + address); } - catch ( Exception e ) - { - throw new IOException ( "Invalid " + PROP_LISTEN_ADDRESS + "=" + address ); - } - log.debug ( PROP_LISTEN_ADDRESS + "=" + address ); + log.debug(PROP_LISTEN_ADDRESS + "=" + address); TransportMapping transport; - - if ( _listenAddress instanceof UdpAddress ) - { - transport = new DefaultUdpTransportMapping ( (UdpAddress)_listenAddress ); + if (_listenAddress instanceof UdpAddress) { + transport = new DefaultUdpTransportMapping((UdpAddress) _listenAddress); + } else { + transport = new DefaultTcpTransportMapping((TcpAddress) _listenAddress); } - else - { - transport = new DefaultTcpTransportMapping ( (TcpAddress)_listenAddress ); - } - _snmp = new Snmp ( _dispatcher, transport ); + _snmp = new Snmp(_dispatcher, transport); + _snmp.getMessageDispatcher().addMessageProcessingModel(new MPv1()); + _snmp.getMessageDispatcher().addMessageProcessingModel(new MPv2c()); + _snmp.getMessageDispatcher().addMessageProcessingModel(new MPv3()); - _snmp.getMessageDispatcher().addMessageProcessingModel ( new MPv1 ( ) ); - _snmp.getMessageDispatcher().addMessageProcessingModel ( new MPv2c ( ) ); - _snmp.getMessageDispatcher().addMessageProcessingModel ( new MPv3 ( ) ); + USM usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0); + SecurityModels.getInstance().addSecurityModel(usm); - USM usm = new USM ( SecurityProtocols.getInstance ( ), - new OctetString ( MPv3.createLocalEngineID ( ) ), - 0 ); - - SecurityModels.getInstance().addSecurityModel ( usm ); - - _snmp.addCommandResponder ( this ); - _snmp.listen ( ); + _snmp.addCommandResponder(this); + _snmp.listen(); } - public int getTrapsReceived ( ) - { + public int getTrapsReceived() { return _received; } - private String getMessage ( CommandResponderEvent event ) - { - StringBuffer msg = new StringBuffer ( ); + private String getMessage(CommandResponderEvent event) { + StringBuffer msg = new StringBuffer(); - Vector vars = event.getPDU().getVariableBindings ( ); - - int size = vars.size ( ); - - for ( int i = 0; i < size; i++ ) - { - VariableBinding var = (VariableBinding)vars.get ( i ); - - msg.append ( var.getVariable().toString().trim ( ) ); - - if ( i < size - 1 ) - { - msg.append ( ", " ); + Vector vars = event.getPDU().getVariableBindings(); + int size = vars.size(); + for (int i = 0; i < size; i++) { + VariableBinding var = (VariableBinding) vars.get(i); + msg.append(var.getVariable().toString().trim()); + if (i < size - 1) { + msg.append(", "); } - } + } - return msg.toString ( ); + return msg.toString(); } - private LogTrackPlugin getPlatformPlugin ( ) - { - // return _manager.getDefaultPlatformPlugin ( ) + private LogTrackPlugin getPlatformPlugin() { + // XXX return _manager.getDefaultPlatformPlugin() final String prop = LogTrackPluginManager.DEFAULT_PLATFORM_PLUGIN; - - String name = _manager.getProperty ( prop ); - - return _manager.getLogTrackPlugin ( name ); + String name = _manager.getProperty(prop); + return _manager.getLogTrackPlugin(name); } - void setPluginManager ( LogTrackPluginManager manager ) - { + void setPluginManager(LogTrackPluginManager manager) { _manager = manager; } - public void processPdu ( CommandResponderEvent event ) - { + public void processPdu(CommandResponderEvent event) { _received++; - Address peer = event.getPeerAddress ( ); - + Address peer = event.getPeerAddress(); InetAddress peerAddress; - - if ( peer instanceof UdpAddress ) - { - peerAddress = ( (UdpAddress)peer ).getInetAddress ( ); - } - else if ( peer instanceof TcpAddress ) - { - peerAddress = ( (TcpAddress)peer ).getInetAddress ( ); - } - else - { - log.debug ( "Unsupported transport: " + peer.getClass().getName ( ) ); - + if (peer instanceof UdpAddress) { + peerAddress = ((UdpAddress) peer).getInetAddress(); + } else if (peer instanceof TcpAddress) { + peerAddress = ((TcpAddress) peer).getInetAddress(); + } else { + log.debug("Unsupported transport: " + peer.getClass().getName()); return; } - String address = peerAddress.getHostAddress ( ); + String address = peerAddress.getHostAddress(); - String community = new OctetString ( event.getSecurityName ( ) ).toString( ); + String community = new OctetString(event.getSecurityName()).toString(); - LogTrackPlugin plugin = getPlugin ( address, community ); - - if ( plugin == null ) - { - plugin = getPlatformPlugin ( ); - - if ( plugin != null ) - { - if ( log.isDebugEnabled ( ) ) - { - log.debug ( "No plugin for " + address + ", routing to default platform: " + plugin.getName ( ) ); + LogTrackPlugin plugin = getPlugin(address, community); + if (plugin == null) { + plugin = getPlatformPlugin(); + if (plugin != null) { + if (log.isDebugEnabled()) { + log.debug("No plugin for " + address + ", routing to default platform: " + plugin.getName()); } } } - - if ( plugin == null ) - { - if ( log.isDebugEnabled ( ) ) - { - log.debug ( "No plugin for " + address + ", msg=" + getMessage ( event ) ); + if (plugin == null) { + if (log.isDebugEnabled()) { + log.debug("No plugin for " + address + ", msg=" + getMessage(event)); } - } - else - { - String msg = getMessage ( event ); - - if ( log.isDebugEnabled ( ) ) - { - log.debug ( "Msg=" + msg ); + } else { + String msg = getMessage(event); + if (log.isDebugEnabled()) { + log.debug("Msg=" + msg); } - - plugin.reportEvent ( System.currentTimeMillis ( ), - LogTrackPlugin.LOGLEVEL_ERROR, - address, - msg ); + plugin.reportEvent(System.currentTimeMillis(), LogTrackPlugin.LOGLEVEL_ERROR, address, msg); } } - public static void main ( String[] args ) throws Exception - { - SNMPTrapReceiver.start ( System.getProperties ( ) ); + public static void main(String[] args) throws Exception { + SNMPTrapReceiver.start(System.getProperties()); - System.out.println ( "Ready" ); - System.in.read ( ); - System.out.print ( "Shutting down..." ); - - SNMPTrapReceiver.shutdown ( ); - - System.out.println ( "done" ); + System.out.println("Ready"); + System.in.read(); + System.out.print("Shutting down..."); + SNMPTrapReceiver.shutdown(); + System.out.println("done"); } } - |
From: <tr...@hy...> - 2010-01-06 19:28:55
|
Author: trader Date: 2010-01-06 11:28:46 -0800 (Wed, 06 Jan 2010) New Revision: 14133 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14133 Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiver.java Log: Same as revision 10487, reformatted with project settings Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiver.java =================================================================== --- trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiver.java 2010-01-06 19:24:46 UTC (rev 14132) +++ trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiver.java 2010-01-06 19:28:46 UTC (rev 14133) @@ -1,3 +1,32 @@ +/* + * 'SNMPTrapReceiver.java' + * + * + * NOTE: This copyright does *not* cover user programs that use HQ + * program services by normal system calls through the application + * program interfaces provided as part of the Hyperic Plug-in Development + * Kit or the Hyperic Client Development Kit - this is merely considered + * normal use of the program, and does *not* fall under the heading of + * "derived work". + * + * Copyright (C) [2004, 2005, 2006, 2007, 2008, 2009], Hyperic, Inc. + * This file is part of HQ. + * + * HQ is free software; you can redistribute it and/or modify + * it under the terms version 2 of the GNU General Public License as + * published by the Free Software Foundation. This program is distributed + * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA. + */ + + package org.hyperic.hq.plugin.netdevice; import java.io.IOException; @@ -35,255 +64,304 @@ import org.snmp4j.util.MultiThreadedMessageDispatcher; import org.snmp4j.util.ThreadPool; -public class SNMPTrapReceiver -implements CommandResponder { - - static final String PROP_LISTEN_ADDRESS = "snmpTrapReceiver.listenAddress"; +public class SNMPTrapReceiver implements CommandResponder +{ + static final String PROP_LISTEN_ADDRESS = "snmpTrapReceiver.listenAddress"; static final String DEFAULT_LISTEN_ADDRESS = "udp:0.0.0.0/162"; private static SNMPTrapReceiver instance = null; - private static final Log log = - LogFactory.getLog(SNMPTrapReceiver.class.getName()); + private static final Log log = LogFactory.getLog ( SNMPTrapReceiver.class.getName ( ) ); + private MultiThreadedMessageDispatcher _dispatcher; private Snmp _snmp; private Address _listenAddress; private ThreadPool _threadPool; - private Map _plugins = new HashMap(); + private Map _plugins = new HashMap ( ); + LogTrackPluginManager _manager; private int _received = 0; - static boolean hasInstance() { + static boolean hasInstance ( ) + { return instance != null; } - public static SNMPTrapReceiver getInstance(Properties props) - throws IOException { - - if (!hasInstance()) { - instance = new SNMPTrapReceiver(); - instance.init(props); + public static SNMPTrapReceiver getInstance ( Properties props ) throws IOException + { + if ( !hasInstance ( ) ) + { + instance = new SNMPTrapReceiver ( ); + instance.init ( props ); } return instance; } - public static void start(Properties props) - throws IOException { - - getInstance(props); + public static void start(Properties props) throws IOException + { + getInstance ( props ); } - public static void shutdown() throws IOException { - if (hasInstance()) { - log.debug("Shutdown instance"); - instance._threadPool.cancel(); - instance._snmp.close(); + public static void shutdown ( ) throws IOException + { + if ( hasInstance ( ) ) + { + log.debug ( "Shutdown instance" ); + + instance._threadPool.cancel ( ); + instance._snmp.close ( ); + instance = null; } } - private static String getPluginKey(String address, String community) { + private static String getPluginKey ( String address, + String community ) + { return address + "-" + community; } - private static String getConfig(LogTrackPlugin plugin, - String key, String def) { + private static String getConfig ( LogTrackPlugin plugin, + String key, + String def ) + { + String value = plugin.getConfig ( key ); - String value = plugin.getConfig(key); - if (value == null) { - //commandline-testing - return plugin.getManager().getProperty(key, def); + if ( value == null ) + { + // Commandline-testing... + return plugin.getManager().getProperty ( key, def ); } - else { + else + { return value; } } - private static String getPluginKey(LogTrackPlugin plugin) { - String address = - getConfig(plugin, - SNMPClient.PROP_IP, - SNMPClient.DEFAULT_IP); + private static String getPluginKey ( LogTrackPlugin plugin ) + { + String address = getConfig ( plugin, + SNMPClient.PROP_IP, + SNMPClient.DEFAULT_IP ); - String community = - getConfig(plugin, - SNMPClient.PROP_COMMUNITY, - SNMPClient.DEFAULT_COMMUNITY); + String community = getConfig ( plugin, + SNMPClient.PROP_COMMUNITY, + SNMPClient.DEFAULT_COMMUNITY ); - return getPluginKey(address, community); + return getPluginKey ( address, community ); } - private LogTrackPlugin getPlugin(String address, String community) { - String key = getPluginKey(address, community); - return (LogTrackPlugin)_plugins.get(key); + private LogTrackPlugin getPlugin ( String address, String community ) + { + String key = getPluginKey ( address, community ); + + return (LogTrackPlugin)_plugins.get ( key ); } - public void add(LogTrackPlugin plugin) - throws IOException { + public void add ( LogTrackPlugin plugin ) throws IOException + { + String key = getPluginKey ( plugin ); - String key = getPluginKey(plugin); - log.debug("Add " + plugin.getName() + " for " + key); - _plugins.put(key, plugin); + log.debug ( "Add " + plugin.getName ( ) + " for " + key ); + + _plugins.put ( key, plugin ); } - public static void remove(LogTrackPlugin plugin) { - if (!hasInstance()) { + public static void remove ( LogTrackPlugin plugin ) + { + if ( !hasInstance ( ) ) + { return; } - String key = getPluginKey(plugin); - log.debug("Remove " + plugin.getName() + " for " + key); - instance._plugins.remove(key); + + String key = getPluginKey ( plugin ); + + log.debug ( "Remove " + plugin.getName ( ) + " for " + key ); + + instance._plugins.remove ( key ); } - private SNMPTrapReceiver () {} + private SNMPTrapReceiver ( ) + { } - private void init(Properties props) - throws IOException { + private void init ( Properties props ) throws IOException + { + String address = props.getProperty ( PROP_LISTEN_ADDRESS, + DEFAULT_LISTEN_ADDRESS ).trim ( ); - String address = - props.getProperty(PROP_LISTEN_ADDRESS, - DEFAULT_LISTEN_ADDRESS).trim(); + String numThreads = props.getProperty ( "snmpTrapReceiver.numThreads", + "1" ); - String numThreads = - props.getProperty("snmpTrapReceiver.numThreads", "1"); + _threadPool = ThreadPool.create ( "SNMPTrapReceiver", + Integer.parseInt ( numThreads ) ); - _threadPool = - ThreadPool.create("SNMPTrapReceiver", - Integer.parseInt(numThreads)); + _dispatcher = new MultiThreadedMessageDispatcher ( _threadPool, + new MessageDispatcherImpl ( ) ); - _dispatcher = - new MultiThreadedMessageDispatcher(_threadPool, - new MessageDispatcherImpl()); + try + { + _listenAddress = GenericAddress.parse ( address ); - try { - _listenAddress = GenericAddress.parse(address); - if (!_listenAddress.isValid()) { - throw new IllegalArgumentException(); + if ( !_listenAddress.isValid ( ) ) + { + throw new IllegalArgumentException ( ); } - } catch (Exception e) { - throw new IOException("Invalid " + - PROP_LISTEN_ADDRESS + "=" + address); } + catch ( Exception e ) + { + throw new IOException ( "Invalid " + PROP_LISTEN_ADDRESS + "=" + address ); + } - log.debug(PROP_LISTEN_ADDRESS + "=" + address); + log.debug ( PROP_LISTEN_ADDRESS + "=" + address ); TransportMapping transport; - if (_listenAddress instanceof UdpAddress) { - transport = - new DefaultUdpTransportMapping((UdpAddress)_listenAddress); + + if ( _listenAddress instanceof UdpAddress ) + { + transport = new DefaultUdpTransportMapping ( (UdpAddress)_listenAddress ); } - else { - transport = - new DefaultTcpTransportMapping((TcpAddress)_listenAddress); + else + { + transport = new DefaultTcpTransportMapping ( (TcpAddress)_listenAddress ); } - _snmp = new Snmp(_dispatcher, transport); - _snmp.getMessageDispatcher().addMessageProcessingModel(new MPv1()); - _snmp.getMessageDispatcher().addMessageProcessingModel(new MPv2c()); - _snmp.getMessageDispatcher().addMessageProcessingModel(new MPv3()); + _snmp = new Snmp ( _dispatcher, transport ); - USM usm = - new USM(SecurityProtocols.getInstance(), - new OctetString(MPv3.createLocalEngineID()), 0); - SecurityModels.getInstance().addSecurityModel(usm); + _snmp.getMessageDispatcher().addMessageProcessingModel ( new MPv1 ( ) ); + _snmp.getMessageDispatcher().addMessageProcessingModel ( new MPv2c ( ) ); + _snmp.getMessageDispatcher().addMessageProcessingModel ( new MPv3 ( ) ); - _snmp.addCommandResponder(this); - _snmp.listen(); + USM usm = new USM ( SecurityProtocols.getInstance ( ), + new OctetString ( MPv3.createLocalEngineID ( ) ), + 0 ); + + SecurityModels.getInstance().addSecurityModel ( usm ); + + _snmp.addCommandResponder ( this ); + _snmp.listen ( ); } - public int getTrapsReceived() { + public int getTrapsReceived ( ) + { return _received; } - private String getMessage(CommandResponderEvent event) { - StringBuffer msg = new StringBuffer(); + private String getMessage ( CommandResponderEvent event ) + { + StringBuffer msg = new StringBuffer ( ); - Vector vars = event.getPDU().getVariableBindings(); - int size = vars.size(); - for (int i=0; i<size; i++) { - VariableBinding var = (VariableBinding)vars.get(i); - msg.append(var.getVariable().toString().trim()); - if (i < size-1) { - msg.append(", "); + Vector vars = event.getPDU().getVariableBindings ( ); + + int size = vars.size ( ); + + for ( int i = 0; i < size; i++ ) + { + VariableBinding var = (VariableBinding)vars.get ( i ); + + msg.append ( var.getVariable().toString().trim ( ) ); + + if ( i < size - 1 ) + { + msg.append ( ", " ); } } - return msg.toString(); + return msg.toString ( ); } - private LogTrackPlugin getPlatformPlugin() { - //XXX return _manager.getDefaultPlatformPlugin() + private LogTrackPlugin getPlatformPlugin ( ) + { + // return _manager.getDefaultPlatformPlugin ( ) final String prop = LogTrackPluginManager.DEFAULT_PLATFORM_PLUGIN; - String name = _manager.getProperty(prop); - return _manager.getLogTrackPlugin(name); + + String name = _manager.getProperty ( prop ); + + return _manager.getLogTrackPlugin ( name ); } - void setPluginManager(LogTrackPluginManager manager) { + void setPluginManager ( LogTrackPluginManager manager ) + { _manager = manager; } - public void processPdu(CommandResponderEvent event) { + public void processPdu ( CommandResponderEvent event ) + { _received++; - Address peer = event.getPeerAddress(); + Address peer = event.getPeerAddress ( ); + InetAddress peerAddress; - if (peer instanceof UdpAddress) { - peerAddress = ((UdpAddress)peer).getInetAddress(); + + if ( peer instanceof UdpAddress ) + { + peerAddress = ( (UdpAddress)peer ).getInetAddress ( ); } - else if (peer instanceof TcpAddress) { - peerAddress = ((TcpAddress)peer).getInetAddress(); + else if ( peer instanceof TcpAddress ) + { + peerAddress = ( (TcpAddress)peer ).getInetAddress ( ); } - else { - log.debug("Unsupported transport: " + - peer.getClass().getName()); + else + { + log.debug ( "Unsupported transport: " + peer.getClass().getName ( ) ); + return; } - String address = - peerAddress.getHostAddress(); + String address = peerAddress.getHostAddress ( ); - String community = - new OctetString(event.getSecurityName()).toString(); + String community = new OctetString ( event.getSecurityName ( ) ).toString( ); - LogTrackPlugin plugin = getPlugin(address, community); - if (plugin == null) { - plugin = getPlatformPlugin(); - if (plugin != null) { - if (log.isDebugEnabled()) { - log.debug("No plugin for " + address + - ", routing to default platform: " + - plugin.getName()); + LogTrackPlugin plugin = getPlugin ( address, community ); + + if ( plugin == null ) + { + plugin = getPlatformPlugin ( ); + + if ( plugin != null ) + { + if ( log.isDebugEnabled ( ) ) + { + log.debug ( "No plugin for " + address + ", routing to default platform: " + plugin.getName ( ) ); } } } - if (plugin == null) { - if (log.isDebugEnabled()) { - log.debug("No plugin for " + address + - ", msg=" + getMessage(event)); + + if ( plugin == null ) + { + if ( log.isDebugEnabled ( ) ) + { + log.debug ( "No plugin for " + address + ", msg=" + getMessage ( event ) ); } } - else { - String msg = getMessage(event); - if (log.isDebugEnabled()) { - log.debug("Msg=" + msg); + else + { + String msg = getMessage ( event ); + + if ( log.isDebugEnabled ( ) ) + { + log.debug ( "Msg=" + msg ); } - plugin.reportEvent(System.currentTimeMillis(), - LogTrackPlugin.LOGLEVEL_ERROR, - address, - msg); + + plugin.reportEvent ( System.currentTimeMillis ( ), + LogTrackPlugin.LOGLEVEL_ERROR, + address, + msg ); } } - public static void main(String[] args) throws Exception { - SNMPTrapReceiver.start(System.getProperties()); + public static void main ( String[] args ) throws Exception + { + SNMPTrapReceiver.start ( System.getProperties ( ) ); - System.out.println("Ready"); - System.in.read(); - System.out.print("Shutting down..."); - SNMPTrapReceiver.shutdown(); - System.out.println("done"); + System.out.println ( "Ready" ); + System.in.read ( ); + System.out.print ( "Shutting down..." ); + + SNMPTrapReceiver.shutdown ( ); + + System.out.println ( "done" ); } } |
From: <tr...@hy...> - 2010-01-06 19:24:55
|
Author: trader Date: 2010-01-06 11:24:46 -0800 (Wed, 06 Jan 2010) New Revision: 14132 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14132 Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiver.java Log: Same as revision 9991, reformatted with project settings Modified: trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiver.java =================================================================== --- trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiver.java 2010-01-06 09:22:50 UTC (rev 14131) +++ trunk/plugins/netdevice/src/org/hyperic/hq/plugin/netdevice/SNMPTrapReceiver.java 2010-01-06 19:24:46 UTC (rev 14132) @@ -1,32 +1,3 @@ -/* - * 'SNMPTrapReceiver.java' - * - * - * NOTE: This copyright does *not* cover user programs that use HQ - * program services by normal system calls through the application - * program interfaces provided as part of the Hyperic Plug-in Development - * Kit or the Hyperic Client Development Kit - this is merely considered - * normal use of the program, and does *not* fall under the heading of - * "derived work". - * - * Copyright (C) [2004, 2005, 2006, 2007, 2008, 2009], Hyperic, Inc. - * This file is part of HQ. - * - * HQ is free software; you can redistribute it and/or modify - * it under the terms version 2 of the GNU General Public License as - * published by the Free Software Foundation. This program is distributed - * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - */ - - package org.hyperic.hq.plugin.netdevice; import java.io.IOException; @@ -64,304 +35,255 @@ import org.snmp4j.util.MultiThreadedMessageDispatcher; import org.snmp4j.util.ThreadPool; -public class SNMPTrapReceiver implements CommandResponder -{ - static final String PROP_LISTEN_ADDRESS = "snmpTrapReceiver.listenAddress"; - static final String DEFAULT_LISTEN_ADDRESS = "udp:0.0.0.0/162"; +public class SNMPTrapReceiver +implements CommandResponder { - private static SNMPTrapReceiver instance = null; + static final String PROP_LISTEN_ADDRESS = "snmpTrapReceiver.listenAddress"; + static final String DEFAULT_LISTEN_ADDRESS = "udp:0.0.0.0/162"; - private static final Log log = LogFactory.getLog ( SNMPTrapReceiver.class.getName ( ) ); + private static SNMPTrapReceiver instance = null; + private static final Log log = + LogFactory.getLog(SNMPTrapReceiver.class.getName()); - private MultiThreadedMessageDispatcher _dispatcher; - private Snmp _snmp; - private Address _listenAddress; - private ThreadPool _threadPool; - private Map _plugins = new HashMap ( ); + private MultiThreadedMessageDispatcher _dispatcher; + private Snmp _snmp; + private Address _listenAddress; + private ThreadPool _threadPool; + private Map _plugins = new HashMap(); + LogTrackPluginManager _manager; - LogTrackPluginManager _manager; + private int _received = 0; - private int _received = 0; + static boolean hasInstance() { + return instance != null; + } - static boolean hasInstance ( ) - { - return instance != null; - } + public static SNMPTrapReceiver getInstance(Properties props) + throws IOException { - public static SNMPTrapReceiver getInstance ( Properties props ) throws IOException - { - if ( !hasInstance ( ) ) - { - instance = new SNMPTrapReceiver ( ); - instance.init ( props ); - } + if (!hasInstance()) { + instance = new SNMPTrapReceiver(); + instance.init(props); + } - return instance; - } + return instance; + } - public static void start(Properties props) throws IOException - { - getInstance ( props ); - } + public static void start(Properties props) + throws IOException { - public static void shutdown ( ) throws IOException - { - if ( hasInstance ( ) ) - { - log.debug ( "Shutdown instance" ); + getInstance(props); + } - instance._threadPool.cancel ( ); - instance._snmp.close ( ); + public static void shutdown() throws IOException { + if (hasInstance()) { + log.debug("Shutdown instance"); + instance._threadPool.cancel(); + instance._snmp.close(); + instance = null; + } + } - instance = null; - } - } + private static String getPluginKey(String address, String community) { + return address + "-" + community; + } - private static String getPluginKey ( String address, - String community ) - { - return address + "-" + community; - } + private static String getConfig(LogTrackPlugin plugin, + String key, String def) { - private static String getConfig ( LogTrackPlugin plugin, - String key, - String def ) - { - String value = plugin.getConfig ( key ); + String value = plugin.getConfig(key); + if (value == null) { + //commandline-testing + return plugin.getManager().getProperty(key, def); + } + else { + return value; + } + } - if ( value == null ) - { - // Commandline-testing... - return plugin.getManager().getProperty ( key, def ); - } - else - { - return value; - } - } + private static String getPluginKey(LogTrackPlugin plugin) { + String address = + getConfig(plugin, + SNMPClient.PROP_IP, + SNMPClient.DEFAULT_IP); - private static String getPluginKey ( LogTrackPlugin plugin ) - { - String address = getConfig ( plugin, - SNMPClient.PROP_IP, - SNMPClient.DEFAULT_IP ); + String community = + getConfig(plugin, + SNMPClient.PROP_COMMUNITY, + SNMPClient.DEFAULT_COMMUNITY); - String community = getConfig ( plugin, - SNMPClient.PROP_COMMUNITY, - SNMPClient.DEFAULT_COMMUNITY ); + return getPluginKey(address, community); + } - return getPluginKey ( address, community ); - } + private LogTrackPlugin getPlugin(String address, String community) { + String key = getPluginKey(address, community); + return (LogTrackPlugin)_plugins.get(key); + } - private LogTrackPlugin getPlugin ( String address, String community ) - { - String key = getPluginKey ( address, community ); + public void add(LogTrackPlugin plugin) + throws IOException { - return (LogTrackPlugin)_plugins.get ( key ); - } + String key = getPluginKey(plugin); + log.debug("Add " + plugin.getName() + " for " + key); + _plugins.put(key, plugin); + } - public void add ( LogTrackPlugin plugin ) throws IOException - { - String key = getPluginKey ( plugin ); - - log.debug ( "Add " + plugin.getName ( ) + " for " + key ); - - _plugins.put ( key, plugin ); - } - - public static void remove ( LogTrackPlugin plugin ) - { - if ( !hasInstance ( ) ) - { - return; - } - - String key = getPluginKey ( plugin ); - - log.debug ( "Remove " + plugin.getName ( ) + " for " + key ); - - instance._plugins.remove ( key ); + public static void remove(LogTrackPlugin plugin) { + if (!hasInstance()) { + return; + } + String key = getPluginKey(plugin); + log.debug("Remove " + plugin.getName() + " for " + key); + instance._plugins.remove(key); } - private SNMPTrapReceiver ( ) - { } + private SNMPTrapReceiver () {} - private void init ( Properties props ) throws IOException - { - String address = props.getProperty ( PROP_LISTEN_ADDRESS, - DEFAULT_LISTEN_ADDRESS ).trim ( ); + private void init(Properties props) + throws IOException { - String numThreads = props.getProperty ( "snmpTrapReceiver.numThreads", - "1" ); + String address = + props.getProperty(PROP_LISTEN_ADDRESS, + DEFAULT_LISTEN_ADDRESS).trim(); - _threadPool = ThreadPool.create ( "SNMPTrapReceiver", - Integer.parseInt ( numThreads ) ); + String numThreads = + props.getProperty("snmpTrapReceiver.numThreads", "1"); - _dispatcher = new MultiThreadedMessageDispatcher ( _threadPool, - new MessageDispatcherImpl ( ) ); + _threadPool = + ThreadPool.create("SNMPTrapReceiver", + Integer.parseInt(numThreads)); - try - { - _listenAddress = GenericAddress.parse ( address ); + _dispatcher = + new MultiThreadedMessageDispatcher(_threadPool, + new MessageDispatcherImpl()); - if ( !_listenAddress.isValid ( ) ) - { - throw new IllegalArgumentException ( ); - } - } - catch ( Exception e ) - { - throw new IOException ( "Invalid " + PROP_LISTEN_ADDRESS + "=" + address ); - } + try { + _listenAddress = GenericAddress.parse(address); + if (!_listenAddress.isValid()) { + throw new IllegalArgumentException(); + } + } catch (Exception e) { + throw new IOException("Invalid " + + PROP_LISTEN_ADDRESS + "=" + address); + } - log.debug ( PROP_LISTEN_ADDRESS + "=" + address ); + log.debug(PROP_LISTEN_ADDRESS + "=" + address); - TransportMapping transport; + TransportMapping transport; + if (_listenAddress instanceof UdpAddress) { + transport = + new DefaultUdpTransportMapping((UdpAddress)_listenAddress); + } + else { + transport = + new DefaultTcpTransportMapping((TcpAddress)_listenAddress); + } - if ( _listenAddress instanceof UdpAddress ) - { - transport = new DefaultUdpTransportMapping ( (UdpAddress)_listenAddress ); - } - else - { - transport = new DefaultTcpTransportMapping ( (TcpAddress)_listenAddress ); - } + _snmp = new Snmp(_dispatcher, transport); + _snmp.getMessageDispatcher().addMessageProcessingModel(new MPv1()); + _snmp.getMessageDispatcher().addMessageProcessingModel(new MPv2c()); + _snmp.getMessageDispatcher().addMessageProcessingModel(new MPv3()); - _snmp = new Snmp ( _dispatcher, transport ); + USM usm = + new USM(SecurityProtocols.getInstance(), + new OctetString(MPv3.createLocalEngineID()), 0); + SecurityModels.getInstance().addSecurityModel(usm); - _snmp.getMessageDispatcher().addMessageProcessingModel ( new MPv1 ( ) ); - _snmp.getMessageDispatcher().addMessageProcessingModel ( new MPv2c ( ) ); - _snmp.getMessageDispatcher().addMessageProcessingModel ( new MPv3 ( ) ); + _snmp.addCommandResponder(this); + _snmp.listen(); + } - USM usm = new USM ( SecurityProtocols.getInstance ( ), - new OctetString ( MPv3.createLocalEngineID ( ) ), - 0 ); + public int getTrapsReceived() { + return _received; + } - SecurityModels.getInstance().addSecurityModel ( usm ); + private String getMessage(CommandResponderEvent event) { + StringBuffer msg = new StringBuffer(); - _snmp.addCommandResponder ( this ); - _snmp.listen ( ); - } + Vector vars = event.getPDU().getVariableBindings(); + int size = vars.size(); + for (int i=0; i<size; i++) { + VariableBinding var = (VariableBinding)vars.get(i); + msg.append(var.getVariable().toString().trim()); + if (i < size-1) { + msg.append(", "); + } + } - public int getTrapsReceived ( ) - { - return _received; - } + return msg.toString(); + } - private String getMessage ( CommandResponderEvent event ) - { - StringBuffer msg = new StringBuffer ( ); + private LogTrackPlugin getPlatformPlugin() { + //XXX return _manager.getDefaultPlatformPlugin() + final String prop = LogTrackPluginManager.DEFAULT_PLATFORM_PLUGIN; + String name = _manager.getProperty(prop); + return _manager.getLogTrackPlugin(name); + } - Vector vars = event.getPDU().getVariableBindings ( ); - - int size = vars.size ( ); - - for ( int i = 0; i < size; i++ ) - { - VariableBinding var = (VariableBinding)vars.get ( i ); - - msg.append ( var.getVariable().toString().trim ( ) ); - - if ( i < size - 1 ) - { - msg.append ( ", " ); - } - } - - return msg.toString ( ); - } - - private LogTrackPlugin getPlatformPlugin ( ) - { - // return _manager.getDefaultPlatformPlugin ( ) - final String prop = LogTrackPluginManager.DEFAULT_PLATFORM_PLUGIN; - - String name = _manager.getProperty ( prop ); - - return _manager.getLogTrackPlugin ( name ); + void setPluginManager(LogTrackPluginManager manager) { + _manager = manager; } - void setPluginManager ( LogTrackPluginManager manager ) - { - _manager = manager; - } + public void processPdu(CommandResponderEvent event) { + _received++; - public void processPdu ( CommandResponderEvent event ) - { - _received++; + Address peer = event.getPeerAddress(); + InetAddress peerAddress; + if (peer instanceof UdpAddress) { + peerAddress = ((UdpAddress)peer).getInetAddress(); + } + else if (peer instanceof TcpAddress) { + peerAddress = ((TcpAddress)peer).getInetAddress(); + } + else { + log.debug("Unsupported transport: " + + peer.getClass().getName()); + return; + } - Address peer = event.getPeerAddress ( ); + String address = + peerAddress.getHostAddress(); - InetAddress peerAddress; + String community = + new OctetString(event.getSecurityName()).toString(); - if ( peer instanceof UdpAddress ) - { - peerAddress = ( (UdpAddress)peer ).getInetAddress ( ); - } - else if ( peer instanceof TcpAddress ) - { - peerAddress = ( (TcpAddress)peer ).getInetAddress ( ); - } - else - { - log.debug ( "Unsupported transport: " + peer.getClass().getName ( ) ); - - return; - } - - String address = peerAddress.getHostAddress ( ); - - String community = new OctetString ( event.getSecurityName ( ) ).toString( ); - - LogTrackPlugin plugin = getPlugin ( address, community ); - - if ( plugin == null ) - { - plugin = getPlatformPlugin ( ); - - if ( plugin != null ) - { - if ( log.isDebugEnabled ( ) ) - { - log.debug ( "No plugin for " + address + ", routing to default platform: " + plugin.getName ( ) ); + LogTrackPlugin plugin = getPlugin(address, community); + if (plugin == null) { + plugin = getPlatformPlugin(); + if (plugin != null) { + if (log.isDebugEnabled()) { + log.debug("No plugin for " + address + + ", routing to default platform: " + + plugin.getName()); + } } - } - } + } + if (plugin == null) { + if (log.isDebugEnabled()) { + log.debug("No plugin for " + address + + ", msg=" + getMessage(event)); + } + } + else { + String msg = getMessage(event); + if (log.isDebugEnabled()) { + log.debug("Msg=" + msg); + } + plugin.reportEvent(System.currentTimeMillis(), + LogTrackPlugin.LOGLEVEL_ERROR, + address, + msg); + } + } - if ( plugin == null ) - { - if ( log.isDebugEnabled ( ) ) - { - log.debug ( "No plugin for " + address + ", msg=" + getMessage ( event ) ); - } - } - else - { - String msg = getMessage ( event ); + public static void main(String[] args) throws Exception { + SNMPTrapReceiver.start(System.getProperties()); - if ( log.isDebugEnabled ( ) ) - { - log.debug ( "Msg=" + msg ); - } - - plugin.reportEvent ( System.currentTimeMillis ( ), - LogTrackPlugin.LOGLEVEL_ERROR, - address, - msg ); - } - } - - public static void main ( String[] args ) throws Exception - { - SNMPTrapReceiver.start ( System.getProperties ( ) ); - - System.out.println ( "Ready" ); - System.in.read ( ); - System.out.print ( "Shutting down..." ); - - SNMPTrapReceiver.shutdown ( ); - - System.out.println ( "done" ); - } + System.out.println("Ready"); + System.in.read(); + System.out.print("Shutting down..."); + SNMPTrapReceiver.shutdown(); + System.out.println("done"); + } } |
From: <bo...@hy...> - 2010-01-06 09:22:58
|
Author: bob Date: 2010-01-06 01:22:50 -0800 (Wed, 06 Jan 2010) New Revision: 14131 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14131 Modified: trunk/etc/version.properties Log: Release 4.3.0 build #1311 Modified: trunk/etc/version.properties =================================================================== --- trunk/etc/version.properties 2010-01-06 01:21:36 UTC (rev 14130) +++ trunk/etc/version.properties 2010-01-06 09:22:50 UTC (rev 14131) @@ -1,3 +1,3 @@ -#Tue Jan 05 00:28:53 PST 2010 +#Wed Jan 06 00:28:32 PST 2010 version=4.3.0 -build=1310 +build=1311 |
From: Raghu K. <ark...@gm...> - 2010-01-06 04:55:46
|
Hi thanks for the reply, i didn't tried what you said. I am going ahead to try out . BR, Raghu Kiran A On Tue, Jan 5, 2010 at 6:02 AM, Doug MacEachern <do...@hy...> wrote: > Hi Raghu, > > I don't have any experience with arm, but the linux ports to ia64 and s390 > architectures use the same build tools as x86 (jdk, ant, perl and gcc): > http://support.hyperic.com/display/SIGAR/Home#Home-building > > Have you tried that? > |
From: <dcr...@hy...> - 2010-01-06 01:21:46
|
Author: dcrutchf Date: 2010-01-05 17:21:36 -0800 (Tue, 05 Jan 2010) New Revision: 14130 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14130 Added: trunk/thirdparty/lib/spring-security/ trunk/thirdparty/lib/spring-security/org.springframework.aop-3.0.0.RELEASE.jar trunk/thirdparty/lib/spring-security/org.springframework.asm-3.0.0.RELEASE.jar trunk/thirdparty/lib/spring-security/org.springframework.beans-3.0.0.RELEASE.jar trunk/thirdparty/lib/spring-security/org.springframework.context-3.0.0.RELEASE.jar trunk/thirdparty/lib/spring-security/org.springframework.context.support-3.0.0.RELEASE.jar trunk/thirdparty/lib/spring-security/org.springframework.core-3.0.0.RELEASE.jar trunk/thirdparty/lib/spring-security/org.springframework.expression-3.0.0.RELEASE.jar trunk/thirdparty/lib/spring-security/org.springframework.jdbc-3.0.0.RELEASE.jar trunk/thirdparty/lib/spring-security/org.springframework.transaction-3.0.0.RELEASE.jar trunk/thirdparty/lib/spring-security/org.springframework.web-3.0.0.RELEASE.jar trunk/thirdparty/lib/spring-security/spring-security-config-3.0.0.RELEASE.jar trunk/thirdparty/lib/spring-security/spring-security-core-3.0.0.RELEASE.jar trunk/thirdparty/lib/spring-security/spring-security-taglibs-3.0.0.RELEASE.jar trunk/thirdparty/lib/spring-security/spring-security-web-3.0.0.RELEASE.jar Modified: trunk/.classpath trunk/build.xml Log: Updated build script to use and deploy Spring Security 3 and it's dependencies Modified: trunk/.classpath =================================================================== --- trunk/.classpath 2010-01-05 09:24:47 UTC (rev 14129) +++ trunk/.classpath 2010-01-06 01:21:36 UTC (rev 14130) @@ -52,6 +52,20 @@ <classpathentry kind="lib" path="thirdparty/lib/commons-chain-1.2.jar"/> <classpathentry kind="lib" path="thirdparty/lib/jstl-1.1.2.jar"/> <classpathentry kind="lib" path="thirdparty/lib/standard-1.1.2.jar"/> + <classpathentry kind="lib" path="thirdparty/lib/spring-security/org.springframework.aop-3.0.0.RELEASE.jar"/> + <classpathentry kind="lib" path="thirdparty/lib/spring-security/org.springframework.asm-3.0.0.RELEASE.jar"/> + <classpathentry kind="lib" path="thirdparty/lib/spring-security/org.springframework.beans-3.0.0.RELEASE.jar"/> + <classpathentry kind="lib" path="thirdparty/lib/spring-security/org.springframework.context-3.0.0.RELEASE.jar"/> + <classpathentry kind="lib" path="thirdparty/lib/spring-security/org.springframework.context.support-3.0.0.RELEASE.jar"/> + <classpathentry kind="lib" path="thirdparty/lib/spring-security/org.springframework.core-3.0.0.RELEASE.jar"/> + <classpathentry kind="lib" path="thirdparty/lib/spring-security/org.springframework.expression-3.0.0.RELEASE.jar"/> + <classpathentry kind="lib" path="thirdparty/lib/spring-security/org.springframework.jdbc-3.0.0.RELEASE.jar"/> + <classpathentry kind="lib" path="thirdparty/lib/spring-security/org.springframework.transaction-3.0.0.RELEASE.jar"/> + <classpathentry kind="lib" path="thirdparty/lib/spring-security/org.springframework.web-3.0.0.RELEASE.jar"/> + <classpathentry kind="lib" path="thirdparty/lib/spring-security/spring-security-config-3.0.0.RELEASE.jar"/> + <classpathentry kind="lib" path="thirdparty/lib/spring-security/spring-security-core-3.0.0.RELEASE.jar"/> + <classpathentry kind="lib" path="thirdparty/lib/spring-security/spring-security-taglibs-3.0.0.RELEASE.jar"/> + <classpathentry kind="lib" path="thirdparty/lib/spring-security/spring-security-web-3.0.0.RELEASE.jar"/> <classpathentry kind="src" path="plugins/vmware/src"/> <classpathentry kind="src" path="plugins/weblogic/doc"/> <classpathentry kind="src" path="plugins/weblogic/src"/> Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2010-01-05 09:24:47 UTC (rev 14129) +++ trunk/build.xml 2010-01-06 01:21:36 UTC (rev 14130) @@ -45,6 +45,7 @@ <property name="xdoclet.lib" location="${thirdparty.lib}/xdoclet"/> <property name="hibernate.lib" location="${thirdparty.lib}/hibernate"/> <property name="tapestry_lib" location="${thirdparty.lib}/tapestry"/> + <property name="spring-security.libs" location="${thirdparty.lib}/spring-security"/> <property name="webapp.home" location="${hq.home}/web" /> <property name="ear.dir" location="${build.dir}/hq.ear" /> @@ -103,8 +104,9 @@ includes="postgresql-8.2-*.jdbc3.jar"/> <fileset dir="${thirdparty.lib}/mysql_jdbc" includes="mysql*.jar"/> <fileset dir="${thirdparty.lib}/mx4j" includes="*.jar" /> + <fileset dir="${spring-security.libs}" includes="*.jar" /> <fileset dir="${thirdparty.lib}/tapestry" includes="*.jar" /> - <fileset dir="${wrapper.lib}" includes="*.jar" /> + <fileset dir="${wrapper.lib}" includes="*.jar" /> <fileset dir="${xdoclet.lib}" includes="*.jar" /> <fileset dir="${hibernate.lib}" includes="*.jar" /> <fileset dir="${jboss.home}/server/default/lib" @@ -501,6 +503,9 @@ <include name="concurrent-1.3.2.jar" /> <include name="dom4j-1.6.1.jar" /> </fileset> + <fileset dir="${spring-security.libs}"> + <include name="org.springframework.*.jar" /> + </fileset> <fileset dir="${tapestry_lib}"> <include name="backport-util-concurrent-3.1.jar" /> <include name="commons-fileupload-1.2.jar" /> @@ -706,6 +711,9 @@ <include name="struts-el-1.3.10.jar" /> <include name="urlrewrite-3.1.0.jar" /> </fileset> + <fileset dir="${spring-security.libs}"> + <include name="spring-security-*.jar" /> + </fileset> </copy> <!--copy todir="${war.dir}/WEB-INF/classes" > Added: trunk/thirdparty/lib/spring-security/org.springframework.aop-3.0.0.RELEASE.jar =================================================================== (Binary files differ) Property changes on: trunk/thirdparty/lib/spring-security/org.springframework.aop-3.0.0.RELEASE.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/thirdparty/lib/spring-security/org.springframework.asm-3.0.0.RELEASE.jar =================================================================== (Binary files differ) Property changes on: trunk/thirdparty/lib/spring-security/org.springframework.asm-3.0.0.RELEASE.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/thirdparty/lib/spring-security/org.springframework.beans-3.0.0.RELEASE.jar =================================================================== (Binary files differ) Property changes on: trunk/thirdparty/lib/spring-security/org.springframework.beans-3.0.0.RELEASE.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/thirdparty/lib/spring-security/org.springframework.context-3.0.0.RELEASE.jar =================================================================== (Binary files differ) Property changes on: trunk/thirdparty/lib/spring-security/org.springframework.context-3.0.0.RELEASE.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/thirdparty/lib/spring-security/org.springframework.context.support-3.0.0.RELEASE.jar =================================================================== (Binary files differ) Property changes on: trunk/thirdparty/lib/spring-security/org.springframework.context.support-3.0.0.RELEASE.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/thirdparty/lib/spring-security/org.springframework.core-3.0.0.RELEASE.jar =================================================================== (Binary files differ) Property changes on: trunk/thirdparty/lib/spring-security/org.springframework.core-3.0.0.RELEASE.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/thirdparty/lib/spring-security/org.springframework.expression-3.0.0.RELEASE.jar =================================================================== (Binary files differ) Property changes on: trunk/thirdparty/lib/spring-security/org.springframework.expression-3.0.0.RELEASE.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/thirdparty/lib/spring-security/org.springframework.jdbc-3.0.0.RELEASE.jar =================================================================== (Binary files differ) Property changes on: trunk/thirdparty/lib/spring-security/org.springframework.jdbc-3.0.0.RELEASE.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/thirdparty/lib/spring-security/org.springframework.transaction-3.0.0.RELEASE.jar =================================================================== (Binary files differ) Property changes on: trunk/thirdparty/lib/spring-security/org.springframework.transaction-3.0.0.RELEASE.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/thirdparty/lib/spring-security/org.springframework.web-3.0.0.RELEASE.jar =================================================================== (Binary files differ) Property changes on: trunk/thirdparty/lib/spring-security/org.springframework.web-3.0.0.RELEASE.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/thirdparty/lib/spring-security/spring-security-config-3.0.0.RELEASE.jar =================================================================== (Binary files differ) Property changes on: trunk/thirdparty/lib/spring-security/spring-security-config-3.0.0.RELEASE.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/thirdparty/lib/spring-security/spring-security-core-3.0.0.RELEASE.jar =================================================================== (Binary files differ) Property changes on: trunk/thirdparty/lib/spring-security/spring-security-core-3.0.0.RELEASE.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/thirdparty/lib/spring-security/spring-security-taglibs-3.0.0.RELEASE.jar =================================================================== (Binary files differ) Property changes on: trunk/thirdparty/lib/spring-security/spring-security-taglibs-3.0.0.RELEASE.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/thirdparty/lib/spring-security/spring-security-web-3.0.0.RELEASE.jar =================================================================== (Binary files differ) Property changes on: trunk/thirdparty/lib/spring-security/spring-security-web-3.0.0.RELEASE.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream |
From: <bo...@hy...> - 2010-01-05 09:24:56
|
Author: bob Date: 2010-01-05 01:24:47 -0800 (Tue, 05 Jan 2010) New Revision: 14129 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14129 Modified: trunk/etc/version.properties Log: Release 4.3.0 build #1310 Modified: trunk/etc/version.properties =================================================================== --- trunk/etc/version.properties 2010-01-04 09:18:59 UTC (rev 14128) +++ trunk/etc/version.properties 2010-01-05 09:24:47 UTC (rev 14129) @@ -1,3 +1,3 @@ -#Mon Jan 04 00:27:24 PST 2010 +#Tue Jan 05 00:28:53 PST 2010 version=4.3.0 -build=1309 +build=1310 |
From: Doug M. <do...@hy...> - 2010-01-05 01:11:50
|
Does it work when you run the following w/ the sigar binary distro? java -jar sigar-bin/lib/sigar.jar version |
From: Doug M. <do...@hy...> - 2010-01-05 01:02:50
|
Hi Justin, This doesn't sound like a linkage issue, SigarFileNotFoundException will be thrown by this method if the disk name is invalid. For example: java -jar sigar.jar iostat g:\ g:\ No such file or directory dir g:\ The system cannot find the path specified. |
From: Doug M. <do...@hy...> - 2010-01-05 00:46:26
|
Hi, SIGAR does not have any built-in remoting. The closest we have are the sigar JMX MBeans which can be loaded into any Java processes and exposed via remote JMX. There's also Hyperic HQ, the agents use sigar to report a central server. |
From: Doug M. <do...@hy...> - 2010-01-05 00:46:26
|
Hi Simon, I created a ticket for this: http://jira.hyperic.com/browse/SIGAR-194 You can grab a copy of the .dll w/ the change here: http://hudson.hyperic.com/job/sigar-1.6-x86-winnt/ You won't see the remote drive letter however, the value of getDevName() will just be: "\\192.168.0.2\user" |
From: Doug M. <do...@hy...> - 2010-01-05 00:36:47
|
Hi Raghu, I don't have any experience with arm, but the linux ports to ia64 and s390 architectures use the same build tools as x86 (jdk, ant, perl and gcc): http://support.hyperic.com/display/SIGAR/Home#Home-building Have you tried that? |