Passing arguments to Groovy Script
Can I pass host properties from the portal into a groovy script?
for example, in the \'\'Access remote servers via SSH session\'\' documentation example, the example code starts:
Line 2. cli = Expect.open(\'\'192.168.211.129\'\', \'\'root\'\', \'\'xxxxxxx\'\')
...
I\'d like to set some host parameters like
myservice.user = user
myservice.pass = 12345
and access them with something like the following:
does some syntax like that exist? if so, where can I read more about it?
Ben_Tucker
Posted 13 years ago·Last reply 13 years ago
2 comments
Heather_Lasher
·13 years agoBen, host properties are split into 2 groups: System properties, and custom properties.rnScreenshot: http://imageshack.us/f/545/sn8u.png/rnSystem properties can be referenced by hostProps.get(system.property) Where property is replaced by the specific property: location, ips, displayname, etc. i.e hostProps.get(system.ips)rn rnCustom properties are usually created with the property.name format. For example: snmp.community, wmi.user, etc; but you can specify the property name any way you like. When referencing the custom property just use the exact name of the property. i.e. hostProps.get(ssh.pass) assuming ssh.pass is specified as a custom property on the host.
Steve_Francis
·13 years agoYes - see http://help.logicmonitor.com/using/datasource/creating-datasources/collectors/script-collector/groovy-support/rnSpecifically :rn