Skip to content

jorgefuertes/bcf-monitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BCFMonitor

BlockchainFUE infraestructure monitor.

Intro

BCFMonitor is a simple service monitor that allows, without any complications, to have a simple email alert when one of the critical services is not responding.

It consists of an executable and a very straightforward configuration file in YAML format.

Installing it is as easy as copying both files to a server and starting the service, for example with a systemd unit, one is included as an example and a Makefile that allows you to install everything and start the service.

Principles

Check if you are looking for at least two of this principles before to use this software:

  • KISS: Keep it simple, stupid!
  • SRP: Single Responsibility Principle.
  • IHNT: I have no time!
  • FAIF: Free as in freedom.

Installation from binary

Download the latest release for your architecture

Just go to the releases page:

If you can't find your arquitecture, please, raise an issue.

Upload the executable to your server

tar xvzf bcf-monitor_linux-amd64_1.2.tar.gz
cd bcf-monitor_linux-amd64_1.2
scp bcf-monitor root@your.server.domain:/usr/local/bin/.

Rename example.yaml to bcf-monitor-prod.yaml

mv example.yaml bcf-monitor-prod.yaml

Edit the configuration and upload it

Edit the yaml and configure your runners, the smtp and the administrative contacts.

At this time we are only supporting the monitorization of

  • ping:
    • Using the system ping command. If we use ICMP then we need root privileges.
  • mongodb
  • redis
  • web applications:
    • GET request with or without aditional headers.
    • In addition it looks for a needle text in the html.

Upload to /etc:

scp bcf-monitor-prod.yml root@your.server.domain:/etc/.

Try it

/usr/local/bin/bcf-monitor -c /etc/bcf-monitor-prod.yaml

Service it

Now you can define a systemd unit, a daemontools svc or whatever you want to have it alwais running.

Example systemd unit

Create this file in /etc/systemd/system/.:

[Unit]
Description=BCF Monitor
After=network.target auditd.service

[Service]
Type=simple
ExecStart=/usr/local/bin/bcf-monitor -c /etc/bcf-monitor-prod.yaml
Restart=always
User=root
WorkingDirectory=/usr/local/bin

[Install]
WantedBy=multi-user.target
Alias=bcf-monitor.service

Load the unit and start the service:

systemctl daemon-reload
service bcf-monitor restart

Watch the log to see if all is working fine:

journalctl -efu bcf-monitor

Installation from source

Clone this repo and change dir

git clone git@github.com:jorgefuertes/bcf-monitor.git
cd bcf-monitor

Makefile

Create a .secrets file like this one:

SERVER=api.blockchainfue.com

Take a look into the make file if you need to modify something or add any other architecture.

Configure the monitor

Copy example.yaml

cp conf/example.yaml conf/prod.yaml

Edit prod.yaml and configure your runners, the smtp and the administrative contacts.

At this time we are only supporting the monitorization of mongodb, redis and web applications via GET request with or without aditional headers. In addition it looks for a needle text in the html.

Try it locally

You may need to raise some tunnels to be allowed to reach the remote services or you can replicate the services on your local machine.

Copy prod.yaml to dev.yaml and configure it properly. Remember to keep only you as admin in order to don't disturb anyone else.

make run

Publish to your server

By default we are building a binary to a GNU/Linux OS, with amd64 architecture. You'll need to adjust the Makefile if it doesn't suit your server, but it's pretty easy.

make publish

Improvements and issues

  • Pull requests are welcome.
  • New runners are welcome, always respecting the KISS principle, please.
  • Open an issue if you need help or you reach a bug.

ToDo

  • Alerting by telegram.
  • Simple authenticated webpage to watch the status in real time.
  • New runners:
    • MySQL.
    • Postgres.
    • Memcached.
    • Nginx.
    • SMTP, IMAP.
    • POST in addition to GET.
    • etc...

Feel you free to improve it and make a pull request.

Author

©2023 Jorge Fuertes Alfranca

License

This software is licensed under GNU GPL v3. You have a copy of this license in this repository, file: gpl-3.0.txt, or you can read it online here: