Code Monkey home page Code Monkey logo

remotesysmonitor's Introduction

RemoteSysMonitor

Crates.io Version Crates.io Total Downloads Crates.io Codacy Badge test

This is a small command-line tool that runs some checks on remote servers and posts the results to a Slack channel.

Check the project's website for a full list of available checks and how to configure them.

TL:DR

Install

Make sure you have Rust and Cargo installed, if not follow the instructions here.

cargo install remotesysmonitor

Execute

Check the output of the remotesysmonitor --help command for a list of available options.

$ remotesysmonitor -h
Usage: remotesysmonitor [OPTIONS] <CONFIG>

Arguments:
  <CONFIG>

Options:
  -f, --full     Post a check to Slack even if there is no ❌ in the checks
  -p, --print    Print the output of the checks in stdout
  -h, --help     Print help
  -V, --version  Print version

You need to define SLACK_HOOK_URL as an environment variable with the URL of the Slack webhook you want to use and a path to the configuration file.

SLACK_HOOK_URL=<your-slack-hook-url> remotesysmonitor configuration.yaml

The configuration file should look like this:

servers:
  - name: name-of-your-server
    host: myserver.nl
    port: 22
    user: rodrigo
    private_key: /home/rodrigo/.ssh/id_ed25519
    checks:
      ping:
        url:
          - /
      load:
        interval: 15
      number_of_subfolders:
        path:
          - /path/full/of/subfolders
      custom_command:
        command: cd /some/path && ./some_script.sh
      list_old_directories:
        loc: /path/full/of/old/directories
        cutoff: 2 # days

  - name: raspberryPi
    host: ip.of.your.raspberry.pi
    port: 22
    user: rodrigo
    private_key: /home/rodrigo/.ssh/id_ed25519
    checks:
      temperature:
        sensor: /sys/bus/w1/devices/28-00000b694311/w1_slave

It might make sense to configure a cron job to run this command periodically.

# Run every 10 minutes, it will only post to Slack if one of the checks has ❌
*/10 * * * * SLACK_HOOK_URL=<your-slack-hook-url> remotesysmonitor configuration.yaml

# Post a full report to Slack at 8, 12, 16 and 20 hours
## Running with -f will post to Slack even if there is no ❌ in the checks
0 8,12,16,20 * * * SLACK_HOOK_URL=<your-slack-hook-url> remotesysmonitor -f configuration.yaml

Development

There is a .devcontainer configuration for VSCode, so you can use it to develop the project. It will setup a development environment and also configure a SSH server to test the checks that require a remote server.

Once inside the dev-container you can tweak the conf/conf.dev.yaml file to your needs and run the project with:

SLACK_HOOK_URL="" cargo run -- -p conf/conf.dev.yaml

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.