More Related Content
6 - Custom Mininet Topology Experiment by Dwina Fitriyandini Siswanto & Siti ... Featured (20)
2024 Trend Updates: What Really Works In SEO & Content Marketing Storytelling For The Web: Integrate Storytelling in your Design Process Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis... How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR... 2024 State of Marketing Report – by Hubspot Everything You Need To Know About ChatGPT Product Design Trends in 2024 | Teenage Engineerings How Race, Age and Gender Shape Attitudes Towards Mental Health AI Trends in Creative Operations 2024 by Artwork Flow.pdf PEPSICO Presentation to CAGNY Conference Feb 2024 Content Methodology: A Best Practices Report (Webinar) How to Prepare For a Successful Job Search for 2024 Social Media Marketing Trends 2024 // The Global Indie Insights Trends In Paid Search: Navigating The Digital Landscape In 2024 5 Public speaking tips from TED - Visualized summary ChatGPT and the Future of Work - Clark Boyd Getting into the tech field. what next Google's Just Not That Into You: Understanding Core Updates & Search Intent How to have difficult conversations Net snmp API
- 2. AGENDA
• SNMP v1 protocol
• SNMP v2c protocol
• Net-SNMP Apps
– snmpget, snmpgetnext, snmpset, snmpbulkget
– snmptrap
– snmptrapd
– Others Apps
- 3. SNMP v1 protocol
• SNMP GET : 取得某些OID的值
• SNMP SET : 設定某些OID的值
• SNMP GET-NEXT : 取得某些OID的下一個OID
與值
• SNMP Walk : 透過Get Next去取得整個tree的
資料,只能walk一個OID
• SNMP trap : 發生特定事件時,設備主動送
出的封包
- 4. SNMP v2c protocol
• SNMP Bulk Get : 用來減少Get-NEXT封包
– Non-Repeaters : 哪幾個OID不做GETNEXT查詢
– Max-Repetitions : 在同一個封包內最多裝幾個
response
• snmpbulkget -v2c -Cn1 -Cr5 -Os -c public 172.18.3.43
system ifTable
sysDescr.0 = STRING: "SunOS zeus.net.cmu.edu 4.1.3_U1 1 sun4m"
ifIndex.1 = INTEGER: 1
ifIndex.2 = INTEGER: 2
ifDescr.1 = STRING: "lo0“
…..
- 5. SNMP v2c protocol
• SNMP Bulk Walk : 用Bulk get去取得整個tree的
資料 (只能walk一個OID下)
– Cc : 不檢查回傳的OID是否有照順序
– Cp : 印出所查詢的數量
– Ci : 所回傳的資料要包含輸入的OID
– Cn : 設定Non-Repeaters
– Cr : 設定Max-Repetitions
• snmpbulkwalk –v2c –c public 172.18.3.43 system
sysDescr.0 = STRING: "SunOS zeus.net.cmu.edu 4.1.3_U1 1 sun4m"
sysObjectID.0 = OID: enterprises.hp.nm.hpsystem.10.1.1
sysUpTime.0 = Timeticks: (155274552) 17 days, 23:19:05
…
- 7. NET-SNMP API - snmpget
1. netsnmp_parse_args()
2. ss = snmp_open(&session)
3. snmp_pdu_create(SNMP_MSG_GET)
4. snmp_add_null_var(pdu, oid, oid_length)
5. snmp_synch_response(ss, pdu, &reponse)
6. snmp_free_pdu(response)
7. snmp_close(ss)
- 8. NET-SNMP API - snmpgetnext
1. netsnmp_parse_args()
2. ss = snmp_open(&session)
3. snmp_pdu_create(SNMP_MSG_GETNEXT)
4. snmp_add_null_var(pdu, oid, oid_length)
5. snmp_synch_response(ss, pdu, &reponse)
6. snmp_free_pdu(response)
7. snmp_close(ss)
- 9. NET-SNMP API - snmpset
1. netsnmp_parse_args()
2. ss = snmp_open(&session)
3. snmp_pdu_create(SNMP_MSG_SET)
4. snmp_add_var(pdu, oid, oid_length,
valute_type, value)
5. snmp_synch_response(ss, pdu, & reponse)
6. snmp_free_pdu(response)
7. snmp_close(ss)
- 10. NET-SNMP API - snmpbulkget
1. netsnmp_parse_args()
2. ss = snmp_open(&session)
3. snmp_pdu_create(SNMP_MSG_GETBULK)
– pdu->non_repeaters = non_repeaters;
– pdu->max_repetitions = max_repetitions;
4. snmp_add_null_var(pdu, oid, oid_length)
5. snmp_synch_response(ss, pdu, &reponse)
6. snmp_free_pdu(response)
7. snmp_close(ss)
- 11. NET-SNMP API - snmptrap –v1
1. snmp_parse_args()
2. ss = snmp_add(&session,
netsnmp_transport_open_client("snmptrap", session.peername), NULL,
NULL);
3. snmp_pdu_create(SNMP_MSG_TRAP)
– memcpy(pdu->enterprise, name, name_length * sizeof(oid));
– pdu->enterprise_length = name_length;
– pdu->trap_type = atoi(trap);
– pdu->specific_type = atoi(specific);
– pdu->time = atol(description);
4. snmp_add_var (pdu, binding_name, binding_name_length, value_type,
value); …
5. status = snmp_send(ss, pdu)
6. snmp_free_pdu(pdu)
7. snmp_close(ss)
- 12. NET-SNMP API - snmptrap –v2
1. snmp_parse_args()
2. ss =
snmp_add(&session, netsnmp_transport_open_client("s
nmptrap", session.peername), NULL, NULL);
3. snmp_pdu_create(SNMP_MSG_TRAP2)
4. snmp_add_var(pdu, objid_sysuptime, sizeof(objid_sysu
ptime) / sizeof(oid), 't', trap);
5. snmp_add_var(pdu, oid, oid_length, valute_type, value)
6. snmp_add_var
(pdu, binding_name, binding_name_length, value_type, value); …
7. status = snmp_send(ss, pdu)
8. snmp_free_pdu(pdu)
9. snmp_close(ss)
- 13. NET-SNMP API - snmptrap –Ci (inform)
1. snmp_parse_args()
2. ss =
snmp_add(&session, netsnmp_transport_open_client("s
nmptrap", session.peername), NULL, NULL);
3. snmp_pdu_create(SNMP_MSG_INFORM)
4. snmp_add_var(pdu, objid_sysuptime, sizeof(objid_sysu
ptime) / sizeof(oid), 't', trap);
5. snmp_add_var(pdu, oid, oid_length, valute_type, value)
6. snmp_add_var
(pdu, binding_name, binding_name_length, value_type, value); …
7. status = snmp_synch_response(ss, pdu, &response);
8. snmp_free_pdu(response)
9. snmp_close(ss)
- 14. NET-SNMP API - snmptrapd
• SnmpTrapdMain
1. SIGTERM / SIGINT / SIGHUP / SIGPIPE
2. snmptrapd_register_configs
1. register_config_handler
3. //Process the options & // Process AGENTX
4. init_snmp
5. netsnmp_transport_open_server
6. snmptrapd_add_session
• snmp_input
7. snmptrapd_main_loop
8. snmptrapd_close_sessions
9. snmp_shutdown
- 15. NET-SNMP API - snmptrapd handler
• syslog_handler (存到syslog)
• print_handler (存到檔案)
• command_handler (執行對應的script)
• axforward_handler (將這個trap)
• forward_handler (將這個trap轉送到其他的
receiver)
- 16. NET-SNMP API - snmp_input
1. 先將收到的trap OID取出
– 將SNMP v1 trap轉為v2的格式
2. netsnmp_auth_global_traphandlers
3. netsnmp_pre_global_traphandlers
– syslog_handler
– print_handler
4. netsnmp_specific_traphandlers |
netsnmp_default_traphandlers
– command_handler
– forward_handler 或 axforward_handler
5. netsnmp_post_global_traphandlers
- 17. NET-SNMP other apps
• snmpusm : SNMPv3 安全認證
• snmpvacm : SNMPv3 存取控制
• snmpdf : 看系統的硬碟與記憶體使用狀況
• snmptable : 輸入某個table的OID,會用table方式呈現
• snmpd : SNMP agent daemon
• snmpdelta : 持續監控某些OID,若有不同才會show
• snmpnetstat : 類似netstat,看目前開啟了哪些port
• snmpstatus : 取得網路使用量的資訊
• snmptest : 用來測試Get/Set/GetNext/GetBulk/Trap等功能
的狀況
• snmptranslate : OID與Name之間的轉換