package module
Version: v0.0.0-...-514fb8c Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2020 License: MIT Imports: 12 Imported by: 0



Server status monitor written in Go


gossm performs checks if servers can be reached every t seconds and notifies when unsuccessful

Web Interface

Dashboard HTTP server


Build and run

Run from terminal:

go get github.com/ssimunic/gossm/cmd/gossm
go build github.com/ssimunic/gossm/cmd/gossm
./gossm -config configs/myconfig.json

This will build and run program with configuration file configs/myconfig.json.

Command line arguments

Following arguments are available:

config configuration file path (default "configs/default.json")

log log file path (default "logs/current-date.log")

http address for http server (default ":8080")

logfilter text to filter log by (both console and file)

nolog presence of this argument will disable logging to file only

Example: ./gossm -config configs/myconfig.json -logfilter tcp -http :1337. Web interface will be available at localhost:1337.

You can also use ./gossm -help for help.


An example Dockerfile is located in the project root. Currently there is no offical build on Docker Hub, but that can be addressed if more people show interest.


An example docker-compose is also found in our project root.

version: "2"

    build: ./
      - "8067:8080"
      - ./configs:/configs
      - ./logs:/var/log/gossum

Getting started with docker-compose is as simple as having Docker and Docker Compose installed on your machine, and typing:

docker-compose build
docker-compose up

Please note that the example config found at configs/default.json is invalid JSON, so we will need to fix that before bringing up the container.


JSON structure is used for configuration. Example can be found in configs/default.json.

    "settings": {
        "notifications": {
            "email": [
                    "smtp": "smtp.gmail.com",
                    "port": 587,
                    "username": "silvio.simunic@gmail.com",
                    "password": "...",
                    "from": "silvio.simunic@gmail.com",
                    "to": [
            "telegram": [
                    "botToken": "123456:ABC-DEF1234...",
                    "chatId": "12341234"
            "slack": [
                    "bearerToken": "bearerToken",
                    "channelId": "channelId"
            "pushover": [
                    "userKey": "user_key",
                    "appToken": "app_token"
            "webhook": [
                    "url": "url",
                    "method": "GET"
            "sms": [
                    "sms": "todo"
        "monitor": {
            "checkInterval": 15,
            "timeout": 5,
            "maxConnections": 50,
            "exponentialBackoffSeconds": 5
    "servers": [
            "name":"Local Webserver 1",
            "port": 80,
            "protocol": "tcp",
            "checkInterval": 5,
            "timeout": 5
            "name":"Test server 1",
            "port": 80,
            "protocol": "tcp",
            "checkInterval": 5,
            "timeout": 5
            "name":"Test server 2",
            "port": 8080,
            "protocol": "tcp",
            "checkInterval": 5,
            "timeout": 5

checkInterval check interval for each server in seconds

timeout check connection timeout in seconds

maxConnections maximum concurrent connections


After each notification, time until next notification is available is increased exponetially. On first unsuccessful server reach, notification will always be sent immediately. If, for example, exponentialBackoffSeconds is set to 5, then next notifications will be available after 5, 25, 125... seconds. On successful server reach after downtime, this will be reset.


name server name for identification

ipAddress server ip address

port server port

protocol network protocol (tcp, udp)

checkInterval check interval for each server in seconds (this will override global settings)

timeout check connection timeout in seconds (this will override global settings)


There can be multiple email or sms notification settings.


smtp smtp server address

port smtp server port

username login email

password login password

from email that notifications will be sent from

to array of recipients


botToken Telegram Bot token obtained via the BotFather.

chatId ChatID of the user to message (Can also be a group id).


bearerToken Bearer auth token for Slack app.

channelId Slack channel ID.


appToken your Pushover application's API token

userKey the user/group key of your Pushover user


url url to make request to

method method to use (GET or POST)

Server information will be stored in server parameter.




JSON of current status is available at /json endpoint.

Example is given below.

    "tcp": [
            "time": "2018-03-06T19:57:33.633712261+01:00",
            "online": true
    "tcp": [
            "time": "2018-03-06T19:57:33.650150286+01:00",
            "online": true




This section is empty.


This section is empty.


func NewTrackerWithExpBackoff

func NewTrackerWithExpBackoff(expBackoffSeconds int) *track.TimeTracker

NewTrackerWithExpBackoff creates TimeTracker with ExpBackoff as Delayer

func RunHttp

func RunHttp(address string, monitor *Monitor)


type Config

type Config struct {
	Servers  Servers   `json:"servers"`
	Settings *Settings `json:"settings"`

func NewConfig

func NewConfig(jsonData []byte) *Config

NewConfig returns pointer to Config which is created from provided JSON data. Guarantees to be validated.

func (*Config) Validate

func (c *Config) Validate() error

type Monitor

type Monitor struct {
	// contains filtered or unexported fields

func NewMonitor

func NewMonitor(c *Config) *Monitor

func (*Monitor) Run

func (m *Monitor) Run()

Run runs monitor infinitely

func (*Monitor) RunForSeconds

func (m *Monitor) RunForSeconds(runningSeconds int)

RunForSeconds runs monitor for runningSeconds seconds or infinitely if 0 is passed as an argument

type MonitorSettings

type MonitorSettings struct {
	CheckInterval             int `json:"checkInterval"`
	Timeout                   int `json:"timeout"`
	MaxConnections            int `json:"maxConnections"`
	ExponentialBackoffSeconds int `json:"exponentialBackoffSeconds"`

func (*MonitorSettings) Validate

func (ms *MonitorSettings) Validate() error

type NotificationSettings

type NotificationSettings struct {
	Email    []*notify.EmailSettings    `json:"email"`
	Sms      []*notify.SmsSettings      `json:"sms"`
	Telegram []*notify.TelegramSettings `json:"telegram"`
	Pushover []*notify.PushoverSettings `json:"pushover"`
	Slack    []*notify.SlackSettings    `json:"slack"`
	Webhook  []*notify.WebhookSettings  `json:"webhook"`

func (*NotificationSettings) GetNotifiers

func (n *NotificationSettings) GetNotifiers() (notifiers notify.Notifiers)

func (*NotificationSettings) Validate

func (ns *NotificationSettings) Validate() error

type Server

type Server struct {
	Name          string `json:"name"`
	IPAddress     string `json:"ipAddress"`
	Port          int    `json:"port"`
	Protocol      string `json:"protocol"`
	CheckInterval int    `json:"checkInterval"`
	Timeout       int    `json:"timeout"`

func (*Server) MarshalText

func (s *Server) MarshalText() (text []byte, err error)

func (*Server) String

func (s *Server) String() string

func (*Server) Validate

func (s *Server) Validate() error

type ServerStatusData

type ServerStatusData struct {
	ServerStatus map[*Server][]*statusAtTime `json:"serverStatus"`
	// contains filtered or unexported fields

func NewServerStatusData

func NewServerStatusData(servers Servers) *ServerStatusData

func (*ServerStatusData) GetServerStatus

func (s *ServerStatusData) GetServerStatus() map[*Server][]*statusAtTime

func (*ServerStatusData) SetStatusAtTimeForServer

func (s *ServerStatusData) SetStatusAtTimeForServer(server *Server, timeNow time.Time, status bool)

SetStatusAtTimeForServer updates map with new entry containing current time and server status at that time

type Servers

type Servers []*Server

func (Servers) Validate

func (servers Servers) Validate() error

type Settings

type Settings struct {
	Monitor       *MonitorSettings
	Notifications *NotificationSettings

func (*Settings) Validate

func (s *Settings) Validate() error


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL