shell script for log files data!


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting shell script for log files data!
# 1  
shell script for log files data!

Hi Team,

please write a shell script.

It is for veritas netbackup logs. The result we currently have is a single file for each day's backups. we will keep the files in the directory and the file names are like below mentioned.

example :/opt/openv/netbackup/reports/Daily/NB_success*. The No of files are above 2000 fiels are there.

The files contains like below mentioned :


SAP_DV4_Archive 11/18/06 18:17(2)
Billing_Grv 11/07/06 01:07
SAP_E4D_Archive 11/18/06 18:38
SAP_E4D_Database none
Granv_Clients 11/07/06 03:37(8)
SAP_E6T_Database none
SAP_FID_Archive 11/18/06 18:17(2)
SAP_FID_Database none
SAP_FIP_Archive 11/18/06 18:08(2)
SAP_FIP_Database none
SAP_FIS_Archive 11/18/06 18:20(2)
SAP_FIS_Database x
SAP_O1D_Archive i
SAP_O1D_Database i
SAP_P6D_Archive 11/18/06 18:40

The first column will contain the archive name and next column will have the date and time if the bacup success otherwise it will have 'x' or 'i','none'.

please write a script and the reuslt should be as given below. if you writen a shell script with name status.sh. the script should take flags like as given below.

1. SAP_DV4_Archive backups for the last month or year successful backups

example : status.sh -m=05 -y=06 -p=SAP_E4D_Archive

script name status.sh

-m month
-y year
-p backup policy name

You could include a "summary" option that will count up the number of input files as a baseline and report that SAP_E4D_Archive ran successfully on 26 of 31 days.

Thanks & Regards

Venkat
# 2  
while read line
do
backupdate=`echo $line|awk '{print $2}'`
if [[ $backupdate = "x" || $backupdate = "i" || $backupdate = "none" ]]
then
continue
fi
backupfile=`echo $line | awk '{print $1}'`
formatstr=`echo $backupdate | awk -F"/" '{ print "status.sh -m="$1 " -y=
"$3 " -p="}'`
echo "$formatstr$backupfile"
done < tmp
# 3  
Hi aju_kup

Its not working. The input files are like "NB_success*". Please dont mind its essential.

Thanks
Venkat
# 4  
#! /usr/bin/ksh
for filename in NB_success*
do
while read line
do
backupdate=`echo $line|awk '{print $2}'`
if [[ $backupdate = "x" || $backupdate = "i" || $backupdate = "n
one" ]]
then
continue
fi
backupfile=`echo $line | awk '{print $1}'`
formatstr=`echo $backupdate | awk -F"/" '{ print "status.sh -m="
$1 " -y="$3 " -p="}'`
echo "$formatstr$backupfile"
done < $filename
done
# 5  
Hi aju_kup,

Its taking multiple input files. but its not giveing exact output

Suppose the Input is like


Viaware_Tol_PVWXP1 06/04/06 03:35
WebMethods_wmprd 06/04/06 06:35
WebMethods_wmprd_lg 06/04/06 07:35
WebMethods_wmprd_tn 06/04/06 06:35
iXOS_Grv 06/04/06 00:15
iXOS_Grv_DS 06/04/06 00:15
iXOS_Grv_ixar 06/04/06 00:35
iXOS_Tol 06/04/06 00:15

if I run the script like

./status.sh -m=04 -y=06 -p=iXOS

the out put should like this I want.

iXOS_Grv 06/04/06 00:15
iXOS_Grv_DS 06/04/06 00:15
iXOS_Grv_ixar 06/04/06 00:35
iXOS_Tol 06/04/06 00:15

Please dont mind can you do it like this

Thanks
Venkat
# 6  
Hi R Rao here is the script

################test.sh##############
###Use: ./test.sh -m 04 -y 06 -p iXOS########
##################################

while getopts m:ySmilie: argmnt ####please use m colon y colon p colon
do
case $argmnt in
m) aflag=1
month="$OPTARG";;
y) bflag=1
year="$OPTARG";;
p) cflag=1
filter="$OPTARG";;
*) echo "Invalid argumetn passed.."
exit 99;;
esac
done
if [[ -z $aflag ]]
then
echo "month missing..Use: -m month -y year -p filter"
exit 1
fi

