mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
nginx_upstream_multi_: simplify configuration retrieval via environment
This commit is contained in:
parent
734da6b9c8
commit
d5fc30a9bf
1 changed files with 7 additions and 21 deletions
|
@ -58,19 +58,13 @@ progName = progName[progName.rfind("/")+1:]
|
|||
|
||||
|
||||
# Where to store plugin state
|
||||
if "MUNIN_PLUGSTATE" in os.environ:
|
||||
stateDir = os.environ["MUNIN_PLUGSTATE"]
|
||||
else:
|
||||
stateDir = None
|
||||
stateDir = os.environ.get("MUNIN_PLUGSTATE", None)
|
||||
|
||||
# Which site configuration we should use
|
||||
siteName = progName[len("nginx_upstream_multi_"):]
|
||||
|
||||
# Log path
|
||||
if "log" in os.environ:
|
||||
logPath = os.environ["log"]
|
||||
else:
|
||||
logPath = "/var/log/nginx/access.log"
|
||||
logPath = os.environ.get("log", "/var/log/nginx/access.log")
|
||||
|
||||
# Http statuses list
|
||||
httpStatusString = (
|
||||
|
@ -89,10 +83,8 @@ httpStatusString = (
|
|||
"506:Variant also negotiates;507:Insufficient storage;508:Loop detected;"
|
||||
"509:Bandwidth limit exceeded;510:Not extended")
|
||||
|
||||
if "statuses" in os.environ:
|
||||
statuses = os.environ["statuses"].split()
|
||||
else:
|
||||
statuses = []
|
||||
# an empty list of wanted statuses is interpreted as: all statuses
|
||||
statuses = os.environ.get("statuses", "").split()
|
||||
|
||||
httpStatusList = {}
|
||||
for statusString in httpStatusString.split(";"):
|
||||
|
@ -121,19 +113,13 @@ if "upstream" in os.environ:
|
|||
else:
|
||||
raise Exception("No upstreams specified")
|
||||
|
||||
if "percentiles" in os.environ:
|
||||
percentiles = os.environ["percentiles"].split()
|
||||
else:
|
||||
percentiles = [80]
|
||||
percentiles = os.environ.get("percentiles", "80").split()
|
||||
|
||||
if "graphs" in os.environ:
|
||||
graphs_enabled = os.environ["graphs"].split()
|
||||
else:
|
||||
graphs_enabled = ["cache", "http", "time", "request"]
|
||||
graphs_enabled = os.environ.get("graphs", "cache http time request").split()
|
||||
|
||||
now = int(time.time())
|
||||
|
||||
lastBytePath = "%s/nginx_upstream_multi_%s_lastByte.txt" % (stateDir, siteName)
|
||||
lastBytePath = os.path.join(stateDir, "nginx_upstream_multi_{}_lastByte.txt".format(siteName))
|
||||
try:
|
||||
lastRun = os.path.getmtime(lastBytePath)
|
||||
except OSError:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue