Merge "Fix Python plugins launching external processes"
This commit is contained in:
commit
a78779fb6b
|
@ -50,10 +50,6 @@ class ApacheCheckPlugin(base.Base):
|
|||
plugin = ApacheCheckPlugin(collectd)
|
||||
|
||||
|
||||
def init_callback():
|
||||
plugin.restore_sigchld()
|
||||
|
||||
|
||||
def config_callback(conf):
|
||||
plugin.config_callback(conf)
|
||||
|
||||
|
@ -61,6 +57,5 @@ def config_callback(conf):
|
|||
def read_callback():
|
||||
plugin.read_callback()
|
||||
|
||||
collectd.register_init(init_callback)
|
||||
collectd.register_config(config_callback)
|
||||
collectd.register_read(read_callback)
|
||||
|
|
|
@ -17,7 +17,6 @@ from functools import wraps
|
|||
import json
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
|
||||
|
@ -224,18 +223,16 @@ class Base(object):
|
|||
|
||||
@staticmethod
|
||||
def restore_sigchld():
|
||||
"""Restores the SIGCHLD handler for Python <= v2.6.
|
||||
"""Restores the SIGCHLD handler.
|
||||
|
||||
This should be provided to collectd as the init callback by plugins
|
||||
that execute external programs.
|
||||
that execute external programs and want to check the return code.
|
||||
|
||||
Note that it will BREAK the exec plugin!!!
|
||||
|
||||
See https://github.com/deniszh/collectd-iostat-python/issues/2 for
|
||||
details.
|
||||
See contrib/python/getsigchld.py in the collectd project for details.
|
||||
"""
|
||||
if sys.version_info[0] == 2 and sys.version_info[1] <= 6:
|
||||
signal.signal(signal.SIGCHLD, signal.SIG_DFL)
|
||||
signal.signal(signal.SIGCHLD, signal.SIG_DFL)
|
||||
|
||||
def notification_callback(self, notification):
|
||||
if not self.depends_on_resource:
|
||||
|
|
|
@ -49,10 +49,6 @@ class LibvirtCheckPlugin(base.Base):
|
|||
plugin = LibvirtCheckPlugin(collectd)
|
||||
|
||||
|
||||
def init_callback():
|
||||
plugin.restore_sigchld()
|
||||
|
||||
|
||||
def config_callback(conf):
|
||||
plugin.config_callback(conf)
|
||||
|
||||
|
@ -60,6 +56,5 @@ def config_callback(conf):
|
|||
def read_callback():
|
||||
plugin.read_callback()
|
||||
|
||||
collectd.register_init(init_callback)
|
||||
collectd.register_config(config_callback)
|
||||
collectd.register_read(read_callback)
|
||||
|
|
|
@ -60,10 +60,6 @@ class MemcachedCheckPlugin(base.Base):
|
|||
plugin = MemcachedCheckPlugin(collectd)
|
||||
|
||||
|
||||
def init_callback():
|
||||
plugin.restore_sigchld()
|
||||
|
||||
|
||||
def config_callback(conf):
|
||||
plugin.config_callback(conf)
|
||||
|
||||
|
@ -71,6 +67,5 @@ def config_callback(conf):
|
|||
def read_callback():
|
||||
plugin.read_callback()
|
||||
|
||||
collectd.register_init(init_callback)
|
||||
collectd.register_config(config_callback)
|
||||
collectd.register_read(read_callback)
|
||||
|
|
|
@ -103,10 +103,6 @@ class MySQLCheckPlugin(base.Base):
|
|||
plugin = MySQLCheckPlugin(collectd)
|
||||
|
||||
|
||||
def init_callback():
|
||||
plugin.restore_sigchld()
|
||||
|
||||
|
||||
def config_callback(conf):
|
||||
plugin.config_callback(conf)
|
||||
|
||||
|
@ -114,6 +110,5 @@ def config_callback(conf):
|
|||
def read_callback():
|
||||
plugin.read_callback()
|
||||
|
||||
collectd.register_init(init_callback)
|
||||
collectd.register_config(config_callback)
|
||||
collectd.register_read(read_callback)
|
||||
|
|
|
@ -92,10 +92,6 @@ class ElasticsearchClusterHealthPlugin(base.Base):
|
|||
plugin = ElasticsearchClusterHealthPlugin(collectd, 'elasticsearch')
|
||||
|
||||
|
||||
def init_callback():
|
||||
plugin.restore_sigchld()
|
||||
|
||||
|
||||
def config_callback(conf):
|
||||
plugin.config_callback(conf)
|
||||
|
||||
|
@ -103,6 +99,5 @@ def config_callback(conf):
|
|||
def read_callback():
|
||||
plugin.read_callback()
|
||||
|
||||
collectd.register_init(init_callback)
|
||||
collectd.register_config(config_callback)
|
||||
collectd.register_read(read_callback)
|
||||
|
|
|
@ -307,10 +307,6 @@ class HAProxyPlugin(base.Base):
|
|||
plugin = HAProxyPlugin(collectd)
|
||||
|
||||
|
||||
def init_callback():
|
||||
plugin.restore_sigchld()
|
||||
|
||||
|
||||
def config_callback(conf):
|
||||
plugin.config_callback(conf)
|
||||
|
||||
|
@ -318,6 +314,5 @@ def config_callback(conf):
|
|||
def read_callback():
|
||||
plugin.read_callback()
|
||||
|
||||
collectd.register_init(init_callback)
|
||||
collectd.register_config(config_callback)
|
||||
collectd.register_read(read_callback)
|
||||
|
|
|
@ -129,10 +129,6 @@ class InfluxDBClusterPlugin(base.Base):
|
|||
plugin = InfluxDBClusterPlugin(collectd)
|
||||
|
||||
|
||||
def init_callback():
|
||||
plugin.restore_sigchld()
|
||||
|
||||
|
||||
def config_callback(conf):
|
||||
plugin.config_callback(conf)
|
||||
|
||||
|
@ -140,6 +136,5 @@ def config_callback(conf):
|
|||
def read_callback():
|
||||
plugin.read_callback()
|
||||
|
||||
collectd.register_init(init_callback)
|
||||
collectd.register_config(config_callback)
|
||||
collectd.register_read(read_callback)
|
||||
|
|
Loading…
Reference in New Issue