Newer
Older
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
Check the Nginx status vhost response.
'''
import os
import requests
import sys
if not os.path.exists('/etc/nginx'):
print('Nginx dir does not exists, test skipped.')
else:
print('Checking http://localhost/nginx_status response.')
try:
req = requests.get('http://localhost/nginx_status', timeout=5)
if req.status_code != 200:
raise Exception('Request failed with status code %s.' % req.status_code)
if 'Active connections' not in req.text:
raise Exception('Invalid response from nginx status url.')
except Exception as e:
print(str(e))
sys.exit(1)