Beispiel #1
0
def main():
    shippers = {}
    finished = {}
    total_finished = 0
    total_ctrs = 0
    ctrs = utils.get_containers()

    # repeats = get_repeat_ips(ctrs)
    # pdb.set_trace()
    # print(f"Repeats {repeats}")

    for shipper in SHIPPERS:
        finished[shipper] = get_finished_ctrs(shipper)
        shipper_ctrs = get_shipper_ctrs(shipper)
        shippers[shipper] = shipper_ctrs
        total_finished += len(finished[shipper])
        total_ctrs += len(shipper_ctrs)
        print(
            f"  {shipper} finished {len(finished[shipper])}/{len(shipper_ctrs)} containers."
        )
    placebos = get_finished_placebos(ctrs, finished)
    print(f"Finished {len(placebos)} placebos.")
    print(f"Finished {total_finished}/{total_ctrs} containers.")
    print(f"len(ctrs), total_ctrs {len(ctrs)} {total_ctrs}")
    write_finished_ctrs(finished)

    missing = get_missing_ctrs(ctrs, shippers)
    print(f"Missing {len(missing)} {missing}")
Beispiel #2
0
def get_ctrs():
    """ Returns valid containers sorted in ascending order by disk usage. """
    ctrs = get_ctrs_from_file(SORTED_CTRS_KEY)
    if len(ctrs) == 0:
        running_containers = utils.get_containers()  # get running containers
        cmd = get_sort_ctrs_cmd(CONFIG[RAW_DIR_KEY])
        res = utils.run_cmd(cmd, output=True)
        ctr_paths = res.strip().split("\n")
        ctrs = [ctr_path.split("/")[-1] for ctr_path in ctr_paths]
        ctrs = [ctr for ctr in ctrs if ctr in running_containers]
        write_ctrs_to_file(SORTED_CTRS_KEY, ctrs)
    return ctrs
def main(dst, last_ctr, transfer, until, scrub, gunzip):
    src_host = CONFIG_SRC["HOST"]
    dst_config = CONFIG_DST[dst]
    dst_host = dst_config["HOST"]
    dst_dir = dst_config["CTR_DIR"]
    ctrs = list(utils.get_containers().keys())
    if last_ctr is not None and last_ctr != -1:
        ctrs = ctrs[ctrs.index(last_ctr) + 1:]
    if until is not None:
        ctrs = ctrs[:ctrs.index(until) + 1]

    if transfer:
        rsync(src_host, dst_config, last_ctr, until, ctrs)

    if scrub:
        filebeat_scrub(dst_host)

    if gunzip:
        unzip(dst_config, last_ctr, scrub, ctrs)
Beispiel #4
0
def main():
    _cleanup()
    _setup()

    _deploy()

    for i in range(100):
        measure_response_time.measure_response_time(URL, "Baseline")
    _cleanup()

    _deploy()
    print("Redo baseline, but dont save to csv") # To establish some API use
    for i in range(100):
        measure_response_time.measure_response_time(URL, "Baseline", write=False)
    print("By CPU Usage")
    containers = utils.get_containers("flaskapp")
    c = utils.find_most_cpu(containers)
    print("Stopping container {}".format(c))
    utils.stop_container(c)
    for i in range(100):
        measure_response_time.measure_response_time(URL, "CPU Usage")
    _cleanup()
Beispiel #5
0
from pathlib import Path
import re
import pdb

from elasticsearch_dsl import Search, A
import pandas as pd
import numpy as np

import utils

# from utils
LOGGER = utils.get_logger("es_utils", "./es_utils.log")
CONFIG = utils.get_config()
SEP = CONFIG["IO"]["CSV_SEP"]
CHUNKSIZE = CONFIG["IO"]["CHUNK_SIZE"]
CTRS = utils.get_containers()
TIME_FMT = CONFIG["TIME"]["FMT"]

# constants
INDICES_IP_MAPPING = {
    "nginx-access-*": "nginx.access.remote_ip.keyword",
    "postfix-smtpd-*": "postfix_client_ip.keyword",
    "telnet-*": "telnet.ip.keyword",
    "ftp-*": "ftp.ip.keyword",
    # "nginx-access-*": "ip.keyword",
    # "postfix-*": "postfix_client_ip.keyword",
    # "telnet-*": "ip.keyword",
    # "ftp-*": "ip.keyword",
    # "ssh-*": "ssh.ip.keyword",
}
Beispiel #6
0
from pytesseract import image_to_string
## TODO: USER: Change this pathing to be universal among users. It might be helpful to look at tesseract-OCR's installation manual and how they suggest setting the path.
pytesseract.pytesseract.tesseract_cmd = 'C:{}\\AppData\\Local\\Tesseract-OCR\\tesseract.exe'.format(os.environ['HOMEPATH'])

## TODO: USER: Make some sort of GUI for the player to interact with where they can login and store their own profiles. For now we will just import a test player object to work with.
#For now we will incorporate a preliminary UI that will run in the terminal. This will be built in the Player class in profile.py. This will allow us to easily remove the UI later.
player = Player()

#Output current data for player for testing
#print(player.player_data[map_string].nodes(data=True))
#print(player.player_data[map_string].edges(data=True))
#player.visualize_data(map_string)

#Define some initial variables
#location, callout1, callout2, playerbox will contain coordinates needed to grab specific data from each screen
location, callout1, callout2, playerbox = get_containers(player.resolution, player.aspect_ratio)
#Path traveled will contain the path for any given round. This will be reinitialized every round.
path_traveled = []
map_string, affiliation = None, None

while True:
    #First we must get the frame from the game
    image = np.array(screen_capture(player.resolution))

    #Then we must find the indicators that tell us whether the player is alive. This information comes from an area we call the playerbox. The playerbox is the icon for the player found on the HUD. In this case we want to see if there is a white box surrounding this player icon. This tells us whether the player is still alive.
    crop_image_playerbox = image[playerbox[1]:playerbox[1]+playerbox[3], playerbox[0]:playerbox[0]+playerbox[2]]
    playerbox_indicators = [
        crop_image_playerbox[(crop_image_playerbox.shape[0]-1)][(crop_image_playerbox.shape[1]-1)],
        crop_image_playerbox[(crop_image_playerbox.shape[0]-1)][0],
        crop_image_playerbox[0][(crop_image_playerbox.shape[1]-1)],
        crop_image_playerbox[0][0]