Need help collecting addational data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help collecting addational data
# 1  
Old 03-25-2008
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
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Collecting logs between two time stamps

Hi, please help me to collect the entire log files between two time stamp. for example, I am looking script to collect the entire log between "2015-03-27 15:59" to "2015-03-27 16:15" in the below sample log file. OS : RHEL 6.3 Date/Time : 24 hours format, the time is printing each log... (12 Replies)
Discussion started by: jerryknj
12 Replies

2. Shell Programming and Scripting

awk : collecting all data between two time frame

Hi Experts , I need your help to collect the complete data between two time frame from the log files, when I try awk it's collecting the data only which is printed with time stamp for example, awk works well from "16:00 to 17:30" but its not collecting <line*> "from 17:30 to 18:00" ... (8 Replies)
Discussion started by: zenkarthi
8 Replies

3. Shell Programming and Scripting

Collecting header from another file

I want to add header description from a file by matching the 2nd col of another file. . The lookup file is at ftp://ftp.ncbi.nlm.nih.gov/pub/COG/KOG/kog The table file looks like comp1001565_c0_seq1 At1g14590 48.48 66 34 0 200 3 171 236 ... (1 Reply)
Discussion started by: ritakadm
1 Replies

4. UNIX for Advanced & Expert Users

Collecting job id from qsub command

Hello. Hopefully this is the right forum, did a search and found some similar questions here. I'm trying to find out if there is a way to get the job id while submitting a job using qsub. I want to monitor the list of active jobs using qstat and when my jobid is no longer on the active list, I... (3 Replies)
Discussion started by: aeoleon88
3 Replies

5. UNIX for Advanced & Expert Users

collecting memory usage by a process

Hi Guys, I work on a AIX environment and I'm trying to write a script where I can collect all the memory used by a process. Basically I'm executing the command 'ps -fu userid' to get all the process ids and then executing the 'ps v PID' to get all the memory allocated by PPID. My question is... (2 Replies)
Discussion started by: arizah
2 Replies

6. Shell Programming and Scripting

Collecting details

Hi all, I am having lots of oracle servers. I want to collect some health check details from all the server and report to one single centralized server. What would be best solution for this? OS: AIX Thanks Gopal (1 Reply)
Discussion started by: ilugopal
1 Replies

7. Shell Programming and Scripting

Need Help: Collecting similar messages in a file

Hi All, Since i am very new to shell scripting, i need help from you guys. Suppose there is a file containing: Log message: Ashish "asasasa" asasa asasa asasas.info1 Log message: Kapil "asasasa" asasa asasa asasas..info1 (2 Replies)
Discussion started by: ashish.kapil
2 Replies

8. UNIX for Advanced & Expert Users

Collecting software inventory

how to obtain/ collect a list of all the applications installed in the system.. is there a configuration file(like the one which exists for hardware ) which holds all this information?? if no is there any command/shell script or utility that we can use for the same ?? I am using Red hat linux... (2 Replies)
Discussion started by: superghost
2 Replies

9. UNIX for Dummies Questions & Answers

Collecting data from TOP to a file

Is there a way to collect data from top command to a file at regular intervals. I need this on HP-UX. I need to gather resident memory usage. I know that sar will give %cpu usage. There is a pmap command which gives memory usage in solaris. Is there a similar command in HP-UX Thanks (5 Replies)
Discussion started by: sssow
5 Replies
Login or Register to Ask a Question