Skip to content

Commit

Permalink
Disable thrift module logging (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
Teddy Reed authored May 29, 2017
1 parent d872596 commit bbb3263
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion osquery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

__title__ = "osquery"
__version__ = "2.2.0"
__version__ = "2.2.1"
__author__ = "osquery developers"
__license__ = "BSD"
__copyright__ = "Copyright 2015 Facebook"
Expand Down
24 changes: 12 additions & 12 deletions osquery/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from __future__ import unicode_literals

import argparse
import logging
import os
import shutil
import socket
Expand Down Expand Up @@ -54,17 +55,15 @@ def __init__(self, path=None):
else:
self.path = path
self._socket = tempfile.mkstemp(prefix="pyosqsock")
self._pidfile = tempfile.mkstemp(prefix="pyosqpid")
with open(self._pidfile[1], "w") as fh:
fh.write("100000")
self._dbpath = tempfile.mkdtemp(prefix="pyoqsdb")

# Disable logging for the thrift module (can be loud).
logging.getLogger('thrift').addHandler(logging.NullHandler())

def __del__(self):
if self.connection is not None:
self.connection.close()
if self.instance is not None:
self.instance.kill()
shutil.rmtree(self._dbpath)
self.instance.wait()

def open(self, timeout=2, interval=0.01):
Expand All @@ -79,13 +78,10 @@ def open(self, timeout=2, interval=0.01):
self.path,
"--extensions_socket",
self._socket[1],
"--database_path",
# This is a temporary directory, there is not FD tuple.
self._dbpath,
"--pidfile",
self._pidfile[1],
"--disable_database",
"--disable_watchdog",
"--disable_logging",
"--ephemeral",
"--config_path",
"/dev/null",
]
Expand Down Expand Up @@ -133,12 +129,12 @@ def parse_cli_params():
parser.add_argument(
"--timeout",
type=int,
default=0,
default=1,
help="Seconds to wait for autoloaded extensions")
parser.add_argument(
"--interval",
type=int,
default=0,
default=1,
help="Seconds delay between connectivity checks")
parser.add_argument(
"--verbose",
Expand Down Expand Up @@ -171,6 +167,10 @@ def start_extension(name="<unknown>", version="0.0.0", sdk_version="1.8.0",
min_sdk_version -- the minimum version of the osquery SDK that you can use
"""
args = parse_cli_params()

# Disable logging for the thrift module (can be loud).
logging.getLogger('thrift').addHandler(logging.NullHandler())

client = ExtensionClient(path=args.socket)
if not client.open(args.timeout):
return
Expand Down

0 comments on commit bbb3263

Please sign in to comment.