Search 97,742 posts and 786 resources contributed by 57,092 members or post a topic.

Already Joined? Sign in
Report Writer - Custom SQL

Page 2 of 2 (20 items) < Previous 1 2 | RSS

rated by 0 users
Answered (Not Verified) This post has 0 verified answers | 19 Replies | 5 Followers | 2,476 Views


22 Posts
Points 58
pchaves replied on Wed, Jan 7 2009 3:40 PM
rated by 0 users

I'm looking for some help with a custom sql report I'm trying to setup.

I wanted to run my custom sql report on the 1st of every month and have it compile data from the previous month (or even previous 30 days). Does anyone happen to know how I could call out the previous month in the code?

I know there is an option for this in the basic option but I had to customize a few things for this report.

Thanks in advance! 

  • | Post Points: 5

All Replies


22 Posts
Points 58
pchaves replied on Tue, Jan 13 2009 11:57 AM
rated by 0 users

Sure, no problem. Here is what I have.

 

SELECT  TOP 10000 Nodes.Caption AS NodeName,
Interfaces.Caption AS Interface_Caption,
AVG(Case InBandwidth
    When 0 Then 0
    Else (In_Averagebps/InBandwidth) * 100
End) AS AVERAGE_of_Recv_Percent_Utilization,
MAX(Case InBandwidth
    When 0 Then 0
    Else (In_Averagebps/InBandwidth) * 100
End) AS MAX_of_Recv_Percent_Utilization,
AVG(Case OutBandwidth
    When 0 Then 0
    Else (Out_Averagebps/OutBandwidth) * 100
End) AS AVERAGE_of_Xmit_Percent_Utilization,
MAX(Case OutBandwidth
    When 0 Then 0
    Else (Out_Averagebps/OutBandwidth) * 100
End) AS MAX_of_Xmit_Percent_Utilization

FROM
(Nodes INNER JOIN Interfaces ON (Nodes.NodeID = Interfaces.NodeID))  INNER JOIN InterfaceTraffic ON (Interfaces.InterfaceID = InterfaceTraffic.InterfaceID)


WHERE
DateTime between  (DATEADD(m, DATEDIFF(m, 0, getdate()) -1 , 0)) AND (DATEADD(m, DATEDIFF(m, 0, getdate()) , 0))
 AND 
(
(Nodes.Caption LIKE '%RI-NCC-2811%') AND
  (Interfaces.InterfaceName = 'Serial0/0/1') OR 
(Interfaces.Caption LIKE '%Qwest%') OR
  (Interfaces.Caption LIKE '%COX-20MB%') OR
  (Interfaces.Caption LIKE '%One-Communications%') OR
  (Interfaces.Caption LIKE '%Verizon-ISP%') OR
(Nodes.Caption LIKE '%Cov2-3745-WAN%') AND
  (Interfaces.InterfaceName = 'Multilink1') OR
(Nodes.Caption LIKE '%East-Greenwich-Warehouse%') AND
  (Interfaces.InterfaceName = 'Serial1/0') OR
(Nodes.Caption LIKE '%PVD-7200%') AND
  (Interfaces.InterfaceName = 'GigabitEthernet0/1') OR
(Nodes.Caption LIKE '%PVD-7200%') AND
  (Interfaces.InterfaceName = 'GigabitEthernet0/2')

 AND

(DATEPART(weekday, DateTime) <> 7)AND
(DATEPART(weekday, DateTime) <> 1) AND
(CONVERT(Char, DateTime, 108) > '0800') AND
(CONVERT(Char, DateTime, 108) < '1700')

)

GROUP BY Nodes.Caption, Interfaces.Caption

 

Thanks again!

  • | Post Points: 3

292 Posts
Points 1,747
Alert Guru
sedmo replied on Tue, Jan 13 2009 2:30 PM
rated by 0 users

I think you have some problems with the groupings in your where statement.  Try this.

 

SELECT  TOP 10000 Nodes.Caption AS NodeName,
Interfaces.Caption AS Interface_Caption,
AVG(Case InBandwidth
    When 0 Then 0
    Else (In_Averagebps/InBandwidth) * 100
End) AS AVERAGE_of_Recv_Percent_Utilization,
MAX(Case InBandwidth
    When 0 Then 0
    Else (In_Averagebps/InBandwidth) * 100
End) AS MAX_of_Recv_Percent_Utilization,
AVG(Case OutBandwidth
    When 0 Then 0
    Else (Out_Averagebps/OutBandwidth) * 100
End) AS AVERAGE_of_Xmit_Percent_Utilization,
MAX(Case OutBandwidth
    When 0 Then 0
    Else (Out_Averagebps/OutBandwidth) * 100
End) AS MAX_of_Xmit_Percent_Utilization

