systatus

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

README

Systatus

GitHub License Go Reference pr's welcome GitHub Repo stars GitHub followers GitHub forks

Note: Systatus is currently in beta, and we are actively working on expanding functionality. Be sure to update frequently to get the latest features and improvements.

What is Systatus?

Systatus is a lightweight Go library inspired by Spring Boot's Actuator, designed to add system observability and monitoring endpoints to any Go application. It allows you to expose essential system information and application health metrics through HTTP routes, enabling quick insights and diagnostics.

With just a of code, Systatus can provide your application with predefined routes to monitor metrics like CPU, memory, and disk usage, as well as application uptime and a simple health check.

Available Routes

Systatus provides the following default routes, which are also documented in swagger.yml:

  • /env: JSON response with host environment variables
  • /health: Simnple Health check route
Installation

To install Systatus, use the following command:

go get github.com/gdegiorgio/systatus
Quick startup
package main

import (
	"fmt"
	"net/http"
	"github.com/gdegiorgio/systatus"
)

func main() {
	opts := SystatusOptions{ Prefix : "/dev"}
	systatus.Enable(opts)
	http.ListenAndServe(":8080", nil)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enable

func Enable(opts SystatusOptions)

func HandleMem

func HandleMem(opts MemHandlerOpts) func(w http.ResponseWriter, r *http.Request)

Types

type CPUHandlerOpts

type CPUHandlerOpts struct {
	Middlewares []func(next http.HandlerFunc) http.HandlerFunc
}

type CPUResponse

type CPUResponse struct{}

type DiskHandlerOpts

type DiskHandlerOpts struct {
	Middlewares []func(next http.HandlerFunc) http.HandlerFunc
}

type DiskResponse

type DiskResponse struct{}

type EnvHandlerOpts

type EnvHandlerOpts struct {
	Middlewares   []func(next http.HandlerFunc) http.HandlerFunc
	SensitiveKeys []string
}

type EnvResponse

type EnvResponse struct {
	Env map[string]string `json:"env"`
}

type HealthHandlerOpts

type HealthHandlerOpts struct {
	Middlewares []func(next http.HandlerFunc) http.HandlerFunc
	Healthcheck func(w http.ResponseWriter, r *http.Request)
}

type HealthResponse

type HealthResponse struct {
	Status string `json:"status"`
}

type MemHandlerOpts

type MemHandlerOpts struct {
	Middlewares []func(next http.HandlerFunc) http.HandlerFunc
}

type MemResponse

type MemResponse struct {
	TotalAlloc uint64 `json:"total_alloc"`
	Alloc      uint64 `json:"alloc"`
	Sys        uint64 `json:"sys"`
}

type SystatusOptions

type SystatusOptions struct {
	Mux               *http.ServeMux
	Prefix            string
	ExposeEnv         bool
	PrettyLogger      bool
	HealthHandlerOpts HealthHandlerOpts
	CPUHandlerOpts    CPUHandlerOpts
	EnvHandlerOpts    EnvHandlerOpts
	DiskHandlerOpts   DiskHandlerOpts
	UptimeHandlerOpts UptimeHandlerOpts
	MemHandlerOpts    MemHandlerOpts
}

type UptimeHandlerOpts

type UptimeHandlerOpts struct {
	Middlewares []func(next http.HandlerFunc) http.HandlerFunc
}

type UptimeResponse

type UptimeResponse struct {
	Systime string `json:"systime"`
	Uptime  string `json:"uptime"`
}

Directories

Path Synopsis
examples
stdlib command

Jump to

Keyboard shortcuts

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