x
1
BEGIN
2
Declare score int;
3
Declare result int;
4
Declare Total int;
5
6
Declare Totalscore int Default 0 ;
7
Declare Totalresult int Default 0 ;
8
Declare TotalTotal int Default 0 ;
9
10
11
SELECT IFNULL(SUM(IF(h_computerstatsdaily.MEM<MemoryLimit,1*(MemoryWeight*.01),0))+
12
SUM(IF(h_computerstatsdaily.CPU>CPULimit,1*(CPUWeight*.01),0)),0) As Result,
13
IFNULL((Count(*) * (1*(MemoryWeight *.01)))+
14
(Count(*) * (1*(CPUWeight *.01))),1) as Total,
15
1 as PerfScore
16
FROM managementScore,h_computerstatsdaily Join Computers Using (ComputerID) Where h_computerstatsdaily.EventDate=DATE(DATE_ADD(CURDATE(),interval -1 day)) and Computers.ClientID=CID into @result,@total,@score;
17
18
set @TotalTotal = @Total;
19
set @Totalresult = @Total-@result;
20
21
SELECT IFNULL(SUM(IF(h_DriveStatsDaily.Free<DriveSpaceLevel,1*(DriveSpaceWeight *.01),0))+
22
SUM(IF(h_DriveStatsDaily.Frag>DriveFragLevel,1*(DriveFragWeight*.01),0)),0) As Result,
23
IFNULL((Count(*) * (1*(DriveSpaceWeight *.01)))+
24
(Count(*) * (1*(DriveFragWeight*.01))),1) as Total,1 as DriveScore
25
FROM managementScore,h_DriveStatsDaily Join Drives Using (DriveID) Join Computers Using (ComputerID) Where h_DrivestatsDaily.EventDate=DATE(DATE_ADD(CURDATE(),interval -1 day)) and Computers.ClientID=CID into @result,@total,@score;
26
27
set @TotalTotal = @TotalTotal + @Total;
28
set @Totalresult = @Totalresult + (@Total-@result);
29
30
SELECT IFNULL((SUM(not h_stats.VirusScanEnabled) * (VirusDisabledWeight *.01)) +
31
(SUM(not h_stats.VirusScanUpToDate)*(VirusOutDateWeight*.01)) +
32
(SUM(h_stats.VirusScanMissing)*(VirusMissingWeight*.01)),0) as Result,IFNULL((Count(*) * (VirusDisabledWeight *.01)) +
33
(Count(*)*(VirusOutDateWeight*.01)) +
34
(Count(*)*(VirusMissingWeight*.01)),1) as Total,
35
1 as VirusScore
36
FROM managementScore,h_stats Join Computers Using (ComputerID) Where h_stats.StatDate>DATE_ADD(NOW(),interval -1 day) and Computers.ClientID=CID into @result,@total,@score;
37
38
set @TotalTotal = @TotalTotal + @Total;
39
set @Totalresult = @Totalresult + (@Total-@result);
40
41
SELECT IFNULL(SUM(IF(h_stats.EventLogSystemErrors>EventLogSystemCount,1*(EventLogSystemWeight*.01),0))+
42
SUM(IF(h_stats.EventLogSecurityErrors>EventLogSecurityCount,1*(EventLogSecurityWeight*.01),0))+
43
SUM(IF(h_stats.EventLogApplicationErrors>EventLogAppCount,1*(EventLogAppWeight*.01),0)),0) As Result,
44
IFNULL((1*(EventLogSystemWeight*.01))+(1*(EventLogSecurityWeight*.01))+(1*(EventLogAppWeight*.01)),1) as total,
45
1 as EventScore
46
FROM managementScore,h_stats Join Computers Using (ComputerID) Where h_stats.StatDate>DATE_ADD(NOW(),interval -1 day) and Computers.ClientID=CID into @result,@total,@score;
47
48
set @TotalTotal = @TotalTotal + @Total;
49
set @Totalresult = @Totalresult + (@Total-@result);
50
51
Select IFNULL((Count(*)*(1*(OSBadWeight*.01)))+(Count(*)*(1*(OSWarningWeight*.01))),1) as Total,IFNULL((SUM(IF(OS like stringsplit(OSBadList,',',1) or OS like stringsplit(OSBadList,',',2) or OS like stringsplit(OSBadList,',',3),1*(OSBadWeight*.01),0)))+(SUM(IF(OS like stringsplit(OSWarningList,',',1) or stringsplit(OSWarningList,',',2) or stringsplit(OSWarningList,',',3),1*(OSWarningWeight*.01),0))),0) as Result,
52
100 as OSScore
53
From Computers,ManagementScore Where Computers.ClientID=CID into @total,@result,@score;
54
55
set @TotalTotal = @TotalTotal + @Total;
56
set @Totalresult = @Totalresult + (@Total-@result);
57
58
SELECT IFNULL(Count(*),1) as Total,
59
IFNULL(SUM( NoneMissing )+(SUM(Missing1to2)*(PatchMissing12Weight*.01))+(
60
SUM(Missing3to5)*(PatchMissing35Weight*.01))+(
61
SUM(Missing5)*(PatchMissing6Weight*.01)),0) as Result,
62
100 as PatchScore
63
from v_Patch,managementscore where ClientID=CID into @total,@result,@score;
64
65
set @TotalTotal = @TotalTotal + @Total;
66
set @Totalresult = @Totalresult + (@Total-@result);
67
68
SELECT IFNULL(Count(*),1) as Total,IFNULL((SUM(IF(Status=1 and TimestampDiff(hour,StartedDate,NOW())>TicketNewAgeLimit,1*(TicketNewAgeWeight*.01),0)))+ (SUM(IF(Status=2 and TimestampDiff(hour,StartedDate,NOW())>TicketOpenAgeLimit,1*(TicketOpenWeight*.01),0))),0) as Result,
69
1 as TicketScore
70
from tickets,managementscore Where ClientID=CID into @total,@result,@score;
71
72
set @TotalTotal = @TotalTotal + @Total;
73
set @Totalresult = @Totalresult + (@Total-@result);
74
75
Select IFNULL(MAX(Reliablity),100) From AgentComputerData Join Computers Using (ComputerID),managementscore Where Computers.ClientID=CID into @result;
76
77
set @TotalTotal = @TotalTotal + 100;
78
set @Totalresult = @Totalresult + @result;
79
80
Set @TotalScore = 100*(@TotalResult/@TotalTotal) ;
81
82
83
return @TotalScore ;
84
END