mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 14:16:00 +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
|
# Where to store plugin state
|
||||||
if "MUNIN_PLUGSTATE" in os.environ:
|
stateDir = os.environ.get("MUNIN_PLUGSTATE", None)
|
||||||
stateDir = os.environ["MUNIN_PLUGSTATE"]
|
|
||||||
else:
|
|
||||||
stateDir = None
|
|
||||||
|
|
||||||
# Which site configuration we should use
|
# Which site configuration we should use
|
||||||
siteName = progName[len("nginx_upstream_multi_"):]
|
siteName = progName[len("nginx_upstream_multi_"):]
|
||||||
|
|
||||||
# Log path
|
# Log path
|
||||||
if "log" in os.environ:
|
logPath = os.environ.get("log", "/var/log/nginx/access.log")
|
||||||
logPath = os.environ["log"]
|
|
||||||
else:
|
|
||||||
logPath = "/var/log/nginx/access.log"
|
|
||||||
|
|
||||||
# Http statuses list
|
# Http statuses list
|
||||||
httpStatusString = (
|
httpStatusString = (
|
||||||
|
@ -89,10 +83,8 @@ httpStatusString = (
|
||||||
"506:Variant also negotiates;507:Insufficient storage;508:Loop detected;"
|
"506:Variant also negotiates;507:Insufficient storage;508:Loop detected;"
|
||||||
"509:Bandwidth limit exceeded;510:Not extended")
|
"509:Bandwidth limit exceeded;510:Not extended")
|
||||||
|
|
||||||
if "statuses" in os.environ:
|
# an empty list of wanted statuses is interpreted as: all statuses
|
||||||
statuses = os.environ["statuses"].split()
|
statuses = os.environ.get("statuses", "").split()
|
||||||
else:
|
|
||||||
statuses = []
|
|
||||||
|
|
||||||
httpStatusList = {}
|
httpStatusList = {}
|
||||||
for statusString in httpStatusString.split(";"):
|
for statusString in httpStatusString.split(";"):
|
||||||
|
@ -121,19 +113,13 @@ if "upstream" in os.environ:
|
||||||
else:
|
else:
|
||||||
raise Exception("No upstreams specified")
|
raise Exception("No upstreams specified")
|
||||||
|
|
||||||
if "percentiles" in os.environ:
|
percentiles = os.environ.get("percentiles", "80").split()
|
||||||
percentiles = os.environ["percentiles"].split()
|
|
||||||
else:
|
|
||||||
percentiles = [80]
|
|
||||||
|
|
||||||
if "graphs" in os.environ:
|
graphs_enabled = os.environ.get("graphs", "cache http time request").split()
|
||||||
graphs_enabled = os.environ["graphs"].split()
|
|
||||||
else:
|
|
||||||
graphs_enabled = ["cache", "http", "time", "request"]
|
|
||||||
|
|
||||||
now = int(time.time())
|
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:
|
try:
|
||||||
lastRun = os.path.getmtime(lastBytePath)
|
lastRun = os.path.getmtime(lastBytePath)
|
||||||
except OSError:
|
except OSError:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue