Other Script Examples

In this section:

The scripts described in this section can be executed as a task or from the file browser. They do not require a parameter to be set.


Top of page

x
Server Import

The following example creates an array of servers and upserts them into iWay Sentinel. The script also checks to see if an admin requested to stop the script and sets the progress while it is running.

var servers = [
    {
name:"localhost",
description:"a default description for an installed server on your localhost",
url:"http://localhost:9001", 
username:"admin", 
password:"admin",
hostUsername:"hostadmin",
hostPassword:"hostadmin"
     },
];
var step = 100 / servers.length;
for(index in servers)
{
if($("#").stop) break;
	$("#").progress += step;
	$(".server").upsert(servers[index]);
logger.info("upserted "+servers[index]);
}

Top of page

x
Turn On Debug by Group

The following example creates a group called my servers containing all servers and upserts it into iWay Sentinel. Then the scripts gets the group, iterates through its servers and changes the debug configuration to true if the status of the server is UP and its Health is either POOR or SEVERE. Notice the Status.UP, Health.POOR and Health.SEVERE objects. The package is imported in which these objects reside and is used to check the status of the server.

importClass(com.ibi.spog.models.Status);
importClass(com.ibi.spog.models.Health);
var servers = $(".server").list();
var group =  { name:"my servers",  description:"All Servers", servers : [ ] }
for(index in servers) group.servers.push(servers[index]);
$(".group").upsert(group);
var servers = $(".group").get("my servers").servers;
var step = 100 / servers.length;
for(index in servers)
{
	if($("#").stop)   break;
	$("#").progress += step;
	if(servers[index].status == Status.UP && 
    (servers[index].health == Health.POOR || servers[index].health == Health.SEVERE))
	{
		$(".server").property(servers[index].id, "config.debug", "true");
	}
}

Top of page

x
Increase Throughput

The following example tries to increase throughput by increasing the number of worker threads for channels that have a max throughput below 0.5 messages per second.

$("#").log("Checking throughput");
var servers = $(".group").get("my servers").servers;
var step = 100 / servers.length;
for(i in servers)
{
	if($("#").stop) break;
	$("#").progress += step;
	var apps = $(".server").applications(servers[i].name);
	for(j in apps)
	{
		var channels = apps[j].channels(servers[i].name, apps[j].name);
		for(k in channels)
		{
			if(channels[k].maxThroughput < 0.5)
			{
				$(".channel").property(
						servers[i].name, 
						apps[j].name, 
						channels[k].name, 
						"config.count", 
						"2");
			}
		}
	}
}

iWay Software