New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

300.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

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

 

Top Tags


View all Tags


Custom SQL Script issue

Votes:

0

Your Vote:

Up

Down

Hi there I want PRTG to run this Script and respond with OK if there is 0 and Error if there is 1 or more

SELECT
db.name DBName,
tl.request_session_id,
wt.blocking_session_id,
OBJECT_NAME(p.OBJECT_ID) BlockedObjectName,
tl.resource_type,
h1.TEXT AS RequestingText,
h2.TEXT AS BlockingTest,
tl.request_mode
FROM sys.dm_tran_locks AS tl
INNER JOIN sys.databases db ON db.database_id =tl.resource_database_id
INNER JOIN sys.dm_os_waiting_tasks AS wt ON tl.lock_owner_address =wt.resource_address
INNER JOIN sys.partitions AS p ON p.hobt_id =tl.resource_associated_entity_id
INNER JOIN sys.dm_exec_connections ec1 ON ec1.session_id =tl.request_session_id
INNER JOIN sys.dm_exec_connections ec2 ON ec2.session_id =wt.blocking_session_id
CROSS APPLY sys.dm_exec_sql_text(ec1.most_recent_sql_handle) AS h1
CROSS APPLY sys.dm_exec_sql_text(ec2.most_recent_sql_handle) AS h2
GO

when I set it up and run it in PRTG I get the error of Invalid Syntax near go when i run the script in SQL Manager it works fine

Please advise thanks Ash

custom-sensor script sql

Created on May 16, 2016 2:15:52 PM by  Ashley Nicholas (50) 1 1

Last change on May 17, 2016 1:47:02 PM by  Stephan Linke [Paessler Support]



3 Replies

Votes:

0

Your Vote:

Up

Down

Would it be possible to migrate this into a stored procedure (so that PRTG only checks the result table)? It may be the cross apply commands, although I'm not sure.. :) What happens when you remove the GO statement at the end?

Created on May 17, 2016 1:46:42 PM by  Stephan Linke [Paessler Support]

Last change on May 17, 2016 1:47:25 PM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hi there If I take the GO statement away, it errors out in PRTG with no Valid Database Returned Although it still works in SQL Does PRTG have issues with GO Statements?

Thanks Ash

Created on May 18, 2016 8:45:48 AM by  Ashley Nicholas (50) 1 1



Votes:

0

Your Vote:

Up

Down

It was just an assumption...what's the actual result of the query? Screenshot will do as well.

Created on May 18, 2016 9:18:27 AM by  Stephan Linke [Paessler Support]



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.