Coder Social home page Coder Social logo

tomasklement / simple-server-report Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 232 KB

Highly configurable bash script which sends nice html email with results of particular commands. Script is pluginable, so you can easily add your own sub-report.

Shell 97.27% HTML 2.73%

simple-server-report's Introduction

Simple server report script

Highly configurable bash script which generates report in html format which can be:

  • piped to another command
  • returned in eml wrapper
  • sent as an email immediately

It can be used to provide very simple server monitoring. Parts of the report are designed as plugins. There are few already prepared plugins:

  • Disks space report
  • Disks health report
  • Processess with highest load
  • Available updates
  • Users logged in the system
  • Two directories differences

Usage

# Generates html email and sends it
./sendreport -o=sendmail

# Prints html report to stdout
./sendreport -o=html

# Prints eml message with html report to stdout
./sendreport -o=eml

Email example

Email screenshot

Installation

You need to have installed GIT before running this command. To install run:

sudo apt install smartmontools
git clone https://github.com/tomasklement/simple-server-report.git && git -C simple-server-report submodule update --init --recursive

This will create directory "simple-server-report" and clone the latest version with its submodules from github.

Upgrade

To upgrade to the latest version simply run:

./upgrade

This will pull the latest version with its submodules from github.

Configuration

  • Create config.sh in the script root directory and place your configuration values to it.
  • Check base_config.sh for available basic configuration values
  • Do not change values directly in base_config.sh file (your changes would be overwritten by update of the script)
  • Check plugins in reports directory. They have their own configuration values located at the top of each script.
  • Configuration of plugins is also placed into config.sh

Example of config.sh

#!/usr/bin/env bash

EMAIL_RECIPIENT="[email protected]"
EMAIL_RECIPIENT_NAME="John Doe"
EMAIL_SENDER="noreply@myserver"
EMAIL_SENDER_NAME="My server"

Writing own plugin

Create plugin script

Lets name our plugin "example". Create script ./reports/example.sh with following content:

#!/usr/bin/env bash

# All the logic should be in this function to avoid possible conflicts in variable names with main script. Also the
# function must have the same name as the plugin and should start with "ssr::" prefix.
function ssr::example {
    local dfReport

    dfReport=$( df -h )

    echo "${dfReport}"
}

Add the name of the script (without the extension) to the configuration variable REPORTS in your config.sh

REPORTS=( "updates" "example" )

Well done. Your report is now part of the report email.

simple-server-report's People

Contributors

tomasklement avatar

Watchers

 avatar

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.