forked from covenanttechnologysolutions/labtech-sql-library
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGetGroupLevelScheduledScripts.sql
More file actions
59 lines (50 loc) · 2.58 KB
/
GetGroupLevelScheduledScripts.sql
File metadata and controls
59 lines (50 loc) · 2.58 KB
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
/*
Description : Get scheduled scripts for each group in LabTech.
Source URL : http://github.com/jesseconnr/labtech-sql-library
Tested Versions :
MySQL 5.7
LabTech 10.0
Table Aliases :
Groups - mastergroups
ScheduledScripts - groupscripts
Scripts - lt_scripts
Searches - sensorchecks
*/
#todo: combine repeat and schedule columns into single readable columns
SET @group_filter = '5,976,977,978,981,982,983,984,985,986,987,988,989,995,996,1023,1579,1580,1581,1582,1584,1585,1593,1606,1609'; # A set of group ids to filter by.
SELECT
CONCAT_WS(' - ', Groups.GroupID, Groups.Name) AS `GroupName`
, Groups.FullName AS `GroupPath`
, CONCAT_WS(' - ', Scripts.ScriptId, Scripts.ScriptName) AS `ScriptName`
, Searches.Name AS `SearchName`
, ScheduledScripts.SkipOffline
, ScheduledScripts.OfflineOnly
, ScheduledScripts.Priority
, ScheduledScripts.RunScriptonProbe
, ScheduledScripts.Parameters
, ScheduledScripts.Last_Date AS `LastDateRan`
, ScheduledScripts.RunTime AS `NextRunDate`
, CASE
WHEN ScheduledScripts.ScheduleType = 1 THEN 'Once'
WHEN ScheduledScripts.ScheduleType = 2 THEN 'Minute'
WHEN ScheduledScripts.ScheduleType = 3 THEN 'Hourly'
WHEN ScheduledScripts.ScheduleType = 4 THEN 'Daily'
WHEN ScheduledScripts.ScheduleType = 5 THEN 'Weekly'
WHEN ScheduledScripts.ScheduleType = 6 THEN 'Monthly'
END AS `ScheduleType`
, ScheduledScripts.Interval AS `RunEveryXScheduleType`
, CASE
WHEN ScheduledScripts.RepeatType = 0 THEN 'None'
WHEN ScheduledScripts.RepeatType = 1 THEN 'Seconds'
WHEN ScheduledScripts.RepeatType = 2 THEN 'Minutes'
WHEN ScheduledScripts.RepeatType = 3 THEN 'Hours'
END AS `RepeatType`
, ScheduledScripts.RepeatAmount
, ScheduledScripts.RepeatStopAfter AS `StopRepeatAfterXRepetitions`
FROM groupscripts AS `ScheduledScripts`
LEFT JOIN lt_scripts AS `Scripts` ON ScheduledScripts.ScriptID = Scripts.ScriptId
LEFT JOIN mastergroups AS `Groups` ON ScheduledScripts.GroupID = Groups.GroupID
LEFT JOIN sensorchecks AS `Searches` ON ScheduledScripts.SearchID = Searches.SensID
WHERE FIND_IN_SET(Groups.GroupID,@group_filter) > 0
GROUP BY `GroupName`,`ScriptName`
ORDER BY Groups.FullName ASC;