i getting data server in file (in format1) everyday ,however getting data last 1 week. have archive data 1.5 months exactly,because data being picked make graphical representation. have tried merge the files of 2 days , sort them uniquely (code1) ,however didn't work because everyday name of raw file changing.however time-stamp unique in file,but not sure how sort unique data on base of specific column also,is there way delete data older 1.5 months. deletion ,the logic thought deleting fetching today's date - least date of file again unable fetch least date.
format1
r01/was2/oss_change0_5.log:2016-03-21t11:13:36.354+0000 | (307,868,305) | oss_change | com.nokia.oss.configurator.rac.provisioningservices.util.log.logauditsuccesswithresources | racprs rnc 6.0 or newer_direct_activation: locking succeeded audit[ | source='server' | user identity='vpaineni' | operation identifier='cmnetworkmowriterlocking' | success code='t' | cause code='n/a' | identifier='success' | target element='plmn- plmn/rnc-199/wbts-720' | client address='10.7.80.21' | source session identifier='' | target session identifier='' | category code='' | effect code='' | network transaction identifier='' | source user identity='' | target user identity='' | timestamp='1458558816354']
code1
cat file1 file2 |sort -u > file3
data on day2 ,the input file name differ
r01/was2/oss_change0_11.log:2016-03-21t11:13:36.354+0000 | (307,868,305) | oss_change | com.nokia.oss.configurator.rac.provisioningservices.util.log.logauditsuccesswithresources | racprs rnc 6.0 or newer_direct_activation: locking succeeded audit[ | source='server' | user identity='vpaineni' | operation identifier='cmnetworkmowriterlocking' | success code='t' | cause code='n/a' | identifier='success' | target element='plmn- plmn/rnc-199/wbts-720' | client address='10.7.80.21' | source session identifier='' | target session identifier='' | category code='' | effect code='' | network transaction identifier='' | source user identity='' | target user identity='' | timestamp='1458558816354']
i have written similar kind of code week back.
awk tool ,if want operation column wise. , sort unique not work file name changing both unique rows , least date can find using awk.
1 unique file content
cat file1 file2 |awk -f "\|" '!repeat[$21]++' > file3;
here -f specifies field separator repeat taking 21st field time stamp , print 1st occurrence of time ,rest ignored so,finally unique content of file1 , file2 available in file3
2 least date , find difference between 2 dates
least_date=`awk -f: '{print substr($2,1,10)}' rmcr10.log|sort|head -1`; today_date=`date +%f` ; diff=`echo "( \`date -d $today_date +%s\` - \`date -d $start_date +%s\`) / (24*3600)" | bc -l`; diff1=${diff/.*}; if [ "$diff1" -ge "90" ]
here have used {:} field separator, , substring exact date field sorting , finding least
value. subtracting today's date using binary calculator , removing decimals.
hope helps .....
Comments
Post a Comment