Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Getting the data from SNMP agent

Posted on 2004-10-11
10
Medium Priority
?
924 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 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

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
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…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

916 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