[
https://issues.apache.org/jira/browse/HCATALOG-389?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13266758#comment-13266758
]
Travis Crawford commented on HCATALOG-389:
------------------------------------------
In general this looks good! A few comments/suggestions:
OPTION PARSING:
Depending on the target python version, perhaps use a more powerful option
paring library? Then you don't need to keep the help in sync like "print_usage"
does; and I find them easier to work with / easier to read.
http://docs.python.org/library/optparse.html#module-optparse
http://docs.python.org/library/argparse.html#module-argparse
LOGGING:
Perhaps use a file logger, and have a flag to enable stdout logging too? I find
this very useful because if someone puts this in cron you'd want a record of
past invocations to see when it started failing. When run with Nagios it could
log to stdout. It might look something like:
{code}
logger = logging.getLogger()
if options.verbose:
logger.setLevel(logging.DEBUG)
else:
logger.setLevel(logging.INFO)
formatter = logging.Formatter("%(asctime)s %(filename)s:%(lineno)d -
%(message)s")
if options.log_file:
file_handler = logging.handlers.RotatingFileHandler(options.log_file,
maxBytes=10*1024*1024, backupCount=3)
file_handler.setFormatter(formatter)
logger.addHandler(file_handler)
else:
stream_handler = logging.StreamHandler()
stream_handler.setFormatter(formatter)
logger.addHandler(stream_handler)
{code}
Then "verbose_log" is not needed. Just logger.verbose or logger.info
ERROR MESSAGES:
Currently the check is a big list of booleans and if any fail it says there's
an error. Perhaps have a list of checks and keep track of which ones failed,
then print that out at the end? That would provide more actionable info.
> hcat_ping (script to check if HCatalog server is running/reachable)
> -------------------------------------------------------------------
>
> Key: HCATALOG-389
> URL: https://issues.apache.org/jira/browse/HCATALOG-389
> Project: HCatalog
> Issue Type: New Feature
> Components: client
> Affects Versions: 0.4.1
> Reporter: Mithun Radhakrishnan
> Assignee: Mithun Radhakrishnan
> Priority: Minor
> Fix For: 0.5
>
> Attachments: HCATALOG-389.patch
>
>
> It would be nice to have a script that checks if hcat_server is running,
> whether it's reachable and if it's "healthy". The current definition of
> "healthy" implies:
> 1. HCatalog responds to requests to list tables/databases.
> 2. Tables can be created/dropped in HCatalog.
> 3. When managed tables are used, table-directories are created/deleted on the
> DFS.
> 4. (Future:) ActiveMQ events are being posted correctly, when
> tables/partitions are created/dropped.
> Monitoring apps might use this script to detect when HCatalog is down.
> I'll post a trivial script that does 1-3, shortly.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira