What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Mutiple channel with vbscript

Votes:

0

I use vbscript and my code is that:

strComputer = "127.0.0.1"

' Leave User and Password blank for local machine

strUser = ""
strPassword = ""

strNamespace = "root/cimv2"

Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objLocator.ConnectServer(strComputer,strNamespace,strUser,strPassword)
Set objTimeZone = objWMIService.ExecQuery ("SELECT * FROM Win32_TimeZone")

For Each colTimeZone in objTimeZone
  strBias = colTimeZone.Bias
  strStandardname = colTimeZone.Standardname
Next
wscript.echo "<?xml version=""1.0"" encoding=""UTF-8"" ?>"
wscript.echo "<prtg>"
wscript.echo "<result>"
wscript.echo "<channle>" & strBias & "</channel>"
wscript.echo "<value>test123</value>"
wscript.echo "</result>"
wscript.echo "<result>"
wscript.echo "<channle>" & strStandardname & "</channel>"
wscript.echo "<value>test234</value>"
wscript.echo "</result></prtg>" 
wscript.quit("0")

but it return error, the error message is

"Response not wellformed: "(<?xml version="1.0" encoding="UTF-8" ?> <prtg> <result> <channle>-480</channel> <value>test123</value> </result> <result> <channle>Pacific Standard Time</channel> <value>test234</value> </result></prtg> )" (code: PE132)"

what wrong with my code?

channel custom-sensor vbscript

Created on Jul 15, 2016 1:43:38 AM

Last change on Jul 15, 2016 6:47:52 AM by  Luciano Lingnau [Paessler]



2 Replies

Accepted Answer

Votes:

0

Hello a23554,
thank you for your Knowledge base Post.

There are two issues in the output of your script, please check (I've formatted the output accordingly for increased legibility):

<?xml version="1.0" encoding="UTF-8" ?>
<prtg>
	<result>
		<channle>-480</channel>
		<value>test123</value>
	</result>
	<result>
		<channle>Pacific Standard Time</channel>
		<value>test234</value>
	</result>
</prtg>
  • The </channel> tag is misspelled as <channle>.
  • The content of the <value> tag MUST be numerical, 123 would be OK but test123 is a String and will cause error PE132 as well..

For more information, see PRTG Manual: Custom Sensors



Best Regards,
Luciano Lingnau [Paessler Support]

Created on Jul 15, 2016 7:47:53 AM by  Luciano Lingnau [Paessler]

Last change on Jul 30, 2018 9:52:06 AM by  Brandy Greger [Paessler Support]



Votes:

0

Alternative you could use the WMI sensors with custom strings or custom numeric values to accomplish the same and not having a specific VBscript wrapped around it.

If you want to have text in your output, there is a <text> tag available for XML - but be aware - the text is not per result, it is a per script tag - so only one text-output in your whole XML response.

You further have some kind of a flaw in your VBscript here:

For Each colTimeZone in objTimeZone
  strBias = colTimeZone.Bias
  strStandardname = colTimeZone.Standardname
Next

This will run through all objTimeZone objects / I am not clear if there is a possible collection - but if there is - so more then one "row" in your WMI query, you would only see the final result / row data.

Depending on what you want to accomplish, you might need to adjust this - cause every colTimeZone will overwrite your values in strBias and strStandardname.

Regards

Florian Rossmark

www.it-admins.com

Created on Jul 30, 2018 3:23:48 PM




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.