Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Scan with open telnet/ssh
- NMAPBIN="/usr/bin/nmap -p22,23 -iL $BDIR/networkscan.txt -oG $HOSTS"
- $NMAPBIN
- awk '{OFS=","}{if ($4=="Ports:") {if($5 ~ /22\/open\/*/) print $2,"ssh"; else if($6 ~ /23\/open\/*/) print $2,"telnet"}}' out.hostsscan.txt > hosts.csv
- wc -l hosts.csv | awk '{print "Hosts detected: "$1}'
- while IFS=, read HOST SERVICE
- do
- HOSTNAME=""
- HOSTTYPE=""
- ADOMAIN=$ADOMAIN_DEFAULT
- OBJECT_PROFILE=$OBJECT_PROFILE_DEFAULT
- #echo "$line|"
- #host=$(awk '{print $1}')
- HOSTNAME=`snmpget -m SNMPv2-MIB -t 1 -v 2c -Oqv -c $SNMP_RO_COMMUNITY $HOST .1.3.6.1.2.1.1.5.0`
- #First case - before all other snmp requests.
- case $HOSTNAME in
- #Skip DSLAMs
- *DSL*) continue;;
- #Even no snmp resnose for hostname, no snmp request to the same host anymore.
- "")
- HOSTNAME=$HOST;;
- #Get another stuff
- *)
- HOSTTYPE=`snmpget -m SNMPv2-MIB -t 1 -v 2c -Oqv -c $SNMP_RO_COMMUNITY $HOST .1.3.6.1.2.1.1.1.0 | head -n 1 | awk '{print $1}'`;;
- esac
- #Next cases - before paste row to import CSV file
- case $HOSTNAME in
- KRD-SCH-*)
- ADOMAIN="Sochi";;
- esac
- case $SERVICE in
- telnet)
- SCHEME=0;;
- ssh)
- SCHEME=1;;
- *)
- SCHEME=2;;
- esac
- case $HOSTTYPE in
- QSW-2800-*|QSW-8200-*|QSW-8300-*)
- PROFILE_NAME="Qtech.QSW2800";;
- "QTECH")
- PROFILE_NAME="Qtech.QSW";;
- *)
- PROFILE_NAME="";;
- esac
- #Other hardcoded sets
- TRAP_SOURCE_IP=$HOST
- echo "$HOST,$SCHEME,$HOSTNAME,$HOSTTYPE,$ADOMAIN,$TRAP_SOURCE_IP,$PROFILE_NAME,"
- done < hosts.csv
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement