forked from allburov/zabbixtools
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ZabbixCommon.py
52 lines (33 loc) · 1 KB
/
ZabbixCommon.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Aleksey Burov, DevOpsHG
# This module common in ZabbixTools
import argparse
import sys
import os
import tempfile
import datetime
ZABBIX_SERVER = "https://server.name.com"
Debug = False
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--verbose", action="store_true",
help="increase output verbosity")
def DebugMsg(msg):
if Debug:
print(msg)
def PrintArgs():
DebugMsg('Script started with next variables: {}'.format(sys.argv[1:]))
def PwdTemp():
tempdir = tempfile.gettempdir()
DebugMsg("Temp dir is: {}".format(tempdir))
os.chdir(tempdir)
DebugMsg("PWD: {}".format(os.getcwd()))
def MainDecorator(func):
def wrapped(*args, **kwargs):
PrintArgs()
PwdTemp()
DebugMsg("Start at {}".format(datetime.datetime.today()))
result = func(*args, **kwargs)
DebugMsg("End at {}".format(datetime.datetime.today()))
return result
return wrapped