ebailey
Enthusiast
Enthusiast

Need HQU help to setup a mass process monitor

Hi

I noticed that in the new hqu plugin section one can create a mass http monitor and I am hoping that I can use something similar to create a mass process monitor so I don't have to create the process monitor one by one. I cant find any docs regarding how groovy works in regards to existing hq services so I am guessing with my settings - this is what I tried to use to create a process monitor that is is looking for the puppetd process on every server

import org.hyperic.hq.hqu.rendit.util.HQUtil
import org.hyperic.hq.hqu.rendit.helpers.ResourceHelper

def overlord = HQUtil.getOverlord()
def rhelp = new ResourceHelper(overlord)
def resourceType = rhelp.findResourcePrototype('Process')
def group = rhelp.findViewableGroups().find { it.name == 'All Platforms' }

def created = []
group.getResources().each { platform ->
def newService = resourceType.createInstance(platform, "$platform.name Puppet Process Monitor", overlord,
[process.query : State.Name.eq=puppetd])
created << newService
}

created.name

and here is the meat of the error after a very long stack trace

Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, /tmp/gcon22555.tmp: 12: illegal colon after argument expression;
solution: a complex label expression before a colon must be parenthesized @ line 12, column 65.
1 error

It seems that groovy does not like

"[process.query : State.Name.eq=puppetd])"

Any idea what I should use? Thanks!

Ed
0 Kudos
4 Replies
brian_mcdonald
Contributor
Contributor

On Sunday 20 April 2008 5:00 pm, Ed Bailey wrote:
> Hi
>
> I noticed that in the new hqu plugin section one can create a mass http
monitor and I am hoping that I can use something similar to create a mass
process monitor so I don't have to create the process monitor one by one. I
cant find any docs regarding how groovy works in regards to existing hq
services so I am guessing with my settings - this is what I tried to use to
create a process monitor that is is looking for the puppetd process on every
server

I used a method similar to this to mass load a bunch of InetAddress Ping
services.. It was.. well, groovy.

[snip]

> It seems that groovy does not like
>
> "[process.query : State.Name.eq=puppetd])"

I think you need quotes around your string:

[ process.query : "State.Name.eq=puppetd" ]

Brian
--
Brian McDonald, Senior Consultant
The Occam Group of Professional Computers Services Organization
1919 Birchwood
Troy, MI 48083
Office: 248.528.3770 / Fax: 248.528.3573 / Mobile: 614.209.0260

0 Kudos
ebailey
Enthusiast
Enthusiast

I tried your suggestion

import org.hyperic.hq.hqu.rendit.util.HQUtil
import org.hyperic.hq.hqu.rendit.helpers.ResourceHelper

def overlord = HQUtil.getOverlord()
def rhelp = new ResourceHelper(overlord)
def resourceType = rhelp.findResourcePrototype('Process')
def group = rhelp.findViewableGroups().find { it.name == 'All Platforms' }

def created = []
group.getResources().each { platform ->
def newService = resourceType.createInstance(platform, "$platform.name Puppet Process Monitor", overlord,
[process.query : "State.Name.eq=puppetd"])
created << newService
}

and got the following error

Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, /tmp/gcon22895.tmp: 12: illegal colon after argument expression;
solution: a complex label expression before a colon must be parenthesized @ line 12, column 16.
1 error


Tried quotes around "State.Name" as well and no luck. I am going to create a ticket and do some groovy research.

Have you found any docs related to using groovy with services other then http checks?

Thanks

Ed
0 Kudos
admin
Immortal
Immortal

You'll also need to quote the key of that map. Only simple strings
can leave the quotes off.

['process.query' : 'State.Name.eq=puppetd']

-- Jon


On Apr 21, 2008, at 6:30 AM, Brian McDonald wrote:

> On Sunday 20 April 2008 5:00 pm, Ed Bailey wrote:
>> Hi
>>
>> I noticed that in the new hqu plugin section one can create a mass
>> http
> monitor and I am hoping that I can use something similar to create
> a mass
> process monitor so I don't have to create the process monitor one
> by one. I
> cant find any docs regarding how groovy works in regards to
> existing hq
> services so I am guessing with my settings - this is what I tried
> to use to
> create a process monitor that is is looking for the puppetd process
> on every
> server
>
> I used a method similar to this to mass load a bunch of InetAddress
> Ping
> services.. It was.. well, groovy.
>
> [snip]
>
>> It seems that groovy does not like
>>
>> "[process.query : State.Name.eq=puppetd])"
>
> I think you need quotes around your string:
>
> [ process.query : "State.Name.eq=puppetd" ]
>
> Brian
> --
> Brian McDonald, Senior Consultant
> The Occam Group of Professional Computers Services Organization
> 1919 Birchwood
> Troy, MI 48083
> Office: 248.528.3770 / Fax: 248.528.3573 / Mobile: 614.209.0260


0 Kudos
ebailey
Enthusiast
Enthusiast

i did as suggested

import org.hyperic.hq.hqu.rendit.util.HQUtil
import org.hyperic.hq.hqu.rendit.helpers.ResourceHelper

def overlord = HQUtil.getOverlord()
def rhelp = new ResourceHelper(overlord)
def resourceType = rhelp.findResourcePrototype('Process')
def group = rhelp.findViewableGroups().find { it.name == 'All Platforms' }

def created = []
group.getResources().each { platform ->
def newService = resourceType.createInstance(platform, "$platform.name Puppet Process Monitor", overlord,
['process.query' : 'State.Name.eq=puppetd'])
created << newService
}

and now I get the following

java.lang.NullPointerException: Cannot invoke method getResources() on null object
at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77)
at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:757)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:733)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:165)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod0(ScriptBytecodeAdapter.java:193)
at gcon23253.run(gcon23253.tmp:10)

Any ideas?

Is "group.getResources().each { platform ->" the correct way to call the object for 'all platforms?


Message was edited by: ebailey
0 Kudos