RHQ CLI alert scripts

Ken Rumer kenrumer at gmail.com
Thu Mar 28 18:17:31 UTC 2013


I'm seeing different results in CLI scripts depending on if I run them from
the CLI or the alert kicks them off.  A simple example is here:

---CLI---------------------
var tomcatServer = ProxyFactory.getResource(14008);
tomcatServer;
#ResourceClientProxy_$$_javassist_0:
#                         availability: ?
#                             children:
#                         contentTypes: {}
#                          createdDate: Mon Mar 18 13:42:11 PDT 2013
#                          description: Tomcat Web Application Server
(tstcdemo3)
#                              handler:
org.rhq.bindings.client.ResourceClientProxy$ClientProxyMethodHandler at d751189
#                                   id: 14008
#                         measurements: [Server Identifier, Availability]
#                         modifiedDate: Mon Mar 18 13:42:11 PDT 2013
#                                 name: Tomcat (8080)
#                           operations: [restart, start,
storeConfiguration, shutdown]
#                  pluginConfiguration:
#        pluginConfigurationDefinition: ConfigurationDefinition[id=10314,
name=Tomcat Server]
#                         resourceType: Tomcat Server
#                     serverIdentifier: ?
#                              version: 7.0.37.0
tomcatServer.restart(); // This works like a charm
---CLI Alert--(tomcat.restart.js)---
  var myResource = ProxyFactory.getResource(
alert.alertDefinition.resource.id);
  var e = exporter;
  e.setTarget('raw', '/local/mnt/workspace/tomcat.restart.out');
  e.write(myResource);
  myResource.restart();
---CLI Alert output----------
Ran script tomcat.restart.js in version rhqadmin: 1.0 from repo
cli.remediation as user rhqadmin.
javax.script.ScriptException:org.mozilla.javascript.EcmaError: TypeError:
Cannot find function restart in object [14008] Tomcat (8080) (Tomcat
Server::Tomcat). (#9) in at line number 9 in script tomcat.restart.js
(rhqadmin: 1.0) in repo cli.remediation at line number 9
---exporter output-----------
cat tomcat.restart.out
#ResourceClientProxy:
#                  id: 14008
#                name: Tomcat (8080)
#             version: 7.0.37.0
#        resourceType: Tomcat Server
#            children:
#        contentTypes: {}
#         createdDate: Mon Mar 18 13:42:11 PDT 2013
#         description: Tomcat Web Application Server (tstcdemo3)
#        measurements: [Server Identifier, Availability]
#        modifiedDate: Mon Mar 18 13:42:11 PDT 2013
#          operations: [restart, start, storeConfiguration, shutdown]




Why is the object different in CLI vs export output?
"ResourceClientProxy_$$_javassist_0" vs "ResourceClientProxy"

If there's a better way to do this, let me know!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.fedorahosted.org/pipermail/rhq-devel/attachments/20130328/15ba700a/attachment.html>


More information about the rhq-devel mailing list