Quantcast
Channel: THWACK: Document List - Network Performance Monitor
Viewing all articles
Browse latest Browse all 1956

NPM CustomPoller SQL script for comparing previous or next record examples (sql 2012+)

$
0
0

HI,

Solarwinds  tech Support does not support this sql script.

But it will work!

Save it to a Report Writer or Custom SQL Web Report...

You will need to modify the Where command..

 

Here is examples showing SQL to allow you to compare value between either previous or next records value in custompoller table.

Again, you must change the where condition to make it work.

-------------------------------------------------------

-- Example 1: show how to display records before and after in table
--
SELECT
--top 1
DateTime,
CustomPollerAssignmentID,

COALESCE(p.RawStatus - (Lead(p.RawStatus) over (order by p.RawStatus desc)),0) AS rawdiff,

-- use next 3 calculated fields for reference * NOT needed *
lag(p.RawStatus) over (order by p.RawStatus desc) PreviousStatus,
p.RawStatus,
Lead(p.RawStatus) over (order by p.RawStatus desc) NextStatus
--

FROM [dbo].[CustomPollerStatistics] p
Where CustomPollerAssignmentID = 'c23ac991-22e8-4df2-a5e9-6836ca84812c'

-------------------------------------------------------

 

 

example 2 - rewritten to show who to use JOIN command

Solarwinds  tech Support does not support this sql script.

But it will work!

Save it to a Report Writer or Custom SQL Web Report...

You will need to modify the Where command..

-- ---------------------------------------------------------

 

-- !SQL Custom Poller - Value - Previous Value Report
SELECT TOP 1
-- *
cpav.CustomPollerName,
n.caption as NodeName,
cps.DateTime,
COALESCE((Lead(cps.DateTime) over (order by cps.DateTime desc)),0) AS ChangefrPrevTime,
rawstatus as CustomPollerValue,
COALESCE(cps.RawStatus - (Lead(cps.RawStatus) over (order by cps.DateTime desc)),0) AS ChangefrPrev

FROM CustomPollerAssignmentView as cpav
inner join NodesData AS n
  on cpav.NodeID = n.NodeID
inner join CustomPollerStatistics as cps
  on cps.CustomPollerAssignmentID  = cpav.CustomPollerAssignmentID
--
where cpav.CustomPollerName ='hrSystemUptime'
--
order by cps.DateTime Desc

 

-- ---------------------------------------------------------


Viewing all articles
Browse latest Browse all 1956

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>