Apache Subnet consolidation script/routine help needed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Apache Subnet consolidation script/routine help needed
# 1  
Old 11-21-2008
Apache Subnet consolidation script/routine help needed

I have a rather simple routine that I would like to fine tune. I am having scripters block if that exists. Trying to tally up that amount of subnets after I performed an awk and uniq from zipped apache logs. For instance, on a solaris 10 system:

This does work
gunzip -c access_log1.200834.gz | awk '{print $1}' | uniq -c | sort -nr > log_tally

log_tally would consist of something like:

2 164.156.43.3
1 10.1.1.3
2 10.1.1.1
756 192.168.1.4
328 192.168.1.4
10 164.156.43.3
2 164.156.43.3
1 10.1.1.3
2 10.1.1.1
1 10.1.1.3
3 10.1.1.1

I would like to consolidate and add the duplicate sunbets so that I can have a top 10 or 20 subnet listing. Not mention sort it in reverse order.

I found this on this forum but I need more sophistication:
awk -F" " '{x +=$1} END {print "SUM: "x}' log_tally

As you can imagine, this will take me a while as I would have to do this for every file with its respective subnet. YUCK.Smilie

How would I combine these two routines and give me sums for each deduplicated subnet in reverse order?

Any help would be greatly appreciated.

Last edited by NYG71; 11-21-2008 at 11:00 AM..
# 2  
Old 02-03-2009
Have you solved this problem of yours? If not, how do you know what "subnet" an IP address is using??
# 3  
Old 02-03-2009
otheus,

I did fix the issue by using an extra sort command...for instance:

gunzip -c access_log1.200834.gz | awk '{print $1}' | sort | uniq -c | sort -nr | awk '{print $2}' | cut -d "." -f 1-3 | sort | uniq -c |sort -nr > log_tally

Kinda long but it listed and consolidated the top subnets out to the 3rd octet in order.

Thanks for your concern.

Last edited by NYG71; 02-03-2009 at 08:46 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to write bash script to subdivide a given subnet into a pre-defined number of smaller subnets?

Bash script to subdivide a given subnet into a pre-defined number of smaller subnets. Show network/broadcast address, number of hosts and assign gateway. For example: Input: ./subnetter.sh 192.168.0.0/24 3 Output: 192.168.0.0/128 subnet 192.168.0.0 broadcast 192.168.0.127 gateway... (1 Reply)
Discussion started by: mail2rias
1 Replies

2. Shell Programming and Scripting

How to write bash script to subdivide a given subnet into a pre-defined number of smaller subnets?

Bash script to subdivide a given subnet into a pre-defined number of smaller subnets. Show network/broadcast address, number of hosts and assign gateway. For example: Input: ./subnetter.sh 192.168.0.0/24 3 Output: 192.168.0.0/128 subnet 192.168.0.0 broadcast 192.168.0.127 gateway... (1 Reply)
Discussion started by: mail2rias
1 Replies

3. Red Hat

KSH script help needed ( nice error trap routine ?)

I am running a script that runs a loop and executes a command on ${i} until the end of the for loop. From time to time the command generates an error ( which is good) for example ERROR0005: How can I trap the error and send an email echoing the ${i} variable in the loop and the error ? ... (2 Replies)
Discussion started by: pcpinkerton
2 Replies

4. UNIX for Advanced & Expert Users

Apache rewrite rule help needed

Hi All, I want to redirect from http://localhost/abc/xyz/def?cc=dk&lc=da to http://localhost/abc/mnc/pdf?cc=dk&lc=da. Please suggest a rewrite rule. (0 Replies)
Discussion started by: jagnikam
0 Replies

5. Shell Programming and Scripting

Bash script for ping in your own subnet

I have a question for one who wants to help me. I want to create a bash script to ping IP-adresses. It must first ask me the beginnen IP, then the ending IP like: 192.168.100.1 - 192.168.100.255. When nothing is filled in, then it must find my subnet and ping that, like when my ip is... (14 Replies)
Discussion started by: ugurgazi
14 Replies

6. UNIX for Dummies Questions & Answers

Help needed to install Apache Tomcat

I want to setup apache tomcat on my linux distribution . I Have downloaded apache tomcat from below mentioned link. Administration Web Application: Apache Tomcat - Apache Tomcat 5 Downloads The setup was in following format. apache-tomcat-5.5.29-admin.tar.gz Below are the command i... (7 Replies)
Discussion started by: pinga123
7 Replies

7. Shell Programming and Scripting

any script can be used to covert IP subnet?

say I have some netblocks, is it possible I can use a script to covert the subnet to every single ip? for example, raw file has "1.2.3.0 255.255.128.0" "2.3.4.0 255.255.255.254" and I want to run the script and print out every single IP in these netblocks. or will it be easier if I... (0 Replies)
Discussion started by: fedora
0 Replies

8. IP Networking

Migrating existing Subnet to a new subnet and changing ip addresses in UNIX

Hi, My project needs to migrate the existing Subnet (255.255.255.0) to a new subnet and change the ipaddresses (currently C class). How can I do that. I need some information. John (0 Replies)
Discussion started by: johnmarsh
0 Replies

9. UNIX for Dummies Questions & Answers

Code Consolidation

My code currently looks like this: #!/usr/bin/ksh clear while true do clear echo "Menu" echo " 1. WPPHA1" echo " 2. WPPHA2" echo " 3. WPPHA3" echo " 4. WPPHB1" echo " 5. WPPHB2" echo " 6. WPPHC0" echo " 7. WPPHD0" echo " 8. WPPHD1" echo " 9. WPPHD2" echo "10. WPPHD3" (1 Reply)
Discussion started by: misterpinkey
1 Replies

10. UNIX for Dummies Questions & Answers

Info Needed in Seting up An apache Web Server on A Sun Sparc with Solaris 8

I need help in the form of the complete procedures necessary in setting up an Apache web server on a Sun Sparc running Solaris 8 David Johnston P.S New to the Unix arena (1 Reply)
Discussion started by: David Johnston
1 Replies
Login or Register to Ask a Question