homehub

package
v0.0.0-...-bb60f61 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package homehub contains utilities for scraping metrics from a BT home hub.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidUpDownBytes = errors.New("invalid value for up/down bytes")

ErrInvalidUpDownBytes is the error given when the up/down bytes in the homehub's XML response cannot be parsed.

View Source
var ErrStatus = errors.New("unexpected status code")

ErrStatus is the error given when an HTTP call to the homehub returns an error status code.

Functions

This section is empty.

Types

type Client

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

The Client type is used to interact with the BT home hub via HTTP.

func New

func New(urlStr string) (*Client, error)

New creates a new instance of the Client type that will scrape a BT home hub at the provided url.

func (*Client) Ping

func (cl *Client) Ping() error

Ping returns a non-nil error if the root path of the configured URL returns a non success status code when an HTTP GET call is made to it.

func (*Client) Summary

func (cl *Client) Summary(ctx context.Context) (*Summary, error)

Summary returns a summary of scraped metrics from the wan_conn.xml endpoint on the home hub.

type GetStatusResponse

type GetStatusResponse struct {
	XMLName           xml.Name `xml:"status"`
	Text              string   `xml:",chardata"`
	WanConnStatusList struct {
		Text  string `xml:",chardata"`
		Type  string `xml:"type,attr"`
		Value string `xml:"value,attr"`
	} `xml:"wan_conn_status_list"`
	WanConnVolumeList struct {
		Text  string `xml:",chardata"`
		Type  string `xml:"type,attr"`
		Value string `xml:"value,attr"`
	} `xml:"wan_conn_volume_list"`
	WanLinestatusRateList struct {
		Text  string `xml:",chardata"`
		Type  string `xml:"type,attr"`
		Value string `xml:"value,attr"`
	} `xml:"wan_linestatus_rate_list"`
	WlanChannelList struct {
		Text  string `xml:",chardata"`
		Type  string `xml:"type,attr"`
		Value string `xml:"value,attr"`
	} `xml:"wlan_channel_list"`
	Curlinkstatus struct {
		Text  string `xml:",chardata"`
		Type  string `xml:"type,attr"`
		Value string `xml:"value,attr"`
	} `xml:"curlinkstatus"`
	Sysuptime struct {
		Text  string `xml:",chardata"`
		Value string `xml:"value,attr"`
	} `xml:"sysuptime"`
	StatusRate struct {
		Text  string `xml:",chardata"`
		Type  string `xml:"type,attr"`
		Value string `xml:"value,attr"`
	} `xml:"status_rate"`
	WanActiveIdx struct {
		Text  string `xml:",chardata"`
		Value string `xml:"value,attr"`
	} `xml:"wan_active_idx"`
	LinkStatus struct {
		Text  string `xml:",chardata"`
		Value string `xml:"value,attr"`
	} `xml:"link_status"`
	IP4InfoList struct {
		Text  string `xml:",chardata"`
		Type  string `xml:"type,attr"`
		Value string `xml:"value,attr"`
	} `xml:"ip4_info_list"`
	IP6LLAList struct {
		Text  string `xml:",chardata"`
		Type  string `xml:"type,attr"`
		Value string `xml:"value,attr"`
	} `xml:"ip6_lla_list"`
	IP6GUAList struct {
		Text  string `xml:",chardata"`
		Type  string `xml:"type,attr"`
		Value string `xml:"value,attr"`
	} `xml:"ip6_gua_list"`
	IP6RDNSList struct {
		Text  string `xml:",chardata"`
		Type  string `xml:"type,attr"`
		Value string `xml:"value,attr"`
	} `xml:"ip6_rdns_list"`
	Locktime struct {
		Text  string `xml:",chardata"`
		Value string `xml:"value,attr"`
	} `xml:"locktime"`
}

The GetStatusResponse type represents the wan_conn.xml response given by the BT home hub.

type Summary

type Summary struct {
	Uptime    float64
	BytesUp   float64
	BytesDown float64
}

The Summary type contains metrics scraped from the BT home hub.

Jump to

Keyboard shortcuts

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