Stop Double Monitoring: NGINX Plus API Helping BIG-IP
How do you prevent double monitoring when a Load Balancer load balances a Load Balancer? Using the NGINX Plus API we can leverage a BIG-IP to monitor the state of your applications and avoi...
Published Nov 14, 2019
Version 1.0Eric_Chen
Employee
Joined May 16, 2013
Eric_Chen
Employee
Joined May 16, 2013
linjing
Jan 03, 2020Employee
an example
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import sys
import urllib2
import json
def get_nginxapi(url):
ct_headers = {'Content-type':'application/json'}
request = urllib2.Request(url,headers=ct_headers)
response = urllib2.urlopen(request)
html = response.read()
return html
api = sys.argv[3]
try:
data = get_nginxapi(api)
data = json.loads(data)
except:
data = ''
m = 0
lowwater = int(sys.argv[4])
try:
for peer in data['peers']:
state = peer['state']
if state == 'up':
m = m + 1
except:
m = 0
#print data['peers'][]['state']
#print m
if m >= lowwater:
print 'UP'