mirror of
				https://github.com/librenms/librenms-agent.git
				synced 2024-05-09 09:54:52 +00:00 
			
		
		
		
	* Format with isort * Format with Black * Fix CRLF * Format with shellcheck * Fix some warning * Fix PHP style * Dont modifiy check_mk files * Fixes
		
			
				
	
	
		
			35 lines
		
	
	
		
			851 B
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			851 B
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/env python
 | 
						|
import re
 | 
						|
 | 
						|
import urllib2
 | 
						|
 | 
						|
data = urllib2.urlopen("http://127.0.0.1/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"]
 | 
						|
 | 
						|
print "<<<nginx>>>\n"
 | 
						|
 | 
						|
for param in dataorder:
 | 
						|
    if param == "Active":
 | 
						|
        Active = (
 | 
						|
            int(params["Reading"]) + int(params["Writing"]) + int(params["Waiting"])
 | 
						|
        )
 | 
						|
        print Active
 | 
						|
    else:
 | 
						|
        print params[param]
 |