Sponsored Content
Full Discussion: Script Advice please?
Top Forums Shell Programming and Scripting Script Advice please? Post 302121818 by earnstaf on Monday 18th of June 2007 02:12:51 PM
Old 06-18-2007
Script Advice please?

Ok. I want to parse a log file and search only for denied traffic for the previous hour. The log looks like this:

Jun 18 17:47:56 routername 36806: Jun 18 17:53:01.088: %SEC-6-IPACCESSLOG: list ingress-filter denied tcp 1.2.3.4(1234) -> 6.7.8.9(53), 4 packets

I only really care about the time, routername and denied (fields 3-4,12)..

I currently have this in place:

Code:
grep "denied" file | grep gress | sed "s/  / /g" | cut -d " " -f 3-4 | sed "s/:/ :/g" | awk '$1 == 13' | cut -d " " -f 4 | sort -u

and then have that cron'ed to run every hour.... The first sed is used because between the 1st and 9th of the month, there is an extra space in the date. Second sed put the hour in it's own column to be matched on the awk. Then end file just has the routernames sorted unique.

There has to be an easier/better way to go about this?

This just came to mind again when Shell Life posted this in another thread:

Code:
sed -n '/18:/,$ p' filename

and I thought that might be a good way to just search within the previous hour.

Help?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

c-shell script advice please.

Hi, I have the following script running in my cron. -------------------------------------------------------------------- #!/bin/csh bnstat -p GPD_VSLinux | grep pg | grep varcon | awk '{print $1, $2, $3, $4, $5, $6, $7, $8, $9, $10}' > /tmp/LX_xbatch.log bnstat -p GPD_VSLinux_test | grep pg... (2 Replies)
Discussion started by: killerserv
2 Replies

2. Shell Programming and Scripting

first script. need help and advice.

Hello everyone, This is my first post here and this is the first time I am using UNIX OS (Slackware). I find it really useful and powerful and would like to master it but as you may guess I am expreicing quite a few problems. I've been reading a few documentations about it and bash this week... (17 Replies)
Discussion started by: sanchopansa
17 Replies

3. Shell Programming and Scripting

Advice on Script

I would like some advice on how to logically put together a script to handle a daily task of data gathering for the following problem. I have two files, file1 has 125,000 records that I cut and remove unwanted fields through scripts and cron. In file2, I have 25000 records that has the same... (4 Replies)
Discussion started by: greengrass
4 Replies

4. Shell Programming and Scripting

Script Help/Advice

Alright, I feel like I have a pretty good basic knowledge of shell scripting, but this one is throwing me for a loop. I know I've seen something similar done with awk, but I couldn't find it with the search function. I've grepped through my log file and get results like this: --... (14 Replies)
Discussion started by: earnstaf
14 Replies

5. Shell Programming and Scripting

advice on shell script

Hello, I have this script running on cron every 20 minutes. By 12pm daily, our system is expecting all input files to be uploaded by the script. After this cutoff time, the script would still be running though, but i need some kind of alerts/logs to know which input files weren't received for... (1 Reply)
Discussion started by: gholdbhurg
1 Replies

6. Shell Programming and Scripting

Looking for optimization advice on a short script

I already have a solution to my problem, but I'm looking to see if it can be made more succinct and faster. The problem: given a list, as shown below, extract the pathname for any file in a directory named 'ample' and return it's index into the list. The index is also in the data itself. Note that... (1 Reply)
Discussion started by: prigo
1 Replies

7. Shell Programming and Scripting

Advice on script

Hi folks, I use following script:- #!/bin/sh # cd Linbread TODAY=`date +"%m%d"` DATA=`grep $TODAY linbread.dat` HOUR=`date +"%H"` if then TOD="Morning" elif then TOD="Afternoon" else TOD="Evening" fi echo $DATA | gawk -F"|" '{printf("%s\n\n%s",$2,$3)}' > $$tmp fold -s -w60... (0 Replies)
Discussion started by: satimis
0 Replies

8. Shell Programming and Scripting

Need advice on approach for script

Greetings all. I have a repository server which receives, without exhaggeration, several million files a week. The majority of these files are in .csv format, which means they're highly compressable. They are spread throughout numerous directories where there are configured monitoring utilities... (4 Replies)
Discussion started by: msarro
4 Replies

9. Shell Programming and Scripting

Script advice

All I have 2 parent directories - input and output. Each parent has multiple sub-directories...each sub-directory has multiple files. Each parent directory structure is a mirror image of itself I need to poll the imput directory and if a new file is found, encrypt the file, move the file to... (2 Replies)
Discussion started by: davidra
2 Replies

