-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprom-test.py
More file actions
executable file
·31 lines (24 loc) · 849 Bytes
/
prom-test.py
File metadata and controls
executable file
·31 lines (24 loc) · 849 Bytes
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
#!/usr/bin/env python3
import random
from prometheus_client import CollectorRegistry, Gauge, push_to_gateway
def testThing():
n = random.randint(1,10)
guess = int(input("Enter a number from 1 to 10: "))
while n != "guess":
if guess < n:
print("Higher")
guess = int(input("Enter a number from 1 to 10: "))
elif guess > n:
print("lower")
guess = int(input("Enter a number from 1 to 10: "))
else:
print("You guessed it")
pushSuccess()
break
def pushSuccess():
registry = CollectorRegistry()
g = Gauge('job_last_success_unixtime', 'User Guessed correctly', registry=registry)
g.set_to_current_time()
push_to_gateway('localhost:9091', job='batchA', registry=registry)
if __name__ == "__main__":
testThing()