Advertisement
Izya12

ip_noc.sh

Mar 16th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.58 KB | None | 0 0
  1. #!/bin/bash
  2. set -o nounset
  3. set -o errexit
  4.  
  5. DATE="$(date +"%Y%m%d")"
  6.  
  7. while read lan
  8. do
  9. sudo nmap -p 161 -sU $lan/24 -oG log.txt && cat log.txt | grep "open\/udp" | awk '{print $2}' > tmp_$lan.txt
  10. done < ../lan.txt
  11.  
  12. cat tmp_*.txt > ../ip.txt
  13.  
  14. while read IP
  15. do
  16.  
  17. model="$(snmpwalk -t 1 -v2c -c xxxxx $IP 1.3.6.1.2.1.47.1.1.1.1.13.1001 | awk '{print $4}')"
  18. name="$(snmpwalk -t 1 -v2c -c xxxx $IP SNMPv2-MIB::sysName.0 | awk '{print $4}')"
  19. #des="$(snmpwalk -t 1 -v2c -c xxxx $IP .1.3.6.1.2.1.1.5.0 | awk '{print $4}')"
  20. echo "$IP, $model, $name"
  21. #echo "$IP, $des"
  22.  
  23. done < ../ip.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement