Documentation ¶
Index ¶
- Constants
- Variables
- func NewTelemetry(name, bucket string, store storage.Store, config TelemetryConfig, ...) *telemetry
- func SanitizeAdafruitIOFeedName(name string) string
- func SanitizePrometheusMetricName(name string) string
- func TestTelemetry(store storage.Store) *telemetry
- type AdafruitIO
- type AlertStats
- type ErrorLogger
- type Factory
- type HealthChecker
- type HealthMetric
- type MQTTClient
- type MQTTConfig
- type Mailer
- type MailerConfig
- type MailerCustomizer
- type Metric
- type NoopMailer
- type Runner
- type Stats
- type StatsManager
- type StatsOnDisk
- type StatsResponse
- type TeleTime
- type Telemetry
- type TelemetryConfig
- type ThrottleType
Constants ¶
View Source
const AdafruitIOTokenStoredPlaceholder = "<stored>"
View Source
const CurrentLimit = 24 * 60
View Source
const DBKey = "telemetry"
View Source
const HealthStatsKey = "health_stats"
View Source
const HistoricalLimit = 24 * 30
View Source
const PasswordStoredPlaceholder = "<stored>"
TODO: translate these TODO: this is a bit of a hack in that it means someone can't have their
actual token/password be the string "<stored>", but that seems rare enough a reasonable trade-off for a quick fix to unsaveable form bugs
Variables ¶
View Source
var DefaultMQTTConfig = MQTTConfig{ Server: "tcp://127.0.0.1:1883", QoS: 0, Retained: false, Username: "", Password: "", ClientID: "reef-pi.local", Prefix: "reef-pi", }
View Source
var DefaultTelemetryConfig = TelemetryConfig{ Mailer: GMailMailer, Throttle: 10, CurrentLimit: CurrentLimit, HistoricalLimit: HistoricalLimit, MQTT: DefaultMQTTConfig, }
View Source
var GMailMailer = MailerConfig{ Server: "smtp.gmail.com", Port: 587, To: []string{}, }
Functions ¶
func NewTelemetry ¶
func NewTelemetry(name, bucket string, store storage.Store, config TelemetryConfig, lr ErrorLogger) *telemetry
func TestTelemetry ¶
Types ¶
type AdafruitIO ¶
type AlertStats ¶
type ErrorLogger ¶
type HealthChecker ¶
type HealthChecker interface { Check() Start() Stop() GetStats(http.ResponseWriter, *http.Request) }
func NewHealthChecker ¶
func NewHealthChecker(b string, i time.Duration, notify settings.HealthCheckNotify, t Telemetry, store storage.Store) HealthChecker
type HealthMetric ¶
type HealthMetric struct { Load5 float64 `json:"cpu"` UsedMemory float64 `json:"memory"` Time TeleTime `json:"time"` UnderVoltage float64 `json:"throttle"` // contains filtered or unexported fields }
func (HealthMetric) Before ¶
func (m1 HealthMetric) Before(mx Metric) bool
type MQTTClient ¶
type MQTTClient struct {
// contains filtered or unexported fields
}
func NewMQTTClient ¶
func NewMQTTClient(conf MQTTConfig) (*MQTTClient, error)
func (*MQTTClient) Publish ¶
func (m *MQTTClient) Publish(topic, msg string) error
type MQTTConfig ¶
type MailerConfig ¶
type MailerConfig struct { Server string `json:"server"` Port int `json:"port"` From string `json:"from"` Username string `json:"username"` Password string `json:"password"` To []string `json:"to"` }
func (*MailerConfig) Mailer ¶
func (c *MailerConfig) Mailer(opts ...MailerCustomizer) Mailer
type MailerCustomizer ¶
type MailerCustomizer func(m *mailer)
type NoopMailer ¶
type NoopMailer struct{}
func (*NoopMailer) Email ¶
func (n *NoopMailer) Email(s, _ string) error
type StatsManager ¶
type StatsOnDisk ¶
type StatsOnDisk struct { Current []json.RawMessage `json:"current"` Historical []json.RawMessage `json:"historical"` }
type StatsResponse ¶
type StatsResponse struct { Current []Metric `json:"current"` Historical []Metric `json:"historical"` }
swagger:model statsResponse
type Telemetry ¶
type Telemetry interface { Alert(string, string) (bool, error) Mail(string, string) (bool, error) EmitMetric(string, string, float64) CreateFeedIfNotExist(string) DeleteFeedIfExist(string) NewStatsManager(string) StatsManager SendTestMessage(http.ResponseWriter, *http.Request) GetConfig(http.ResponseWriter, *http.Request) UpdateConfig(http.ResponseWriter, *http.Request) LogError(string, string) error }
func Initialize ¶
type TelemetryConfig ¶
type TelemetryConfig struct { AdafruitIO AdafruitIO `json:"adafruitio"` MQTT MQTTConfig `json:"mqtt"` Mailer MailerConfig `json:"mailer"` Notify bool `json:"notify"` Prometheus bool `json:"prometheus"` Throttle int `json:"throttle"` HistoricalLimit int `json:"historical_limit"` CurrentLimit int `json:"current_limit"` }
type ThrottleType ¶
type ThrottleType uint64
const ( UnderVoltage ThrottleType = 0 //0x5000 ARMFrequencyCapped ThrottleType = 1 CurrentlyThrottled ThrottleType = 2 SoftcoreTempLimit ThrottleType = 3 UnderVoltageHasOccurred ThrottleType = 16 ARMFrequencyCappedHasOccurred ThrottleType = 17 ThrottlingHasOccurred ThrottleType = 18 SoftcoreTmpLimitHasOccurred ThrottleType = 19 )
func GetThrottleTypes ¶
func GetThrottleTypes(v int) (tTypes []ThrottleType)
func GetThrottled ¶
func GetThrottled(ctx context.Context, cf Factory) ([]ThrottleType, error)
func VcgencmdGetThrottled ¶
func VcgencmdGetThrottled() ([]ThrottleType, error)
func (*ThrottleType) String ¶
func (t *ThrottleType) String() string
Click to show internal directories.
Click to hide internal directories.