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

Mutualize Powershell for custom sensors

Votes:

0

Hi I swear I had been looking for an answer on this KB but could not find any.

The idea is that each time I run a powershell script it takes (a long) time to execute. The script by itself takes 15 to 18 ms but when I run it from command line it executes in no less than 500ms. At a client's with many sensors time increases up to 1000 mseconds.

  1. Is there any mean to "pre-launch" Powershell under PRTG to make it ready to execute all scripts.
  2. Another approach could be to have a single script doing the query for all sensors, but the question is now how to spread the results in the respective sensors
  3. Is it a silly question?

custom-sensor exe-script-sensor powershell

Created on May 2, 2016 1:53:54 PM

Last change on May 3, 2016 9:33:25 AM by  Luciano Lingnau [Paessler]



2 Replies

Votes:

0

Hello dgiraud,
thank you for your post.

I'll answer your questions in reverse because I want to start with the last one:

3. "There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand the world. There is no such thing as a (silly) question". -Carl Sagan

2. There are actually a couple of approaches to this, I will list some of them that should apply in your case:

  • Run the script as one (or multiple) windows task(s) and write all results to disk on the probe, then use a small(er) Powershell EXE/Script Advanced Sensor to simply "read" the XML file(which will be very fast), similar to what is explained here. For multiple scripts, save the outputs as "sensor_123456.txt" (or device_123456) and then either supply %sensorid or %deviceid as a parameter to the sensor that reads the file from disk.
  • Run the scripts either on the PRTG Probe or on the Monitored Device(s) and write the XML result somewhere where it can be read with the HTTP Data Advanced Sensor. This is a very advisable approach because it completely removes the overhead for custom Exe/Script sensors.
  • Run the scripts as windows tasks directly on the "monitored device" and PUSH the results into PRTG using HTTP with the HTTP Push Data Advanced Sensor as described here.

1. Due to the way that the scheduler (which balances monitoring requests) within the PRTG Probe works this is not something that would be easily implemented and as there are several alternatives something that we're not considering at the moment.

Best Regards,

Created on May 3, 2016 9:52:20 AM by  Luciano Lingnau [Paessler]

Last change on May 3, 2016 9:53:07 AM by  Luciano Lingnau [Paessler]



Votes:

0

Thank you so much for your exhaustive answer
Some explanations about my question and why I can neither use HTTP Data Advanced sensor or run the script from the device
It is a custom application and we agreed on a protocol (kind of telnet based) with the developer because they are specialized devices we cannot touch The result yields several fields (Status and client version) wich I parse in PS to provide PRTG an error code and a message:
"Active - Version client 2.3.7.19339"

I had in mind to report all installed versions in the future to simplify update planning (this is another topic and I'll check the API before asking here how to) I found it simpler to make a PS script while keeping in mind that I may have got to make a small exe which is quite simple (only read a socket and parse an xml)

About point 3: Thank you for the nice quote

Created on May 10, 2016 9:52:06 AM

Last change on May 10, 2016 10:35:44 AM by  Luciano Lingnau [Paessler]




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.