
INSERT INTO `Agents` (`Name`,`LocID`,`ClientID`,`ComputerID`,`DriveID`,`CheckAction`,`AlertAction`,`AlertMessage`,`ContactID`,`interval`,`Where`,`What`,`DataOut`,`Comparor`,`DataIn`,`LastScan`,`LastFailed`,`FailCount`,`IDField`,`AlertStyle`,`Changed`,`Last_Date`,`Last_User`,`ReportCategory`,`TicketCategory`,`Flags`,`GUID`,`AgentDefaultGUID`,`WarningCount`,`DeviceId`) Values('CWA - User Adds/Changes','0','0','0','0','0','3','%NAME% %STATUS% on %CLIENTNAME%\\%COMPUTERNAME% at %LOCATIONNAME% for %FIELDNAME% result %RESULT%.!!!%NAME% %STATUS% on %CLIENTNAME%\\%COMPUTERNAME% at %LOCATIONNAME% for %FIELDNAME% result %RESULT%.','0','300','RAWSQL','RAWSQL','SET @AgentID=1374\;\r\n\r\nDELETE FROM dba USING \r\ndatabasealerts AS dba\r\nLEFT JOIN (SELECT users.*, IFNULL(ue.IsIntegrator,0) AS IsIntegrator FROM users LEFT JOIN users_extend AS ue ON ue.UserID=users.UserID) AS uinfo\r\nON CONCAT_WS(\':\', uinfo.userid, uinfo.email, MD5(CONCAT_WS(\':\', uinfo.clientid, uinfo.secondary, uinfo.Permissions)),  uinfo.Flags, uinfo.CommandLevel, uinfo.AuditLevel, uinfo.IsIntegrator)=dba.FieldName \r\nWHERE dba.AgentID=@AgentID AND uinfo.userid IS NULL\;\r\n\r\nSELECT CONCAT_WS(\'\\r\\n\',\r\nCONCAT(uinfo.name,\' - \',uinfo.email, \' (ID \',uinfo.userid, \')\'),\r\nCONCAT(\'User Classes: \',IFNULL(GROUP_CONCAT(DISTINCT uc.Name ORDER BY uc.Name),\'None\')),\r\nCONCAT(\'Groups: \',IFNULL(GROUP_CONCAT(DISTINCT mg.Name ORDER BY uc.Name),\'None\')),\r\nCONCAT(\'Command Level (0=Lowest,4=Highest): \',uinfo.CommandLevel),\r\nCONCAT(\'Audit Level: \',ELT(uinfo.AuditLevel+1,\'None\',\'Critical\',\'Significant\',\'Informational\',\'Normal\',\'Everything\')),\r\nCONCAT(\'Integrator: \',IF(uinfo.IsIntegrator=1,\'Yes\',\'No\'))) AS testvalue, \r\nCONCAT_WS(\':\', uinfo.userid, uinfo.email, MD5(CONCAT_WS(\':\', uinfo.clientid, uinfo.secondary, uinfo.Permissions)),  uinfo.Flags, uinfo.CommandLevel, uinfo.AuditLevel, uinfo.IsIntegrator) AS identity, \r\n0 AS computerid, \'0\' AS noalerts, \'00:00:00\' AS uptimestart, \'23:59:59\' AS uptimeend \r\nFROM \r\n(SELECT users.*, IFNULL(ue.IsIntegrator,0) AS IsIntegrator FROM users LEFT JOIN users_extend AS ue ON ue.UserID=users.UserID) AS uinfo\r\nLEFT JOIN userclasses AS uc ON FIND_IN_SET(uc.classid,uinfo.Clientid)>0\r\nLEFT JOIN mastergroups AS mg ON FIND_IN_SET(mg.groupid,uinfo.secondary)>0\r\nGROUP BY uinfo.userid\;','1','','2022/03/29 08:59:07','2022/03/29 08:59:07','1','','1825','0','2022/03/29 08:59:07','WYoung@localhost','23','113','1','a6c0bc8c-b9af-44a4-b3f7-eea2972db0b0','','0','0');
