handleEdit method: controls the parameters and saves the values corresponds to handleractions = edit in restmap.conf """ import json import splunk.clilib.cli_common as scc import splunk.admin as admin import tab_splunktalib.common.util as utils import tab_splunktalib.common.log as log from tab_splunktalib.conf_manager import ta_conf_manager as ta_conf from tab_splunktalib.conf_manager import conf_manager as conf import consts as c logger = log.Logs().get_logger("setup") class ConfigApp(admin.MConfigHandler): valid_args = ("all_settings", ) stanza_map = { c.global_settings: True, c.proxy_settings: True, c.myta_credential_settings: True, c.myta_customized_settings: True, } cred_fields = (c.password, ) encrypt_fields_credential = (c.password, ) encrypt_fields_customized = (c.password, )
import os.path as op import traceback from tab_splunktalib.common import log logger = log.Logs().get_logger("util") class FileMonitor(object): def __init__(self, callback, files): """ :files: files to be monidtored with full path """ self._callback = callback self._files = files self.file_mtimes = {file_name: None for file_name in self._files} for k in self.file_mtimes: try: self.file_mtimes[k] = op.getmtime(k) except OSError: logger.debug("Getmtime for %s, failed: %s", k, traceback.format_exc()) def check_changes(self): logger.debug("Checking files=%s", self._files) file_mtimes = self.file_mtimes changed_files = [] for f, last_mtime in file_mtimes.iteritems(): try:
import os import threading import time import traceback from tab_splunktalib.common import log logger = log.Logs().get_logger("ta_util") class OrphanProcessChecker(object): def __init__(self, callback=None): """ Only work for Linux platform. On Windows platform, is_orphan is always False """ if os.name == "nt": self._ppid = 0 else: self._ppid = os.getppid() self._callback = callback def is_orphan(self): if os.name == "nt": return False return self._ppid != os.getppid() def check_orphan(self): res = self.is_orphan() if res and self._callback: