pinguino

package module
v0.0.0-...-ddf14ad Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2015 License: MIT Imports: 13 Imported by: 0

README

Go-pinguino

This is a Go daemon/service that performs a list of actions based on the result of Http Get or Ping.

circleci

Go Walker

Disclaimer

This application aim to be run as Go Service (daemon). The project goals are small, we just want to perform certain actions on an internal network based on microservice states. We are not trying to replace nagios or any monitoring platform, Pinguino was build to be use on personal computer, with minimal effort for deployment and dependencies.

Usage

You may find Pinguino useful if you want to activate/deactivate some services or run custom actions on your computer/server based on the output of webservices and surroundings.

Install / Run

The config file need to be installed at the following location /etc/pinguino.yaml

To install and run the go-pinguino daemon, follow those steps:

$ git clone https://github.com/areski/go-pinguino.git
$ cd go-pinguino
$ export GOPATH=`pwd`
$ make build
$ ./bin/daemon-pinguino

Configuration file

Config file /etc/pinguino.yaml:

# checker: check to trigger an action (HTTPGet | Ping)
# NOTE: Ping is not implemented yet
checker_type: "HTTPGet"

# checker_source: URL or IP that will be checked
checker_source: "http://192.168.1.1/"

# checker_regex: Regular expresion to verify on source
checker_regex: "RouterOS|WebFig"
# <title>RouterOS router configuration page</title>

# checker_freq: Frequence of check in seconds (300 -> 5min)
checker_freq: 5

# action to perform when checker_regex is true (leave action_cmd_* empty if no action)
# Use a tuple to define the command ie [ touch, /tmp/touchedfile.txt, ] or [./runme.sh, ]
action_cmd_on: ["touch", "/tmp/touchedfile_on.txt", ]

# action to perform when checker_regex is false ( leave action_cmd_* empty if no action)
# Use a tuple to define the command ie [ touch, /tmp/touchedfile.txt, ] or [./runme.sh, ]
action_cmd_off: ["touch", "/tmp/touchedfile_off.txt", ]

License

Go-pinguino is licensed under MIT, see LICENSE file.

TODO

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default_conf = "./pinguino.yaml"

Default_conf is the config file used by pinguino

View Source
var Prod_conf = "/etc/pinguino.yaml"

Prod_conf is the config file used in production by pinguino

Functions

func CheckHTTPGet

func CheckHTTPGet(url string, checker_regex string) (bool, error)

CheckHTTPGet function check the content of a URL against a regular expression This function returns a tuple (bool, error)

func CheckPing

func CheckPing(ipaddress string, checker_regex string) (bool, error)

CheckPing function will ping an IP, this function is not implemented yet This function returns a tuple (bool, error)

func LoadConfig

func LoadConfig(configfile string) bool

LoadConfig load the configuration from the conf file and set the configuration inside the structure config It will returns boolean, true if the yaml config load is successful it will 'panic' otherwise

func RunCommand

func RunCommand(command []string) bool

RunCommand run the command received as parameter, a tuple []string is expected or a single command element It returns boolean, true if the command is passed to sh.Command

func StartDaemon

func StartDaemon()

StartDaemon loads configation and create the Service

Types

type Config

type Config struct {
	// First letter of variables need to be capital letter
	Checker_type   string
	Checker_source string
	Checker_regex  string
	Checker_freq   int
	Action_cmd_on  []string
	Action_cmd_off []string
}

Config held the structure for the configuration file

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service has embedded daemon

func (*Service) Manage

func (service *Service) Manage() (string, error)

Manage by daemon commands or run the daemon

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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