add telemetry
This commit is contained in:
parent
5c57e26652
commit
00e3baf117
2 changed files with 23 additions and 0 deletions
16
btv
16
btv
|
@ -10,6 +10,8 @@ import os
|
|||
import shlex
|
||||
import sys
|
||||
import time
|
||||
import socket
|
||||
import urllib.request
|
||||
|
||||
CONFIG = "/etc/btv/config.ini"
|
||||
LOCKFILE = "/run/lock/btv/serialization.lock"
|
||||
|
@ -259,6 +261,12 @@ def serialize(snap, outdir, key, snap_from=None):
|
|||
|
||||
return 0
|
||||
|
||||
def ping(url):
|
||||
try:
|
||||
urllib.request.urlopen(url, timeout=10)
|
||||
except socket.error as e:
|
||||
print("Ping failed: %s" %(e))
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Verbs
|
||||
|
||||
|
@ -306,6 +314,10 @@ def do_create(args):
|
|||
elif snaps_since_rank_1 >= cfg.getint("snap", "rank_1_interval"):
|
||||
snapshot.rank = 1
|
||||
|
||||
ping_url = cfg.get("monitoring", "rank2_start_url")
|
||||
if snapshot.rank == 2 and ping_url:
|
||||
ping(ping_url)
|
||||
|
||||
## create the snapshot itself
|
||||
##
|
||||
os.makedirs(snapshot.path)
|
||||
|
@ -358,6 +370,10 @@ def do_create(args):
|
|||
|
||||
## garbage collection
|
||||
do_gc()
|
||||
|
||||
ping_url = cfg.get("monitoring", "rank2_end_url")
|
||||
if snapshot.rank == 2 and ping_url:
|
||||
ping(ping_url)
|
||||
|
||||
def do_list(args):
|
||||
"""
|
||||
|
|
|
@ -35,3 +35,10 @@ dir = /mnt/pool/subvol/_backup
|
|||
rank_0_count=25
|
||||
rank_1_count=36
|
||||
rank_2_count=42
|
||||
|
||||
[monitoring]
|
||||
# GETs this URL before starting a rank2 snapdhot
|
||||
rank2_start_url =
|
||||
|
||||
# GETs this URL after successfully completing a rank2 snapshot
|
||||
rank2_end_url =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue