-
Notifications
You must be signed in to change notification settings - Fork 2
/
ceph_collector
executable file
·102 lines (79 loc) · 2.43 KB
/
ceph_collector
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env python3
#
# Marc Schoechlin <[email protected]>
# Marc Schoechlin <[email protected]>
import json
import subprocess
import sys
import os
import argparse
import datetime
import time
import fcntl
import socket
import re
import glob
import logging
from pyzabbix import ZabbixMetric, ZabbixSender
from pprint import pprint, pformat
from modules.osd_measures import OsdStats
from modules.helpers import file_is_locked, debug_cmd, execute_cmd, check_on_leader, get_daemons
########################################################################################################################
###
### MAIN
parser = argparse.ArgumentParser(
description='collect data from ceph environments'
)
parser.add_argument('--loglevel',
type=str,
nargs='?',
help='the name of the python loglevel',
default="INFO",
)
parser.add_argument(
'--dryrun',
help='simulation mode',
action='store_true',
)
parser.add_argument('--frequency',
type=int,
nargs='?',
help='seconds',
default=120,
)
parser.add_argument('--discovery_deadline',
type=int,
nargs='?',
help='seconds',
default=(3600*3),
)
parser.add_argument('--regex_filter',
type=str,
nargs='?',
help='regex to match imagenames',
default=".*",
)
parser.add_argument('--zabbix_host',
type=str,
nargs='?',
help='The zabbix host',
default=socket.gethostname()
)
args, pools = parser.parse_known_args()
lockfile = "/tmp/ceph_collector.lock"
if file_is_locked(lockfile):
print('ERROR: another instance is running, exiting now')
sys.exit(0)
root_logger = logging.getLogger()
root_logger.setLevel(args.loglevel)
count = 0
osd_stats = OsdStats(args)
try:
while True:
count += 1
logging.info("measurement loop %s (loop time %s seconds, discovery deadline %s seconds)" % (count, args.frequency, args.discovery_deadline))
osd_stats.collect()
time.sleep(args.frequency)
except KeyboardInterrupt:
logging.info("request for termination, exiting")
sys.exit(1)