Exemple #1
0
#!/usr/bin/env python
#-*- coding:utf-8 -*-
# Author: Kun Huang <*****@*****.**>

import subprocess
from scalpels.db import api as db_api

data_dir = db_api.setup_config_get()["data_dir"].rstrip("/")
def run_agent(task_uuid, ag):
    """
    python <path-to-dir>/agent.py <uuid> mysql
    """
    cmd = "python %s/agent.py %s %s" % (data_dir, task_uuid, ag)
    ag = subprocess.Popen(cmd.split())
    return ag.pid

def _parse_traffic(out, name):
    """
    in:
        ts, 123.00 pkts  2312 bytes
        ...
        ...
    out:
        name: Port Traffic
        unit: pkts
        data: [(ts, 123.00), ...]

        name: Port Traffic
        unit: bytes
        data: [(ts, 2312.00), ...]
    """
Exemple #2
0
def read_from_ag(ag):
    # wrong impl. here, need read from config or db instead
    from scalpels.cli.actions.start import agents_map
    data_dir = db_api.setup_config_get()["data_dir"].rstrip("/")
    return agents_map.get(ag) % data_dir