Version: v0.0.11 Latest Latest

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

Go to latest
Published: Jan 1, 2021 License: MIT Imports: 11 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


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.

Source Files

Jump to

Keyboard shortcuts

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