Skip to content

Commit

Permalink
gauge
Browse files Browse the repository at this point in the history
  • Loading branch information
sholdee committed Jun 22, 2024
1 parent 20db503 commit c93e424
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions adguard_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import json
import os
import sys
from prometheus_client import start_http_server, Counter
from prometheus_client import start_http_server, Gauge

# Define a single Prometheus metric
dns_queries = Counter('dns_queries', 'Details of DNS queries', ['qh', 'ip', 'qt', 'response_size', 'result_reason', 'status', 'upstream'])
dns_queries = Gauge('dns_queries', 'Details of DNS queries', ['qh', 'ip', 'qt', 'response_size', 'result_reason', 'status', 'upstream'])

log_file_path = '/opt/adguardhome/work/data/querylog.json'
position_file_path = '/opt/adguardhome/work/data/.position'
Expand All @@ -14,8 +14,9 @@ def get_last_position():
if os.path.exists(position_file_path):
try:
with open(position_file_path, 'r') as f:
pos = int(f.read().strip())
inode = os.stat(log_file_path).st_ino
pos, inode = f.read().strip().split('\n')
pos = int(pos)
inode = int(inode)
print(f"Read last position: {pos}, inode: {inode}")
sys.stdout.flush()
return pos, inode
Expand Down

0 comments on commit c93e424

Please sign in to comment.