Skip to content

Robust services healthiness probing written in Go. (with notification support of slack, telegram, email and more)

License

Notifications You must be signed in to change notification settings

TibebeJS/go-alive

Repository files navigation

Go Reference codecov Go Report Card

Robust services healthiness probing written in Go. (with notification support of telegram, slack, email and more)

Getting Started

Please follow the steps below to get started quick

Using as a CLI tool (using the go binary directly)

If you are using Go 1.17 , run the following:

$ go install github.com/TibebeJs/go-alive@latest

If you are using an older version of golang,

$ GO111MODULE=on go get github.com/TibebeJs/go-alive@latest

Using Docker

Alternative 1: Building the Image locally

Clone the source code repository first:

$ [email protected]:TibebeJS/go-alive.git && cd go-alive

Then build the Docker Image (with Docker BuildKit enabled):

$ DOCKER_BUILDKIT=1 docker build . -t go-alive

Finally mount a folder where your config.yml file resides at as /config and run the image:

$ docker run -v $(pwd):/config go-alive         # assuming config.yml is in the current working directory

Alternative 2: Pull the image from the Docker Hub Registry and run it

To pull the docker image:

$ docker pull tibebesjs/go-alive

Then simplyy mount a folder where you have your config.yml in as /config and run the image:

$ docker run -v $(pwd):/config go-alive

Configuration

Every operational aspects of go-alive is configured through the yaml file.

targets:                                          # list of services to scan
  - name: "Test Server"  
    ip: "127.0.0.1"
    cron: "*/5 * * * *"                           # scan every 5 seconds
    strategy: status-code                         # can be "ping", "telnet" or "status-code"
    https: false
    ports:                                        # list of ports to scan for the specified host
      - port: 8000
        notify:                                   # notification channels for the result of the specific port scan
          - via: telegram
            chat: go-alive-test-group
            from: go-alive-test-bot               # defined in the notifications block
            template: ""
      - port: 8010
        notify:
    rules:                                        # conditional rules to check on host scan result
      - failures: ">0"                            # can be "<num", "num", ">num". eg. <4 (less than 4 failures)
        notify:
        - via: telegram
          chat: go-alive-test-group
          from: go-alive-test-bot
          template: >                             # template for telegram message (go template is supported)
            IP: {{.Host}}
            Scan Type: {{.Strategy}}
            Scan summary:
            {{range .Results}}
              port: {{.Port}}
              reachable: {{.IsReachable}}
                ------------{{end}}
        - via: email
          from: "tibebe"
          to: [email protected]
          subject: "Go-Alive Test Report"
          template: >
            IP: {{.Host}}
            Scan Type: {{.Strategy}}
            Scan summary:
            {{range .Results}}
              port: {{.Port}}
              reachable: {{.IsReachable}}
              {{ if .Error }}
                error:
                  {{ .Error }}
              {{end}}
                ------------
            {{end}}
        - via: slack
          channel: go-alive-test-group
          from: go-alive-test-bot
          template: >
            IP: {{.Host}}

            Scan Type: {{.Strategy}}

            Scan summary:
            {{range .Results}}
              port: {{.Port}}
              reachable: {{.IsReachable}}
                ------------{{end}}
notifications:                                      # notification channels configurations
  telegram:
    bots:                                           # telegram bots to send messages from
      - name: "go-alive-test-bot"
        token: "123456:bot-token"
    chats:                                          # list of telegram recipients
      - name: "go-alive-test-group"
        chatid: 1123232322
      - name: "tibebe"
        chatid: 12345678
  slack:
    apps:
      - name: "go-alive-test-bot"
        token: "bot user token"
    channels:
      - name: "go-alive-test-group"
        channelid: 'channel id'
  email:                                            # email configuration
    smtp:
      - name: "tibebe"
        sender: "[email protected]"
        auth:
          username: "[email protected]"
          password: "password"
        server: "smtp.gmail.com"
        port: 587
  webhook:
    - name: "webhook api"
      endpoint: "http://localhost:8000"
      auth:
        endpoint: "http://localhost:7000"
        email: "[email protected]"
        password: "password"

Bugs

Bugs or suggestions? Visit the issue tracker

Contribution

Feel free to fork, edit and send a PR.