Custom powershell script MSSQL

CMK Version: 2.1.0p8 Free Edition (When we go into production we will chose for Enterprise edition)
Debian 11
Currently my host doesn’t have TLS activated but I don’t expect this to be the reason.

The agent runs on Local System.
Local System has sysadmin permissions on all the databases, this seems to work OK as seen by the output of my local agent.
We have made a custom powershell script to output some values from query’s from MSSQL.
In Powershell running under my admin account i get the following result:
0 DB1 Users=0
0 application Users=17

When I test the output of the local agent with:
“C:\Program Files (x86)\checkmk\service\check_mk_agent.exe” test
I see the following section:
<<local:sep(0)>>
0 DB1 Users=0
0 application Users=17
<<>>
1668174335

When I run cmk -d [hostname] from my site I see:
<<local:sep(0)>>
0 Users=
0 Users=
<<>>
1668174490

What I want to achieve:
I want to see some information from multiple databases.
I want the data to output per database per query in a different service.
The output should always be OK/green.

In the below posted Powershell script I’m only writing the CustomerUsers.
I will also want to do the same for TotalUserRows and some other values.
My prefferred output would be:
Servicename: DBNAME_CustomerUsers
Output: [amount of users]

Powershell script

$Databases = Invoke-Sqlcmd -Query "SELECT name FROM master.dbo.sysdatabases WHERE name NOT IN ('master', 'tempdb', 'model', 'msdb')" -ServerInstance "$env:computername" -Database "master"
$TotalDiskSize = (Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType = 3" | Select-Object -Property DeviceID,@{'Name' = 'Size (GB)'; Expression= { [int]($_.Size / 1GB) }} | Measure-Object -Property 'Size (GB)' -Sum).sum


Foreach ($Database in $Databases) {
$DB = $database.name 
$Exists = Invoke-Sqlcmd -Query "select * from INFORMATION_SCHEMA.TABLES Where TABLE_NAME = N'UserProfile'" -ServerInstance "$env:computername" -Database "$DB"
if ($Exists) {$Return = $True}
else {$Return = $False}


If ($Return -eq $True){
$ApplicationDBUSers = Invoke-Sqlcmd -Query "select DB_NAME() as DBName, sum(case when isnull(emailaddress,'') not like '%companyname%' and (logintype =1 or logintype =2) then 1 else 0 end ) as customermachineUsers, sum(case when isnull(emailaddress,'') like '%company%' and logintype =1 then 1 else 0 end ) as companyUsers, sum(case when logintype =0 then 1 else 0 end ) as NonLoginRoles, COUNT(1) as TotalUserRows, case when @@version like '%express%' then 'express' else 'standard' end as SQLVersion from dbo.userprofile with (nolock)" -ServerInstance "$env:computername" -Database "$DB"
$ApplicationDBArticles = Invoke-Sqlcmd -Query "select count (1) from article with (nolock)" -ServerInstance "$env:computername" -Database "$DB"

$DBName = $applicationDBUSers.DBName
$customermachineUsers = $applicationDBUSers.customermachineUsers
$companyUsers = $applicationDBUSers.companyUsers
$NonLoginRoles = $applicationDBUSers.NonLoginRoles
$TotalUserRows = $applicationDBUSers.TotalUserRows
$SQLVersion = $applicationDBUSers.SQLVersion
$applicationDBArticles = $applicationDBArticles.Column1
}
Write-Host (“0 $DBName Users=$customermachineUsers”)
}

Output of cmk --debug -vvn [hostname]

cmk --debug -vvn customermachine
Checkmk version 2.1.0p8
Try license usage history update.
Trying to acquire lock on /omd/sites/dallas/var/check_mk/license_usage/next_run
Got lock on /omd/sites/dallas/var/check_mk/license_usage/next_run
Trying to acquire lock on /omd/sites/dallas/var/check_mk/license_usage/history.json
Got lock on /omd/sites/dallas/var/check_mk/license_usage/history.json
Next run time has not been reached yet. Abort.
Releasing lock on /omd/sites/dallas/var/check_mk/license_usage/history.json
Released lock on /omd/sites/dallas/var/check_mk/license_usage/history.json
Releasing lock on /omd/sites/dallas/var/check_mk/license_usage/next_run
Released lock on /omd/sites/dallas/var/check_mk/license_usage/next_run
+ FETCHING DATA
  Source: SourceType.HOST/FetcherType.TCP
[cpu_tracking] Start [7f4e66644190]
[TCPFetcher] Fetch with cache settings: DefaultAgentFileCache(customermachine, base_path=/omd/sites/dallas/tmp/check_mk/cache, max_age=MaxAge(checking=0, discovery=120, inventory=120), disabled=False, use_outdated=False, simulation=False)
Not using cache (Too old. Age is 32 sec, allowed is 0 sec)
[TCPFetcher] Execute data source
Connecting via TCP to 10.80.10.66:6556 (5.0s timeout)
Detected transport protocol: TransportProtocol.PLAIN (b'<<')
Reading data from agent
Write data to cache file /omd/sites/dallas/tmp/check_mk/cache/customermachine
Trying to acquire lock on /omd/sites/dallas/tmp/check_mk/cache/customermachine
Got lock on /omd/sites/dallas/tmp/check_mk/cache/customermachine
Releasing lock on /omd/sites/dallas/tmp/check_mk/cache/customermachine
Released lock on /omd/sites/dallas/tmp/check_mk/cache/customermachine
Closing TCP connection to 10.80.10.66:6556
[cpu_tracking] Stop [7f4e66644190 - Snapshot(process=posix.times_result(user=0.0, system=0.0, children_user=0.0, children_system=0.0, elapsed=21.940000001341105))]
  Source: SourceType.HOST/FetcherType.PIGGYBACK
[cpu_tracking] Start [7f4e66648e80]
[PiggybackFetcher] Fetch with cache settings: NoCache(customermachine, base_path=/omd/sites/dallas/tmp/check_mk/data_source_cache/piggyback, max_age=MaxAge(checking=0, discovery=120, inventory=120), disabled=True, use_outdated=False, simulation=False)
Not using cache (Cache usage disabled)
[PiggybackFetcher] Execute data source
No piggyback files for 'customermachine'. Skip processing.
No piggyback files for '10.80.10.66'. Skip processing.
Not using cache (Cache usage disabled)
[cpu_tracking] Stop [7f4e66648e80 - Snapshot(process=posix.times_result(user=0.0, system=0.0, children_user=0.0, children_system=0.0, elapsed=0.0))]
+ PARSE FETCHER RESULTS
  Source: SourceType.HOST/FetcherType.TCP
<<<check_mk>>> / Transition NOOPParser -> HostSectionParser
<<<cmk_agent_ctl_status:sep(0)>>> / Transition HostSectionParser -> HostSectionParser
<<<wmi_cpuload:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
<<<uptime>>> / Transition HostSectionParser -> HostSectionParser
<<<winperf_phydisk>>> / Transition HostSectionParser -> HostSectionParser
<<<winperf_if>>> / Transition HostSectionParser -> HostSectionParser
<<<winperf_processor>>> / Transition HostSectionParser -> HostSectionParser
<<<fileinfo:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
<<<df:sep(9)>>> / Transition HostSectionParser -> HostSectionParser
<<<logwatch>>> / Transition HostSectionParser -> HostSectionParser
<<<mem>>> / Transition HostSectionParser -> HostSectionParser
<<<services>>> / Transition HostSectionParser -> HostSectionParser
<<<checkmk_agent_plugins_win:sep(0)>>> / Transition HostSectionParser -> HostSectionParser
<<<ps:sep(9)>>> / Transition HostSectionParser -> HostSectionParser
<<<dotnet_clrmemory:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
<<<wmi_webservices:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
Transition HostSectionParser -> NOOPParser
<<<mssql_instance:sep(124)>>> / Transition NOOPParser -> HostSectionParser
<<<mssql_databases:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_counters:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_tablespaces>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_blocked_sessions:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_backup:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_transactionlogs:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_datafiles:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_cluster:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_jobs:sep(9)>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_mirroring:sep(9)>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_versions:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_connections>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_instance:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_instance:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_instance:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_counters:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_blocked_sessions:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_tablespaces>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_backup:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_transactionlogs:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_datafiles:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_databases:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_cluster:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_connections>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_jobs:sep(9)>>> / Transition HostSectionParser -> HostSectionParser
<<<mssql_mirroring:sep(9)>>> / Transition HostSectionParser -> HostSectionParser
<<<check_mk:cached(1668171620,86400)>>> / Transition HostSectionParser -> HostSectionParser
Transition HostSectionParser -> NOOPParser
<<<local:sep(0)>>> / Transition NOOPParser -> HostSectionParser
<<<systemtime>>> / Transition HostSectionParser -> HostSectionParser
No persisted sections
  -> Add sections: ['check_mk', 'checkmk_agent_plugins_win', 'cmk_agent_ctl_status', 'df', 'dotnet_clrmemory', 'fileinfo', 'local', 'logwatch', 'mem', 'mssql_backup', 'mssql_blocked_sessions', 'mssql_cluster', 'mssql_connections', 'mssql_counters', 'mssql_databases', 'mssql_datafiles', 'mssql_instance', 'mssql_jobs', 'mssql_mirroring', 'mssql_tablespaces', 'mssql_transactionlogs', 'mssql_versions', 'ps', 'services', 'systemtime', 'uptime', 'winperf_if', 'winperf_phydisk', 'winperf_processor', 'wmi_cpuload', 'wmi_webservices']
  Source: SourceType.HOST/FetcherType.PIGGYBACK
No persisted sections
  -> Add sections: []
Received no piggyback data
Received no piggyback data
[cpu_tracking] Start [7f4e665a8f10]
value store: synchronizing
Trying to acquire lock on /omd/sites/dallas/tmp/check_mk/counters/customermachine
Got lock on /omd/sites/dallas/tmp/check_mk/counters/customermachine
value store: loading from disk
Releasing lock on /omd/sites/dallas/tmp/check_mk/counters/customermachine
Released lock on /omd/sites/dallas/tmp/check_mk/counters/customermachine
CPU utilization      Total CPU: 1.53%
Check_MK Agent       Version: 2.1.0p8, OS: windows, TLS is not activated on monitored host (see details)(!), Update error: The agent updater is not registered at the deployment server(!), No successful connect to server yet(!), Agent plugins: 2, Local checks: 1
Disk IO SUMMARY      Read: 24.5 kB/s, Write: 48.5 kB/s, Latency: 68 microseconds
Filesystem C:/       54.26% used (48.50 of 89.40 GB), trend: +294.18 MB / 24 hours
Filesystem E:/       59.35% used (296.75 of 499.98 GB), trend: +34.62 kB / 24 hours
Interface 1          [vmxnet3 Ethernet Adapter], (Connected), Speed: 10 GBit/s, In: 2.60 kB/s (<0.01%), Out: 6.15 kB/s (<0.01%)
MSSQL Connections SQLEXPRESS DB1 Connections: 2
MSSQL Connections SQLEXPRESS application Connections: 16
MSSQL Connections SQLEXPRESS master Connections: 45
MSSQL Connections SQLEXPRESS model Connections: 0
MSSQL Connections SQLEXPRESS msdb Connections: 1
MSSQL Connections SQLEXPRESS tempdb Connections: 0
MSSQL Datafile SQLEXPRESS.DB1.MSDBData Used: 13.0 MiB, Allocated used: 13.0 MiB, Allocated: 14.0 MiB, Maximum size: 40.9 GiB
MSSQL Datafile SQLEXPRESS.application.MSDBData Used: 13.0 MiB, Allocated used: 13.0 MiB, Allocated: 14.0 MiB, Maximum size: 40.9 GiB
MSSQL Datafile SQLEXPRESS.master.master Used: 3.00 MiB, Allocated used: 3.00 MiB, Allocated: 4.00 MiB, Maximum size: 40.9 GiB
MSSQL Datafile SQLEXPRESS.model.tempdev Used: 4.00 MiB, Allocated used: 4.00 MiB, Allocated: 456 MiB, Maximum size: 40.9 GiB
MSSQL Datafile SQLEXPRESS.msdb.MSDBData Used: 13.0 MiB, Allocated used: 13.0 MiB, Allocated: 14.0 MiB, Maximum size: 40.9 GiB
MSSQL Datafile SQLEXPRESS.tempdb.tempdev Used: 4.00 MiB, Allocated used: 4.00 MiB, Allocated: 456 MiB, Maximum size: 40.9 GiB
MSSQL MSSQL_SQLEXPRESS DB1 Backup No backup found
MSSQL MSSQL_SQLEXPRESS DB1 File Sizes Data files: 6.80 GiB, Log files total: 51.2 MiB, Log files used: 4.07 MiB
MSSQL MSSQL_SQLEXPRESS DB1 Sizes Size: 15.50 MB, Unallocated space: 962.56 kB, 6.06%, Reserved space: 13.81 MB, 89.11%, Data: 10.09 MB, 65.12%, Indexes: 3.26 MB, 21.02%, Unused: 472.00 kB, 2.97%
MSSQL MSSQL_SQLEXPRESS DB1 Transactions Transactions: 0.0/s, Write Transactions: 0.0/s, Tracked Transactions: 0.0/s
MSSQL MSSQL_SQLEXPRESS Locks per Batch 301.3
MSSQL MSSQL_SQLEXPRESS application Backup No backup found
MSSQL MSSQL_SQLEXPRESS application File Sizes Data files: 226 GiB, Log files total: 35.8 GiB, Log files used: 40.0 MiB
MSSQL MSSQL_SQLEXPRESS application Sizes Size: 15.50 MB, Unallocated space: 962.56 kB, 6.06%, Reserved space: 13.81 MB, 89.11%, Data: 10.09 MB, 65.12%, Indexes: 3.26 MB, 21.02%, Unused: 472.00 kB, 2.97%
MSSQL MSSQL_SQLEXPRESS application Transactions Transactions: 0.0/s, Write Transactions: 0.0/s, Tracked Transactions: 0.0/s
MSSQL MSSQL_SQLEXPRESS _Total File Sizes Data files: 233 GiB, Log files total: 35.9 GiB, Log files used: 47.8 MiB
MSSQL MSSQL_SQLEXPRESS _Total Transactions Transactions: 0.8/s, Write Transactions: 0.2/s, Tracked Transactions: 0.0/s
MSSQL MSSQL_SQLEXPRESS master Backup No backup found
MSSQL MSSQL_SQLEXPRESS master File Sizes Data files: 4.44 MiB, Log files total: 1.99 MiB, Log files used: 758 KiB
MSSQL MSSQL_SQLEXPRESS master Sizes Size: 6.44 MB, Unallocated space: 880.64 kB, 13.35%, Reserved space: 3.58 MB, 55.56%, Data: 1.50 MB, 23.29%, Indexes: 1.59 MB, 24.75%, Unused: 496.00 kB, 7.52%
MSSQL MSSQL_SQLEXPRESS master Transactions Transactions: 0.1/s, Write Transactions: 0.0/s, Tracked Transactions: 0.0/s
MSSQL MSSQL_SQLEXPRESS model Backup No backup found
MSSQL MSSQL_SQLEXPRESS model File Sizes Data files: 8.00 MiB, Log files total: 7.99 MiB, Log files used: 558 KiB
MSSQL MSSQL_SQLEXPRESS model Sizes Size: 528.00 MB, Unallocated space: 452.88 MB, 85.77%, Reserved space: 3.12 MB, 0.59%, Data: 1.01 MB, 0.19%, Indexes: 1.27 MB, 0.24%, Unused: 856.00 kB, 0.16%
MSSQL MSSQL_SQLEXPRESS model Transactions Transactions: 0.0/s, Write Transactions: 0.0/s, Tracked Transactions: 0.0/s
MSSQL MSSQL_SQLEXPRESS msdb Backup No backup found
MSSQL MSSQL_SQLEXPRESS msdb File Sizes Data files: 14.8 MiB, Log files total: 760 KiB, Log files used: 628 KiB
MSSQL MSSQL_SQLEXPRESS msdb Sizes Size: 15.50 MB, Unallocated space: 962.56 kB, 6.06%, Reserved space: 13.81 MB, 89.11%, Data: 10.09 MB, 65.12%, Indexes: 3.26 MB, 21.02%, Unused: 472.00 kB, 2.97%
MSSQL MSSQL_SQLEXPRESS msdb Transactions Transactions: 0.1/s, Write Transactions: 0.0/s, Tracked Transactions: 0.0/s
MSSQL MSSQL_SQLEXPRESS mssqlsystemresource File Sizes Data files: 40.0 MiB, Log files total: 1.24 MiB, Log files used: 623 KiB
MSSQL MSSQL_SQLEXPRESS mssqlsystemresource Transactions Transactions: 0.0/s, Write Transactions: 0.0/s, Tracked Transactions: 0.0/s
MSSQL MSSQL_SQLEXPRESS tempdb Backup No backup found
MSSQL MSSQL_SQLEXPRESS tempdb File Sizes Data files: 456 MiB, Log files total: 72.0 MiB, Log files used: 1.22 MiB
MSSQL MSSQL_SQLEXPRESS tempdb Sizes Size: 528.00 MB, Unallocated space: 452.88 MB, 85.77%, Reserved space: 3.12 MB, 0.59%, Data: 1.01 MB, 0.19%, Indexes: 1.27 MB, 0.24%, Unused: 856.00 kB, 0.16%
MSSQL MSSQL_SQLEXPRESS tempdb Transactions Transactions: 0.6/s, Write Transactions: 0.2/s, Tracked Transactions: 0.0/s
MSSQL MSSQL_SQLEXPRESS:Buffer_Manager None Page Activity Reads: 0.0/s, Writes: 0.0/s, Lookups: 512.2/s
MSSQL MSSQL_SQLEXPRESS:Buffer_Manager None buffer_cache_hit_ratio 100.00%
MSSQL MSSQL_SQLEXPRESS:Buffer_Manager page_life_expectancy 22 days 22 hours
MSSQL MSSQL_SQLEXPRESS:Buffer_Node 000 page_life_expectancy 22 days 22 hours
MSSQL MSSQL_SQLEXPRESS:Catalog_Metadata DB1 cache_hit_ratio 99.63%
MSSQL MSSQL_SQLEXPRESS:Catalog_Metadata application cache_hit_ratio 60.40%
MSSQL MSSQL_SQLEXPRESS:Catalog_Metadata _Total cache_hit_ratio 72.40%
MSSQL MSSQL_SQLEXPRESS:Catalog_Metadata master cache_hit_ratio 94.40%
MSSQL MSSQL_SQLEXPRESS:Catalog_Metadata model cache_hit_ratio 98.28%
MSSQL MSSQL_SQLEXPRESS:Catalog_Metadata msdb cache_hit_ratio 76.46%
MSSQL MSSQL_SQLEXPRESS:Catalog_Metadata mssqlsystemresource cache_hit_ratio 96.12%
MSSQL MSSQL_SQLEXPRESS:Catalog_Metadata tempdb cache_hit_ratio 80.36%
MSSQL MSSQL_SQLEXPRESS:Locks AllocUnit Locks Requests: 0.0/s, Timeouts: 0.0/s, Deadlocks: 0.0/s, Waits: 0.0/s
MSSQL MSSQL_SQLEXPRESS:Locks Application Locks Requests: 0.0/s, Timeouts: 0.0/s, Deadlocks: 0.0/s, Waits: 0.0/s
MSSQL MSSQL_SQLEXPRESS:Locks Database Locks Requests: 4.7/s, Timeouts: 0.0/s, Deadlocks: 0.0/s, Waits: 0.0/s
MSSQL MSSQL_SQLEXPRESS:Locks Extent Locks Requests: 0.1/s, Timeouts: 0.0/s, Deadlocks: 0.0/s, Waits: 0.0/s
MSSQL MSSQL_SQLEXPRESS:Locks File Locks Requests: 0.0/s, Timeouts: 0.0/s, Deadlocks: 0.0/s, Waits: 0.0/s
MSSQL MSSQL_SQLEXPRESS:Locks HoBT Locks Requests: 0.2/s, Timeouts: 0.0/s, Deadlocks: 0.0/s, Waits: 0.0/s
MSSQL MSSQL_SQLEXPRESS:Locks Key Locks Requests: 228.5/s, Timeouts: 0.0/s, Deadlocks: 0.0/s, Waits: 0.0/s
MSSQL MSSQL_SQLEXPRESS:Locks Metadata Locks Requests: 54.4/s, Timeouts: 0.0/s, Deadlocks: 0.0/s, Waits: 0.0/s
MSSQL MSSQL_SQLEXPRESS:Locks OIB Locks Requests: 0.0/s, Timeouts: 0.0/s, Deadlocks: 0.0/s, Waits: 0.0/s
MSSQL MSSQL_SQLEXPRESS:Locks Object Locks Requests: 259.9/s, Timeouts: 0.0/s, Deadlocks: 0.0/s, Waits: 0.0/s
MSSQL MSSQL_SQLEXPRESS:Locks Page Locks Requests: 1.5/s, Timeouts: 0.0/s, Deadlocks: 0.0/s, Waits: 0.0/s
MSSQL MSSQL_SQLEXPRESS:Locks RID Locks Requests: 0.4/s, Timeouts: 0.0/s, Deadlocks: 0.0/s, Waits: 0.0/s
MSSQL MSSQL_SQLEXPRESS:Locks RowGroup Locks Requests: 0.0/s, Timeouts: 0.0/s, Deadlocks: 0.0/s, Waits: 0.0/s
MSSQL MSSQL_SQLEXPRESS:Locks Xact Locks Requests: 0.0/s, Timeouts: 0.0/s, Deadlocks: 0.0/s, Waits: 0.0/s
MSSQL MSSQL_SQLEXPRESS:Locks _Total Locks Requests: 549.7/s, Timeouts: 0.0/s, Deadlocks: 0.0/s, Waits: 0.0/s
MSSQL MSSQL_SQLEXPRESS:Plan_Cache Bound_Trees cache_hit_ratio 96.63%
MSSQL MSSQL_SQLEXPRESS:Plan_Cache Extended_Stored_Procedures cache_hit_ratio 94.94%
MSSQL MSSQL_SQLEXPRESS:Plan_Cache Object_Plans cache_hit_ratio 99.87%
MSSQL MSSQL_SQLEXPRESS:Plan_Cache SQL_Plans cache_hit_ratio 61.19%
MSSQL MSSQL_SQLEXPRESS:Plan_Cache Temporary_Tables_&_Table_Variables cache_hit_ratio 99.86%
MSSQL MSSQL_SQLEXPRESS:Plan_Cache _Total cache_hit_ratio 88.57%
MSSQL MSSQL_SQLEXPRESS:SQL_Statistics None batch_requests/sec 1.8/s
MSSQL MSSQL_SQLEXPRESS:SQL_Statistics None sql_compilations/sec 0.5/s
MSSQL MSSQL_SQLEXPRESS:SQL_Statistics None sql_re-compilations/sec 0.0/s
MSSQL SQLEXPRESS Blocked Sessions No blocking sessions
MSSQL SQLEXPRESS DB1 Database Status: ONLINE, Recovery: SIMPLE, Auto close: off, Auto shrink: off
MSSQL SQLEXPRESS Instance Version: Microsoft SQL Server 2019 (RTM) (15.0.2000.5) - Standard Edition (64-bit)
MSSQL SQLEXPRESS application Database Status: ONLINE, Recovery: SIMPLE, Auto close: off, Auto shrink: off
MSSQL SQLEXPRESS master Database Status: ONLINE, Recovery: SIMPLE, Auto close: off, Auto shrink: off
MSSQL SQLEXPRESS model Database Status: ONLINE, Recovery: SIMPLE, Auto close: off, Auto shrink: off
MSSQL SQLEXPRESS msdb Database Status: ONLINE, Recovery: SIMPLE, Auto close: off, Auto shrink: off
MSSQL SQLEXPRESS tempdb Database Status: ONLINE, Recovery: SIMPLE, Auto close: off, Auto shrink: off
MSSQL Transactionlog SQLEXPRESS.DB1.MSDBLog Used: 0 B, Allocated used: 0 B, Allocated: 0 B, Maximum size: 40.9 GiB
MSSQL Transactionlog SQLEXPRESS.application.MSDBLog Used: 0 B, Allocated used: 0 B, Allocated: 0 B, Maximum size: 40.9 GiB
MSSQL Transactionlog SQLEXPRESS.master.mastlog Used: 0 B, Allocated used: 0 B, Allocated: 2.00 MiB, Maximum size: 40.9 GiB
MSSQL Transactionlog SQLEXPRESS.model.templog Used: 1.00 MiB, Allocated used: 1.00 MiB, Allocated: 72.0 MiB, Maximum size: 40.9 GiB
MSSQL Transactionlog SQLEXPRESS.msdb.MSDBLog Used: 0 B, Allocated used: 0 B, Allocated: 0 B, Maximum size: 40.9 GiB
MSSQL Transactionlog SQLEXPRESS.tempdb.templog Used: 1.00 MiB, Allocated used: 1.00 MiB, Allocated: 72.0 MiB, Maximum size: 40.9 GiB
Memory               RAM: 58.72% - 56.38 GB of 96.00 GB, Commit charge: 53.59% - 57.43 GB of 107.17 GB
Processor Queue      15 min load: 4.48, 15 min load per core: 0.75 (6 logical cores)
Service Summary      Autostart services: 69, Stopped services: 3
System Time          Offset: -1.36 s
Uptime               Up since Oct 19 2022 14:52:28, Uptime: 22 days 22 hours
Web Service Default Web Site Connections: 0.00
Web Service us-test.applicationcloud.com Connections: 0.00
No piggyback files for 'customermachine'. Skip processing.
No piggyback files for '10.80.10.66'. Skip processing.
[cpu_tracking] Stop [7f4e665a8f10 - Snapshot(process=posix.times_result(user=0.030000000000000027, system=0.0, children_user=0.0, children_system=0.0, elapsed=0.030000001192092896))]
[agent] Success, execution time 22.0 sec | execution_time=21.970 user_time=0.030 system_time=0.000 children_user_time=0.000 children_system_time=0.000 cmk_time_agent=21.940

I think I’ve just found the reason… The system account doesn’t seem to have sufficient rights in MSSQL after all, even though it did look like it. I just changed the CheckMK service to run under my user and i now see output with cmk -d [hostname]
It seems that when I use:
“C:\Program Files (x86)\checkmk\service\check_mk_agent.exe” test
It runs under my user and not the user the service for the agent runs on.

That’s correct. After i installed a plugin where I’m not sure if it run’s with the system account, I would check in the CMK side with “cmk -d [hostname]” to retrieve the actual agent output.

1 Like

The checkmk agent will ALWASY run under SYSTEM in Windows (this cannot be changed) - So you can manually change this. And as you don’t have agent bakery and automatic updates you should be fine.

Of course you should not run the agent as yourselves, but I hope you understand that

Hello Anders,

In our datacenter we will be going for the Enterprise edition as soon as we have it set up and we’ve tested if CheckMK can do all things our current monitoring does, which I believe it can.
What happens if i decide to run the CheckMK Agent under a service account and i use the agent bakery for automatic updates? Will it switch back to the System user or stay under the user manually configured? Thanks

yes it will (I have to type random stuff here, not allowed to write less than 20 chars…)

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.