What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

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

Monitoring sql consulting

Votes:

0

Your Vote:

Up

Down

Hi,

I did a sql query and i have to, in the Microsoft power shell. I need that PRTG can read the result of my query. That's my script:

invoke-sqlcmd -query "select campo from DB..tabla where campo = 10" -ServerInstance "192.168.1.1\instancia" -Username user -Password prtg | format-wide

Ande result is:

9899

I need that the PRTG reed that.

custom-sensor powershell sql

Created on Jul 26, 2016 3:30:02 PM by  adix_alex (0) 1

Last change on Jul 27, 2016 12:19:37 PM by  Luciano Lingnau [Paessler]



2 Replies

Votes:

0

Your Vote:

Up

Down

If you have a working powershell script that returns a numerical value and you want to read/use that value with PRTG. There are two API Formats that you can use, regardless of scripting language:

The "XML" output, as exemplified here(output):

            <prtg>
            <result>
            <channel>First channel</channel>
            <value>10</value>
            </result>
            <text>This is the sensors optional text</text>
            </prtg>

The "standard" format, as exemplified here(code):

Write-Host "10:This is the sensors optional text"
exit 0

For more information, see PRTG Manual: Custom Sensors

Please note that if your query provides a numerical result directly, you should also be able to use the built-in SQL v2 sensors: PRTG Manual: Microsoft SQL v2 Sensor

You can find examples for the SQL Sensors here:

Best Regards,
Luciano Lingnau [Paessler Support]

Created on Jul 27, 2016 1:18:41 PM by  Luciano Lingnau [Paessler]

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



Votes:

0

Your Vote:

Up

Down

You actually could just create a SQL-Query script and use the SQL-Sensors to execute the script. This would be way easier then having a PowerShell executing an Invoke-SQLCMD to grab the data - you actually just add to the complexity of the sensor.

Of course - I don't know the whole scenario, but from what you wrote it seems to be a bit complex using PowerShell to execute a SQL query. I did monitoring of database table values to gain statistics and even alerts. You can do a lot using the SQL sensors that execute SQL scripts/queries.

Regards

Florian Rossmark

www.it-admins.com

Created on Jul 30, 2018 3:15:29 PM by  Florian Rossmark (4,369) 4 2



Please log in or register to enter your reply.


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.