Clear Oversized Automation Logs
Summary
This monitor acts as a daily housekeeper for your computers, making sure our background tools don't leave behind too much clutter.
- What it does: Once a day, it checks the machine for any overgrown script logs (generated by our Automate scripts) and safely clears them out.
- Why it matters: Every time a script runs, it leaves a note in a log file about what it did. If those files get too big, the computer has to work harder just to open and add new notes to them, which can actually slow the machine down.
- The benefit: This automatic, daily cleanup keeps those log files small. It ensures our Automate scripts can do their jobs quickly and quietly without causing any performance hiccups on your end.
Details
Suggested "Limit to": All
Suggested Alert Style: Once
Suggested Alert Template: Default - Do Nothing
| Check Action | Server Address | Check Type | Execute Info | Condition | Interval |
|---|---|---|---|---|---|
| System | 127.0.0.1 | Run File | REDACTED | State Based | 26400 |
Target
- Managed Windows Workstations and Servers
Implementation
Step 1
Obtain the group ID(s) of the group(s) that the remote monitor should be applied to.
Step2
Copy the following query and replace YOUR COMMA SEPARATED LIST OF GROUPID(S) with the Group ID(s) of the relevant groups:
(The string to replace can be found at the very bottom of the query, right after WHERE)
INSERT INTO groupagents
SELECT '' as `AgentID`,
`groupid` as `GroupID`,
'0' as `SearchID`,
'ProVal - Production - Clear Oversized Automation Logs' as `Name`,
'6' as `CheckAction`,
'1' as `AlertAction`,
'<NoAlert>~~~<NoAlert>!!!<NoAlert>~~~<NoAlert>' as `AlertMessage`,
'0' as `ContactID`,
'86400' as `interval`,
'127.0.0.1' as `Where`,
'7' as `What`,
'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -ExecutionPolicy Bypass -Command "$threshold = 2; $WarningPreference = \'SilentlyContinue\'; $ProgressPreference = \'SilentlyContinue\'; $workingDirectory = \'{0}\\_Automation\\Script\' -f $env:ProgramData; try { Get-ChildItem -Path $workingDirectory -Force -Recurse -Filter \'*-log.txt\' -ErrorAction SilentlyContinue | Where-Object -FilterScript { $_.Length/1MB -gt $threshold } | Remove-Item -Force -Confirm:$false -ErrorAction Stop } catch { return (\'File removal failure. Reason: {0}\' -f $Error[0].Exception.Message) }"' as `DataOut`,
'16' as `Comparor`,
'10|(?m)^(OK)*\\s*$|11|(?m)^((OK)*\\s*$%7C\\s*File removal failure)|10|(?m)^\\s*File removal failure' as `DataIn`,
'' as `IDField`,
'1' as `AlertStyle`,
'0' as `ScriptID`,
'' as `datacollector`,
'21' as `Category`,
'0' as `TicketCategory`,
'1' as `ScriptTarget`,
(UUID()) as `GUID`,
'root' as `UpdatedBy`,
(NOW()) as `UpdateDate`
FROM mastergroups m
WHERE m.groupid IN (YOUR COMMA SEPARATED LIST OF GROUPID(S))
AND m.groupid NOT IN (SELECT DISTINCT groupid FROM groupagents WHERE `Name` = 'ProVal - Production - Clear Oversized Automation Logs')
Step 3
An example of a query with a group ID:
INSERT INTO groupagents
SELECT '' as `AgentID`,
`groupid` as `GroupID`,
'0' as `SearchID`,
'ProVal - Production - Clear Oversized Automation Logs' as `Name`,
'6' as `CheckAction`,
'1' as `AlertAction`,
'<NoAlert>~~~<NoAlert>!!!<NoAlert>~~~<NoAlert>' as `AlertMessage`,
'0' as `ContactID`,
'86400' as `interval`,
'127.0.0.1' as `Where`,
'7' as `What`,
'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -ExecutionPolicy Bypass -Command "$threshold = 2; $WarningPreference = \'SilentlyContinue\'; $ProgressPreference = \'SilentlyContinue\'; $workingDirectory = \'{0}\\_Automation\\Script\' -f $env:ProgramData; try { Get-ChildItem -Path $workingDirectory -Force -Recurse -Filter \'*-log.txt\' -ErrorAction SilentlyContinue | Where-Object -FilterScript { $_.Length/1MB -gt $threshold } | Remove-Item -Force -Confirm:$false -ErrorAction Stop } catch { return (\'File removal failure. Reason: {0}\' -f $Error[0].Exception.Message) }"' as `DataOut`,
'16' as `Comparor`,
'10|(?m)^(OK)*\\s*$|11|(?m)^((OK)*\\s*$%7C\\s*File removal failure)|10|(?m)^\\s*File removal failure' as `DataIn`,
'' as `IDField`,
'1' as `AlertStyle`,
'0' as `ScriptID`,
'' as `datacollector`,
'21' as `Category`,
'0' as `TicketCategory`,
'1' as `ScriptTarget`,
(UUID()) as `GUID`,
'root' as `UpdatedBy`,
(NOW()) as `UpdateDate`
FROM mastergroups m
WHERE m.groupid IN (2,3,855,856)
AND m.groupid NOT IN (SELECT DISTINCT groupid FROM groupagents WHERE `Name` = 'ProVal - Production - Clear Oversized Automation Logs')
Step 4
Now execute your query using a RAWSQL monitor set.
Step 5
Reload System Cache (Ctrl + R)
Step 6
Locate your remote monitor by opening the group(s) remote monitors tab.
Changelog
2026-05-05
- Initial version of the document