LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-08-2016, 01:13 PM   #1
pavan27
LQ Newbie
 
Registered: Nov 2007
Posts: 14

Rep: Reputation: 0
Log parse script


Hello Experts,
i am trying to write script to monitor replication, fir this i need to read the replication log file and report if my condition is matched. i have below file
Code:
stream id: 8ad5917c1992e82b0c5a9577124603ab/beer-sample/beer-sample
   status: running
   source: beer-sample
   target: /remoteClusters/8ad5917c1992e82b0c5a9577124603ab/buckets/beer-sample
stream id: 8ad5917c1992e82b0c5a9577124603ab/beer-sample/beer-sample1
   status: aborted  >>>>>>>>
   source: beer-sample
   target: /remoteClusters/8ad5917c1992e82b0c5a9577124603ab/buckets/beer-sample1
from the above file, i have two replication streams, one stream is going good another stream is aborted.
my requirement is to read stream id and its status (below line) and report only failed portion (3 lines below stream id (status, source, target).
could you please help me to solve this puzzle.

Thank you,
 
Old 02-08-2016, 01:17 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Please review the following link Welcome to LQ

Please realize that the intention of LQ is that you learn how to help yourself.

Check some of the links in my signature which refer to BASH scripting.

Attempt to write a BASH script of your own, or some other means to try to resolve your problem.

Post what you've tried. You say you're trying to write a script, then please post what you have thus far.

Note that people do not know your level of expertise if you don't at least show what you've tried to resolve this problem on your own.

If you've tried nothing except asking a question, then a suggestion is to at least perform a web search to find a potential answer for your question.
 
1 members found this post helpful.
Old 02-08-2016, 01:19 PM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,633

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by pavan27 View Post
Hello Experts,
i am trying to write script to monitor replication, fir this i need to read the replication log file and report if my condition is matched. i have below file
Code:
stream id: 8ad5917c1992e82b0c5a9577124603ab/beer-sample/beer-sample
   status: running
   source: beer-sample
   target: /remoteClusters/8ad5917c1992e82b0c5a9577124603ab/buckets/beer-sample
stream id: 8ad5917c1992e82b0c5a9577124603ab/beer-sample/beer-sample1
   status: aborted  >>>>>>>>
   source: beer-sample
   target: /remoteClusters/8ad5917c1992e82b0c5a9577124603ab/buckets/beer-sample1
from the above file, i have two replication streams, one stream is going good another stream is aborted. my requirement is to read stream id and its status (below line) and report only failed portion (3 lines below stream id (status, source, target).
could you please help me to solve this puzzle.
You've asked similar questions in the past. And since you say you're trying to write a script, why don't you POST that script?? We are not going to write it for you, but will be happy to help. Read the "Question Guidelines" link in my posting signature. You've been a member here for NINE YEARS now.

Last edited by TB0ne; 02-08-2016 at 01:20 PM.
 
1 members found this post helpful.
Old 02-08-2016, 01:56 PM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by pavan27 View Post
Hello Experts,
i am trying to write script to monitor replication
What have you read?
Where did you read it?
What have you tried?
Show us your work.
 
Old 02-08-2016, 04:14 PM   #5
pavan27
LQ Newbie
 
Registered: Nov 2007
Posts: 14

Original Poster
Rep: Reputation: 0
Hello Experts,

Thank you so much for reply. i have completed my script.

Quote:
ChkRepl

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~#
# Check Couchbase status #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~#
ChkRepl () {

$CB_HOME/bin/couchbase-cli xdcr-replicate -c ${HN}:8091 --list >${LOG}

}

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~#
# let check the status #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~#

setup_environment
ChkRepl

STATUS=`grep -iw 'paused' ${LOG}`
if [ $? -eq 0 ]; then
MESSAGE="${HN}:${CB_ENV}: Coubhcase replicaton is had issue "
grep -A2 'paused' ${LOG}|mailx -s "${MESSAGE}" ${CB_EDBA}
fi
exit;


 
Old 02-08-2016, 04:27 PM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Does the script do what you wished it to do? If so, then it's good that you posted it and then also please mark the thread as solved. If there are problems, then it might be helpful to describe those problems.
 
Old 02-09-2016, 06:16 AM   #7
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,006

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
I realise you have only shown a snippet of your script, but am curious how the first line shown would execute correctly if the definition is coming after it is called? Unless of course you have
multiple definitions of the same function?? (if so this could cause a headache in the future)
 
  


Reply

Tags
parse, programing, shell script



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] /var/log/secure parse with perl script - guidance needed Habitual Programming 16 10-26-2012 10:28 AM
Need Shell Script to parse Zimbra Sync.log rlug Linux - General 1 01-08-2012 08:29 AM
Parse log file with bash mijohnst Linux - General 8 09-09-2010 10:46 PM
Help w/ script to read file and parse log message shyork2001 Linux - General 4 04-06-2010 11:48 AM
Parse Log files nima0102 Linux - Server 2 11-23-2009 11:24 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration