![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Open Aerial Map project is collecting free data | iBot | UNIX and Linux RSS News | 0 | 01-29-2008 01:20 PM |
| Need Help: Collecting similar messages in a file | ashish.kapil | Shell Programming and Scripting | 2 | 01-16-2008 02:57 AM |
| Collecting software inventory | superghost | UNIX for Advanced & Expert Users | 2 | 11-26-2005 02:01 AM |
| collecting system harware info | soliberus | SUN Solaris | 1 | 05-25-2005 04:17 AM |
| Collecting data from TOP to a file | sssow | UNIX for Dummies Questions & Answers | 5 | 09-06-2001 04:38 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Need help collecting addational data
I am attempting to gather data from 700 + routers. I have written a script that gets me about 70% of the information I need but I am in need of some assistance getting the remainder. I am fairly new to unix and I have not done programming since my 2nd year of high school in 1992.
I have a list of fqdn devices and the current script that I have takes the device name, verifies that it is in DNS, pings the ip, preforms an operation utilizing the Read only string and the Read write string for SNMP The remaining data I need to gather lies in the Config file of the router. I need to verify the following strings are defined in the config file (yes the communtiy strings and IP addresses have been altered for posting) snmp-server host 192.36.0.231 public snmp-server host 192.87.219.165 public config Also verify the following ACL’s are applied access-list 23 permit 192.36.0.0 0.0.0.255 – (multiple networks) access-list 23 permit 187.87.219.160 0.0.0.15 access-list 26 permit 167.36.0.0 0.0.0.255 access-list 26 permit 135.87.219.160 0.0.0.15 I want to store the information in variables to be output at the end of the script. I also need to match the IP listed in DNS to the interface it goes with on the router. I am looking for output of yes or no. example Variable $accces23 = yes if it is there or no if it is not found Below is the current script that I have it works perfectly as it sits I just need the expanded data lines with (temporary edit) are a modification made tonight when my boss decided he wanted not only our fdqn name but the name the client assigns to the router. Any help would be great # #======================================================================# #This section tests for the file device.log, and removes if it exists # #======================================================================# if [ device.log ] then rm device.log fi cat des.txt | while read device do #======================================================================# #This section will pull the ip address from DNS and assign the value # #To the variable "ip". It will then test to see if the variable "ip" # #Has a Null (value of no length) or if it contains data. If a value is # #Found it is stored in the variable "dns" If no data is found in the # #variable "ip" it will assign the string value of "Not in DNS" to the # #variable "dns" # #======================================================================# # ip=`(host $device | awk ' /has/ {print $4}')` if [ "$ip" ] then dns="$ip" # else # dns="Not in DNS" #fi # #======================================================================# #This section will Ping the variable "device" and record a yes or no # #Answer in the variable "routable". Error messages such as unknown # #Host are sent to /dev/null to prevent them from displaying # #======================================================================# # answer=`(ping -c 1 -q -w 2 -n $device 2>/dev/null | grep received | awk '{print $4}')` if [ $answer > 0 ]; then answer="YES" else answer="NO" fi # #======================================================================# #This section will test the read and read/write snmp community strings # #Yes or No answer is stored in the variable "snmpread" and "snmpwrite" # #======================================================================# # snmpread=`(snmpget -t 2 -r 0 -Oqv -Os -v 2c -c public $device 2>/dev/null SNMPv2-MIB::sysName.0)` if [ "$snmpread" = "" ]; then snmpread="NO" # else snmpread="YES" (temporary edit) fi snmpwrite=`(snmpget -t 2 -r 0 -Oqv -Os -v 2c -c public $device 2>/dev/null SNMPv2-MIB::sysName.0)` if [ "$snmpwrite" = "" ]; then snmpwrite="NO" # else snmpwrite="YES" (temporary edit) fi # #======================================================================# #This section takes the values of the variables and outputs them to # #The file device.log and echos the values on the screen as well # #======================================================================# echo "$device,$dns,$answer,$snmpread,$snmpwrite" >> device.log echo "$device,$dns,$answer,$snmpread,$snmpwrite" else dns="Not in DNS" answer="NO" snmpread="NO" snmpwrite="NO" echo "$device,$dns,$answer,$snmpread,$snmpwrite" >> device.log echo "$device,$dns,$answer,$snmpread,$snmpwrite" fi done |
|||
| Google The UNIX and Linux Forums |
| Forum Sponsor | ||
|
|