Computer Science Final Degree Project @ USAL - Host to monitor
First, download the repository into your Home folder or the directory you prefer:
git clone https://github.com/n0nuser/monitor-agent
Install the Python dependencies:
sudo pip3 install -r requirements.txt
Then, create a Systemd service in /etc/systemd/system/
called agent.service
.
sudo nano /etc/systemd/system/agent.service
:
[Unit]
Description=RESTful web to track agents
After=network.target network-online.target
Requires=network-online.target
[Service]
RemainAfterExit=true
Restart=on-failure
ExecStart=/usr/bin/python3 /home/MYUSER/monitor-agent/monitor_agent/main.py
[Install]
WantedBy=multi-user.target
Modify MYUSER
with your user, and DIRECTORY
with the path to the main.py
. In case you downloaded the repository in your Home folder you wouldn't need to change the directory in the service file.
Once the service is installed, you can enable it to run forever and start on startup:
sudo systemctl enable agent.service
sudo systemctl start agent.service
systemctl status agent.service
The user can configure the agent and server settings with the settings.json
file:
{
"alerts": {
"url": "http://localhost:8000/api/alerts/"
},
"auth": {
"agent_token": "fb79210dd15ea00aeeb4bb21f81b27421a4e11a7",
"name": "Laptop",
"user_token": "19fc6e57b8fb0e5a1a7b55976952ab02865aa771"
},
"endpoints": {
"agent_endpoint": "http://localhost:8000/api/agents/",
"metric_endpoint": "http://localhost:8000/api/metrics/"
},
"logging": {
"filename": "monitor.log",
"level": "info"
},
"metrics": {
"enable_logfile": false,
"get_endpoint": false,
"log_filename": "metrics.json",
"post_interval": 60
},
"thresholds": {
"cpu_percent": 50,
"ram_percent": 30
},
"uvicorn": {
"backlog": 2048,
"debug": false,
"host": "0.0.0.0",
"log_level": "trace",
"port": 8080,
"reload": true,
"timeout_keep_alive": 5,
"workers": 4
}
}
It's best to use the configurator from the Monitor Web App as it automatically generates it with the approppiate configuration. You can always update the configuration with a form in the Web App.
Once configured, restart the service:
sudo systemctl restart agent.service
Check the Roadmap here.
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the GPL-3.0 License. See LICENSE.txt
for more information.
Pablo González Rubio - @n0nuser_ - [email protected]
Project Link: https://github.com/n0nuser/Monitor-Agent