First off I'll say - I am a bad perl programmer.
I want to be better and with your help I'll get there and then be able
to contribute more here.
That being said, I have a simple problem compounded by file size.
I have a PIX that logs to my syslog server for a ton of items - my
logs sizes get extremely large; ~13 GIGABYTEs daily and they are
rotated daily.
I'm trying to set up some intrusion detection but with file sizes that
big just counting incidents to start getting a baseline gets time, cpu
and memory intensive using shell commands like grep. So I wanted to do
something in perl but I don't know if because of the file size and
memory limitations I can do that.
Here's the shell command based perl script I run to get a basic count
on a certain number of incidents.
#!/usr/bin/perl
$LOG = "$ARGV[1]";
$VARIABLE = "$ARGV[0]";
$GREP = `zgrep -c $VARIABLE $LOG`;
print "$GREP\n";
I print out the number and another program uses that output to put the
number into a database.
How would I accompilish this simply in perl?
More complicated would be to match multiple variables against the same
log at one time. I would just pull the log into memory if it were a
manageable size but it is not...
Anyway - your help is appreciated.
The Mikester 7 5196 su*********@yah oo.com (mikester) wrote in message news:<69******* *************** ****@posting.go ogle.com>... First off I'll say - I am a bad perl programmer.
I want to be better and with your help I'll get there and then be able to contribute more here.
That being said, I have a simple problem compounded by file size.
I have a PIX that logs to my syslog server for a ton of items - my logs sizes get extremely large; ~13 GIGABYTEs daily and they are rotated daily.
I'm trying to set up some intrusion detection but with file sizes that big just counting incidents to start getting a baseline gets time, cpu and memory intensive using shell commands like grep. So I wanted to do something in perl but I don't know if because of the file size and memory limitations I can do that.
Here's the shell command based perl script I run to get a basic count on a certain number of incidents.
#!/usr/bin/perl $LOG = "$ARGV[1]"; $VARIABLE = "$ARGV[0]"; $GREP = `zgrep -c $VARIABLE $LOG`; print "$GREP\n";
I print out the number and another program uses that output to put the number into a database.
How would I accompilish this simply in perl?
More complicated would be to match multiple variables against the same log at one time. I would just pull the log into memory if it were a manageable size but it is not...
Anyway - your help is appreciated.
The Mikester
Sorry, typo it is actually
#!/usr/bin/perl $LOG = "$ARGV[1]"; $VARIABLE = "$ARGV[0]"; $GREP = `grep -c $VARIABLE $LOG`; <---- print "$GREP\n";
Thanks
In article <69************ **************@ posting.google. com>, mikester
<su*********@ya hoo.com> wrote:
[snip] Here's the shell command based perl script I run to get a basic count on a certain number of incidents.
#!/usr/bin/perl $LOG = "$ARGV[1]"; $VARIABLE = "$ARGV[0]"; $GREP = `zgrep -c $VARIABLE $LOG`; print "$GREP\n";
I print out the number and another program uses that output to put the number into a database.
How would I accompilish this simply in perl?
Here is a simple perl program that will do that:
#!/usr/bin/perl
use strict;
use warnings;
my $log = $ARGV[1];
my $count = 0;
open(LOG,$log) or die("Can't open $log: $!");
while(<LOG>) {
$count++ if /$ARGV[0]/;
}
print "count of '$ARGV[0]' in $log is $count\n"; More complicated would be to match multiple variables against the same log at one time. I would just pull the log into memory if it were a manageable size but it is not...
Scanning one line at a time is better. You can make the regular
expression (/$ARGV[0]/ above) as complicated as you want it. Anyway - your help is appreciated.
The Mikester
Jim Gibson <jg*****@mail.a rc.nasa.gov> wrote in message news:<191220031 038058768%jg*** **@mail.arc.nas a.gov>... In article <69************ **************@ posting.google. com>, mikester <su*********@ya hoo.com> wrote:
[snip]
Here's the shell command based perl script I run to get a basic count on a certain number of incidents.
#!/usr/bin/perl $LOG = "$ARGV[1]"; $VARIABLE = "$ARGV[0]"; $GREP = `zgrep -c $VARIABLE $LOG`; print "$GREP\n";
I print out the number and another program uses that output to put the number into a database.
How would I accompilish this simply in perl?
Here is a simple perl program that will do that:
#!/usr/bin/perl
use strict; use warnings;
my $log = $ARGV[1]; my $count = 0;
open(LOG,$log) or die("Can't open $log: $!"); while(<LOG>) { $count++ if /$ARGV[0]/; } print "count of '$ARGV[0]' in $log is $count\n";
More complicated would be to match multiple variables against the same log at one time. I would just pull the log into memory if it were a manageable size but it is not...
Scanning one line at a time is better. You can make the regular expression (/$ARGV[0]/ above) as complicated as you want it.
Anyway - your help is appreciated.
The Mikester
I'll give that a shot tomorrow, Thanks - I'll let you know how it goes.
Jim Gibson <jg*****@mail.a rc.nasa.gov> wrote in message news:<191220031 038058768%jg*** **@mail.arc.nas a.gov>... In article <69************ **************@ posting.google. com>, mikester <su*********@ya hoo.com> wrote:
[snip]
Here's the shell command based perl script I run to get a basic count on a certain number of incidents.
#!/usr/bin/perl $LOG = "$ARGV[1]"; $VARIABLE = "$ARGV[0]"; $GREP = `zgrep -c $VARIABLE $LOG`; print "$GREP\n";
I print out the number and another program uses that output to put the number into a database.
How would I accompilish this simply in perl?
Here is a simple perl program that will do that:
#!/usr/bin/perl
use strict; use warnings;
my $log = $ARGV[1]; my $count = 0;
open(LOG,$log) or die("Can't open $log: $!"); while(<LOG>) { $count++ if /$ARGV[0]/; } print "count of '$ARGV[0]' in $log is $count\n";
More complicated would be to match multiple variables against the same log at one time. I would just pull the log into memory if it were a manageable size but it is not...
Scanning one line at a time is better. You can make the regular expression (/$ARGV[0]/ above) as complicated as you want it.
Anyway - your help is appreciated.
The Mikester
I'll give that a shot tomorrow, Thanks - I'll let you know how it goes. su*********@yah oo.com (mikester) wrote in message news:<69******* *************** ****@posting.go ogle.com>... Jim Gibson <jg*****@mail.a rc.nasa.gov> wrote in message news:<191220031 038058768%jg*** **@mail.arc.nas a.gov>... In article <69************ **************@ posting.google. com>, mikester <su*********@ya hoo.com> wrote:
[snip]
Here's the shell command based perl script I run to get a basic count on a certain number of incidents.
#!/usr/bin/perl $LOG = "$ARGV[1]"; $VARIABLE = "$ARGV[0]"; $GREP = `zgrep -c $VARIABLE $LOG`; print "$GREP\n";
I print out the number and another program uses that output to put the number into a database.
How would I accompilish this simply in perl?
Here is a simple perl program that will do that:
#!/usr/bin/perl
use strict; use warnings;
my $log = $ARGV[1]; my $count = 0;
open(LOG,$log) or die("Can't open $log: $!"); while(<LOG>) { $count++ if /$ARGV[0]/; } print "count of '$ARGV[0]' in $log is $count\n";
More complicated would be to match multiple variables against the same log at one time. I would just pull the log into memory if it were a manageable size but it is not...
Scanning one line at a time is better. You can make the regular expression (/$ARGV[0]/ above) as complicated as you want it.
Anyway - your help is appreciated.
The Mikester
I'll give that a shot tomorrow, Thanks - I'll let you know how it goes.
It works great - but not with the large files. The files are in the
13GB files size and I just don't have the memory to load that up.
In article <69************ *************@p osting.google.c om>, mikester
<su*********@ya hoo.com> wrote: su*********@yah oo.com (mikester) wrote in message news:<69******* *************** ****@posting.go ogle.com>... Jim Gibson <jg*****@mail.a rc.nasa.gov> wrote in message news:<191220031 038058768%jg*** **@mail.arc.nas a.gov>... In article <69************ **************@ posting.google. com>, mikester <su*********@ya hoo.com> wrote:
[snip]
> > Here's the shell command based perl script I run to get a basic count > on a certain number of incidents. >
[snip]
Here is a simple perl program that will do that:
#!/usr/bin/perl
use strict; use warnings;
my $log = $ARGV[1]; my $count = 0;
open(LOG,$log) or die("Can't open $log: $!"); while(<LOG>) { $count++ if /$ARGV[0]/; } print "count of '$ARGV[0]' in $log is $count\n"; It works great - but not with the large files. The files are in the 13GB files size and I just don't have the memory to load that up.
It shouldn't take much more memory to run that program on a 13GB file
than it does no a small one. The program only reads in one line at a
time. What doesn't "work great" with the large file? What happens?
Jim Gibson <jg*****@mail.a rc.nasa.gov> wrote in message news:<231220031 527288072%jg*** **@mail.arc.nas a.gov>... In article <69************ *************@p osting.google.c om>, mikester <su*********@ya hoo.com> wrote:
su*********@yah oo.com (mikester) wrote in message news:<69******* *************** ****@posting.go ogle.com>... Jim Gibson <jg*****@mail.a rc.nasa.gov> wrote in message news:<191220031 038058768%jg*** **@mail.arc.nas a.gov>... > In article <69************ **************@ posting.google. com>, mikester > <su*********@ya hoo.com> wrote: > > [snip] > > > > > Here's the shell command based perl script I run to get a basic count > > on a certain number of incidents. > > [snip] Here is a simple perl program that will do that: > > #!/usr/bin/perl > > use strict; > use warnings; > > my $log = $ARGV[1]; > my $count = 0; > > open(LOG,$log) or die("Can't open $log: $!"); > while(<LOG>) { > $count++ if /$ARGV[0]/; > } > print "count of '$ARGV[0]' in $log is $count\n"; >
It works great - but not with the large files. The files are in the 13GB files size and I just don't have the memory to load that up.
It shouldn't take much more memory to run that program on a 13GB file than it does no a small one. The program only reads in one line at a time. What doesn't "work great" with the large file? What happens?
I'll post the output after the holiday. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Joerg Schuster |
last post by:
Hello,
I am looking for a method to "shuffle" the lines of a large file.
I have a corpus of sorted and "uniqed" English sentences that has been
produced with (1):
(1) sort corpus | uniq > corpus.uniq
corpus.uniq is 80G large. The fact that every sentence appears only
|
by: Sam Lowry |
last post by:
Greetings. I am trying to do something which should elementary for
Perl, but I have only been able to find bits and pieces on it. When I
put the bits together they do not work. Maybe I am going in the wrong
direction.
I want to count several strings of text in a file (security.txt) and
output the counts with a brief description of each. I have tried
specifying the descriptions (name) and the strings (exe) in the array
within the perl...
|
by: jabailo |
last post by:
Which would be faster for counting lines in a StreamReader:
(a) iterate through a file using .ReadLine() and adding to a counter, i++
(b) doing a .ReadToEnd() and then using an IndexOf() method to count the
occurances of \r\n
(c) doing a .ReadToEnd() and using a RegEx to count the number of occurances
of \r\n
|
by: Conrad F |
last post by:
Hello all,
I am waiting for receipt of files in a directory. I use the
FileSystemWatcher to detect when files arrive in said folder. I need
to read the data from these files ASAP but the files are created and
detected before writing completes and so I cannot read them until the
file handle used in their creation has been released.
This would be easy to get around with file renaming or other file
locking mechanisms which I could use...
|
by: Anders K. Jacobsen [DK] |
last post by:
Hi
We have a rather large asp.net project with serveral utility projects
(written in C#). Is there at tool out there which can give an estimate of
the total amount of code lines all projects results in?
thanks in regads
Anders
| |
by: Steve McLellan |
last post by:
Hi,
Sorry to repost, but this is becoming aggravating, and causing me a lot of
wasted time. I've got a reasonably large mixed C++ project, and after a
number of builds (but not a constant number) linking (and sometimes
compiling) becomes immensely slow, and task manager shows that link.exe (or
cl.exe) is barely using any processor time, but an awful lot of RAM (around
150-200MB). I'm going to keep an eye on page faults since I can't...
|
by: j |
last post by:
Hi,
I've been trying to do line/character counts on documents that are
being uploaded. As well as the "counting" I also have to remove
certain sections from the file.
So, firstly I was working with uploaded MS WORD .doc files. Using code
like that below:
strLine = sr.ReadLine
While Not IsNothing(strLine) 'Not eof
If Trim(strLine) <> "" Then 'Not blank
|
by: Mark..... |
last post by:
Hi,
Can someone tell me the easiest way to count the number of lines in a
text file?
I can write a loop to do this but it seems cumbersome.... there must be
an easier way??
Thanks in advance
|
by: peraklo |
last post by:
Hello,
there is another problem i am facing. i have a text file which is
about 15000 lines big. i have to cut the last 27 lines from that file
and create a new text file that contans those 27 lines. and after that
save both of those files... since that is a big block of text (15000
lines) i thint that it is a big job to look for a keyword... so my
question is this exactly:
how do i do this:
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |