api

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultSocketPath

func DefaultSocketPath() string

DefaultSocketPath matches the system service. MONITO_SOCKET selects an explicitly configured user daemon without changing behavior based on UID.

func UserSocketPath

func UserSocketPath() string

UserSocketPath is used by an explicitly launched unprivileged daemon.

Types

type AppUsageResponse

type AppUsageResponse struct {
	AppID       int64                 `json:"app_id"`
	Identity    *identity.AppIdentity `json:"identity"`
	Category    int                   `json:"category"`
	CategoryStr string                `json:"category_str"`
	BytesIn     int64                 `json:"bytes_in"`
	BytesOut    int64                 `json:"bytes_out"`
	TotalBytes  int64                 `json:"total_bytes"`
	PacketsIn   int64                 `json:"packets_in"`
	PacketsOut  int64                 `json:"packets_out"`
	RateIn      float64               `json:"rate_in"`
	RateOut     float64               `json:"rate_out"`
}

AppUsageResponse wraps a traffic record with instantaneous rates

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client queries the versioned Monito collector API over Unix domain socket

func NewClient

func NewClient(socketPath string) *Client

NewClient creates a new Unix socket API client

func (*Client) GetApps

func (c *Client) GetApps(date string, sort string, filter string) ([]AppUsageResponse, error)

GetApps retrieves ranked application usage for a given date

func (*Client) GetDoctor

func (c *Client) GetDoctor() (*DoctorReport, error)

GetDoctor retrieves doctor system check results

func (*Client) GetHistory

func (c *Client) GetHistory(appKey string, days int) ([]storage.AppHistoryPoint, error)

GetHistory retrieves history points for an application

func (*Client) GetLive

func (c *Client) GetLive() (*LiveStatus, error)

GetLive retrieves real-time bandwidth rates

func (*Client) GetStatus

func (c *Client) GetStatus() (*CollectorStatus, error)

GetStatus retrieves collector health and diagnostics

func (*Client) GetSummary

func (c *Client) GetSummary(date string) (*storage.DaySummary, error)

GetSummary retrieves day summary

type CollectorStatus

type CollectorStatus struct {
	ExcludedNamespacePackets uint64    `json:"excluded_namespace_packets"`
	NamespaceReadErrors      uint64    `json:"namespace_read_errors"`
	RecoveredSockets         uint64    `json:"recovered_sockets"`
	RecoveryErrors           uint64    `json:"recovery_errors"`
	UptimeSeconds            int64     `json:"uptime_seconds"`
	StartTime                time.Time `json:"start_time"`
	LastFlushTime            time.Time `json:"last_flush_time"`
	TotalIngressPackets      uint64    `json:"total_ingress_packets"`
	TotalEgressPackets       uint64    `json:"total_egress_packets"`
	SocketsRegistered        uint64    `json:"sockets_registered"`
	UnattributedIngress      uint64    `json:"unattributed_ingress"`
	UnattributedEgress       uint64    `json:"unattributed_egress"`
	MapErrors                uint64    `json:"map_errors"`
	ActiveAppCount           int       `json:"active_app_count"`
	Version                  string    `json:"version"`
}

CollectorStatus represents daemon health, diagnostics, and capacity

type DataProvider

type DataProvider interface {
	GetLiveStatus() LiveStatus
	GetCollectorStatus() CollectorStatus
	GetDoctorReport() DoctorReport
}

DataProvider supplies live rates, collector diagnostics, and doctor checks to the API server

type DoctorReport

type DoctorReport struct {
	KernelVersion   string   `json:"kernel_version"`
	CgroupV2Mounted bool     `json:"cgroup_v2_mounted"`
	BTFAvailable    bool     `json:"btf_available"`
	SELinuxStatus   string   `json:"selinux_status"`
	HasCAPBPF       bool     `json:"has_cap_bpf"`
	HasCAPNetAdmin  bool     `json:"has_cap_net_admin"`
	SocketReachable bool     `json:"socket_reachable"`
	DBWritable      bool     `json:"db_writable"`
	Warnings        []string `json:"warnings"`
}

DoctorReport contains diagnostic system checks

type LiveAppRate

type LiveAppRate struct {
	AppKey      string  `json:"app_key"`
	DisplayName string  `json:"display_name"`
	Category    string  `json:"category"`
	RateIn      float64 `json:"rate_in"`  // bytes per second
	RateOut     float64 `json:"rate_out"` // bytes per second
	TotalRate   float64 `json:"total_rate"`
}

LiveAppRate represents live transfer rates for an app

type LiveStatus

type LiveStatus struct {
	Timestamp    time.Time     `json:"timestamp"`
	TotalRateIn  float64       `json:"total_rate_in"`
	TotalRateOut float64       `json:"total_rate_out"`
	TotalRate    float64       `json:"total_rate"`
	AppRates     []LiveAppRate `json:"app_rates"`
}

LiveStatus represents current real-time transfer rates across the system

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server provides the HTTP-over-UDS versioned API

func NewServer

func NewServer(store *storage.Storage, provider DataProvider, socketPath string) *Server

NewServer creates a new API server instance

func (*Server) Start

func (s *Server) Start() error

Start listens on the Unix socket and serves API requests

func (*Server) Stop

func (s *Server) Stop() error

Stop shuts down the API server and removes the socket file

Jump to

Keyboard shortcuts

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