#!/usr/bin/env python
def myzootyscript(messaging):
web1 = messaging.newGroup('HTTP', 'group1') # Create a HTTP agent group with the groupname group1, var name is only for script
web1.sizes = 'minmax(10000, 50000)'
web1.think = 'minmax(1,1)'
web1.servers = 'fc6'
web1.clients = 'fc4'
web1.START()
# do something
web1.STOP()
if __name__ == '__main__':
from backend.scriptbase import run
run(myzootyscript)
A messaging group is a simple object that you can assign values to properties like normal. Note that if you set a property that isn’t defined for the particular agent type, it won’t be sent anywhere. The scripting interface expects strings at this point. They must also be formatted properly so that agents can decode them based on their types. i.e. an integer should be just numbers
Any time you call a method on the object that matches a specified event in the agent, it treats the function name as an event type and sends that event along with any modified properties, in this case START and STOP.
When running scripts from the GUI, it will search the file for any defined functions and run them all, passing in the messaging parameter. If you run a script on the control node, you should add a call to backend.scriptbase.run(functionname) to have it executed. It is advised that you place the call under a check for __name__ == ‘__main__’ so that the function isn’t called if run from the GUI.
setForNode(key, regex, val). Setting a property is like calling this function with key=property, regex=’*’ and val equal to the value to set. The regex can be used to specify a value that only applies on particular nodes.