File: stats.py

package info (click to toggle)
python-adguardhome 0.7.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 504 kB
  • sloc: python: 1,648; makefile: 6
file content (44 lines) | stat: -rw-r--r-- 1,420 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# pylint: disable=W0621
"""Asynchronous Python client for the AdGuard Home API."""

import asyncio

from adguardhome import AdGuardHome


async def main() -> None:
    """Show example on stats from your AdGuard Home instance."""
    async with AdGuardHome("192.168.1.2") as adguard:
        version = await adguard.version()
        print("AdGuard version:", version)

        period = await adguard.stats.period()
        print("Stats period:", period)

        result = await adguard.stats.avg_processing_time()
        print("Average processing time per query in ms:", result)

        result = await adguard.stats.dns_queries()
        print("DNS queries:", result)

        result = await adguard.stats.blocked_filtering()
        print("Blocked DNS queries:", result)

        result = await adguard.stats.blocked_percentage()
        print("Blocked DNS queries ratio:", result)

        result = await adguard.stats.replaced_safebrowsing()
        print("Pages blocked by safe browsing:", result)

        result = await adguard.stats.replaced_parental()
        print("Pages blocked by parental control:", result)

        result = await adguard.stats.replaced_safesearch()
        print("Number of enforced safe searches:", result)

        result = await adguard.filtering.rules_count(allowlist=False)
        print("Total number of active rules:", result)


if __name__ == "__main__":
    asyncio.run(main())