def main():
    csv_path = "data/example_nodes.csv"
    tool_bag = Tools()

    # Set keys = None if you're not using IN in your query
    # Otherwise, provide csv file with node names at given index
    keys = tool_bag.csv_pull_key(csv_path, 0)

    # Put your query here
    query_str = """SELECT TOP 10 NodeName, NodeID, Uri
                   FROM Orion.Nodes
                   WHERE NodeName IN %s"""
    # Put your suppression dates here
    suppress_start = '04/28/2019 08:00 AM'
    suppress_end = '04/28/2019 08:01 AM'

    #updated_props = {'City': None}

    # Authentication
    username = input("Username: "******"Password: "******"solarwinds.server"
    sw = SolarWindsInterface(username, password, server)

    # Send your query.
    sw.query(query_str, nodes=keys)
    # Suppress alerts
    sw.suppress_alerts(suppress_start, suppress_end)

    print("Exit status complete")
Exemple #2
0
def ping_status(message, host):
    input_str = '{}'.format(host)
    if input_str is not None:
        target = Tools()
        nw_status = target.exec_ping(str(input_str))
        message.reply('{host} {reco}'.format(host=input_str, reco=nw_status))
    else:
        message.reply('Please set target!')
Exemple #3
0
def managed_roles(end_point, chef):
    """Pull down list of specified roles for use with loader"""
    tool_bag = Tools()
    save_path = "data/managed_roles.csv"
    patching_role = []
    empty_role = []
    response = chef.chef_get(end_point)
    for k in response.keys():
        run_list = (chef.chef_get(end_point, node=k))['run_list']
        run_list = [cleaner(item) for item in run_list]
        if 'chef-client' in run_list:
            patching_role.append(k)
    print(patching_role)
    print(empty_role)

    tool_bag.text_writer(save_path, patching_role)
Exemple #4
0
def main():
    """Runs the loader"""
    # Set paths
    auth_path = "data/sw_access.txt"

    # Define tools
    tool_bag = Tools()

    # Initialize SolarWinds and Chef objects
    sw = SolarWindsInterface(auth_path)
    chef = ChefAPI()

    # Set query string
    query_str = """SELECT n.NodeName, n.NodeID, n.Uri, n.Agent.AgentID
                   FROM Orion.Nodes n
                   WHERE n.Agent.AgentID is not null"""

    query_results = sw.query(query_str)
    nodes = query_results['results']

    loader_menu(chef, sw, tool_bag, nodes)

    print("Exit")
Exemple #5
0
 def __init__(self, printer):
     """
     On initialisation of the Classify class we get the handle of the printer class from the instantiating function
     and store it, then we make the categories bare bone, which is a RanDep skeleton
     :param printer: the handle of the Printer class
     """
     self.printer = printer
     self.tools = Tools()
     self.categories = {
         "stealth": {
             "fingerprinting": {},
             "propagating": {},
             "communicating": {},
             "mapping": {}
         },
         "suspicious": {
             "encrypting": {},
             "locking": {}
         },
         "termination": {
             "deleting": {},
             "threatening": {}
         }
     }
def main():
    """Demonstrates different methods available within the Chef Interface"""
    chef = ChefAPI()
    chef.auth()
    tool_bag = Tools()

    index = 'node'
    query = 'name:node'
    header = {}

    nodes = tool_bag.csv_pull_key('data/example_nodes.csv', 0)

    response = json.loads(chef.chef_search())
    response = json.loads(chef.chef_search(index=index))
    response = json.loads(chef.chef_search(index=index, query=query))
    response = json.loads(
        chef.chef_search(index=index, query=query, header=header))

    response = chef.chef_get('/nodes/tst2asvcnow')
    response = json.loads(chef.chef_get('/nodes/', 'tst2asvcnow'))
    print(response['chef_environment'])

    with open('chef_search.json', 'w') as file:
        json.dump(response, file, indent=4)
Exemple #7
0
sys.path.append(os.path.join(os.path.dirname(__file__)))
#pwd = os.path.dirname(__file__)
'''
added head source directory in path for import from any location and relative testing and pwd for open() relative files
'''
from tools.tools import Tools
import boto3

if __name__ == '__main__':

    # you must provide your credentials in the recomanded way, here we are
    # passing it by ENV variables
    s3 = boto3.client('s3')

    #initialize the tools class
    tools = Tools(s3)

    # checking for established connections between E-L-K
    tools.check_elk_connection()

    # function to index the default template mapping of the data
    tools.index_template()

    # getting the required buckets names to index from get_s3_bucket_dir_to_index()
    s3_dir_to_index = tools.get_s3_bucket_dir_to_index()
    if s3_dir_to_index == 1:
        print 'I could not find any billing report under Bucket ', os.environ[
            'S3_BUCKET_NAME'], ' under Path ', os.environ['S3_REPORT_PATH']
        sys.exit(1)

    # downloading the csv file with get_req_csv_from_s3() and then calling the index_csv() to index it in our elasticsearch
from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
from functools import partial
from tools.tools import Tools

MYNONE = ""
to = Tools()


class CalculatorWindow(GridLayout):
    def __init__(self, **kwargs):
        super(CalculatorWindow, self).__init__(**kwargs)
        self.cols = 6
        self.rows = 6
        """
            ERSTE ZEILE
        """
        self.add_widget(Label(text=MYNONE))
        self.add_widget(Label(text="Result"))

        self.result_tf = TextInput(password=False, multiline=False)

        # result textfield
        self.add_widget(self.result_tf)
        self.add_widget(Label(text=MYNONE))
        self.add_widget(Label(text=MYNONE))
        self.add_widget(Label(text=MYNONE))
        """
Exemple #9
0
 def __init__(self):
     self.check_tools = Tools()
Exemple #10
0
sys.path.append(os.path.join(os.path.dirname(__file__)))
#pwd = os.path.dirname(__file__)
'''
added head source directory in path for import from any location and relative testing and pwd for open() relative files
'''
from tools.tools import Tools
import boto3
import subprocess
import time

if __name__ == '__main__':

    print('Orchestrate-test Running')
    #initialize the tools class
    tools = Tools()

    # checking for established connections between E-L-K
    tools.check_elk_connection()

    # function to index the default template mapping of the data
    tools.index_template()

    # index a sample test file with sum of unblended cost 1.24185686
    tools.index_csv('test/sample/test_ub_cost_2016-06.csv',
                    '20160601-20160701')
    # rows of data in the csv, must be given as string
    data_count = '315'
    while (True):
        index_names = subprocess.check_output(
            ['curl -XGET "elasticsearch:9200/_cat/indices/"'],
Exemple #11
0
NAME = args.g
PATH = args.file

HOUR = args.hour
MINUTE = args.minute
FLAG = args.flag
te = args.text

arg = Analy(NAME, PATH, te, HOUR, MINUTE).parser()
arg['text'] = None if 'text' not in arg else arg['text']
text = arg['text'] if arg['text'] else arg['pathText']  # 读取函数的text和从文件获得的pathText
hour = arg['hour']  # 读取hour
minute = arg['minute']  # 读取minute

# ===========================================================


itchat.auto_login(hotReload=True)
print('=======登录成功========')
fun = Tools(NAME, text, hour, minute)

# ===========================================================


if FLAG == 1:
    fun.send_msg()  # 直接发送消息函数
else:
    fun.timing()

# ======================YM=20201.31=============================
Exemple #12
0
 def __init__(self, printer):
     self.printer = printer
     self.tools = Tools()
     self.process_list = []
Exemple #13
0
def help_cmd(message):
    target = Tools()
    yaml_file = target.get_yaml("/root/slackbot/plugins/tools/help.yml")
    for k, v in yaml_file.items():
        message.reply('> {key} => {value}'.format(key=k, value=v))
Exemple #14
0
 def __init__(self):
     self.tools = Tools()