gocontrol

command module
v0.0.0-...-ccb52e9 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: MIT Imports: 15 Imported by: 0

README

Build Status gocontrol

Very simple Go app to check if app(s) is(are) up, and relaunch it(them). statuscode refers to the single status codes and not the family (500 does not serve 501,502,...)

Configuration file format

Format file: JSON structured:

[
	{"name": "Github index",
	"url": "github.com", 
	"secure": true,
	"interval": 60, 
	"statuscode": [401,500,501,502,503],
	"maxalerts": 2,
	"script": "./script_1.sh", 
	"delayedby": 2,
	"email": true, 
	"smtphost": "mailtrap.io",
	"smtpport":2525,
	"smtpemail": "sender@me.com",
	"smtpusername": "smtpusername123",
	"smtppassword": "123456",
	"emailaddress": "me@me.com", 
	"log": true, 
	"logfile": "gocontrol_1.log"},
	
	{"name": "Google index",
	"url": "google.com", 
	"secure": false,
	"interval": 60, 
	"statuscode": [404,501,502,503],
	"maxalerts": 2,
	"script": "./script_2.sh", 
	"delayedby": 2,
	"email": true,
	"smtphost": "mailtrap.io",
	"smtpport":2525,
	"smtpemail": "sender@me.com",
	"smtpusername": "smtpusername123",
	"smtppassword": "123456", 
	"emailaddress": "me@me.com", 
	"log": true, 
	"logfile": "gocontrol_2.log"}
]
Use

When maxalerts (maximum number of alerts) is reached, the alerts will no longer be logged or sent. When the service is up again, returning no error, the maxalerts counter is reset to zero.

The delayedby int is the number of times the execution of the script is delayed by alert counts. After that it is executed. If 0, gets executed upon first alert.

Configuration fields
  • name: (string) the name for this monitoring section.
  • url: (string) the address to monitor.
  • secure: (bool) http vs https.
  • interval: (int) the interval in seconds between monitor requests.
  • statuscode: ([]int) int array of the status codes to monitor and generate alert; name them all, not the family.
  • maxalerts: (int) the max number os alerts to be sent; after that it becomes silent until the service is up again.
  • script: (string) the script to run via sh
  • delayedby: (int) the number of detections before executing the script.
  • email: (bool) send an email ?
  • smtphost: (string) the hostname of the email provider
  • smtpport: (int) the port of the smtp host
  • smtpemail: (string) the email of the sender (from header)
  • smtpusername: (string) the username for the smtp auth
  • smtppassword: (string) the password for the smtp auth
  • emailaddress: (string) email to receive the alerts.
  • log: (bool) log ?
  • logfile: (string) # file to append the log.
Cross Compile

If you are building on OSX for Linux usage, make sure your Go e prepared to generate binaries for other architectures. To enable it for Linux:

$ cd  $GOROOT/src
$ GOOS=linux GOARCH=386 ./make.bash

Then to generate a linux specific binary:

$ GOOS=linux GOARCH=386 CGO_ENABLED=0 go build -o gocontrol.linux gocontrol.go

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL