exporter

package
v0.0.0-...-f6a25d2 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureConfigDefaults

func EnsureConfigDefaults(cfg *Config) bool

func EnsureWebConfigDefaults

func EnsureWebConfigDefaults(config *WebConfig) bool

EnsureWebConfigDefaults handles setting sane defaults and migrating the config forward. It returns `true` if any changes were made.

func SaveConfig

func SaveConfig(filename string, cfg *Config) error

Types

type CliAuthenticator

type CliAuthenticator struct {
}

func (*CliAuthenticator) Prompt2FACode

func (*CliAuthenticator) Prompt2FACode() (string, error)

Prompt2FACode implements `ringapi.Authenticator` interface

func (*CliAuthenticator) PromptCredentials

func (*CliAuthenticator) PromptCredentials() (string, string, error)

PromptCredentials implements `ringapi.Authenticator` interface

type Config

type Config struct {
	ApiConfig ringapi.ApiConfig `json:"api_config"`
	WebConfig WebConfig         `json:"web_config"`

	PollIntervalSeconds uint32 `json:"poll_interval_seconds"`
	SaveIntervalSeconds uint32 `json:"save_interval_seconds"`
}

func LoadConfig

func LoadConfig(filename string) (*Config, error)

type Monitor

type Monitor struct {
	StateHandler *RingStateHandler
	Session      *ringapi.AuthorizedSession
	Config       *Config
	// contains filtered or unexported fields
}

Monitor performs the ringapi query calls and population into prometheus metrics

func NewMonitor

func NewMonitor(cfgFile string, metrics *prometheus.Registry) (*Monitor, error)

NewMonitor creates a new Monitor instance with the required parameters

func (*Monitor) PollOnce

func (m *Monitor) PollOnce() error

PollOnce performs the API queries and metrics updates

type RingState

type RingState struct {
	Token      *oauth2.Token `json:"token"`
	DingCounts []dingCount   `json:"ding_counts"`
}

RingState is a serializable object for holding state

type RingStateHandler

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

RingStateHandler exposes persistence of the `RingState` and also implements `ringapi.TokenHandler`

func NewRingStateHandler

func NewRingStateHandler(cfgFile string) *RingStateHandler

NewRingStateHandler creates a new RingStateHandler instance

func (*RingStateHandler) FetchToken

func (s *RingStateHandler) FetchToken() *oauth2.Token

Fetch implements `ringapi.TokenHandler` interface

func (*RingStateHandler) Save

func (s *RingStateHandler) Save()

func (*RingStateHandler) StoreToken

func (s *RingStateHandler) StoreToken(token *oauth2.Token)

Fetch implements `ringapi.TokenHandler` interface

func (*RingStateHandler) UpdateDingCount

func (s *RingStateHandler) UpdateDingCount(id uint32, dings *[]ring_types.DoorBotDing) (uint32, error)

UpdateDingCount updates the `RingState` with the historical set of dings and updates the gauge reprsenting the ding counter appropriate. This returns the current count (across restart) for the device as seen by this exporter and state.

type WebConfig

type WebConfig struct {
	Port         uint32 `json:"port"`
	MetricsRoute string `json:"metrics_route"`
}

WebConfig contains the serializable config items for the web service.

Jump to

Keyboard shortcuts

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