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

Benomi/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/Benomi/go-alive@latest

If you are using an older version of golang,

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

Using Docker

Alternative 1: Building the Image locally

Clone the source code repository first:

$ [email protected]:Benomi/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 benomiteklef/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: "benomi"
          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: "benomi"
        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: "benomi"
        sender: "[email protected]"
        auth:
          username: "[email protected]"
          password: "password"
        server: "smtp.gmail.com"
        port: 587
  webhook:
    - name: "webhook api"
      endpoint: "https://localhost:8000"
      auth:
        endpoint: "https://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.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published