コード例 #1
0
ファイル: ext_cscan.py プロジェクト: sakom117/politraf
 def __init__(self, url, name, password):
     # Init clickhouse
     try:
         self.db = dbmodels.Database('politraf',
                                     db_url=url,
                                     username=name,
                                     password=passw,
                                     readonly=False,
                                     autocreate=True)
         self.db.drop_table(dbmodels.OPEN_PORTS)
         self.db.create_table(dbmodels.OPEN_PORTS)
     except Exception as e:
         logging.error(e)
コード例 #2
0
ファイル: iocwatch.py プロジェクト: sakom117/politraf
    try:
        config = (yaml.safe_load(stream))
        time_zone = config['time_zone']
        tz = timezone(time_zone)
        url = config['db_url']
        name = config['username']
        passw = config['password']
    except yaml.YAMLError as e:
        logging.error(e)
    logging.info("Config is OK")

# Init clickhouse
try:
    db = dbmodels.Database('politraf',
                           db_url=url,
                           username=name,
                           password=passw,
                           readonly=False,
                           autocreate=True)
except Exception as e:
    logging.error(e)

# 5 min time
to_time = datetime.datetime.now(tz)
from_time = (datetime.datetime.now(tz) -
             datetime.timedelta(minutes=2)).replace(microsecond=0)
from_time_epoch = str(from_time.timestamp())
today = datetime.datetime.strftime(datetime.datetime.now(tz), '%Y-%m-%d')


def get_traf_last():
    try:
コード例 #3
0
ファイル: install.py プロジェクト: sakom117/politraf
    shutil.copy2('src/ext_cscan.py', '/opt/politraf/ext_cscan.py')
    shutil.copy2('src/iocwatch.py', '/opt/politraf/iocwatch.py')
    shutil.copy2('dbmodels.py', '/opt/politraf/dbmodels.py')
    #os.chmod("src/systat.py", stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
    #os.chmod("src/otxget.py", stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
    #os.chmod("src/constat.py", stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
    #os.chmod("src/dbmodels.py", stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
    print(green + 'Done' + greene)
except Exception as e:
    print(orange, e, orangee)
try:
    print(green + 'Wait for clickhouse init and create database with tables' +
          greene)
    time.sleep(10)
    # Create tables
    db = dbmodels.Database('politraf',
                           db_url="http://127.0.0.1:8123/",
                           username="******",
                           password="",
                           readonly=False,
                           autocreate=True)
    db.create_table(dbmodels.CONNStats)
    db.create_table(dbmodels.CPUStats)
    db.create_table(dbmodels.MEMStats)
    db.create_table(dbmodels.DISKStats)
    db.create_table(dbmodels.IOCStats)
    db.create_table(dbmodels.OPEN_PORTS)
    print(green + 'Done' + greene)
except Exception as e:
    print(orange, e, orangee)