forked from covenanttechnologysolutions/labtech-sql-library
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGetUnusedGroups.sql
More file actions
40 lines (31 loc) · 1.24 KB
/
GetUnusedGroups.sql
File metadata and controls
40 lines (31 loc) · 1.24 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
/*
Description : Get a quick list of unused groups.
Source URL : http://github.com/jesseconnr/labtech-sql-library
Tested Versions :
MySQL 5.7
LabTech 11.0
Table Aliases :
Groups - mastergroups
*/
SELECT @GROUP_COUNT := (COUNT(*) * 5) FROM mastergroups;
SET SESSION GROUP_CONCAT_MAX_LEN = @GROUP_COUNT;
SELECT @SAFE_GROUPS := GROUP_CONCAT(DISTINCT(mastergroups.GroupID))
FROM mastergroups
WHERE
(mastergroups.FullName LIKE '_System Automation%'
OR mastergroups.FullName LIKE 'All Agents'
OR mastergroups.FullName LIKE 'All Clients%'
OR mastergroups.FullName LIKE 'Agent Types%'
OR mastergroups.FullName LIKE 'Patching%'
OR mastergroups.FullName LIKE 'Network Devices%'
OR mastergroups.FullName LIKE 'Windows Updates%'
OR mastergroups.FullName LIKE '__SF - %'); # custom groups
SELECT
Groups.GroupId AS `GroupId`,
Groups.FullName AS `FullName`,
IFNULL(Searches.Name, '') AS `AutoJoinScript`,
Groups.LimitToParent AS `LimitToParent`
FROM `mastergroups` AS Groups
LEFT JOIN `sensorchecks` AS Searches ON Groups.AutoJoinScript = Searches.SensID
WHERE (find_in_set(Groups.GroupId, @SAFE_GROUPS) <= 0)
ORDER BY Groups.FullName ASC;