from __future__ import absolute_import import os import sys import json import csv import cherrypy import shutil import splunk import splunk.auth as auth import splunk.appserver.mrsparkle.controllers as controllers import splunk.appserver.mrsparkle.lib.util as util import splunk.bundle as bundle from splunk.models.saved_search import SavedSearch import splunk.util import splunk.saved import splunk.search from splunk.appserver.mrsparkle.lib.decorators import expose_page from splunk.appserver.mrsparkle.lib.routes import route from splunk.appserver.mrsparkle.lib import jsonresponse import six dir = os.path.join(util.get_apps_dir(), __file__.split('.')[-2], 'bin') if not dir in sys.path: sys.path.append(dir) from sc_rest import setup_logging logger = setup_logging('unixsetup') from unix.models.app import App from unix.models.macro import Macro from unix.models.unix_setup import UnixConfigured APP_NAME = 'DA-ITSI-CP-unix-dashboards' ## the macros to be displayed by the setup page MACROS = [ 'os_index', 'cpu_sourcetype', 'df_sourcetype', 'hardware_sourcetype', 'interfaces_sourcetype', 'iostat_sourcetype', 'lastlog_sourcetype', 'lsof_sourcetype', 'memory_sourcetype', 'netstat_sourcetype', 'open_ports_sourcetype', 'package_sourcetype', 'protocol_sourcetype', 'ps_sourcetype', 'rlog_sourcetype', 'syslog_sourcetype', 'time_sourcetype', 'top_sourcetype', 'users_with_login_privs_sourcetype', 'who_sourcetype' ] '''Unix Setup Controller''' class UnixSetup(controllers.BaseController): def parse_dynamic(self, tokenized_string): try: seq = tokenized_string.split(' OR ') # convert to set to deduplicate set_seq = set(seq) # convert back to list to sort tokenlist = list(set_seq) tokenlist.sort() except Exception as ex: tokenlist = [] return tokenlist def render_json(self, response_data, set_mime="text/json"): cherrypy.response.headers["Content-Type"] = set_mime if isinstance(response_data, jsonresponse.JsonResponse): response = response_data.toJson().replace("