Solved

Getting the data from SNMP agent

Posted on 2004-10-11
10
879 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 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
 

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
Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Microsoft Access - Strange behavior calculating totals, Properties form will not load 4 17
How to split this in C++ 4 119
c++ syntax question 9 58
JItbit AD intergration 4 111
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

733 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