User Tools

Site Tools


zabbix_-_построение_топологии_сети

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
zabbix_-_построение_топологии_сети [2018/09/28 10:01]
val [История вопроса]
zabbix_-_построение_топологии_сети [2019/06/10 14:32] (current)
val [Zabbix API]
Line 162: Line 162:
  
 server.corp1.un:​~#​ rsh switch1 -n show cdp nei | dos2unix | grep switch | tr -s " " | cut -d " " -f1,​2,​3,​9,​10 server.corp1.un:​~#​ rsh switch1 -n show cdp nei | dos2unix | grep switch | tr -s " " | cut -d " " -f1,​2,​3,​9,​10
 +  или
 +server.corp1.un:​~#​ rsh switch1 -n show cdp nei | dos2unix | tr '​\n'​ ' ' | sed '​s/​switch/​\nswitch/​g'​ | grep switch | tr -s " " | cut -d " " -f1,​2,​3,​9,​10
 </​code>​ </​code>​
  
Line 253: Line 255:
 server.corp1.un:​~#​ /​root/​zab_get_hosts.sh | jq '​.result | .[] | {hostid: .hostid, host: .host} | tostring'​ | grep switch | tr -d '​{}\\'​ | tr '"'​ ' ' | cut -d ' ' -f5,9  server.corp1.un:​~#​ /​root/​zab_get_hosts.sh | jq '​.result | .[] | {hostid: .hostid, host: .host} | tostring'​ | grep switch | tr -d '​{}\\'​ | tr '"'​ ' ' | cut -d ' ' -f5,9 
 </​code>​ </​code>​
-Добавляем конвеер в конец скрипта и записываем результат в файл:+Добавляем конвейер в конец скрипта и записываем результат в файл:
 <​code>​ <​code>​
 server.corp1.un:​~#​ /​root/​zab_get_hosts.sh | tee list_hostid_host.txt server.corp1.un:​~#​ /​root/​zab_get_hosts.sh | tee list_hostid_host.txt
Line 281: Line 283:
 } " http://​127.0.0.1/​zabbix/​api_jsonrpc.php | \ } " http://​127.0.0.1/​zabbix/​api_jsonrpc.php | \
 #jq #jq
 +###zabbix3
 jq '​.result | .[] | .selements | .[] | {elementid: .elementid, selementid: .selementid} | tostring'​ | tr -d '​{}\\'​ | tr '"'​ ' ' | cut -d ' ' -f5,9 jq '​.result | .[] | .selements | .[] | {elementid: .elementid, selementid: .selementid} | tostring'​ | tr -d '​{}\\'​ | tr '"'​ ' ' | cut -d ' ' -f5,9
 +###zabbix4
 +#jq '​.result[1].selements[] | {elements, selementid} | tostring'​ | tr -d '​{}\\'​ | tr '"'​ ' ' | cut -d ' ' -f7,11
 </​code><​code>​ </​code><​code>​
 server.corp1.un:​~#​ /​root/​zab_get_maps.sh | tee list_hostid_selementid.txt server.corp1.un:​~#​ /​root/​zab_get_maps.sh | tee list_hostid_selementid.txt
zabbix_-_построение_топологии_сети.1538118094.txt.gz · Last modified: 2018/09/28 10:01 by val