42 lines
861 B
Go
42 lines
861 B
Go
package pihole
|
|
|
|
import (
|
|
"encoding/json"
|
|
"log"
|
|
)
|
|
|
|
type Summary struct {
|
|
Queries Queries `json:"queries"`
|
|
Clients Clients `json:"clients"`
|
|
Gravity Gravity `json:"gravity"`
|
|
}
|
|
|
|
type Queries struct {
|
|
Total int64 `json:"total"`
|
|
Blocked int64 `json:"blocked"`
|
|
PercentBlocked float64 `json:"percent_blocked"`
|
|
UniqueDomains int64 `json:"unique_domains"`
|
|
Forwarded int64 `json:"forwarded"`
|
|
Cached int64 `json:"cached"`
|
|
}
|
|
|
|
type Clients struct {
|
|
Active int64 `json:"active"`
|
|
Total int64 `json:"total"`
|
|
}
|
|
|
|
type Gravity struct {
|
|
DomainsBeingBlocked int64 `json:"domains_being_blocked"`
|
|
LastUpdated int64 `json:"last_updated"`
|
|
}
|
|
|
|
func (ph *PiHConnector) Summary() Summary {
|
|
summary := &Summary{}
|
|
|
|
err := json.Unmarshal(ph.get("stats/summary"), summary)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
return *summary
|
|
}
|