Back to godoc.org

Package pihole

v0.0.0-...-467d683
Latest Go to latest

The latest major version is .

Published: Jul 27, 2020 | License: MIT | Module: github.com/eko/pihole-exporter

Index

type Client

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

Client struct is a PI-Hole client to request an instance of a PI-Hole ad blocker.

func NewClient

func NewClient(protocol, hostname string, port uint16, password, apiToken string, interval time.Duration) *Client

NewClient method initializes a new PI-Hole client.

func (*Client) Scrape

func (c *Client) Scrape()

Scrape method authenticates and retrieves statistics from PI-Hole JSON API and then pass them as Prometheus metrics.

type Stats

type Stats struct {
	DomainsBeingBlocked int                `json:"domains_being_blocked"`
	DNSQueriesToday     int                `json:"dns_queries_today"`
	AdsBlockedToday     int                `json:"ads_blocked_today"`
	AdsPercentageToday  float64            `json:"ads_percentage_today"`
	UniqueDomains       int                `json:"unique_domains"`
	QueriesForwarded    int                `json:"queries_forwarded"`
	QueriesCached       int                `json:"queries_cached"`
	ClientsEverSeen     int                `json:"clients_ever_seen"`
	UniqueClients       int                `json:"unique_clients"`
	DNSQueriesAllTypes  int                `json:"dns_queries_all_types"`
	ReplyNoData         int                `json:"reply_NODATA"`
	ReplyNxDomain       int                `json:"reply_NXDOMAIN"`
	ReplyCname          int                `json:"reply_CNAME"`
	ReplyIP             int                `json:"reply_IP"`
	TopQueries          map[string]int     `json:"top_queries"`
	TopAds              map[string]int     `json:"top_ads"`
	TopSources          map[string]int     `json:"top_sources"`
	ForwardDestinations map[string]float64 `json:"forward_destinations"`
	QueryTypes          map[string]float64 `json:"querytypes"`
	Status              string             `json:"status"`
}

Stats struct is the PI-Hole statistics JSON API corresponding model.

func (*Stats) ToString

func (s *Stats) ToString() string

ToString method returns a string of the current statistics struct.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier