SNMP Manager Programmer's Guide
Programming Examples
SNMP Manager Programmer’s Guide–134249
2-125
SNMPHOST Source Code
37. The OIDs for the three MIB objects this function can retrieve are initialized, and a 
request packet structure (pkt1) and response packet structure (recv_pkt1) are 
declared.
38. A packet for a Get request for a single MIB object is initialized.
39. If the value of nDeviceType is 3, 5, or 6 (the final digit of the OID value of the 
current hrDeviceType), one of the following functions is called to initialize to 0 a 
field in the current DEV_ENTRY_T structure: SetCpuLoad(), SetPrinterStatus(), 
or SetDiskCapacity().
40. The oidstring2oid() function formats the string representation of the 
hrProcessorLoad OID into a representation needed for binding later.
41. An instance value is appended to the current hrDeviceIndex OID.
42. A variable binding is added to the request packet.
43. This for loop uses the retry counter to encode, transmit, receive, and decode the 
Get packet and resets the request ID to 1 if the request ID has reached MAX-
REQID_VALUE. The response packet is received into ebuffAux and decoded into 
recv_pkt1.
44. The memory allocated for pkt1 is released, and the descriptors for ebuffAux are 
reset. Then the contents of the response packet are saved in pkt1 for parsing.
45.  Switching on the final integer of hrDeviceType, the function uses one of the 
following functions to save the value retrieved in the current DEV_ENTRY_T 
structure: SetCpuLoad(), SetPrinterStatus(), or SetDiskCapacity().
46. DisplayHostDevices() prints the contents of all the DEV_ENTRY_T structures to 
which device information has been written. It accepts a pointer to pptable, an 
integer indicating how many structures to process, and the display mode specified at 
invocation. 
47. The dev_status_to_str() function converts the value of hrDeviceStatus to a string.
48. GetCpuLoad() retrieves the value of hrProcessorLoad from the DEV_ENTRY_T 
structure.
49. The prn_status_to_str() function converts the value of hrPrinterStatus, retrieved by 
GetPrinterStatus(), to a string.
50. GetDiskCapacity() retrieves the value of hrDiskStorageCapacity().
51. This logic is executed to control the display of information if the display mode is 
interactive. 
52. The main block begins.
53. Command-line parameter values are initialized.
54. After command-line arguments are parsed, SNMP_Init_() is called to determine 
whether to use IPC or UDP communication with the agent.
55. SNMP_Open_() creates a socket or opens a NonStop agent process.










