SNMP
בכל שפה ובכל מערכת הפעלה תצטרך חבילת תוכנה זו או אחרת ע"מ לשלוח ולקבל SNMP. בהינתן שאתה עובד ב-VC/WIN, יש את WINSNMP של MICROSOFT (הכל קורה בחלונות: חלון שולח ובסוף מקבל MESSAGE), וחבילת SNMP++ של HP. החבילה השניה קיימת גם ל-UNIX. שם הכל פשוט:
#include “snmp_pp.h” #define SYSDESCR “1.3.6.1.2.1.1.1.0” // Object ID for System Descriptor void get_system_descriptor() { int status; // return status CTarget ctarget( (IpAddress) “10.4.8.5”); // SNMP++ community target Vb vb( SYSDESCR); // SNMP++ Variable Binding Object Pdu pdu; // SNMP++ PDU //-------[ Construct a SNMP++ SNMP Object ]--------------------------------------- Snmp snmp( status); // Create a SNMP++ session if ( status != SNMP_CLASS_SUCCESS) { // check creation status cout << snmp.error_msg( status); // if fail, print error string return; } //-------[ Invoke a SNMP++ Get ]------------------------------------------------------- pdu += vb; // add the variable binding to the PDU if ( (status = snmp.get( pdu, ctarget)) != SNMP_CLASS_SUCCESS) cout << snmp.error_msg( status); else { pdu.get_vb( vb,0); // extract the variable binding from PDU cout << “System Descriptor = ”<< vb.get_printable_value(); } // print out the value }; // Thats all!
(הדוגמה מ-MANUAL) המרות MIB. ל-H. לא מצאתי, אם תמצא - תשלח גם לי. האם זה הפורום הנכון - אינני יודע