Skip to content

Commit

Permalink
Merge pull request #5 from inexio/dev
Browse files Browse the repository at this point in the history
Thola v0.1.3
  • Loading branch information
toberd authored Jan 4, 2021
2 parents 1c85984 + e812b0f commit 1a70f8d
Show file tree
Hide file tree
Showing 79 changed files with 2,307 additions and 725 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,16 @@ on:
push:
branches:
- '*'
pull_request:
branches:
- '*'

jobs:

build:
name: Build
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.13
id: go
go-version: ^1.14

- name: Check out code into the Go module directory
uses: actions/checkout@v2
Expand All @@ -39,4 +33,4 @@ jobs:
run: go build -v .

- name: Build client
run: go build -tags client -v .
run: go build -tags client -v .
5 changes: 1 addition & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ on:
push:
branches:
- '*'
pull_request:
branches:
- '*'

jobs:
fmt:
Expand All @@ -31,4 +28,4 @@ jobs:
uses: grandcolline/[email protected]
with:
run: vet
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
19 changes: 7 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,26 @@ jobs:
name: Release
runs-on: ubuntu-latest
steps:
-
name: Checkout
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

-
name: Set up Go
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14
go-version: ^1.14

-
name: Generate configs
- name: Generate configs
run: go generate

-
name: Tidy go mod
- name: Tidy go mod
run: go mod tidy

-
name: Run GoReleaser
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 1 addition & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,16 @@ on:
push:
branches:
- '*'
pull_request:
branches:
- '*'

jobs:

test:
name: Test
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.13
id: go
go-version: ^1.14

- name: Check out code into the Go module directory
uses: actions/checkout@v2
Expand Down
14 changes: 5 additions & 9 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
builds:
- id: "thola"

goos:
- linux
ignore:
- goos: linux
goarch: 386
Expand All @@ -15,12 +13,10 @@ builds:
ldflags:
- -s -w
env:
- CGO_ENABLED=1
- CGO_ENABLED=0

- id: "thola-client"

goos:
- linux
ignore:
- goos: linux
goarch: 386
Expand All @@ -29,17 +25,17 @@ builds:
binary: thola-client

flags:
- -tags
- client
- -tags=client
ldflags:
- -s -w
env:
- CGO_ENABLED=1
- CGO_ENABLED=0

archives:
- builds:
- thola
- thola-client

replacements:
amd64: 64-bit
amd64: 64-bit
darwin: macOS
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,28 @@ Thola currently has three main modes of operation with various subcommands:
- `read available-components` returns the available components for the device.
- `read interfaces` outputs the interfaces with several values like error counters and statistics.
- `read count-interfaces` counts the interfaces.
- `read cpu-load` returns the current cpu load of all CPUs.
- `read memory-usage` reads out the current memory usage.
- `read ups` outputs the special values of a UPS device.
- `check` performs checks that can be used in monitoring systems. Output is by default in check plugin format.
- `check identify` compares the device properties with given expectations.
- `check snmp` checks SNMP reachability.
- `check interface-metrics` outputs performance data for the interfaces, including special values based on the interface type (e.g. Radio Interface).
- `check ups` checks if a UPS device has its main voltage applied and outputs additional performance data like battery capacity and current load.
- `check cpu-load` checks the average CPU load of all CPUs against given thresholds and outputs the current load of all CPUs as performance data.
- `check memory-usage` checks the current memory usage against given thresholds.
- `check ups` checks if a UPS device has its main voltage applied and outputs additional performance data like battery capacity or current load, and compares them to optionally given thresholds.
- `check metrics` outputs all possible metrics.
- `check thola-server` checks reachability of a Thola API.

More features are coming soon:

- Read out additional information
- Inventory data
- System data
- Sensors and Status Flags like temperatures, frequencies, alarms, etc.
- Device specific data (e.g. DSLAMs)
- More checks
- CPU load
- Memory usage
- Hardware health
- Device specific checks
- Configuration/Provisioning

## Quick Start
Expand Down
52 changes: 52 additions & 0 deletions api/logger.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package api

import (
"github.com/labstack/echo"
"github.com/rs/zerolog/log"
"strconv"
"time"
)

func loggerMiddleware() echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
var err error
req := c.Request()
res := c.Response()
start := time.Now()

if err = next(c); err != nil {
c.Error(err)
}

stop := time.Now()

logger := log.Logger.With().Str("request_id", res.Header().Get(echo.HeaderXRequestID)).Logger()

evt := logger.Info()
evt.Str("remote_ip", c.RealIP())
evt.Str("host", req.Host)
evt.Str("method", req.Method)
evt.Str("uri", req.RequestURI)
evt.Str("user_agent", req.UserAgent())
evt.Int("status", res.Status)

if err != nil {
evt.Err(err)
}

evt.Str("latency", stop.Sub(start).String())

cl := req.Header.Get(echo.HeaderContentLength)
if cl == "" {
cl = "0"
}

evt.Str("bytes_in", cl)
evt.Str("bytes_out", strconv.FormatInt(res.Size, 10))
evt.Msg("handled request")

return err
}
}
}
File renamed without changes.
Loading

0 comments on commit 1a70f8d

Please sign in to comment.