Counting unique IP in warning log


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Counting unique IP in warning log
# 1  
Old 01-25-2011
Counting unique IP in warning log

Hi

I have a log that look like this:

Code:
12:20:28.522 Connection from IP: 185.164.118.136 Login Failed!
12:20:29.389 Connection from IP: 84.20.182.63 Login Failed!
12:20:30.111 Connection from IP: 80.180.143.79 Login Failed!
12:20:31.038 Connection from IP: 83.226.102.106 Login Failed!
12:20:39.491 Connection from IP: 185.164.118.136 Login Failed!
12:20:39.902 Connection from IP: 84.20.182.63 Login Failed!
12:20:41.418 Connection from IP: 83.226.102.106 Login Failed!
12:20:43.227 Connection from IP: 80.180.143.79 Login Failed!

(IP are only example)

I need some help making a script that do count unique IP.
That is the easy part
awk '{a[$5]}END{for(i in a){n++};print n}' warnings.txt
cat warnings.txt | awk '{print $5}' | sort | uniq | wc -l


But I would like to set a threshold on number of hits.
Example 20
If a IP has not been in log more than 20 times, do not count
# 2  
Old 01-25-2011
Code:
awk ' {arr[$5]++; next} END { for (i in arr) { if(arr[i]>19 ) {print i,arr[i] }  } } ' logfile

Change the 19 to any number you need.
This User Gave Thanks to jim mcnamara For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] Isolating & Counting IP from log file

Dear Community, today my website was under attack for several hours. 2 specific IPs make a tons of "get requests" to a specific page and apache server goes up and down. Now the problem is solved because I put in firewall blacklist these IPs, but I took a lot of time to analyze the apache log to... (6 Replies)
Discussion started by: Lord Spectre
6 Replies

2. UNIX for Dummies Questions & Answers

Print unique lines without sort or unique

I would like to print unique lines without sort or unique. Unfortunately the server I am working on does not have sort or unique. I have not been able to contact the administrator of the server to ask him to add it for several weeks. (7 Replies)
Discussion started by: cokedude
7 Replies

3. Shell Programming and Scripting

Counting Pattern and unique pattern

Hi, I have a log file which amongst other text has these lines: (id is always the same format - ) e.g. <username>user1</username> <name>fdfsdf</name> Multiple other tags <id>A111</id> <username>user2</username> <name>fdfsdf</name> Multiple other tags <id>A222</id>... (1 Reply)
Discussion started by: arsenalfan01
1 Replies

4. Shell Programming and Scripting

Change unique file names into new unique filenames

I have 84 files with the following names splitseqs.1, spliseqs.2 etc. and I want to change the .number to a unique filename. E.g. change splitseqs.1 into splitseqs.7114_1#24 and change spliseqs.2 into splitseqs.7067_2#4 So all the current file names are unique, so are the new file names.... (1 Reply)
Discussion started by: avonm
1 Replies

5. Shell Programming and Scripting

Problem counting unique disks/slices

I want to create a unique listing of slices/disks from a large list that will have duplicates. Here is a sample of the input file. #array.txt Disk4:\s93 Disk4:\s93 Disk4:\s94 Disk4:\s95\s96\s97 Disk4:\s93 Disk4:\s95\s96\s103 Disk4:\s93 Disk4:\s93 Disk4:\s95\s96\s105 Disk4:\s93... (5 Replies)
Discussion started by: jontjioe
5 Replies

6. Shell Programming and Scripting

Counting specific words from the log

Hi, I need a shell script which can provide details from error logs like this Aug 23 21:19:41 red mountd: authenticated mount request from bl0110.bang.m pc.local:651 for /disk1/jobs (/disk1) Aug 23 08:49:52 red dhcpd: DHCPDISCOVER from 00:25:90:2b:cd:7c via eth0: unknown client Aug 24... (2 Replies)
Discussion started by: ratheeshp
2 Replies

7. UNIX for Advanced & Expert Users

Count number of unique patterns from a log file

Hello Everyone I need your help in fixing this issue., I have a log file which has data of users logging in to an application. I want to search for a particular pattern in the log ISSessionValidated=N If this key word is found , the above 8 lines will contain the name of the user who's... (12 Replies)
Discussion started by: xtechkid
12 Replies

8. Shell Programming and Scripting

get part of file with unique & non-unique string

I have an archive file that holds a batch of statements. I would like to be able to extract a certain statement based on the unique customer # (ie. 123456). The end for each statement is noted by "ENDSTM". I can find the line number for the beginning of the statement section with sed. ... (5 Replies)
Discussion started by: andrewsc
5 Replies

9. Shell Programming and Scripting

pattern search for multiple log files and counting

I have 10 appservers and each appserver has 4 jvms . Each of these logs is archived and stored on a nfs directory . For example the files are /logs/200907/ap1-jvm1.server.log.20090715.gz /logs/200907/ap2-jvm2.server.log.20090714.gz /logs/200908/ap1-jvm1.server.log.20090812.gz I want to... (3 Replies)
Discussion started by: gubbu
3 Replies

10. Shell Programming and Scripting

Need help with finding unique string in log file

Shell script help Here is 3 sample lines from a log file <date> INFO <java.com.blah> abcd:ID= user login <date> DEBUG <java.com.blah> <nlah bla> abcd:ID=123 user login <date> INFO <java.com.blah> abcd:ID=3243 user login I want to find unique "ID" from this log... (3 Replies)
Discussion started by: gubbu
3 Replies
Login or Register to Ask a Question