-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprometheus_exporter
executable file
·34 lines (27 loc) · 1012 Bytes
/
prometheus_exporter
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
#! /usr/bin/env python
import sys
import os
from argchecker import argchecker
from metrics import metrics_exporter
from pygtail import Pygtail
from prometheus_client import start_http_server,Counter
exporter_port = 9376
active_connections = []
if argchecker(sys.argv):
logfile = sys.argv[1]
else:
exit()
rsync_all_conn = Counter ('rsync_all_connections', 'Count all opened connections')
rsync_all_conn_unique_source = Counter('rsync_unique_connections','Count all unique peers')
rsync_all_bytes_transfered = Counter('rsync_all_transferred_bytes','Show all transferred bytes')
start_http_server(exporter_port)
print("The exporter port is: " ,exporter_port)
try:
while True:
for line in Pygtail(logfile):
return_metrics = metrics_exporter(line)
rsync_all_conn.inc(return_metrics["rsync_all_conn"])
rsync_all_conn_unique_source.inc(return_metrics["rsync_all_conn_unique_source"])
rsync_all_bytes_transfered.inc(return_metrics["rsync_all_bytes_transfered"])
except KeyboardInterrupt:
pass