10. UNIX for Advanced & Expert Users

Advice on a backup script, maybe one is out there already?

Hi, Not sure whether this is the right place to post it. I decided to post it here 'coz Advanced and Expert users will most likely have the answer to what I am looking for. I want to backup scripts that I have access to to a tar file file and zip it. At the moment I am creating a directory... (4 Replies)
Discussion started by: newbie_01
4 Replies
psiclean(1)															       psiclean(1)

NAME
psiclean - delete files in the PSI temporary directories DESCRIPTION
The psiclean command finds a job name by scanning the input file for a keyword assignment of the form DEFAULT:FILES:DEFAULT:NAME = string It then goes through all of the machine's temporary directories and deletes all files of the form string.*. In previous versions of psi- clean , temporary directories were assumed to be of the form /tmp[0-9]/$user In this version of psiclean , we get the names of the temporary directories from the user input file by looking for volume paths of the form DEFAULT:FILES:DEFAULT:VOLUMEi = string It is essential that users see to the removal of their scratch files as soon as their job completes, because temporary directories are usu- ally a shared resource and there is not necessarily an automatic way for files to be deleted from these areas. Thus, the last command run after a job has finished should be the psiclean command. The user must take care to follow certain conventions when choosing filenames. Any files which are to be kept after a job completes should not be kept in the default temporary directories. The FILES input must be used to specify other locations for the specific files which are to be kept. psiclean will ignore files which are specifically listed by number (e.g., PSIF_CHKPT ) in the FILES section. Files which are not needed after the run should use the default path given in the input file. Otherwise, these files will remain on the system and will impede other jobs. EXAMPLE
Suppose the PSI temporary directories contained the following subdirectories and files: /tmp1/cpuhog: -rw-r--r-- 1 cpuhog 14492 Jun 11 16:48 dicubane.30 -rw-r--r-- 1 cpuhog 187320 Jun 8 17:20 diketene.34 -rw-r--r-- 1 cpuhog 16384 Jun 7 19:17 o4big.30 -rw-r--r-- 1 cpuhog 16384 Jun 7 19:17 o4.30 -rw-r--r-- 1 cpuhog 974848 Jun 7 18:41 o4.34 /tmp2/cpuhog: -rw-r--r-- 1 cpuhog 14492 Jun 11 16:48 dicubane.30 -rw-r--r-- 1 cpuhog 187320 Jun 8 17:20 diketene.34 -rw-r--r-- 1 cpuhog 10904 Jun 7 18:50 o4big.30 -rw-r--r-- 1 cpuhog 10904 Jun 7 18:50 o4.30 -rw-r--r-- 1 cpuhog 973752 Jun 7 18:41 o4.34 /tmp3/cpuhog: -rw-r--r-- 1 cpuhog 14492 Jun 11 16:48 dicubane.30 -rw-r--r-- 1 cpuhog 187320 Jun 8 17:20 diketene.34 -rw-r--r-- 1 cpuhog 8192 Jun 7 19:17 o4big.30 -rw-r--r-- 1 cpuhog 8192 Jun 7 19:17 o4.30 -rw-r--r-- 1 cpuhog 966656 Jun 7 18:41 o4.34 Let's also say that the user cpuhog is in a directory which contains an input file which has the following line in it: DEFAULT:FILES:DEFAULT:NAME = "o4" If the user cpuhog now executes the psiclean command, then the o4 files in the temporary directories would be deleted, leaving the follow- ing files: /tmp1/cpuhog: -rw-r--r-- 1 cpuhog 14492 Jun 11 16:48 dicubane.30 -rw-r--r-- 1 cpuhog 187320 Jun 8 17:20 diketene.34 -rw-r--r-- 1 cpuhog 16384 Jun 7 19:17 o4big.30 /tmp2/cpuhog: -rw-r--r-- 1 cpuhog 14492 Jun 11 16:48 dicubane.30 -rw-r--r-- 1 cpuhog 187320 Jun 8 17:20 diketene.34 -rw-r--r-- 1 cpuhog 10904 Jun 7 18:50 o4big.30 /tmp3/cpuhog: -rw-r--r-- 1 cpuhog 14492 Jun 11 16:48 dicubane.30 -rw-r--r-- 1 cpuhog 187320 Jun 8 17:20 diketene.34 -rw-r--r-- 1 cpuhog 8192 Jun 7 19:17 o4big.30 AUTHOR
C. David Sherrill <sherrill@alum.mit.edu> Psi Version 3.0 29 July, 1999 psiclean(1)
All times are GMT -4. The time now is 07:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy