TracNav menu
-
How To
- Setup An Experiment
-
GUI
- Overview
- Options
- Controls
- Topology
-
Agents and Variables
- Overview
- Functions
- Scripting
- Topology
- Traffic
- Attacks
- Analysis
-
Development/Extending
- Overview
- Adding GUI Panels
- Adding Agent Types
Scripting Interface
Any executable program that can inject events into the event system can be executed on the experiment control node directly or via the GUI to script the experiment. By default, the current backend provides a python interface that you can use to write scripts that will inject events. The basic program will look like the following.
#!/usr/bin/python import sys sys.path.append('/usr/seer/backend') import scripts scripts.openConnection() myagent = scripts.Agent('HTTP', 'web2B') myagent.Set({'NODES': 'net1 net4', 'servers': 'net3', 'think': 'minmax(0.1, 0.9)', 'sizes': 'pareto(1.4, 5000, 200000)' }) myagent.Start() # do other things, other agent work, sleep, etc myagent.Stop() scripts.closeConnection()
The above script is the same as the following from withing the GUI
- Selecting Web
- Selecting New Group and entering a name of 'web2B'
- Clicking Clients and selecting net1 and net4
- Clicking Servers and selecting net3
- Clicking Thinking Time and selecting minmax, 0.1, 0.9
- Clicking File Sizes and selecting pareto, 1.4, 5000, 200000
- Clicking Set
- Clicking Start
- Clicking Stop
The scripts import is what takes care of most of the details for you. When executed on the control node, you can simply call scripts.openConnection() without any extra arguments.
- scripts.openConnection() will create a connection to the event system and a thread for sending/receiving events
- scripts.Agent() creates a local object with a type and group values
- The Agent methods Set(), Start(), Stop(), and sendEvent() will cause events to be sent to the associated type and group
- scripts.closeConnection() makes sure all the events are sent and then stops the sending thread
You can create loops with different variables, sleep times, list of agents for calling the Start and Stop methods on, etc. Basically, anything you want to do in python. You have agent objects with methods that cause events to be sent to the specified agent groups in the experiment.
Tip
agent variables that are not marked with (g) [group variable only] may be prepended with 'node.' to set the variable on node only
e.g. (n1.var => 10, var => 20)
will cause var to be read as 20 by the agent on all nodes
except n1 where it will be 10
