VMware Cloud Community
sadeMan
Contributor
Contributor

Writing Script Plugins

I was wondering if anyone can help with writing script plugins? I am testing out this plugin type and wrote a generic script just to get some data from the agents operating system. The key=values output is like this:
(vb script)
Wscript.Echo "name=" & objItem.Name
Wscript.Echo "prq=" & objItem.PercentRegistryQuotaInUse
Wscript.Echo "prcs=" & objItem.Processes
Wscript.Echo "pql=" & objItem.ProcessorQueueLength
Wscript.Echo "sc/s=" & objItem.SystemCallsPersec
Wscript.Echo "systm=" & objItem.SystemUpTime
Wscript.Echo "trds=" & objItem.Threads

So then I have a plugin written to get this data from the script.
Here is part of the plugin:
<metric name="Availability"
template="${template}:Availability"
indicator="true"/>

<metric name="Processes"
category="PERFORMANCE"
indicator="true"
template="${template}:prcs"/>

<metric name="System Uptime"
category="PERFORMANCE"
indicator="true"
template="${template}:systm"/>

<metric name="Threads"
category="PERFORMANCE"
indicator="true"
template="${template}:trds"/>

Now the availability does show up but the other metrics do not show up. I think the key names in the script and the plugin need to be the same. I do not know if I am doing something wrong with that naming or what? Can anyone give me a clue.

Thanks,
Brian
0 Kudos
5 Replies
deeboh
Enthusiast
Enthusiast

Interesting that you used vbscript(presumably on a windows box:) ). I too tried to create a script plugin using perl and got nearly the same results. I have yet to discover my problem, but I did notice some pretty nasty stack traces in both the agent and server log files. I wrote my script in perl for a solaris 10 server.

did you place your plugin.xml in both the sever and agent plugin directories?

hoping someone finds an answer for us both.

good luck,

Deeboh
0 Kudos
staceyeschneide
Hot Shot
Hot Shot

I don't have an answer for you - but I can suggest that you post scripting plugin questions in the developer forum - that way the right engineers and people on the lists are paying attention. I'll pass it over to an engineer though in case they missed it on the user forum.
0 Kudos
scottmf
Enthusiast
Enthusiast

Hi,
How is your template defined?

You need something like this:
template="exec:timeout=%timeout%,file=${script}:${alias}"

Also, here is a quick way to test your plugin from the command line:

java -jar pdk/lib/hq-product.jar -Dplugins.include=<plugin name> -Dlog=debug
0 Kudos
sadeMan
Contributor
Contributor

This is how my template is definedin my plugin:
<filter name="template"
value="exec:file=%script%,args=%scriptArg%"/>
where script is defined as the path to the script.
and scriptArg is the argument passed to the script.

You have exec:timeout, what does that do?

Also when I run the plugin in the command line what should it do?

Message was edited by: sadeMan
0 Kudos
scottmf
Enthusiast
Enthusiast

The timeout just specifies when to interrupt the script. It is not really needed, the default is something like 2 mins, but nice to explicitly define.

For the output of the script, this is how you want to structure it:

(based on this xml metadata)
<filter name="template">
exec:timeout=%timeout%,file=${script},args=-p '%arg%':${alias}
</filter>
<metric name="Metric"
alias="metric"
category="AVAILABILITY"
units="percentage"
indicator="true"
collectionType="dynamic"/>

$ script.pl
metric=.87

another example:

<filter name="template">
exec:timeout=%timeout%,file=${script},args=-p '%arg%':foo.${alias}
</filter>
<metric name="Metric"
alias="metric2"
category="AVAILABILITY"
units="MB"
indicator="true"
collectionType="dynamic"/>

$ script.pl
foo.metric2=8192
0 Kudos