Red Hat Training
A Red Hat training course is available for Red Hat JBoss Operations Network
18.6. Getting Inventory and Status Information: status.js
This is a simple little script, just to print the current status of all the JBoss instances in the group.
As with the other scripts, set up the group information.
function usage() { println("Usage: status groupName"); throw "Illegal arguments"; } if( args.length < 1 ) usage(); var groupName = args[0]; groupcriteria = new ResourceGroupCriteria(); groupcriteria.addFilterName(groupName); var groups = ResourceGroupManager.findResourceGroupsByCriteria(groupcriteria); if( groups != null ) { if( groups.size() > 1 ) { println("Found more than one group."); } else if( groups.size() == 1 ) { group = groups.get(0); } }
Also include information to search for the resources, based on the group:
criteria = new ResourceCriteria(); var groupArray= new Array(); groupArray[0]=group.id; criteria.addFilterExplicitGroupIds(groupArray); var resources = ResourceManager.findResourcesByCriteria(criteria); for( i =0; i < resources.size(); ++i) { var resource = resources.get(i); println(" found " + resource.name ); }
Then, run through the resources and print their availability.
var server = ProxyFactory.getResource(resource.id); var avail = AvailabilityManager.getCurrentAvailabilityForResource(server.id); println(" " + server.name ); println(" - Availability: " + avail.availabilityType.getName()); println(" - Started : " + avail.startTime.toGMTString()); println(""); var avail = AvailabilityManager.getCurrentAvailabilityForResource(server.id); if( avail.availabilityType.toString() == "DOWN" ) { println(" Server is DOWN. Please first start the server and run this script again!"); println(""); }
When the script is run, it prints the availability and last start time for the servers.
[jsmith@server cli]$ ./wrapper.sh status myGroup Remote server version is: 3.0.1.GA (b2cb23b:859b914) Login successful found AS server.example.com JBossAS App 1 AS server.example.com JBossAS App 1 - Availability: UP - Started : 11 Feb 2012 04:07:37 GMT