FROM
(Nodes INNER JOIN Interfaces ON (Nodes.NodeID = Interfaces.NodeID))  INNER JOIN InterfaceTraffic ON (Interfaces.InterfaceID = InterfaceTraffic.InterfaceID)


WHERE
DateTime between  (DATEADD(m, DATEDIFF(m, 0, getdate()) -1 , 0)) AND (DATEADD(m, DATEDIFF(m, 0, getdate()) , 0))
 AND
(
 (Nodes.Caption like '%RI-NCC-2811%' and
  (Interfaces.InterfaceName = 'Serial0/0/1' or
  Interfaces.Caption like '%Qwest%' or
  Interfaces.Caption like '%COX-20MB%' or
  Interfaces.Caption like '%One-Communications%' or
  Interfaces.Caption like '%Verizon-ISP%')
 )
or
 (Nodes.Caption like '%Cov2-3745-WAN%' and
  (Interfaces.InterfaceName = 'Multilink1')
 )
or
 (Nodes.Caption LIKE '%East-Greenwich-Warehouse%' and
  (Interfaces.InterfaceName = 'Serial1/0')
 )
or
 (Nodes.Caption LIKE '%PVD-7200%' and
  (Interfaces.InterfaceName = 'GigabitEthernet0/1' or
   Interfaces.InterfaceName = 'GigabitEthernet0/2')
 )
)
AND
(
(DATEPART(weekday, DateTime) <> 7)AND
(DATEPART(weekday, DateTime) <> 1) AND
(CONVERT(Char, DateTime, 108) > '0700') AND
(CONVERT(Char, DateTime, 108) < '1700')
)

GROUP BY Nodes.Caption, Interfaces.Caption

  • | Post Points: 3

22 Posts
Points 58
pchaves replied on Tue, Jan 13 2009 2:41 PM
rated by 0 users

That seems to give me the correct timeframe but now it's ignoring the first section of nodes and interfaces (from RI-NCC-2811 to Verizon-ISP), only giving information fro the last three....

 

  • | Post Points: 3

292 Posts
Points 1,747
Alert Guru
sedmo replied on Tue, Jan 13 2009 3:21 PM
rated by 0 users

I assumed that those interfaces where on the RI-NCC-2811 device.  If that is not the case then the grouping will need to be modified.  The way it is currently written, the interface has to match one of the five statements below.

caption like RI-NCC-2811 and interfacename = Serial0/0/1

caption like RI-NCC-2811 and interfaces.caption like '%Qwest%'

caption like RI-NCC-2811 and interfaces.caption like '%COX-20MB%'

caption like RI-NCC-2811 and interfaces.caption like '%One-Communications%'

caption like RI-NCC-2811 and interfaces.caption like '%Verizon-ISP%'

 

  • | Post Points: 1

194 Posts
Points 4,956
BakerD replied on Wed, Jan 14 2009 2:33 PM
rated by 0 users

In one of my reports on the Time Frame tab I set it to last 30 days.  Then on the Filter Results tab I have two lines that narrow it down to working hours for me of 8am - 6pm.

 

Records where Time of Day (24 hour format) is less than 08:00

Records where Time of Day (24 hour format) is greater than or equal to 18:00

 

I use this ina filter to give me WAN utilization for the last 30 days during working hours.

  • | Post Points: 1
Page 2 of 2 (20 items) < Previous 1 2 | RSS

© 2003 - 2010 SolarWinds, Inc. All Rights Reserved.

Who is SolarWinds?

SolarWinds is rewriting the rules for how companies manage their networks. Guided by a global community of network engineers, SolarWinds develops simple and powerful network management software and network monitoring software for networks of all sizes. SolarWinds also offers a network certification program to become a SolarWinds Certified Professional (SCP).

What is thwack?

thwack, SolarWinds online community site, was designed by network engineers, for network engineers. thwack is a vibrant, growing community of more than 30,000 IT pros who share a passion for technology.

Explore Resources, Answers, Templates, and Advice

Download Free Networking Tools


Learn More About SolarWinds Products