Author: glaullon Date: 2010-03-01 10:32:14 -0800 (Mon, 01 Mar 2010) New Revision: 14336 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14336 Added: trunk/plugins/netapp/ trunk/plugins/netapp/etc/ trunk/plugins/netapp/etc/hq-plugin.xml trunk/plugins/netapp/src/ trunk/plugins/netapp/src/org/ trunk/plugins/netapp/src/org/hyperic/ trunk/plugins/netapp/src/org/hyperic/hq/ trunk/plugins/netapp/src/org/hyperic/hq/plugin/ trunk/plugins/netapp/src/org/hyperic/hq/plugin/netapp/ trunk/plugins/netapp/src/org/hyperic/hq/plugin/netapp/NetAppMeasurement.java trunk/plugins/netapp/src/org/hyperic/hq/plugin/netapp/NetAppPlatformDetector.java trunk/plugins/netapp/src/org/hyperic/hq/plugin/netapp/NetAppServicesDetector.java Log: [HPD-198] Netapp plugin Added: trunk/plugins/netapp/etc/hq-plugin.xml =================================================================== --- trunk/plugins/netapp/etc/hq-plugin.xml (rev 0) +++ trunk/plugins/netapp/etc/hq-plugin.xml 2010-03-01 18:32:14 UTC (rev 14336) @@ -0,0 +1,274 @@ + +<plugin> + <classpath> + <include name="pdk/plugins/netdevice-plugin.jar"/> + </classpath> + + <platform name="NetApp Filer"> + + <config include="snmp"> + </config> + <!--option name="snmpVersion" description="SNMP Version" type="enum"> + <include name="v1"/> + <include name="v2c"/> + <include name="v3"/> + </option> + </config--> + + <properties> + <!-- sysContact --> + <property name="1.3.6.1.2.1.1.4.0" description="Contact Name"/> + <!-- sysName --> + <property name="1.3.6.1.2.1.1.5.0" description="Name"/> + <!-- sysLocation --> + <property name="1.3.6.1.2.1.1.6.0" description="Location"/> + <!-- productGuiUrl --> + <property name="1.3.6.1.4.1.789.1.1.7.0" description="Admin URL"/> + <!-- productSerialNum --> + <property name="1.3.6.1.4.1.789.1.1.9.0" description="Serial number"/> + <!-- productMachineType --> + <property name="1.3.6.1.4.1.789.1.1.13.0" description="Machine Type"/> + <property name="1.3.6.1.4.1.789.1.2.3.6" description="Cluster Failover Partner Name"/> + <property name="1.3.6.1.4.1.789.1.2.3.7" description="Cluster Failover Partner System ID"/> + </properties> + + <plugin type="autoinventory" class="org.hyperic.hq.plugin.netapp.NetAppPlatformDetector"/> + <plugin type="measurement" class="org.hyperic.hq.plugin.netapp.NetAppMeasurement"/> + <plugin type="log_track" class="org.hyperic.hq.plugin.netdevice.SNMPTrapReceiverPlugin"/> + + <filter name="template" value="${snmp.template}:${alias}"/> + <!-- sysUpTime --> + <metric name="Availability" template="${snmp.template},Avail=true:1.3.6.1.2.1.1.3.0" indicator="true"/> + <!-- sysUpTime --> + <metric name="Uptime" alias="1.3.6.1.2.1.1.3.0" category="AVAILABILITY" units="jiffys" collectionType="static"/> + <!-- cpuBusyTimePerCent --> + <metric name="CPU Busy" alias="1.3.6.1.4.1.789.1.2.1.3.0" indicator="true" units="percent"/> + <!-- calc=misc[High,Low]NfsOps --> + <metric name="NFS Operations" alias="calc=1.3.6.1.4.1.789.1.2.2.[5,6].0" indicator="true" collectionType="trendsup" units="none"/> + <!-- calc=misc[High,Low]CifsOps --> + <metric name="CIFS Operations" alias="calc=1.3.6.1.4.1.789.1.2.2.[7,8].0" indicator="true" collectionType="trendsup" units="none"/> + <!-- calc=misc[High,Low]HttpOps --> + <metric name="HTTP Operations" alias="calc=1.3.6.1.4.1.789.1.2.2.[9,10].0" indicator="true" collectionType="trendsup" units="none"/> + <!-- calc=misc[High,Low]NetRcvdBytes --> + <metric name="Bytes Received" alias="calc=1.3.6.1.4.1.789.1.2.2.[11,12].0" indicator="true" collectionType="trendsup" units="B"/> + <!-- calc=misc[High,Low]NetSentBytes --> + <metric name="Bytes Sent" alias="calc=1.3.6.1.4.1.789.1.2.2.[13,14].0" indicator="true" collectionType="trendsup" units="B"/> + <!-- calc=misc[High,Low]DiskReadBytes --> + <metric name="Bytes Read From Disk" alias="calc=1.3.6.1.4.1.789.1.2.2.[15,16].0" indicator="true" collectionType="trendsup" units="B"/> + <!-- calc=misc[High,Low]DiskWriteBytes --> + <metric name="Bytes Write To Disk" alias="calc=1.3.6.1.4.1.789.1.2.2.[17,18].0" indicator="true" collectionType="trendsup" units="B"/> + <!-- calc=misc[High,Low]TapeReadBytes --> + <metric name="Bytes Read From Tape" alias="calc=1.3.6.1.4.1.789.1.2.2.[19,20].0" indicator="true" collectionType="trendsup" units="B"/> + <!-- calc=misc[High,Low]TapeWriteBytes --> + <metric name="Bytes Write To Tape" alias="calc=1.3.6.1.4.1.789.1.2.2.[21,22].0" indicator="true" collectionType="trendsup" units="B"/> + + + <server> + <plugin type="autoinventory" class="org.hyperic.hq.plugin.netapp.NetAppServicesDetector"/> + <plugin type="measurement" class="org.hyperic.hq.plugin.netapp.NetAppMeasurement"/> + + <service name="File System"> + <plugin type="measurement" class="org.hyperic.hq.plugin.netapp.NetAppMeasurement"/> + <plugin type="autoinventory"/> + <config> + <option name="snmpIndexValue" description="File System"/> + </config> + <!-- dfFileSys --> + <property name="snmpIndexName" value="1.3.6.1.4.1.789.1.5.4.1.2"/> + <properties> + <!-- dfMountedOn --> + <property name="1.3.6.1.4.1.789.1.5.4.1.10" description="Mount point"/> + </properties> + <filter name="index" value="snmpIndexName=${snmpIndexName},snmpIndexValue=%snmpIndexValue%"/> + <filter name="template" value="${snmp.template}:${alias}:${index}"/> + <!-- dfStatus --> + <metric name="Availability" template="${snmp.template},Avail=true:1.3.6.1.4.1.789.1.5.4.1.20:${index}" indicator="true"/> + <!-- dfPerCentKBytesCapacity --> + <metric name="Space Used percent" alias="1.3.6.1.4.1.789.1.5.4.1.6" units="percent" indicator="true"/> + <!-- dfPerCentInodeCapacity --> + <metric name="Inodes Used percent" alias="1.3.6.1.4.1.789.1.5.4.1.9" units="percent" indicator="true"/> + <!-- dfKBytesTotal --> + <metric name="Space Total" alias="1.3.6.1.4.1.789.1.5.4.1.3" units="KB"/> + <!-- dfKBytesUsed --> + <metric name="Space Used" alias="1.3.6.1.4.1.789.1.5.4.1.4" units="KB"/> + <!-- dfKBytesAvail --> + <metric name="Space Avail" alias="1.3.6.1.4.1.789.1.5.4.1.5" units="KB"/> + <!-- dfInodesUsed --> + <metric name="Inodes Used" alias="1.3.6.1.4.1.789.1.5.4.1.7" units="none"/> + <!-- dfInodesFree --> + <metric name="Inodes Avail" alias="1.3.6.1.4.1.789.1.5.4.1.8" units="none"/> + <!-- dfMaxFilesUsed --> + <metric name="Files Used" alias="1.3.6.1.4.1.789.1.5.4.1.12" units="none"/> + <!-- dfMaxFilesAvail --> + <metric name="Files Max" alias="1.3.6.1.4.1.789.1.5.4.1.11" units="none"/> + </service> + + <service name="Interface"> + <plugin type="measurement" class="org.hyperic.hq.plugin.netapp.NetAppMeasurement"/> + <plugin type="autoinventory"/> + <config> + <option name="snmpIndexValue" description="Interface name"/> + </config> + + <!-- ifDescr --> + <property name="snmpIndexName" value="1.3.6.1.2.1.2.2.1.2"/> + + + <properties> + <!-- ifType --> + <property name="1.3.6.1.2.1.2.2.1.3" description="Type"/> + <!-- ifSpeed --> + <property name="1.3.6.1.2.1.2.2.1.5" description="Speed"/> + <!-- ifMtu --> + <property name="1.3.6.1.2.1.2.2.1.4" description="MTU"/> + </properties> + + <filter name="index" value="snmpIndexName=${snmpIndexName},snmpIndexValue=%snmpIndexValue%"/> + <filter name="template" value="${snmp.template}:${alias}:${index}"/> + + <!-- ifOperStatus --> + <metric name="Availability" template="${snmp.template},Avail=true:1.3.6.1.2.1.2.2.1.8:${index}" indicator="true"/> + <!-- calc=if[High,Low]InOctets --> + <metric name="Bytes Received" alias="calc=1.3.6.1.4.1.789.1.22.1.2.1.[3,4]" category="THROUGHPUT" units="B" collectionType="trendsup" indicator="true"/> + <!-- calc=if[High,Low]OutOctets --> + <metric name="Bytes Sent" alias="calc=1.3.6.1.4.1.789.1.22.1.2.1.[15,16]" category="THROUGHPUT" units="B" collectionType="trendsup" indicator="true"/> + <!-- calc=if[High,Low]InUcastPkts --> + <metric name="Inbound Unicast Packets" alias="calc=1.3.6.1.4.1.789.1.22.1.2.1.[5,6]" category="THROUGHPUT" units="B" collectionType="trendsup"/> + <!-- calc=if[High,Low]OutUcastPkts --> + <metric name="OutBound Unicast Packets" alias="calc=1.3.6.1.4.1.789.1.22.1.2.1.[17,18]" category="THROUGHPUT" units="B" collectionType="trendsup"/> + <!-- calc=if[High,Low]InNUcastPkts --> + <metric name="Inbound Non-Unicast Packets" alias="calc=1.3.6.1.4.1.789.1.22.1.2.1.[7,8]" category="THROUGHPUT" units="B" collectionType="trendsup"/> + <!-- calc=if[High,Low]OutNUcastPkts --> + <metric name="OutBound Non-Unicast Packets" alias="calc=1.3.6.1.4.1.789.1.22.1.2.1.[19,20]" category="THROUGHPUT" units="B" collectionType="trendsup"/> + <!-- calc=if[High,Low]InDiscards --> + <metric name="Inbound Packets Discarded" alias="calc=1.3.6.1.4.1.789.1.22.1.2.1.[9,10]" category="THROUGHPUT" units="B" collectionType="trendsup"/> + <!-- calc=if[High,Low]OutDiscards --> + <metric name="OutBound Packets Discarded" alias="calc=1.3.6.1.4.1.789.1.22.1.2.1.[21,22]" category="THROUGHPUT" units="B" collectionType="trendsup"/> + <!-- calc=if[High,Low]InErrors --> + <metric name="Inbound Packets Errors" alias="calc=1.3.6.1.4.1.789.1.22.1.2.1.[11,12]" category="THROUGHPUT" units="B" collectionType="trendsup"/> + <!-- calc=if[High,Low]OutErrors --> + <metric name="OutBound Packets Errors" alias="calc=1.3.6.1.4.1.789.1.22.1.2.1.[23,24]" category="THROUGHPUT" units="B" collectionType="trendsup"/> + <!-- calc=if[High,Low]InUnknownProtos --> + <metric name="Inbound Packets Protocol Errors" alias="calc=1.3.6.1.4.1.789.1.22.1.2.1.[13,14]" category="THROUGHPUT" units="B" collectionType="trendsup"/> + </service> + + <service name="CIFS Server"> + <plugin type="measurement" class="org.hyperic.hq.plugin.netapp.NetAppMeasurement"/> + <filter name="template" value="${snmp.template}:${alias}"/> + <!-- cifsIsEnabled --> + <metric name="Availability" template="${snmp.template},AvailOK=2:1.3.6.1.4.1.789.1.7.1.1.0" indicator="true"/> + <!-- cifsNSessions --> + <metric name="Sessions" alias="1.3.6.1.4.1.789.1.7.2.12.0" indicator="true" units="none"/> + <!-- cifsNOpenFiles --> + <metric name="Open Files" alias="1.3.6.1.4.1.789.1.7.2.13.0" indicator="true" units="none"/> + <!-- cifsTotalOps --> + <metric name="Operations" alias="1.3.6.1.4.1.789.1.7.3.1.1.1.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- cifsTotalCalls --> + <metric name="Calls" alias="1.3.6.1.4.1.789.1.7.3.1.1.2.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- cifsBadCalls --> + <metric name="Bad Calls" alias="1.3.6.1.4.1.789.1.7.3.1.1.3.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- cifsGetAttrs --> + <metric name="GetAttr" alias="1.3.6.1.4.1.789.1.7.3.1.1.4.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- cifsReads --> + <metric name="Read" alias="1.3.6.1.4.1.789.1.7.3.1.1.5.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- cifsWrites --> + <metric name="Write" alias="1.3.6.1.4.1.789.1.7.3.1.1.6.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- cifsLocks --> + <metric name="Lock" alias="1.3.6.1.4.1.789.1.7.3.1.1.7.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- cifsOpens --> + <metric name="Open/Cl" alias="1.3.6.1.4.1.789.1.7.3.1.1.8.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- cifsDirOps --> + <metric name="Direct" alias="1.3.6.1.4.1.789.1.7.3.1.1.9.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- cifsOthers --> + <metric name="Other" alias="1.3.6.1.4.1.789.1.7.3.1.1.10.0" indicator="true" collectionType="trendsup" units="none"/> + </service> + + <service name="NFS server v2"> + <plugin type="measurement" class="org.hyperic.hq.plugin.netapp.NetAppMeasurement"/> + + <filter name="template" value="${snmp.template}:${alias}"/> + <!-- nfsIsLicensed --> + <metric name="Availability" template="${snmp.template},AvailOK=2:1.3.6.1.4.1.789.1.3.3.1.0" indicator="true"/> + <!-- tv2Read512Calls --> + <metric name="Read request 0-511" alias="1.3.6.1.4.1.789.1.3.2.2.6.1.1.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv2Write512Calls --> + <metric name="Write request 0-511" alias="1.3.6.1.4.1.789.1.3.2.2.6.2.1.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv2Read1KCalls --> + <metric name="Read request 512-1023" alias="1.3.6.1.4.1.789.1.3.2.2.6.1.2.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv2Write1KCalls --> + <metric name="Write request 512-1023" alias="1.3.6.1.4.1.789.1.3.2.2.6.2.2.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv2Read2KCalls --> + <metric name="Read request 1K-2047" alias="1.3.6.1.4.1.789.1.3.2.2.6.1.3.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv2Write2KCalls --> + <metric name="Write request 1K-2047" alias="1.3.6.1.4.1.789.1.3.2.2.6.2.3.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv2Read4KCalls --> + <metric name="Read request 2K-4095" alias="1.3.6.1.4.1.789.1.3.2.2.6.1.4.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv2Write4KCalls --> + <metric name="Write request 2K-4095" alias="1.3.6.1.4.1.789.1.3.2.2.6.2.4.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv2Read8KCalls --> + <metric name="Read request 4K-8191" alias="1.3.6.1.4.1.789.1.3.2.2.6.1.5.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv2Write8KCalls --> + <metric name="Write request 4K-8191" alias="1.3.6.1.4.1.789.1.3.2.2.6.2.5.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv2Read16KCalls --> + <metric name="Read request 8K-16383" alias="1.3.6.1.4.1.789.1.3.2.2.6.1.6.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv2Write16KCalls --> + <metric name="Write request 8K-16383" alias="1.3.6.1.4.1.789.1.3.2.2.6.2.6.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv2Read32KCalls --> + <metric name="Read request 16K-32767" alias="1.3.6.1.4.1.789.1.3.2.2.6.1.7.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv2Write32KCalls --> + <metric name="Write request 16K-32767" alias="1.3.6.1.4.1.789.1.3.2.2.6.2.7.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv2Read128KCalls --> + <metric name="Read request 64K-131071" alias="1.3.6.1.4.1.789.1.3.2.2.6.1.9.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv2Write64KCalls --> + <metric name="Write request 32K-65535" alias="1.3.6.1.4.1.789.1.3.2.2.6.2.8.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv2Read64KCalls --> + <metric name="Read request 32K-65535" alias="1.3.6.1.4.1.789.1.3.2.2.6.1.8.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv2Write128KCalls --> + <metric name="Write request 64K-131071" alias="1.3.6.1.4.1.789.1.3.2.2.6.2.9.0" indicator="true" collectionType="trendsup" units="none"/> + </service> + + <service name="NFS server v3"> + <plugin type="measurement" class="org.hyperic.hq.plugin.netapp.NetAppMeasurement"/> + <filter name="template" value="${snmp.template}:${alias}"/> + <!-- nfsIsLicensed --> + <metric name="Availability" template="${snmp.template},AvailOK=2:1.3.6.1.4.1.789.1.3.3.1.0" indicator="true"/> + <!-- tv3Read512Calls --> + <metric name="Read request 0-511" alias="1.3.6.1.4.1.789.1.3.2.2.6.3.1.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv3Write512Calls --> + <metric name="Write request 0-511" alias="1.3.6.1.4.1.789.1.3.2.2.6.4.1.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv3Read1KCalls --> + <metric name="Read request 512-1023" alias="1.3.6.1.4.1.789.1.3.2.2.6.3.2.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv3Write1KCalls --> + <metric name="Write request 512-1023" alias="1.3.6.1.4.1.789.1.3.2.2.6.4.2.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv3Read2KCalls --> + <metric name="Read request 1K-2047" alias="1.3.6.1.4.1.789.1.3.2.2.6.3.3.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv3Write2KCalls --> + <metric name="Write request 1K-2047" alias="1.3.6.1.4.1.789.1.3.2.2.6.4.3.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv3Read4KCalls --> + <metric name="Read request 2K-4095" alias="1.3.6.1.4.1.789.1.3.2.2.6.3.4.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv3Write4KCalls --> + <metric name="Write request 2K-4095" alias="1.3.6.1.4.1.789.1.3.2.2.6.4.4.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv3Read8KCalls --> + <metric name="Read request 4K-8191" alias="1.3.6.1.4.1.789.1.3.2.2.6.3.5.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv3Write8KCalls --> + <metric name="Write request 4K-8191" alias="1.3.6.1.4.1.789.1.3.2.2.6.4.5.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv3Read16KCalls --> + <metric name="Read request 8K-16383" alias="1.3.6.1.4.1.789.1.3.2.2.6.3.6.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv3Write16KCalls --> + <metric name="Write request 8K-16383" alias="1.3.6.1.4.1.789.1.3.2.2.6.4.6.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv3Read32KCalls --> + <metric name="Read request 16K-32767" alias="1.3.6.1.4.1.789.1.3.2.2.6.3.7.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv3Write32KCalls --> + <metric name="Write request 16K-32767" alias="1.3.6.1.4.1.789.1.3.2.2.6.4.7.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv3Read128KCalls --> + <metric name="Read request 64K-131071" alias="1.3.6.1.4.1.789.1.3.2.2.6.3.9.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv3Write64KCalls --> + <metric name="Write request 32K-65535" alias="1.3.6.1.4.1.789.1.3.2.2.6.4.8.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv3Read64KCalls --> + <metric name="Read request 32K-65535" alias="1.3.6.1.4.1.789.1.3.2.2.6.3.8.0" indicator="true" collectionType="trendsup" units="none"/> + <!-- tv3Write128KCalls --> + <metric name="Write request 64K-131071" alias="1.3.6.1.4.1.789.1.3.2.2.6.4.9.0" indicator="true" collectionType="trendsup" units="none"/> + </service> + </server> + </platform> +</plugin> \ No newline at end of file Added: trunk/plugins/netapp/src/org/hyperic/hq/plugin/netapp/NetAppMeasurement.java =================================================================== --- trunk/plugins/netapp/src/org/hyperic/hq/plugin/netapp/NetAppMeasurement.java (rev 0) +++ trunk/plugins/netapp/src/org/hyperic/hq/plugin/netapp/NetAppMeasurement.java 2010-03-01 18:32:14 UTC (rev 14336) @@ -0,0 +1,78 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.hyperic.hq.plugin.netapp; + +import org.apache.commons.logging.Log; +import org.hyperic.hq.product.Metric; +import org.hyperic.hq.product.MetricNotFoundException; +import org.hyperic.hq.product.MetricUnreachableException; +import org.hyperic.hq.product.MetricValue; +import org.hyperic.hq.product.PluginException; +import org.hyperic.hq.product.SNMPMeasurementPlugin; +import org.hyperic.util.config.ConfigResponse; + +/** + * + * @author laullon + */ +public class NetAppMeasurement extends SNMPMeasurementPlugin { + + Log log = getLog(); + private final static double HIGH = Math.pow(2, 32); + + public String translate(String template, ConfigResponse config) { + template = super.translate(template, config); + if ((template.contains("AvailOK=")) || (template.contains(":calc="))) { + log.debug("[translate] --> " + template); + template = template.replace(":" + SNMPMeasurementPlugin.DOMAIN + ":", ":calc_" + SNMPMeasurementPlugin.DOMAIN + ":"); + template = template.replaceAll("calc=([^\\[]*)\\[([^,]*),([^\\]]*)\\]([^_|:]*)", "calc=$1$2$4,$1$3$4"); + log.debug("[translate] <-- " + template); + } + + return template; + } + + public MetricValue getValue(Metric metric) throws MetricUnreachableException, MetricNotFoundException, PluginException { + MetricValue res = null; + + if (metric.getAttributeName().startsWith("calc=")) { + String template_a = metric.toString().replaceAll("calc=([^,]*),([^$|:]*)", "$1"); + String template_b = metric.toString().replaceAll("calc=([^,]*),([^$|:]*)", "$2"); + + Metric metric_a = Metric.parse(template_a); + Metric metric_b = Metric.parse(template_b); + if (log.isDebugEnabled()) { + log.debug("[getValue] " + metric_a + "'"); + log.debug("[getValue] " + metric_b + "'"); + } + + double res_a = super.getValue(metric_a).getValue(); + double res_b = super.getValue(metric_b).getValue(); + + res = new MetricValue((res_a * HIGH) + res_b); + if (log.isDebugEnabled()) { + log.debug("[getValue] " + metric_a.getAttributeName() + " = '" + res_a + "'"); + log.debug("[getValue] " + metric_b.getAttributeName() + " = '" + res_b + "'"); + log.debug("[getValue] res = '" + res + "'"); + } + } else if (metric.getObjectProperty("AvailOK") != null) { + double resOK = Double.parseDouble(metric.getObjectProperty("AvailOK")); + res = super.getValue(metric); + + if (log.isDebugEnabled()) { + log.debug("[getValue] " + metric.getAttributeName() + " = '" + res + "' (AvailOK=" + resOK + ")"); + } + + if (res.getValue() == resOK) { + res = new MetricValue(Metric.AVAIL_UP); + } else { + res = new MetricValue(Metric.AVAIL_DOWN); + } + } else { + res = super.getValue(metric); + } + return res; + } +} Added: trunk/plugins/netapp/src/org/hyperic/hq/plugin/netapp/NetAppPlatformDetector.java =================================================================== --- trunk/plugins/netapp/src/org/hyperic/hq/plugin/netapp/NetAppPlatformDetector.java (rev 0) +++ trunk/plugins/netapp/src/org/hyperic/hq/plugin/netapp/NetAppPlatformDetector.java 2010-03-01 18:32:14 UTC (rev 14336) @@ -0,0 +1,36 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.hyperic.hq.plugin.netapp; + +import org.apache.commons.logging.Log; +import org.hyperic.hq.plugin.netdevice.NetworkDevicePlatformDetector; +import org.hyperic.hq.product.PlatformDetector; +import org.hyperic.hq.product.PlatformResource; +import org.hyperic.hq.product.PluginException; +import org.hyperic.hq.product.ProductPlugin; +import org.hyperic.snmp.SNMPClient; +import org.hyperic.util.config.ConfigResponse; + +/** + * + * @author administrator + */ +public class NetAppPlatformDetector extends NetworkDevicePlatformDetector { + + private Log log = getLog(); + + public PlatformResource getPlatformResource(ConfigResponse config) throws PluginException { + log.debug("[getPlatformResource] config=" + config); + String platformIp = config.getValue(ProductPlugin.PROP_PLATFORM_IP); + + config.setValue(SNMPClient.PROP_IP, platformIp); + config.setValue(SNMPClient.PROP_VERSION, SNMPClient.VALID_VERSIONS[0]); + config.setValue(SNMPClient.PROP_COMMUNITY, SNMPClient.DEFAULT_COMMUNITY); + config.setValue(SNMPClient.PROP_PORT, SNMPClient.DEFAULT_PORT_STRING); + + PlatformResource res = super.getPlatformResource(config); + return res; + } +} Added: trunk/plugins/netapp/src/org/hyperic/hq/plugin/netapp/NetAppServicesDetector.java =================================================================== --- trunk/plugins/netapp/src/org/hyperic/hq/plugin/netapp/NetAppServicesDetector.java (rev 0) +++ trunk/plugins/netapp/src/org/hyperic/hq/plugin/netapp/NetAppServicesDetector.java 2010-03-01 18:32:14 UTC (rev 14336) @@ -0,0 +1,88 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.hyperic.hq.plugin.netapp; + +import java.util.ArrayList; +import java.util.List; +import org.apache.commons.logging.Log; +import org.hyperic.hq.product.PlatformServiceDetector; +import org.hyperic.hq.product.PluginException; +import org.hyperic.hq.product.SNMPDetector; +import org.hyperic.hq.product.ServerResource; +import org.hyperic.hq.product.ServiceResource; +import org.hyperic.snmp.SNMPClient; +import org.hyperic.snmp.SNMPException; +import org.hyperic.snmp.SNMPSession; +import org.hyperic.util.config.ConfigResponse; + +/** + * + * @author laullon + */ +public class NetAppServicesDetector extends PlatformServiceDetector { + + private Log log = getLog(); + + private SNMPSession getSession(ConfigResponse config) { + SNMPSession res = null; + try { + config.setValue(SNMPClient.PROP_VERSION, SNMPClient.VALID_VERSIONS[0]); + res = new SNMPClient().getSession(config); + } catch (SNMPException e) { + log.error("Error getting SNMP session: " + e.getMessage(), e); + } + return res; + } + + public List getServerResources(ConfigResponse config) { + List res = new ArrayList(); + log.debug("[getServerResources] netapp:'" + config.getValue(SNMPClient.PROP_IP) + "' config=" + config); + if (config.getValue(SNMPClient.PROP_IP) != null) { + ServerResource server = getServer(config); + server.setProductConfig(config); + res.add(server); + } + return res; + } + + protected List discoverServices(ConfigResponse config) throws PluginException { + log.debug("[discoverServices] netapp:'" + config.getValue("snmpIp") + "' config=" + config); + List extServices = new ArrayList(); + + try { + extServices.addAll(SNMPDetector.discoverServices(this, config, getSession(config))); + } catch (PluginException e) { + log.debug("Error discoverServices netapp:'" + config.getValue("snmpIp") + "'" + e.getMessage(), e); + } + + ServiceResource s_cifs = new ServiceResource(); + s_cifs.setType(config.getValue("platform.type") + " CIFS Server"); + s_cifs.setServiceName("CIFS Server"); + s_cifs.setProductConfig(); + s_cifs.setMeasurementConfig(); + s_cifs.setResponseTimeConfig(new ConfigResponse()); + extServices.add(s_cifs); + + ServiceResource s_nfs_v3 = new ServiceResource(); + s_nfs_v3.setType(config.getValue("platform.type") + " NFS server v3"); + s_nfs_v3.setServiceName("NFS server v3"); + s_nfs_v3.setProductConfig(); + s_nfs_v3.setMeasurementConfig(); + s_nfs_v3.setResponseTimeConfig(new ConfigResponse()); + extServices.add(s_nfs_v3); + + ServiceResource s_nfs_v2 = new ServiceResource(); + s_nfs_v2.setType(config.getValue("platform.type") + " NFS server v2"); + s_nfs_v2.setServiceName("NFS server v2"); + s_nfs_v2.setProductConfig(); + s_nfs_v2.setMeasurementConfig(); + s_nfs_v2.setResponseTimeConfig(new ConfigResponse()); + extServices.add(s_nfs_v2); + + log.debug("[discoverServices] netapp:'" + config.getValue("snmpIp") + "' -> " + extServices.size() + " services"); + + return extServices; + } +} |