Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Getting the data from SNMP agent

Posted on 2004-10-11
10
Medium Priority
?
917 Views
Last Modified: 2016-10-28
Hi All,
I have to write code to get the data from SNMP agents installed on win2k server machines. Has anyone written a code for this, please share it. Or if there are available free APIs which i can use to create SNMP Manager to get the Data like CPU usage, Memory Usage, Disk Usage from remote machines, please share.

Thanks
Alok
0
Comment
Question by:alokgupt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
10 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 504 total points
ID: 12280299
Check out the samples at http://www.winsnmp.com/samples/c/index.htm

>>to get the Data like CPU usage, Memory Usage, Disk Usage

That's not part of SNMP, you'd use the PDH library to do that. Check out http://msdn.microsoft.com/library/default.asp?url=/library/en-us/perfmon/base/accessing_counters_on_remote_machines.asp ("Accessing Counters on Remote Machines"), http://support.microsoft.com/default.aspx?scid=kb;en-us;287157 ("How To Determine Physical Memory on a Remote Machine") and http://support.microsoft.com/default.aspx?scid=kb;en-us;287157 ("INFO: PDH Sample Code to Enumerate Performance Counters and Instances")
0
 

Author Comment

by:alokgupt
ID: 12283979
Thanks JKR,
 But there are several tools available in the market who use SNMP to get Machine data (CPU/Memory/Hard Disk) across the network. One such tool is " Paessler RouterTraffic Grapher". So i think there should be some way to get OIDs for these parameters (CPU/Memory/Hard Disk). Does Microsoft provide OIDs for these parameters (CPU/Memory/Hard Disk)?????


Thanks
--Alok
0
 

Author Comment

by:alokgupt
ID: 12285913
The following code is a part of service which is running with an interval of 5 mins (300000 ms)
//////////////////////////////////////////////////////////////////////////////////////////////////////////
LPSNMP_MGR_SESSION lpSNMPSession;
LPSTR lpAgentAddress = "172.17.32.144";
LPSTR lpAgentCommunity = "public";
INT nTimeOut = 30000;
INT nRetries = 100;
lpSNMPSession = SnmpMgrOpen(lpAgentAddress,lpAgentCommunity,nTimeOut,nRetries);
if (lpSNMPSession != NULL)
{
      SNMPAPI snmpapiRetVal;
      SnmpVarBindList* variableBindings = NULL;
      AsnInteger* errorStatus = SNMP_ERRORSTATUS_NOERROR;
      AsnInteger* errorIndex;
/* I don't know what SnmpMgrRequest will return so i tried this part */
      snmpapiRetVal = SnmpMgrRequest(lpSNMPSession,SNMP_PDU_GET,variableBindings,errorStatus,errorIndex);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////

Now here SnmpMgrRequest is returning an error "Request Timed-out." or SNMP_MGMTAPI_TIMEOUT. Can anyone let me know what can be the reason. And how should i call SnmpMgrRequest so that i can some data from the Remote agent.

--Thanks
Alok
0
 

Author Comment

by:alokgupt
ID: 12305338
I have one more query: While i am calling

HSNMP_ENTITY pSrcEntity ;
HSNMP_ENTITY pDstEntity ;
HSNMP_CONTEXT pContext ;
HSNMP_PDU PDU ;
SnmpRecvMsg(hSession,&pSrcEntity,&pDstEntity,&pContext,&PDU);

it returns SNMPAPI_SUCCESS but PDU is empty for OID "1,3,6,1,2,1,1,3,0". This OID is correct as i have checked using one of the third party tool.

Can anyone let me know what can be wrong with it.

Thanks
Alok

0
 

Author Comment

by:alokgupt
ID: 12336446
Does anyone know OID for Memory Usage and Hard Disk Drive available space?


Thanks
Alok
0
 

Author Comment

by:alokgupt
ID: 12441966
Ne updates???
0
 
LVL 1

Assisted Solution

by:monu85
monu85 earned 500 total points
ID: 12442546
For Memory you can try these OIds
.1.3.6.1.2.1.25.2.1.2
.1.3.6.1.2.1.25.2.1.3
.1.3.6.1.2.1.25.2.1.8
.1.3.6.1.2.1.25.2.2
.1.3.6.1.2.1.25.2.3.1.5
.1.3.6.1.2.1.25.2.3.1.6

And For Hard Disk check you can try these
.1.3.6.1.2.1.25.3.1.6
.1.3.6.1.2.1.25.3.1.20
.1.3.6.1.2.1.25.3.1.21
.1.3.6.1.2.1.25.3.6.1.1
.1.3.6.1.2.1.25.3.6.1.2
.1.3.6.1.2.1.25.3.6.1.3
.1.3.6.1.2.1.25.3.6.1.4

Hope atleast one of them will work.

0
Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
PRTG Network Monitor lets you monitor your bandwidth usage, so you know who is using up your bandwidth, and what they're using it for.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question