if [[ -z $bflag ]]
then
echo "year missing..Use: -m month -y year -p filter"
exit 2
fi
if [[ -z $cflag ]]
then
echo "Filter missing..Use: -m month -y year -p filter"
exit 3
fi
grep -h "$filter" NB_success* | grep "$month/$year"

Last edited by jambesh; 11-30-2006 at 10:09 AM..
# 7  
#! /usr/bin/ksh
mon=`echo $1 | awk -F"=" '{print $2}'`
year=`echo $2 | awk -F"=" '{print $2}'`
file=`echo $3 | awk -F"=" '{print $2}'`

for filename in tmp*.a
do
awk "/$file/ && /$mon\/[0-9][0-9]\/$year/"'{ print $0 }' $filename
done

Last edited by aju_kup; 11-30-2006 at 11:21 AM..
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #819
Difficulty: Medium
In CSS, E ~ F matches an F element preceded by an E element.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Help with a shell script? List files, delete them and log them

Hello, i'm trying to solve this script. List, one at a time, all files larger than 100K in the /home/username directory tree. Give the user the option to delete or compress the file, then proceed to show the next one. Write to a logfile the names of all deleted files and the deletion times. I... (7 Replies)
Discussion started by: jose2802
7 Replies

2. Shell Programming and Scripting

Standardization of input source data files using shell script

Hi there, I'm a newbie in unix and am fishing for options related to how raw input data files are handled. The scenario, as I'm sure y'all must be very familiar with, is this : we receive upwards of 50 data files in ASCII format from various source systems - now each file has its own structure... (3 Replies)
Discussion started by: Prat Khos
3 Replies

3. Shell Programming and Scripting

Shell Script to zip users cmd history log files

I admit I am terrible with scripting, so when I was asked to store users' command history lines and zip them on monthly basis what I did was to create a file "user_history_Feb" with the following contents: Part A # more user_history_Feb cp -p /var/log/user_history/*history... (6 Replies)
Discussion started by: hedkandi
6 Replies

4. Homework & Coursework Questions

Shell script calling Perl function, sort and find data, write to new files

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I must write a shell script that calls two external Perl functions--one of which sorts the data in a file, and... (6 Replies)
Discussion started by: kowit010
6 Replies

5. Shell Programming and Scripting

need a shell script to extract data from a log file.

If I have a log like : Mon Jul 19 05:07:34 2010; TCP; eth3; 52 bytes; from abc to def Mon Jul 19 05:07:35 2010; UDP; eth3; 46 bytes; from aaa to bbb Mon Jul 19 05:07:35 2010; TCP; eth3; 52 bytes; from def to ghi I will need an output like this : Time abc to def... (1 Reply)
Discussion started by: hitha87
1 Replies

6. Shell Programming and Scripting

Shell script to identify the number of files and to append data

Hi I am having a question where I have to 1) Identify the number of files in a directory with a specific format and if the count is >1 we need to concatenate those two files into one file and remember that in the second file the header should not be copied. it should be form first file.... (4 Replies)
Discussion started by: pradkumar
4 Replies

7. Shell Programming and Scripting

Compare semicolon seperated data in 2 files using shell script

hello members, I have some data ( seperated by semicolon ) with close to 240 rows in a text file temp1. temp2.txt stores 204 rows of data ( seperated by semicolon ). I want to : Sort the data in both files by field1.i.e first data field in every row. compare the data in both files and print... (6 Replies)
Discussion started by: novice82
6 Replies

8. Shell Programming and Scripting

shell script to remove old files and write to a log file

Hi, I have a script that works on a unix box but am trying to get it working on a linux box that uses shell. I am not a programmer so this is proving harder than I imagined. I made some changes and ended up with the script below but when I run it I get the following messages. Any help would be... (4 Replies)
Discussion started by: yabai
4 Replies

9. Shell Programming and Scripting

Shell script to read multiple log files

Hi all, I have to generate some report from shell script .We have stacktrace log file which generate hourly basis. So now my q is that how this shell script will read all stacktrace log file for particlular day and parse accordingly desire output. Any help or suggestion as i am newbie with... (1 Reply)
Discussion started by: esungoe
1 Replies

10. Shell Programming and Scripting

shell-script which extract data from log file

give me a shell-script which extract data from log file on a server by giving date and time as input (for both start time and end time) and it will give the logs generated during the given time as output. (4 Replies)
Discussion started by: abhishek27
4 Replies

Featured Tech Videos