**Internal Monitors** do not run on remote computers. Instead, they run only on the Automate server and process the information received from the remote agents through [[Structured Query Language (SQL)|SQL]] statements and database queries. These [[Automate Monitors|monitors]] can then generate alerts based on this information. # How Internal Monitors Work ```mermaid flowchart A[Agent reports to Server] --> B[Server records Agent data] --> C[Internal Monitor runs on Server] --> D[Condition Detected]; D -- No --> C D -- Yes --> E[Alert Template determines action] --> F[Action is executed on Group]; ``` # Writing Additional Conditions Good example of using [[ConnectWise Automate Extra Data Field|EDF]]s as exceptions for monitors is DRV - Wkstn Free Space Remaining MT Custom. # Writing Custom Monitors ## Exclude/Include Servers ```SQL Computers.OS like '%server%' ``` ## Filter by EDF ```SQL (SELECT 'Automatic Server Updates' FROM v_extradatacomputers WHERE v_extradatacomputers.computerid = computers.computerid) = 1 ``` ## Configuration ### Result When running SQL in the result field be sure to wrap the Result query in () > When you build and view I believe it adds the parenthesis for you, but when you save the monitor I think it stores it literally and it runs without them (fail). This was a KI a while back, but I thought they fixed it. (IIRC it would crash when you used Build and View, but would run OK.. So maybe this is something else, but it feels very similar) - DarrenWhite99 (MSPGeek Discord) ## Referencing Other Tables on [[2023-10-18]] Jaydin and I attempted to ### Drive Space Monitor to Ignore if EDF is checked ![[Pasted image 20240108102621.png]] This monitor is attempting to not include any computers that have the 'MT Wkstn Disable Any Drive < 10GB Alert' [[ConnectWise Automate Extra Data Field|EDF]] checked. ### LT Agent No Check In ![[Pasted image 20240108103340.png]] This monitor will exclude results from computers that have the 'MT Computer Regularly Offline' [[ConnectWise Automate Extra Data Field|EDF]] checked. This was my first success writing something like this quickly. # Examples ## Service Plan monitor ### First draft, checking for service plan The first draft that Jaydin and I worked on only checked that 'MT' was included somewhere in the name of the service plan. ![[Pasted image 20231018165300.png]] Result: ```SELECT LocationID FROM v_extradatalocations WHERE v_extradatalocations.`Workstation Service Plan` OR v_extradatalocations.`Server Service Plan` NOT LIKE '%MT%'``` ### Draft 2 - Full client location configuration ```SQL SELECT computers.Name, computers.ComputerID, computers.LocationID, v_extradatalocations.`Workstation Service Plan`, v_extradatalocations.`Server Service Plan`, v_extradatalocations.`Enable Onboarding`, v_extradatalocations.`Enable Patching Servers`, v_extradatalocations.`Enable Patching Workstations`, v_extradatalocations.`Patch Day Workstations`, v_extradatalocations.`Patch Day Servers` FROM computers LEFT JOIN v_extradatalocations ON computers.LocationID = v_extradatalocations.LocationID WHERE v_extradatalocations.LocationID IS NULL OR v_extradatalocations.`Workstation Service Plan` NOT LIKE '%MT%' OR v_extradatalocations.`Server Service Plan` NOT LIKE '%MT%' OR v_extradatalocations.`Enable Onboarding` IS NOT NULL OR v_extradatalocations.`Enable patching servers` IS NOT NULL OR v_extradatalocations.`enable patching workstations` IS NOT NULL OR v_extradatalocations.`Patch Day Servers` IS NOT NULL OR v_extradatalocations.`Patch Day Workstations` IS NOT NULL; ``` ## Draft 3 - Per Endpoint Search This search cross references the `locationID` from the `computers` table to the `v_extradatalocations` table. I think that looking at the `v_extradatalocations` table directly will be better. We should also only be searching servers that have patching enabled. ## Draft 2.5 > [!Note] > In this example it only searches for 'Server Service Plan' not like MT and *NOT* 'Workstation Service Plan'. Table: `computers` Field: `LocationID` Check Condition: `InSet` Result: ```SQL (SELECT LocationID FROM v_extradatalocations WHERE v_extradatalocations.`Workstation Service Plan` OR v_extradatalocations.`Server Service Plan` NOT LIKE '%MT%') ``` ![[Pasted image 20240517140259.png]]