Git Product home page Git Product logo

monitor-agent's Introduction

Hi there

I'm Pablo GonzÑlez, a spanish Computer Engineer passionate about backend development in Python. 🐍

As a developer, I specialize in OOP with Python, system architecture, developing API-First systems, and leading backend projects from start to finish. πŸ’»πŸš€

My experience includes the design, implementation and deployment of web applications and microservices, database management, and server administration. I am very committed to improving code quality, efficiency and maintainability. πŸŒπŸ”


πŸ“ž You can reach me in:

🌐 Website | πŸ”— LinkedIn | πŸ“‹ Resume | πŸ“š Manual of Me | βœ‰οΈ Email Me | πŸ“· Flickr

monitor-agent's People

Contributors

dependabot[bot] avatar n0nuser avatar

Stargazers

 avatar

Watchers

 avatar

monitor-agent's Issues

Authentication

Is your feature request related to a problem? Please describe.
Being able to execute commands with an endpoint and without authentication makes the agent a vulnerability in itself.

Describe the solution you'd like
Implement auth, at least with the token provided in the config file. Use user token, or agent token.

Add command execution support

Describe the solution you'd like
Receive POST with command as string and return a JSON with keys: stdout, stderr and elapsed time.

Improve Logging

Is your feature request related to a problem? Please describe.
Logging is managed with Open() instead with Logging module.

Describe the solution you'd like
Change logging to Logging module.

Modify settings file

Split config file in sections.

{
    "uvicorn": {
        "host":"0.0.0.0",
        "port":8000,
        "workers":4,
        "reload":true,
        "debug":true,
        "log_level":"trace",
        "ssl_keyfile":null,
        "ssl_keyfile_password":null,
        "ssl_certfile":"None",
        "ssl_version":3,
        "ssl_cert_reqs":null,
        "ssl_ca_certs":null,
        "ssl_ciphers":"TLSv1",
        "limit_concurrency":null,
        "limit_max_requests":null,
        "backlog":2048,
        "timeout_keep_alive":5
    },
    "metrics": {
        "endpoint":true,
        "url":"http://httpbin.org/post",
        "post_interval":60,
        "enable_file":false,
        "metrics_file":"metrics.json"
    },
    "alerts":{
        "url":""
    }
}

Document & Optimize

Describe the solution you'd like
Document with Google Style the code when the agent is done, so it's done when finishing the Final Degree Project to directly create an HTML with Sphinx.

Optimize and refactor the code

Usage of template for Metrics

Describe the solution you'd like
User may don't want all of the data from the host. Use templates to select which data is required to be processed.

Send JSON with breaklines

Is your feature request related to a problem? Please describe.
When receiving the JSON, the message doesn't have any breaklines and makes it illegible.

Describe the solution you'd like
Replace \n with some characters and replace it again for a
in the Web app.

Format of Data in Metrics

Is your feature request related to a problem? Please describe.
Numeric metrics like space (bytes, ...) and time are strings but will cause problem in the server in terms of:

  • Storage due to encoding
  • Unformatting of every metric of every host in each petition.

Describe the solution you'd like
Not format the metrics and leave that load to the web client.

Command Execution blocks requests

Describe the bug
Executing an interactive command blocks incoming requests until it finishes.

To Reproduce
Steps to reproduce the behavior:

  1. POST: localhost:8000/command?command=python -m http.server 8080&timeout=60
  2. POST: localhost:8000/command?command=dir&timeout=5

Expected behavior
First POST launch and be in background or at least not blocking second POST.

Desktop (please complete the following information):

  • OS: Windows
  • Version 1.0.0

Additional context
Check Subprocess calls

Web Server logs?

Is your feature request related to a problem? Please describe.
Does Uvicorn logs into a file?

Describe the solution you'd like
If not, use Gunicorn and use it's logging mechanism.

Implement Alert Manager

Describe the solution you'd like
Implement an Alert Manager in each Agent to trigger when a specified value surpass the value set in a JSON config file.
This Alert Manager may send the request with a POST or a Webhook.

Additional context
Implemented in the Agent to remove the load from the REST API server (many values for many hosts to check, may need to be implemented with Celery but this is more flexible and lightweight).

Note: This doesn't remove the need of an alert system in the REST API server for when a hosts is down.

Merge FastAPI with TimeLoop

Is your feature request related to a problem? Please describe.
Agent needs to listen for POST data (command or new settings) but as of now it's not possible because of the execution flow.

Describe the solution you'd like

  • Launch 2 threads and set Timeloop and FastAPI in each of them.
  • Launch Timeloop from FastAPI.

Add ability to receive settings via POST

Is your feature request related to a problem? Please describe.
It improves flexibility in the Agent execution flow because it allows not to interrupt the program manually and launch it again.

Describe the solution you'd like
Receive settings as JSON. Replace Pydantic for a new designed class.
When new settings are received, refresh the server with the new settings. Authenticate with the agent with a token, else return auth error.

JSON Settings

Describe the bug
Agent does not test type and data of the parameters from the settings file.

To Reproduce
I can POST this invalid JSON config without any error showing up:

{
    "alert_url": "",
    "backlog": 2048,
    "debug": "a",
    "host": "300",
    "limit_concurrency": "None",
    "limit_max_requests": null,
    "log_level": "trace",
    "metric_enable_file": false,
    "metric_endpoint": true,
    "metric_file": "metrics.json",
    "port": 8000,
    "post_interval": "a",
    "post_metric_url": "http://httpbin.org/post",
    "reload": true,
    "ssl_ca_certs": null,
    "ssl_cert_reqs": null,
    "ssl_certfile": null,
    "ssl_ciphers": "TLSv1",
    "ssl_keyfile": null,
    "ssl_keyfile_password": null,
    "ssl_version": 3,
    "timeout_keep_alive": 5,
    "workers": 4
}

Expected behavior
It should return an error for each of the invalid parameters.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.