This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import os | |
def haproxy_ctrl(command, socket_path, backend, machine): | |
command_str = '' | |
if os.path.exists(socket_path): | |
client = socket.socket( socket.AF_UNIX, socket.SOCK_STREAM ) | |
print socket_path | |
client.connect(socket_path) | |
command_str+=command+' server '+backend+'/'+machine+"\n" | |
try: | |
print '[debug] executing =>',command_str | |
client.send(command_str) | |
except Exception, e: | |
print str(e) | |
client.close() | |
#invoke | |
command = 'disable' | |
ha_socket = '/var/lib/run/haproxystat' | |
backend = 'tomcats' | |
machine = 'tomcat01.domain.local' | |
haproxy_ctrl (command, ha_socket, backend, machine) |
1 comment:
Thank you so much for these kinds of informative blogs. side effects of hair transplant turkey
Post a Comment