Skip to content

Commit

Permalink
nginx script clean up (#197)
Browse files Browse the repository at this point in the history
- Change script name for simplify of configuration management orchestration scripts.
- Change 172.0.0.1 to localhost for better nginx handling.
  • Loading branch information
sparknsh authored and laf committed Oct 17, 2018
1 parent 1c61a96 commit e0dcd4a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 37 deletions.
34 changes: 34 additions & 0 deletions snmp/nginx
@@ -0,0 +1,34 @@
#!/usr/bin/env python
import urllib2
import re

data = urllib2.urlopen('http://localhost/nginx-status').read()

params = {}

for line in data.split("\n"):
smallstat = re.match(r"\s?Reading:\s(.*)\sWriting:\s(.*)\sWaiting:\s(.*)$", line)
req = re.match(r"\s+(\d+)\s+(\d+)\s+(\d+)", line)
if smallstat:
params["Reading"] = smallstat.group(1)
params["Writing"] = smallstat.group(2)
params["Waiting"] = smallstat.group(3)
elif req:
params["Requests"] = req.group(3)
else:
pass

dataorder = [
"Active",
"Reading",
"Writing",
"Waiting",
"Requests"
]

for param in dataorder:
if param == "Active":
Active = int(params["Reading"]) + int(params["Writing"]) + int(params["Waiting"])
print Active
else:
print params[param]
37 changes: 0 additions & 37 deletions snmp/nginx-stats

This file was deleted.

0 comments on commit e0dcd4a

Please sign in to comment.