mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-04 18:25:22 +03:00
wip
This commit is contained in:
parent
4349bcf09b
commit
6594882b95
@ -1,6 +1,6 @@
|
|||||||
from prometheus_client import CollectorRegistry
|
from prometheus_client import CollectorRegistry
|
||||||
from prometheus_client.metrics_core import GaugeMetricFamily
|
from prometheus_client.metrics_core import GaugeMetricFamily
|
||||||
from util.requester import Requester
|
from requester import Requester
|
||||||
|
|
||||||
|
|
||||||
def setupRegistry():
|
def setupRegistry():
|
||||||
|
|||||||
34
frigate/requester.py
Normal file
34
frigate/requester.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import requests
|
||||||
|
|
||||||
|
|
||||||
|
def convertMicroToMilliSeconds(microseconds):
|
||||||
|
if microseconds is not None:
|
||||||
|
return microseconds / 1000
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
class CustomResponse:
|
||||||
|
def __init__(self, url, response_ms, up_or_down):
|
||||||
|
self.url = url
|
||||||
|
self.response_ms = response_ms
|
||||||
|
self.up_or_down = up_or_down
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{self.url}:\nstatus -> {self.up_or_down}\nresponse_ms -> {self.response_ms}\n"
|
||||||
|
|
||||||
|
|
||||||
|
class Requester:
|
||||||
|
def __init__(self, url):
|
||||||
|
self.url = url
|
||||||
|
|
||||||
|
def get_request(self):
|
||||||
|
res = requests.get(self.url)
|
||||||
|
if res is not None:
|
||||||
|
upDown = 0
|
||||||
|
if res.status_code == 200:
|
||||||
|
upDown = 1
|
||||||
|
milliseconds = convertMicroToMilliSeconds(res.elapsed.microseconds)
|
||||||
|
return CustomResponse(self.url, milliseconds, upDown)
|
||||||
|
else:
|
||||||
|
# The request did not return anything
|
||||||
|
return CustomResponse(self.url, 0, 0)
|
||||||
Loading…
Reference in New Issue
Block a user