change to cluster by installing node config and restart bro for bro host based cluster with 4 works

parent 439a820c
......@@ -231,8 +231,13 @@ def deidtectScaling(dic, start_response, environ):
remoteIP = get_client_address(environ);
print "IDS IP: %s reported : %d usage" % (remoteIP, int(usage))
usageData = int(usage);
responseData = 'standalone'
if usageData > 75:
responseData = 'cluster'
return sendText(start_response, responseData);
def deidtectWhitelist(dic, start_response, environ):
......
#!/usr/bin/expect --
spawn sudo /usr/local/bro/bin/broctl
#expect ">" { send "help\r" }
expect ">" { send "stop\r" }
expect ">" { send "check\r" }
expect ">" { send "install\r" }
expect ">" { send "start\r" }
expect ">" { send "status\r" }
expect ">" { send "cron enable\r" }
expect ">" { send "exit\r" }
puts "Bro restart script finished..\r"
......@@ -20,7 +20,29 @@ def sendIDSScalingMsg(usage):
if out == 'standalone':
print "Stay in the same state"
else:
mode_filename = "idsmode.file";
if os.path.exists(mode_filename) is True:
print "Already in cluster mode"
return ;
print "In standalone mode"
f = open(mode_filename, 'w')
f.close();
print "create config file to set the mode of operation"
print "Transitioning to Cluster Mode"
print "Copy the node.cfg to etc and restart bro"
new_config_file='/home/ubuntu/node.cfg'
cmdlist = []
copycmd = "sudo cp /home/ubuntu/node.cfg /usr/local/bro/etc/node.cfg"
cmdlist.append(copycmd);
brocmd = "sudo /home/ubuntu/./restartbro.exp"
cmdlist.append(brocmd);
for cmd in cmdlist:
print cmd
p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
out, err = p.communicate()
print out, err
return 0
if __name__ == '__main__':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment