Team,
I have application where it sends the information to syslog server in XML format.
The requirement is that we have to use that XML output and manipulate and out it in certain format. I cant use Nth column as the data changes with the length of the message. With that said, I am wondering where I am doing wrong.
XML input in to Syslog file:
Code:
Jun 18 13:02:04 avamar MCS:BS::ACTIVITY::STOP: <Code> 30010 <Type> INFORMATION <Severity> PROCESS <Category> SECURITY <HwSource> avamar <Summary> Activity cancelled. <status_code> 30010 <endtime> 2015-06-18 20:02:04 <WID> TestGroup-1434657706517 <starttime> 2015-06-18 20:01:46 <client> /clients/linux/test.home.net <PID> Unix <hard_limit> 0 <bytes_modified_sent> 305683 <bytes_scanned> 2222290214 <plugin_name> Linux File System <Group> TestGroup <account_name> test.home.net <CID> 48324b01cdddd5355ff6f52379c8be278d040d90 <schedule> Admin On-Demand Schedule <snapup_number> 239 <Action> On-Demand Backup <snapup_label> TestGroup-1434657706517 <dataset> /Default Dataset <retention_policy> Minimal Retention <domain> /clients/linux <account> /clients/linux/test.home.net <targetCid> 48324b01cdddd5355ff6f52379c8be278d040d90 <errorcode> 10019 <client_name> test.home.net
Swatch.conf:
Code:
watchfor /MCS:BS:/
echo
exec echo $0 | awk -v date="$(date +'%m/%d/%y %H:%M:%S')" -v g="$(echo $0 | awk '{print $NF}')" -v pgp="$(cat bkpClient_pgp.csv | grep $g | cut -d, -f2)" -v grp="$(echo $0 | grep -Po '(?<=Group>\s)[^\s]*')" '{print $NF","$(NF-2)","$4","date","pgp","grp}' >> /var/log/avamar-formatted
Expected Output:
Code:
test.home.net,10019,avamar,06/18/15 13:02:04,pgp1083,TestGroup
Instead the file /var/log/avamar-formatted shows up as empty and below lines on the terminal.
Code:
sh: -c: line 0: unexpected EOF while looking for matching `''
sh: -c: line 1: syntax error: unexpected end of file
Please let me know where i am doing wrong. Thanks in advance.
Thanks
Gadikota