yes, Patrick is right. If you type nc you will see the available supported
flags. For example,
Usage: nc [OPTIONS] HOST PORT - connect
nc [OPTIONS] -l -p PORT [HOST] [PORT] - listen

-e PROG Run PROG after connect (must be last)
-l Listen mode, for inbound connects
-lk With -e, provides persistent server
-p PORT Local port
-s ADDR Local address
-w SEC Timeout for connects and final net reads
-i SEC Delay interval for lines sent
-n Don’t do DNS resolution
-u UDP mode
-v Verbose
-o FILE Hex dump traffic
-z Zero-I/O mode (scanning)

-q was used to wait for x seconds for a response to come back from the
server. This usually helps to give some secs for the server to respond and
reduce false positives if any.

On the same note, I would suggest using *zkServer.sh status *command and
grep the mode to see in which mode an instance is running. In the cluster,
the zookeeper runs in either leader or a follower. So this enhances the
healthcheck and guarantees that the zookeeper cluster is running as well as
it is in a quorum (which I believe is a good thing :) )


On Thu, Oct 29, 2020 at 9:25 AM Patrick Hunt <[email protected]> wrote:

> I believe it depends which version of netcat you're using, see the
> following for background:
> https://issues.apache.org/jira/browse/ZOOKEEPER-737
>
> Regards,
>
> Patrick
>
> On Thu, Oct 29, 2020 at 6:18 AM Debraj Manna <[email protected]>
> wrote:
>
> > Anyone any thoughts on this one? Same has been asked in stackoverflow
> also
> >
> >
> >
> https://stackoverflow.com/questions/64587307/correct-way-to-check-zookeepers-running-mode
> >
> > On Wed, Oct 28, 2020 at 9:37 PM Debraj Manna <[email protected]>
> > wrote:
> >
> > > Hi
> > >
> > > Can someone let me know what is the recommended way to check if
> zookeeper
> > > is running via netcat?
> > >
> > > The documentation
> > > <https://zookeeper.apache.org/doc/r3.5.2-alpha/zookeeperAdmin.html>
> > > states echo "isro" | nc localhost 2181 .
> > >
> > > But in few places it is recommended to use -q with netcat
> > >
> > > https://stackoverflow.com/a/28424409/785523
> > >
> > > Can someone let me know if -q is needed ?
> > >
> > >
> > >    - Zookeeper Version 3.4.13
> > >    - OS - Ubuntu 18
> > >
> > >
> >
>

Reply via email to