簡(jiǎn)單網(wǎng)絡(luò)管理語(yǔ)言(Simple Network Management Language)是一種類自然語(yǔ)言的腳本語(yǔ)言,它采用snmp火本、telnet危队、ping、dns钙畔、arp茫陆、ssh、tcp擎析、udp簿盅、web等協(xié)議訪問(wèn)網(wǎng)絡(luò)設(shè)備挥下,內(nèi)置smtp協(xié)議用于告警等郵件的發(fā)送,支持excel桨醋、mysql棚瘟、sqlite等3種方式進(jìn)行網(wǎng)管數(shù)據(jù)的存取。
手冊(cè)最新版:https://ladybirdsnml.github.io/snmlipv6utf8snmptelnetsshweb/snmldoc_utf8ipv6.html
第9章喜最、ping
??“ping”這個(gè)名字源于聲納定位操作偎蘸。目的是為了測(cè)試另一臺(tái)主機(jī)、網(wǎng)絡(luò)設(shè)備是否可達(dá)瞬内。ping是一個(gè)通信協(xié)議迷雪,是TCP/IP協(xié)議的一部分;ping也是Windows、Unix和Linux系統(tǒng)下的一個(gè)命令, ping命令可檢查網(wǎng)絡(luò)是否連通虫蝶,分析和判定網(wǎng)絡(luò)故障章咧。
1、ping語(yǔ)句分析
ping.ip {220.181.12.207} ttl {64} size {32}
ping測(cè)試能真,主機(jī)赁严、設(shè)備ip為220.181.12.207,發(fā)送報(bào)文的ttl值為64粉铐,發(fā)送報(bào)文的長(zhǎng)度為32字節(jié)
ping語(yǔ)句執(zhí)行后误澳,系統(tǒng)創(chuàng)建、更新以下變量秦躯,示例值如下:
ping.dest_ip=[220.181.12.207]忆谓,目的IP
ping.received_responses=[1],接收到響應(yīng)報(bào)文的個(gè)數(shù)
ping.roundtrip_time_milliseconds=[56]踱承,響應(yīng)時(shí)間(毫秒)
ping.reply_ip=[220.181.12.207]倡缠,應(yīng)答報(bào)文的IP,當(dāng)ttl減小到0的時(shí)候茎活,網(wǎng)絡(luò)設(shè)備應(yīng)答
ping.reply_ttl=[54]昙沦,應(yīng)答報(bào)文的ttl
ping.reply_bytes=[32],應(yīng)答報(bào)文的長(zhǎng)度
ping.status=[IP_SUCCESS]
ping語(yǔ)句執(zhí)行后载荔,通過(guò)檢查變量“ping.status”是否為“IP_SUCCESS”來(lái)判斷ping是否成功盾饮。
2、示例腳本[C:\snmlipv6\ping\ping_ipv4.txt]
C:\snmlipv6\ping\ping_ipv4.txt
001screen.text at point {150} {30} string {9.ping test (ipv4): ttl,size,roundtrip_time,ip}
002
003var {v_ttl} value {0}
004var {v_y} value {60}
005screen.text at point {50} {~v_y~} string {send ping request}
006screen.line from point {10} {75} to point {180} {75}
007screen.text at point {350} {~v_y~} string {ping response}
008screen.line from point {200} {75} to point {630} {75}
009
010var {v_y} value {80}
011screen.text at point {10} {~v_y~} string {Dest IP Addr}
012screen.text at point {110} {~v_y~} string {TTL}
013screen.text at point {150} {~v_y~} string {Bytes}
014
015screen.text at point {200} {~v_y~} string {IP Addr}
016screen.text at point {300} {~v_y~} string {TTL}
017screen.text at point {350} {~v_y~} string {Bytes}
018screen.text at point {400} {~v_y~} string {ms}
019screen.text at point {450} {~v_y~} string {ping.status}
020
021run.set loglevel {debug}
022dns.get var {ip_addr} host {mail.163.com}
023run.set loglevel {nolog}
024
025var {v_ttl} value {0}
026var {v_y} value {80}
027var {v_sendbytes} value {1000}
028loop.begin
029??var {v_ttl} add number {1}
030??var {v_y} add number {20}
031??run.set loglevel {debug}
032??ping.ip {~ip_addr~} ttl {~v_ttl~} size {~v_sendbytes~}
033??run.set loglevel {nolog}
034??screen.text at point {10} {~v_y~} string {~ping.dest_ip~}
035??screen.text at point {110} {~v_y~} string {~v_ttl~}
036??screen.text at point {150} {~v_y~} string {~v_sendbytes~}
037??
038??screen.text at point {200} {~v_y~} string {~ping.reply_ip~}
039??screen.text at point {300} {~v_y~} string {~ping.reply_ttl~}
040??screen.text at point {350} {~v_y~} string {~ping.reply_bytes~}
041??screen.text at point {400} {~v_y~} string {~ping.roundtrip_time_milliseconds~}
042??screen.text at point {450} {~v_y~} string {~ping.status~}
043??if.var {v_ttl} > {16}
044????loop.exit
045??if.end
046loop.end
047
048run.end
??腳本執(zhí)行畫面如下:
3懒熙、示例腳本[C:\snmlipv6\ping\ping_ipv6.txt]
C:\snmlipv6\ping\ping_ipv6.txt
001screen.text at point {150} {30} string {9.ping test (ipv6): ttl,size,roundtrip_time,ip}
002
003var {v_ttl} value {0}
004var {v_y} value {60}
005screen.text at point {50} {~v_y~} string {send ping request}
006screen.line from point {10} {75} to point {180} {75}
007screen.text at point {350} {~v_y~} string {ping response}
008screen.line from point {200} {75} to point {630} {75}
009
010var {v_y} value {80}
011screen.text at point {10} {~v_y~} string {Dest IP Addr}
012screen.text at point {110} {~v_y~} string {TTL}
013screen.text at point {150} {~v_y~} string {Bytes}
014
015screen.text at point {200} {~v_y~} string {IP Addr}
016screen.text at point {400} {~v_y~} string {ms}
017screen.text at point {450} {~v_y~} string {ping.status}
018
019#run.set loglevel {debug}
020dns.set ipmode {ipv6}
021#dns.get var {ip_addr} host {www.ipv6-test.com}
022
023var {ip_addr} value {FE80::1}
024
025var {v_ttl} value {0}
026var {v_y} value {80}
027var {v_sendbytes} value {1000}
028loop.begin
029??var {v_ttl} add number {1}
030??var {v_y} add number {20}
031??ping.ip {~ip_addr~} ttl {~v_ttl~} size {~v_sendbytes~}
032??
033??screen.text at point {10} {~v_y~} string {~ping.dest_ip~}
034??screen.text at point {110} {~v_y~} string {~v_ttl~}
035??screen.text at point {150} {~v_y~} string {~v_sendbytes~}
036??screen.text at point {200} {~v_y~} string {~ping.reply_ip~}
037??screen.text at point {400} {~v_y~} string {~ping.roundtrip_time_milliseconds~}
038??screen.text at point {450} {~v_y~} string {~ping.status~}
039??if.var {v_ttl} > {16}
040????loop.exit
041??if.end
042loop.end
043
044run.end
??腳本執(zhí)行畫面如下:
目錄:?1丘损、var?2、screen?3工扎、snmp?4徘钥、telnet?5、text?6肢娘、if?7呈础、loop?8舆驶、dns?9、ping?10而钞、arp?11沙廉、excel?12、smtp?13臼节、tcp?14蓝仲、udp?15鲫竞、ssh?16我抠、web?17耀怜、mysql?18、sqlite?19途凫、Run?20、sys?21溢吻、macro?附錄1维费、全部語(yǔ)句