[SNMP4J] using snmp4j 1.9.3c

Ted Yu yuzhihong at gmail.com
Sat Jun 19 01:10:34 CEST 2010


Object Ids we use conform to:
http://www.oidview.com/mibs/0/HOST-RESOURCES-V2-MIB.html

On Fri, Jun 18, 2010 at 3:56 PM, Ted Yu <yuzhihong at gmail.com> wrote:

> Hi,
> Here are the packages on my CentOS:
> [hadoop at sjc9-flash-grid04 ~]$ yum list | grep snmp
> net-snmp.x86_64                            1:5.3.2.2-9.el5_5.1
> installed
> net-snmp-libs.x86_64                       1:5.3.2.2-9.el5_5.1
> installed
> net-snmp-utils.x86_64                      1:5.3.2.2-9.el5_5.1
> installed
> cluster-snmp.x86_64                        0.12.1-2.el5.centos
> base
> net-snmp-devel.i386                        1:5.3.2.2-9.el5_5.1
> updates
> net-snmp-devel.x86_64                      1:5.3.2.2-9.el5_5.1
> updates
> net-snmp-libs.i386                         1:5.3.2.2-9.el5_5.1
> updates
> net-snmp-perl.x86_64                       1:5.3.2.2-9.el5_5.1
> updates
> php-snmp.x86_64                            5.1.6-27.el5                base
>
>
> I use the following code:
>     public SnmpQueryResolver(MonitorAgentConf snmpAgentConf, Snmp snmp) {
>         _snmpAgentConf = snmpAgentConf;
>         _snmp = snmp;
>         _agentAddress = GenericAddress.parse("udp:" +
> snmpAgentConf.getAddress().replace(":", "/"));
>
>         _communityTarget = new CommunityTarget();
>         _communityTarget.setCommunity(new OctetString("public"));
>         _communityTarget.setAddress(_agentAddress);
>         _communityTarget.setRetries(1);
>         _communityTarget.setTimeout(2000);
>         _communityTarget.setVersion(SnmpConstants.version2c);
>     }
>
>     public void executeQueries(List<IMibQuery> queryDefinitions, long time,
> IResultReporter resultReporter) throws IOException {
>         List<IMibQuery> singleValueQueries = new ArrayList<IMibQuery>();
>         for (IMibQuery mibElement : queryDefinitions) {
>             if (mibElement instanceof CustomMibQuery) {
>                 CustomMibQuery customMibElement = (CustomMibQuery)
> mibElement;
>                 String value = customMibElement.getValue(_communityTarget,
> _snmp);
>                 resultReporter.report(time, _snmpAgentConf, mibElement,
> value);
>             } else {
>                 singleValueQueries.add(mibElement);
>             }
>         }
>         querySingleValueMibElements(singleValueQueries, resultReporter);
>     }
>
> I see the following snmp query results:
>
> 1276892267175 | hadoopMasterUnix | sjc9-flash-grid04.iq.com:161 |
> unix.MEMORY_USED | 0
> 1276892267175 | hadoopMasterUnix | sjc9-flash-grid04.iq.com:161 |
> unix.SWAP_USED | 0
> 1276892267175 | hadoopMasterUnix | sjc9-flash-grid04.iq.com:161 |
> unix.DISC_SPACE_USED | 0
> 1276892267175 | hadoopMasterUnix | sjc9-flash-grid04.iq.com:161 |
> unix.NETWORK_IO_IN | 0
> 1276892267175 | hadoopMasterUnix | sjc9-flash-grid04.iq.com:161 |
> unix.NETWORK_IO_OUT | 0
> 1276892267192 | hadoopMasterUnix | sjc9-flash-grid04.iq.com:161 |
> unix.CPU_USER | noSuchObject
> 1276892267192 | hadoopMasterUnix | sjc9-flash-grid04.iq.com:161 |
> unix.CPU_SYSTEM | noSuchObject
>
> Can someone tell me why 0 was returned for the metrics ?
>
> Thanks
>



More information about the SNMP4J mailing list