forked from Skatterbrainz/CMWT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompstatus1.asp
140 lines (129 loc) · 4.05 KB
/
compstatus1.asp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!-- #include file=_core.asp -->
<%
'-----------------------------------------------------------------------------
' filename....... compstatus1.asp
' lastupdate..... 05/23/2017
' description.... component status summary
'-----------------------------------------------------------------------------
time1 = Timer
FilterFN = CMWT_GET("fn", "")
FilterFV = CMWT_GET("fv", "")
QueryOn = CMWT_GET("qq", "")
SortBy = CMWT_GET("s", "ComponentName")
PageTitle = "Component Status"
PageBackLink = "cmsite.asp"
PageBackName = "Site Hierarchy"
CMWT_NewPage "", "", ""
Sub CMWT_DB_IntTableGrid (rs, Caption, LinkField, LinkQualifier, SortBy)
Dim xrows, xcols, fn, fv, i, rs2
if not (rs.BOF and rs.EOF) then
xrows = rs.RecordCount
xcols = rs.Fields.Count
Response.Write "<h2 class=""tfx"">" & Caption & "</h2>"
Response.Write "<table class=""tfx""><tr>"
for i = 0 to xcols -1
fn = rs.fields(i).name
Select Case Ucase(fn)
Case "QTY","RECS","COUNT","MEMBERS","GROUPCOUNT","COMPUTERS","CLIENTS","COVERAGE":
Response.Write "<td class=""td6 v10 bgGray w80 " & CMWT_DB_ColumnJustify(fn) & """>"
Case Else:
Response.Write "<td class=""td6 v10 bgGray"">"
End Select
Response.Write CMWT_SORTLINK("compstatus1.asp", fn, SortBy) & "</td>"
next
Response.Write "</tr>"
Set rs2 = CreateObject("ADODB.RecordSet")
rs2.CursorLocation = adUseClient
For i = 0 to xcols - 1
rs2.Fields.Append rs.Fields(i).Name, adVarChar, 255
Next
rs2.Open
Do Until rs.EOF
rs2.AddNew
For i = 0 to xcols - 1
rs2.Fields(i).Value = rs.Fields(i).Value
Next
rs2.Update
rs.MoveNext
Loop
rs2.Sort = SortBy
rs2.MoveFirst
Do Until rs2.EOF
if rs2.Fields("Errors").value > 0 Then
Response.Write "<tr class=""bgRed"">"
lqv = "1073741824"
ElseIf rs2.Fields("Warnings").value > 0 Then
Response.Write "<tr class=""bgOrange"">"
lqv = "2147483648"
Else
Response.Write "<tr class=""tr1"">"
End If
For i = 0 to xcols-1
fn = rs2.Fields(i).Name
fv = rs2.Fields(i).Value
If Ucase(LinkField) = Ucase(fn) Then
fv = "<a href=""compstatus2.asp?fn=" & LinkField & "&fv=" & fv & "&lq=" & lqv & _
""" title=""Show Details"">" & fv & "</a>"
End If
Response.Write "<td class=""td6 v10 " & CMWT_DB_ColumnJustify(fn) & """>" & fv & "</td>"
next
rs2.MoveNext
Loop
rs2.Close
Set rs2 = Nothing
Response.Write "<tr>" & _
"<td class=""td6 v10 bgGray"" colspan=""" & xcols+1 & """>" & _
xrows & " rows returned</td></tr></table>"
end if
End Sub
Dim conn, cmd, rs
query = "SELECT " & _
"T1.SiteCode, " & _
"T1.ComponentName, " & _
"T1.MachineName, " & _
"SUM(CASE WHEN T1.Category='ERROR' THEN 1 ELSE 0 END) AS Errors, " & _
"SUM(CASE WHEN T1.Category='WARNING' THEN 1 ELSE 0 END) AS Warnings, " & _
"SUM(CASE WHEN T1.Category='INFO' THEN 1 ELSE 0 END) AS Info " & _
"FROM ( " & _
"SELECT DISTINCT " & _
"com.SiteCode, " & _
"com.ComponentName, " & _
"com.MachineName, " & _
"CASE " & _
"WHEN Severity='-2147483648' THEN 'WARNING' " & _
"WHEN Severity='-1073741824' THEN 'ERROR' " & _
"ELSE 'INFO' " & _
"END AS Category " & _
"FROM " & _
"dbo.v_StatusMessage stat " & _
"JOIN v_ServerComponents com ON " & _
"stat.SiteCode = com.SiteCode " & _
"AND " & _
"stat.MachineName = com.MachineName " & _
"AND " & _
"stat.Component = com.ComponentName " & _
"WHERE " & _
"Time > DATEADD(ss,-240-(24*3600),GetDate()) " & _
"GROUP BY " & _
"com.SiteCode, " & _
"com.MachineName, " & _
"com.ComponentName, " & _
"Severity " & _
") AS T1 " & _
"GROUP BY " & _
"T1.SiteCode, " & _
"T1.ComponentName, " & _
"T1.MachineName " & _
"ORDER BY " & _
"T1.ComponentName"
%>
<!-- #include file="_sm.asp" -->
<!-- #include file="_banner.asp" -->
<%
CMWT_DB_QUERY Application("DSN_CMDB"), query
CMWT_DB_IntTableGrid rs, "", "ComponentName", "", SortBy
CMWT_DB_CLOSE()
CMWT_SHOW_Query()
CMWT_Footer()
Response.Write "</body></html>"
%>