예제 #1
0
def main():
    config = get_config()
    service = SystemService(config)

    system_disable = config.config["drakmon"].get("system_disable", "1")

    if system_disable == "1":
        service.log.info("Refusing to start, system_disable=1 is set in config.ini")
        return

    bucket_name = config.minio_config["bucket"]

    service.log.info("Verifying bucket existence...")
    minio = get_minio_helper(config)
    if not minio.bucket_exists(bucket_name):
        service.log.info("Bucket %s is missing. Creating new one...", bucket_name)
        minio.make_bucket(bucket_name)

    service.loop()
예제 #2
0
def main():
    conf = get_config()
    processor = AnalysisProcessor(conf, REGISTERED_PLUGINS)
    processor.loop()
예제 #3
0
import pathlib
from tempfile import NamedTemporaryFile
from zipfile import ZipFile, ZIP_DEFLATED

from flask import Flask, jsonify, request, send_file, send_from_directory, abort
from karton.core import Producer, Task, Resource
from karton.core.task import TaskState
from minio.error import NoSuchKey

from drakcore.system import SystemService
from drakcore.util import get_config
from drakcore.analysis import AnalysisProxy
from drakcore.database import Database

app = Flask(__name__, static_folder="frontend/build/static")
conf = get_config()

backend = SystemService(conf).backend
minio = backend.minio
db = Database(
    conf.config["drakmon"].get("database",
                               "sqlite:///var/lib/drakcore/drakcore.db"),
    pathlib.Path(__file__).parent / "migrations",
)


@app.before_first_request
def update_metadata_cache():
    """ Scans whole MinIO bucket and fetch missing metadata files """
    for analysis in AnalysisProxy(minio, None).enumerate():
        try: