mirror of
https://github.com/valitydev/yandex-tank.git
synced 2024-11-06 02:15:22 +00:00
expvar enable/disable
This commit is contained in:
parent
4293e79d2c
commit
47e6a36e3d
@ -694,6 +694,9 @@ Disable phantom first (unless you really want to keep it active alongside at you
|
||||
; Pandora executable path
|
||||
pandora_cmd=/usr/bin/pandora
|
||||
|
||||
; Enable/disable expvar monitoring
|
||||
expvar = 1 ; default
|
||||
|
||||
; Pandora config contents (json)
|
||||
config_content = {
|
||||
"pools": [
|
||||
|
@ -30,6 +30,7 @@ class Plugin(AbstractPlugin, GeneratorPlugin):
|
||||
self.process_start_time = None
|
||||
self.custom_config = False
|
||||
self.sample_log = "./phout.log"
|
||||
self.expvar = True
|
||||
|
||||
@staticmethod
|
||||
def get_key():
|
||||
@ -39,10 +40,12 @@ class Plugin(AbstractPlugin, GeneratorPlugin):
|
||||
opts = [
|
||||
"pandora_cmd", "buffered_seconds",
|
||||
"config_content", "config_file",
|
||||
"expvar"
|
||||
]
|
||||
return opts
|
||||
|
||||
def configure(self):
|
||||
self.expvar = self.get_option("expvar", "1") == "1"
|
||||
self.pandora_cmd = self.get_option("pandora_cmd", "pandora")
|
||||
self.buffered_seconds = int(
|
||||
self.get_option("buffered_seconds", self.buffered_seconds))
|
||||
@ -82,7 +85,7 @@ class Plugin(AbstractPlugin, GeneratorPlugin):
|
||||
"Linking sample and stats readers to aggregator. Reading samples from %s",
|
||||
self.sample_log)
|
||||
aggregator.reader = PhantomReader(self.sample_log)
|
||||
aggregator.stats_reader = PandoraStatsReader()
|
||||
aggregator.stats_reader = PandoraStatsReader(self.expvar)
|
||||
|
||||
try:
|
||||
console = self.core.get_plugin_of_type(ConsolePlugin)
|
||||
|
@ -7,12 +7,21 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class PandoraStatsReader(object):
|
||||
# TODO: maybe make stats collection asyncronous
|
||||
def __init__(self):
|
||||
def __init__(self, expvar):
|
||||
self.closed = False
|
||||
self.expvar = expvar
|
||||
|
||||
def next(self):
|
||||
if self.closed:
|
||||
raise StopIteration()
|
||||
if not self.expvar:
|
||||
return [{
|
||||
'ts': int(time.time() - 1),
|
||||
'metrics': {
|
||||
'instances': 0,
|
||||
'reqps': 0
|
||||
}
|
||||
}]
|
||||
try:
|
||||
pandora_response = requests.get("http://localhost:1234/debug/vars")
|
||||
pandora_stat = pandora_response.json()
|
||||
|
Loading…
Reference in New Issue
Block a user