game-game 0 Report post Posted February 17, 2008 selamat pagi semua..actually aku nk tanye, snmp ni dalam kategori ape dalam subtopic2 dalam ebooks? dalam network? aku tak jmpe kat ctu..sape2 tau tak? bagi example paling ringkas pon takpe.. aku cme nak tngok ape command die je.. cam get request, trap ke..thanks.. Quote Share this post Link to post Share on other sites
Paralys3r 0 Report post Posted February 17, 2008 sebagai permulaan - http://en.wikipedia.org/wiki/Simple_Networ...gement_Protocol. Tapi lebih baik lagi kalau baca relevan RFCs. http://www.net-snmp.org/ kalau awak nak open source SNMP library (C or perl). Quote Share this post Link to post Share on other sites
game-game 0 Report post Posted February 17, 2008 thanks untuk info tu.. aku ade jmpe satu coding ni#include <net-snmp/net-snmp-config.h>#include <net-snmp/net-snmp-includes.h>#include <string.h>int main(int argc, char ** argv){ struct snmp_session session; struct snmp_session *sess_handle; struct snmp_pdu *pdu; struct snmp_pdu *response; struct variable_list *vars; oid id_oid[MAX_OID_LEN]; oid serial_oid[MAX_OID_LEN]; size_t id_len = MAX_OID_LEN; size_t serial_len = MAX_OID_LEN; int status; struct tree * mib_tree; /*********************/ if(argv[1] == NULL){printf("Please supply a hostname\n");exit(1); } init_snmp("APC Check"); snmp_sess_init( &session ); session.version = SNMP_VERSION_1; session.community = "public"; session.community_len = strlen(session.community); session.peername = argv[1]; sess_handle = snmp_open(&session); add_mibdir("."); mib_tree = read_mib("PowerNet-MIB.txt"); pdu = snmp_pdu_create(SNMP_MSG_GET); read_objid("PowerNet-MIB::upsBasicIdentModel.0", id_oid, &id_len); snmp_add_null_var(pdu, id_oid, id_len); read_objid("PowerNet-MIB::upsAdvIdentSerialNumber.0", serial_oid, &serial_len); snmp_add_null_var(pdu, serial_oid, serial_len); status = snmp_synch_response(sess_handle, pdu, &response); for(vars = response->variables; vars; vars = vars->next_variable)print_value(vars->name, vars->name_length, vars); snmp_free_pdu(response); snmp_close(sess_handle); return (0);}ble aku run, gcc 'net-snmp-config --cflags' 'net-snmp-config --libs''net-snmp-config --external-libs' snmp_test.c -o snmp_testdie cakap, gcc: net-snmp-config --cflags: No such file or directorygcc: net-snmp-config --libsnet-snmp-config --external-libs: No such file or directorysnmp_test.c:1:38: error: net-snmp/net-snmp-config.h: No such file or directorysnmp_test.c:2:40: error: net-snmp/net-snmp-includes.h: No such file or directorysnmp_test.c: In function ‘main’:snmp_test.c:6: error: storage size of ‘session’ isn’t knownsnmp_test.c:11: error: ‘oid’ undeclared (first use in this function)snmp_test.c:11: error: (Each undeclared identifier is reported only oncesnmp_test.c:11: error: for each function it appears in.)snmp_test.c:11: error: expected ‘;’ before ‘id_oid’snmp_test.c:12: error: expected ‘;’ before ‘serial_oid’snmp_test.c:13: error: ‘MAX_OID_LEN’ undeclared (first use in this function)snmp_test.c:19: warning: incompatible implicit declaration of built-in function ‘printf’snmp_test.c:20: warning: incompatible implicit declaration of built-in function ‘exit’snmp_test.c:24: error: ‘SNMP_VERSION_1’ undeclared (first use in this function)snmp_test.c:28: warning: assignment makes pointer from integer without a castsnmp_test.c:30: warning: assignment makes pointer from integer without a castsnmp_test.c:31: error: ‘SNMP_MSG_GET’ undeclared (first use in this function)snmp_test.c:31: warning: assignment makes pointer from integer without a castsnmp_test.c:32: error: ‘id_oid’ undeclared (first use in this function)snmp_test.c:34: error: ‘serial_oid’ undeclared (first use in this function)snmp_test.c:37: error: dereferencing pointer to incomplete typesnmp_test.c:37: error: dereferencing pointer to incomplete typesnmp_test.c:38: error: dereferencing pointer to incomplete typesnmp_test.c:38: error: dereferencing pointer to incomplete typekenape ek? aku dah install net-snmp ni..untuk mkluman korang, aku refer guide ni...The Cuddletech Guide to SNMP Programming Quote Share this post Link to post Share on other sites