mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-04-13 09:42:01 +00:00
25 lines
792 B
Python
Executable file
25 lines
792 B
Python
Executable file
#!/usr/bin/env python
|
|
|
|
import os
|
|
import re
|
|
import urllib.request
|
|
from vendor.munin import MuninPlugin
|
|
|
|
class MuninNginxPlugin(MuninPlugin):
|
|
category = "Nginx"
|
|
|
|
status_re = re.compile(
|
|
r"Active connections:\s+(?P<active>\d+)\s+"
|
|
r"server accepts handled requests\s+"
|
|
r"(?P<accepted>\d+)\s+(?P<handled>\d+)\s+(?P<requests>\d+)\s+"
|
|
r"Reading: (?P<reading>\d+) Writing: (?P<writing>\d+) Waiting: (?P<waiting>\d+)")
|
|
|
|
def __init__(self):
|
|
super(MuninNginxPlugin, self).__init__()
|
|
self.url = os.environ.get('NX_STATUS_URL') or "http://localhost/nginx_status"
|
|
|
|
def autoconf(self):
|
|
return bool(self.get_status())
|
|
|
|
def get_status(self):
|
|
return self.status_re.search(urllib.request.urlopen(self.url).read()).groupdict()
|