Giter VIP home page Giter VIP logo

uptime's Introduction

Uptime

Uptime is a tool used to monitor all kind of services and notify the state of every one of them in real time by many notifications channels as Slack, Google Workspace, Microsoft Teams, etc.

This tool can be hosted anywhere because it is a really light tool and can access to protected services via ssh.

How to Use

Define your services in a config file

To set up the services that the tool will be checking we use a YML configuration file.

A configuration file Should look like this:

database:
  type: influxdb
  spec:
    token: DA8osWZB208kHI7CpQVn1Fz0E_gXsrTfk2oz0_U0XkfKNUwQ224cShAz2_nh_j84TgrvD5Y8mw8X1Ag4uHG7mg==
    url: http://localhost:8086
    org: myOrg
    bucket: firstBucket
    measurement: services
services:
  - name: My Http Service
    type: http
    timeout: 30
    waiting-time: 60
    inverted: false
    notification-channels: ["Telegram"]
    spec:
      url: http://www.google.com
      method: POST
      headers:
        content-type: application/json
        authentication: bearer 
      expected-status: 201
      body: '{"ID": 4524}'
  - name: My Tcp Service
    type: tcp
    timeout: 30
    waiting-time: 60
    inverted: false
    notification-channels: ["Telegram"]
    spec:
      host: www.google.com
      port: 3000
  - name: My Ping Service
    type: ping
    timeout: 30
    waiting-time: 60
    inverted: false
    notification-channels: ["Telegram"]
    spec:
      host: www.google.com
      ping-count: 4
      must-receive: 4
port-forward:
  - server-address: www.host.com
    remote-address: localhost:5432
    local-address: localhost:8000
    username: <YourUsername>
    password: <YourPassword>
notification-channels:
  - name: Telegram
    type: telegram
    spec:
      token:
      chat-id:

Lets explain all of this.

Set up database

Influxdb
database:
  # Database Type
  type: influxdb
  # Specifications of this database Type
  spec:
    # Influxdb authentication token
    token: DA8osWZB208kHI7CpQVn1Fz0E_gXsrTfk2oz0_U0XkfKNUwQ224cShAz2_nh_j84TgrvD5Y8mw8X1Ag4uHG7mg==
    # Database Url
    url: http://localhost:8086
    # Influxdb Organization
    org: myOrg
    # Influxdb Bucket
    bucket: firstBucket
    # Influxdb Measurement
    measurement: services

Set up your services

Http
services:
  - name: My Http Service
    type: http
    # Specifies the timeout of the request
    timeout: 30
    # Time between every request
    waiting-time: 60
    # If the request is successful then the service is dead
    inverted: false
    # Name of the channel that it will notify through
    notification-channels: ["Telegram"]
    spec:
      # Http Request specifications
      url: http://www.google.com
      method: POST
      headers:
        content-type: application/json
        Authorization: <auth-scheme> <authorization-parameters>
      # Expected status code of the response
      expected-status: 201
      body: '{"ID": 4524}'
Tcp
services:
  - name: My Tcp Service
    type: tcp
    # Tcp dial timeout
    timeout: 30
    # Time between each request
    waiting-time: 60
    # If the request is successful then the service is dead
    inverted: false
    # Name of the channel that it will notify through
    notification-channels: ["Telegram"]
    spec:
      host: www.google.com
      port: 80
Ping
services:
  - name: My Ping Service
    type: ping
    # Timeout of the ping request
    timeout: 30
    # Time between each ping request
    waiting-time: 60
    # If the request is successful then the service is dead
    inverted: false
    # Name of the channel that it will notify through
    notification-channels: ["Telegram"]
    spec:
      # Host of the ping request
      host: www.google.com
      # How many packages will be send
      ping-count: 4
      # How many packages must receive to be alive
      must-receive: 4

Notification Channels

Slack

Sending messages to Slack using incoming webhooks

notification-channels:
  - name: Slack
    type: slack
    spec:
      webhook: https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
Microsoft Teams

Sending messages to Teams using incoming webhooks

notification-channels:
  - name: Microsoft Teams
    type: microsoft-teams
    spec:
      webhook: https://xxxxx.webhook.office.com/xxxxxxxxx
Google Workspace

Sending messages to Google Workspace using incoming webhooks

notification-channels:
  - name: Google Workspace
    type: google-workspace
    spec:
      webhook: https://chat.googleapis.com/v1/spaces/SPACE_ID/messages
Discord

Sending messages to Discord using incoming webhooks

notification-channels:
  - name: Discord
    type: discord
    spec:
      webhook: https://discord.com/api/webhooks/000000/XXXXXXXXXXXXX
Telegram

For telegram you need a bot-token and a chat id. How to get it?

notification-channels:
  - name: Telegram
    type: telegram
    spec:
      # Token of the bot
      token: 63xxxxxx71:AAFoxxxxn0hwA-2TVSxxxNf4c
      # Chat id that you want to notify to
      chat-id: "827317315"

Ssh Tools

PortForwarding

We this we are capable of forward a remote port through ssh.

port-forward:
    # Ssh Host
  - server-address: www.host.com
    # remote address to access
    remote-address: localhost:5432
    # Local address 
    local-address: localhost:8000
    # External host Username
    username: <YourUsername>
    # External host Password
    password: <YourPassword>

Run it

To use this tool you can download the binary file or build it by yourself. Then Execute the command bellow to run it:

uptime -f uptime-config.yml

How to Compile it

Windows

git clone https://github.com/dunielm02/uptime.git
cd uptime
go mod download
env GOOS=windows GOARCH=amd64 go build -o ./build/uptime.exe
./build/uptime.exe -f uptime-config.yml

Linux

git clone https://github.com/dunielm02/uptime.git
cd uptime
go mod download
env GOOS=linux GOARCH=arm go build -o ./build/uptime.exe
./build/uptime.exe -f uptime-config.yml

Contribute

uptime's People

Contributors

dunielm02 avatar

Stargazers

 avatar

Watchers

 avatar

uptime's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.