Solved

Getting the data from SNMP agent

Posted on 2004-10-11
10
789 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
  • 5
10 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 126 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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 125 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

Join & Write a Comment

Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now