03-20-2011
How to find ip addresses in logfiles?
Hi guys,
I need to check a few log files as below to find out whether certain ip addresses is present on these log files.
type8code0: ls -alt
-rw-r--r-- 1 root other 796219588 Mar 20 02:25 logfile
drwxr-xr-x 2 root root 1536 Mar 20 02:00 .
-rw-r--r-- 1 root other 1854093343 Mar 20 02:00 logfile.hour02
-rw-r--r-- 1 root other 366729263 Mar 20 01:00 logfile.hour01
-rw-r--r-- 1 root other 9001399293 Mar 20 00:47 logfile.20.Z
-rw-r--r-- 1 root other 8267721901 Mar 19 00:45 logfile.19.Z
-rw-r--r-- 1 root other 7498682761 Mar 18 00:39 logfile.18.Z
-rw-r--r-- 1 root other 6196926607 Mar 17 00:31 logfile.17.Z
-rw-r--r-- 1 root other 4794493570 Mar 16 00:23 logfile.16.Z
I've saved the list of ip addresses in “iplist” file.
cat iplist
10.10.10.10
10.10.10.11
10.10.10.12
10.10.10.13
10.10.10.14
What is the best command to do this?
This is what I do now, but it takes sometime. Hopefully there is easy way to do this.
grep 10.10.10.10 logfile > output_logfile_10.10.10.10
grep 10.10.10.11 logfile > output_ logfile_10.10.10.11
and so on
zcat logfile.16.Z | grep 10.10.10.10 > output_logfile.16.Z_10.10.10.10
zcat logfile.16.Z | grep 10.10.10.11 > output_logfile.16.Z_10.10.10.11
and so on
Thanks
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
My server has only has access logs turned on. How do I turn on the other standard logs (i.e. I'd like to see the referring urls).
Thanks in advance. (3 Replies)
Discussion started by: pingdom
3 Replies
2. UNIX for Dummies Questions & Answers
I support an app that outputs alert and audit messages to one log file (vendor says they can't be separated). The script that I have written takes a copy (mv cmd) of the file to do the separation and reformatting. I have a problem that I loose records (messages are being written constantly, upto 3+... (5 Replies)
Discussion started by: nhatch
5 Replies
3. IP Networking
Arright, here's what I'm trying to do. I want to dig up currently active IP addresses on my subnet, and my present strategy is to ping every address until I find active ones, then ping them more often to verify their status. Next, I want to find the names of the computers associated with those... (1 Reply)
Discussion started by: sladuuch
1 Replies
4. Shell Programming and Scripting
Hi All
There are some cron jobs ,which runs 24 hrs. Log files are generated when one job fails.
So I need the log files to be emailed to my personal e-mail id. So that I can see the log files at my home If there is any error.
How can I implement this in Unix shell programming.
Thanks... (4 Replies)
Discussion started by: deep_kol
4 Replies
5. Shell Programming and Scripting
Hi,
I have a lot of logfiles like fooYYYYMM.log (foo200301.log, foo200810.log) with lines like
YYYY-MM-DD TIMESTAMP,text1,text2,text3...
but I need (for postprocessing) the form fooYYYYMMDD.log (so foo200402.log becomes foo20040201.log, foo20040202.log...)
with unmodified content of lines.
... (1 Reply)
Discussion started by: clzupp
1 Replies
6. Shell Programming and Scripting
Hi All,
I have a peculiar problem. I will call a script from another script.
Script abc.ksh is called by ABC.ksh as
ABC.ksh abc.ksh
in abc.ksh I will create and redirect all the statements to log file.
ABC.ksh will also has a log file. I want all the logs generated in file abc in ABC... (5 Replies)
Discussion started by: javeed7
5 Replies
7. Red Hat
Hi,
I need to logrotate logs in directories in /var/log/httpd/. There are 4 directories in /var/log/httpd/... these directories are /var/log/httpd/access/
/var/log/httpd/debug/
/var/log/httpd/error/
/var/log/httpd/required/
Each of the access, required, error and debug directories have around... (1 Reply)
Discussion started by: renuka
1 Replies
8. Shell Programming and Scripting
Hi,
I have a file having following content.
<sip:9376507346@97.208.31.7:51088
<sip:9907472291@97.208.31.7:51208
<sip:8103742422@97.208.31.7:51024
<sip:9579892841@97.208.31.7:51080
<sip:9370904222@97.208.31.7:51104
<sip:9327665215@97.208.31.7:51104
<sip:9098364262@97.208.31.7:51024... (2 Replies)
Discussion started by: SunilB2011
2 Replies
9. UNIX for Advanced & Expert Users
Hi,
I have a web server running on Debian 6.0.4 in a computer outside my university, but the web URL is blocked by my university, the security group of the university said because it was scanning computers inside university.
I could not find any applications in my web server are doing... (3 Replies)
Discussion started by: hce
3 Replies
10. UNIX for Beginners Questions & Answers
Hi,
I have a file with a list of bunch of IP addresses from different VLAN's . I am trying to find the list the number of each vlan occurence in the output
Here is how my file looks like
1.1.1.1
1.1.1.2
1.1.1.3
1.1.2.1
1.1.2.2
1.1.3.1
1.1.3.2
1.1.3.3
1.1.3.4
So what I am trying... (2 Replies)
Discussion started by: new2prog
2 Replies
LEARN ABOUT REDHAT
logwatch
LOGWATCH(8) User Manuals LOGWATCH(8)
NAME
logwatch - system log analyzer and reporter
SYNOPSIS
logwatch [--detail level ] [--logfile log-file-group ] [--service service-name ] [--print] [--mailto address ] [--archives] [--range range
] [--debug level ] [--save file-name ] [--logdir directory ] [--hostname hostname ] [--help|--usage]
DESCRIPTION
LogWatch is a customizable, pluggable log-monitoring system. It will go through your logs for a given period of time and make a report in
the areas that you wish with the detail that you wish. Easy to use - works right out of the package on almost all systems.
OPTIONS
--detail level
This is the detail level of the report. level can be high, med, low.
--logfile log-file-group
This will force LogWatch to process only the set of logfiles defined by log-file-group (i.e. messages, xferlog, ...). LogWatch will
therefore process all services that use those logfiles. This option can be specified more than once to specify multiple logfile-
groups.
--service service-name
This will force LogWatch to process only the service specified in service-name (i.e. login, pam, identd, ...). LogWatch will there-
fore also process any log-file-groups necessary to process these services. This option can be specified more than once to specify
multiple services to process. A useful service-name is All which will process all services (and logfile-groups) for which you have
filters installed.
--print
Print the results to stdout (i.e. the screen).
--mailto address
Mail the results to the email address or user specified in address.
--archives
Each log-file-group has basic logfiles (i.e. /var/log/messages) as well as archives (i.e. /var/log/messages.? or /var/log/mes-
sages.?.gz). This option will make LogWatch search through the archives in addition to the regular logfiles. The entries must
still be in the proper date range (see below) to be processed, however.
--range range
You can specify a date-range to process. This option is currently limited to only Yesterday, Today and All.
--debug level
For debugging purposes. level can range from 0 to 100. This will really clutter up your output. You probably don't want to use
this.
--save file-name
Save the output to file-name instead of displaying or mailing it.
--logdir directory
Look in directory for log files instead of the default directory.
--hostname hostname
Use hostname for the reports instead of this system's hostname. In addition, if HostLimit is set in /etc/log.d/logwatch.conf, then
only logs from this hostname will be processed (where appropriate).
--usage
Displays usage information
--help same as --usage.
FILES
/etc/log.d/logwatch.conf
Really a symlink to /etc/log.d/conf/logwatch.conf. This file sets the default values of all the above options. These defaults are
used when LogWatch is called without any parameters (i.e. from cron.daily). The file is well-documented, but the explanations above
also apply to this config file.
/etc/log.d/conf/services/*
Configuration files for the various services whose log entries LogWatch can process.
/etc/log.d/conf/logfiles/*
Configuration files for the various logfiles that the above service's log entries are stored in.
/etc/log.d/scripts/shared/*
Filters common to many services and/or logfiles.
/etc/log.d/scripts/logfiles/*
Filters specific to just particular logfiles.
/etc/log.d/scripts/services/*
Actual filter programs for the various services.
EXAMPLES
logwatch --service ftpd-xferlog --range all --detail high --print --archives
This will print out all FTP transfers that are stored in all current and archived xferlogs.
logwatch --service pam_pwdb --range yesterday --detail high --print
This will print out login information for the previous day...
MORE INFORMATION
For information on adding your own filter, please see the file HOWTO-Make-Filter which should have been included with Logwatch. If you
installed from an RPM, it is probably under /usr/share/doc/logwatch-XXX.
BUGS
The --range option is very weak... this will be fixed in the future.
AUTHOR
Kirk Bauer <kirk@kaybee.org>
http://www.kaybee.org/~kirk
ftp://ftp.kaybee.org/pub/redhat/RPMS
Linux MARCH 1998 LOGWATCH(8)