CMK version: 2.1.op26 cfe
OS version: Ubuntu 20.04.2 LTS
Error message:
I have writen a powershell script to monitor my media server. The powershell script is located in /omd/sites/borgir/local/share/check_mk/agents/custom/plex_check/lib/local on my server. When I backe a new agent the file is backed into the agent and gets distributed to my server. But when I do a service discovery on my server it does not show up and therefore I can’t monitor my media server.
I can run the script manually on my server and it works and I also see it in the agent test output (See below)
I might be missing something or it just is not possible to run a powershell script on CFE edition of chekmk.
Cheers.
$CMK_VERSION = "2.1.0p26"
#echo off
# URL of service
$ServiceURI = "https://server.domain.com:32400/web/index.html#!/settings/web/general"
# Process name
$ProcName = "Plex Media Server"
# Path to process executable
$ProcPath = "D:\Program Files\Plex\Plex Media Server\Plex Media Server.exe"
# Number of seconds to wait for the service to respond
$TimeOutSecs = 5
# Check if the process is running
$WatchProc = Get-Process $ProcName -ErrorAction SilentlyContinue
if ($WatchProc) {
# If the process is running, return OK
Write-Host 0 "Plex server" - Plex Media Server is running
#echo 0 "Plex server" - Plex Media Server is running
} else {
# If the process is not running, attempt to restart it
# Write-Host "$(Get-Date -Format 'MM/dd/yyy HH:mm:ss') - $($ProcName) failed, attempting to restart"
Try {
$Connect = Invoke-WebRequest -Uri $ServiceURI -TimeoutSec $TimeOutSecs
# If the service is responding, start the process
Start-Process -FilePath $ProcPath
Write-Host 1 "Plex server" - Plex Media Server restarted successfully
#echo 1 "Plex server" - Plex Media Server restarted successfully
} Catch {
# If the service is not responding, return CRITICAL
Write-Host 2 "Plex server" - Plex Media Server failed to restart
#echo 2 "Plex server" - Plex Media Server failed to restart
}
}
This is the output from .\check_mk_agent.exe test so as you can see here the powershell script is there but the output is not shown in checkmk webinterface for the server. I have tryed service discovery but it does not show up.
<<<checkmk_agent_plugins_win:sep(0)>>>
pluginsdir C:\ProgramData\checkmk\agent\plugins
localdir C:\ProgramData\checkmk\agent\local
C:\ProgramData\checkmk\agent\plugins\cmk_update_agent.checkmk.py:CMK_VERSION = "2.1.0p26"
C:\ProgramData\checkmk\agent\plugins\windows_updates.vbs:CMK_VERSION = "2.1.0p26"
C:\ProgramData\checkmk\agent\local\plex_check.ps1:CMK_VERSION = "2.1.0p26"
<<<local:sep(0)>>>
0 Plex server - Plex Media Server is running
Output from agent test after moving the powershell script to C:\ProgramData\checkmk\agent\plugins
<<<>>>
0 Plex server - Plex Media Server is running
<<<>>>
Output of “cmk --debug -vvn hostname”: (If it is a problem with checks or plugins)
Checkmk version 2.1.0p26
Try license usage history update.
Trying to acquire lock on /omd/sites/borgir/var/check_mk/license_usage/next_run
Got lock on /omd/sites/borgir/var/check_mk/license_usage/next_run
Trying to acquire lock on /omd/sites/borgir/var/check_mk/license_usage/history.json
Got lock on /omd/sites/borgir/var/check_mk/license_usage/history.json
Next run time has not been reached yet. Abort.
Releasing lock on /omd/sites/borgir/var/check_mk/license_usage/history.json
Released lock on /omd/sites/borgir/var/check_mk/license_usage/history.json
Releasing lock on /omd/sites/borgir/var/check_mk/license_usage/next_run
Released lock on /omd/sites/borgir/var/check_mk/license_usage/next_run
+ FETCHING DATA
Source: SourceType.HOST/FetcherType.TCP
[cpu_tracking] Start [7f1545a61e80]
[TCPFetcher] Fetch with cache settings: DefaultAgentFileCache(server.domain.com, base_path=/omd/sites/borgir/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 29 sec, allowed is 0 sec)
[TCPFetcher] Execute data source
Connecting via TCP to 192.168.1.21:6556 (5.0s timeout)
Detected transport protocol: TransportProtocol.TLS (b'16')
Reading data from agent via TLS socket
Reading data from agent
Detected transport protocol: TransportProtocol.PLAIN (b'<<')
Write data to cache file /omd/sites/borgir/tmp/check_mk/cache/server.domain.com
Trying to acquire lock on /omd/sites/borgir/tmp/check_mk/cache/server.domain.com
Got lock on /omd/sites/borgir/tmp/check_mk/cache/server.domain.com
Releasing lock on /omd/sites/borgir/tmp/check_mk/cache/server.domain.com
Released lock on /omd/sites/borgir/tmp/check_mk/cache/server.domain.com
Closing TCP connection to 192.168.1.21:6556
[cpu_tracking] Stop [7f1545a61e80 - Snapshot(process=posix.times_result(user=0.010000000000000231, system=0.010000000000000009, children_user=0.0, children_system=0.0, elapsed=2.8799999989569187))]
Source: SourceType.HOST/FetcherType.PIGGYBACK
[cpu_tracking] Start [7f1545a6d370]
[PiggybackFetcher] Fetch with cache settings: NoCache(server.domain.com, base_path=/omd/sites/borgir/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 'server.domain.com'. Skip processing.
No piggyback files for '192.168.1.21'. Skip processing.
Not using cache (Cache usage disabled)
[cpu_tracking] Stop [7f1545a6d370 - 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
<<<mem>>> / Transition HostSectionParser -> HostSectionParser
<<<fileinfo:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
<<<df:sep(9)>>> / Transition HostSectionParser -> HostSectionParser
<<<services>>> / Transition HostSectionParser -> HostSectionParser
<<<logwatch>>> / Transition HostSectionParser -> HostSectionParser
<<<checkmk_agent_plugins_win:sep(0)>>> / Transition HostSectionParser -> HostSectionParser
<<<dotnet_clrmemory:sep(124)>>> / Transition HostSectionParser -> HostSectionParser
<<<ps:sep(9)>>> / Transition HostSectionParser -> HostSectionParser
Transition HostSectionParser -> NOOPParser
<<<check_mk:cached(1683237962,300)>>> / Transition NOOPParser -> HostSectionParser
<<<windows_updates:cached(1683237593,14400)>>> / 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', 'ps', 'services', 'systemtime', 'uptime', 'windows_updates', 'winperf_if', 'winperf_phydisk', 'winperf_processor', 'wmi_cpuload']
Source: SourceType.HOST/FetcherType.PIGGYBACK
No persisted sections
-> Add sections: []
Received no piggyback data
Received no piggyback data
[cpu_tracking] Start [7f1545a6d400]
value store: synchronizing
Trying to acquire lock on /omd/sites/borgir/tmp/check_mk/counters/server.domain.com
Got lock on /omd/sites/borgir/tmp/check_mk/counters/server.domain.com
value store: loading from disk
Releasing lock on /omd/sites/borgir/tmp/check_mk/counters/server.domain.com
Released lock on /omd/sites/borgir/tmp/check_mk/counters/server.domain.com
CPU utilization Total CPU: 6.06%
Check_MK Agent Version: 2.1.0p26, OS: windows, Last update: May 04 2023 21:58:16, Agent plugins: 2, Local checks: 1
Disk IO SUMMARY Read: 104 kB/s, Write: 288 kB/s, Latency: 250 microseconds
DotNet Memory Management _Global_ Time in GC: 0.008%
Filesystem C:/ 13.8% used (64.19 of 465.09 GB, warn/crit at 94.67%/97.34%), trend: +786.18 MB / 24 hours
Filesystem D:/ 33.7% used (37.67 of 111.79 GB, warn/crit at 90.44%/95.22%), trend: +239.11 MB / 24 hours
Filesystem E:/ 80.21% used (4.38 of 5.46 TB, warn/crit at 96.76%/98.38%), trend: 0.00 B / 24 hours
Filesystem F:/ 75.86% used (706.63 of 931.51 GB, warn/crit at 95.36%/97.68%), trend: -352.60 MB / 24 hours
Filesystem G:/ 81.3% used (8.87 of 10.91 TB, warn/crit at 97.18%/98.59%), trend: +21.14 GB / 24 hours
Filesystem H:/ 30.53% used (853.00 GB of 2.73 TB, warn/crit at 96.28%/98.14%), trend: +11.10 GB / 24 hours
Filesystem I:/ 71.5% used (1.95 of 2.73 TB, warn/crit at 96.28%/98.14%), trend: +76.60 MB / 24 hours
Filesystem Y:/ 44.97% used (4.50 of 10.00 TB, warn/crit at 97.13%/98.56%), trend: -216.48 MB / 24 hours
Interface 1 [Realtek PCIe GbE Family Controller], (Connected), Speed: 1 GBit/s, In: 22.7 kB/s (0.02%), Out: 160 kB/s (0.13%)
Memory RAM: 70.98% - 22.66 GB of 31.93 GB, Commit charge: 81.39% - 29.85 GB of 36.68 GB
Processor Queue 15 min load: 1.66, 15 min load per core: 0.14 (12 logical cores)
Service Bazarr Bazarr: running (start type is auto)
Service Ombi Ombi: running (start type is auto)
Service Radarr Radarr: running (start type is auto)
Service Sonarr Sonarr: running (start type is auto)
Service Summary Autostart services: 78, Stopped services: 4
Service filezilla-server filezilla-server: running (start type is auto)
Service sshd OpenSSH SSH Server: running (start type is auto)
System Time Offset: -711 ms
System Updates Important: 0, Optional: 0
Uptime Up since Apr 26 2023 20:54:36, Uptime: 8 days 1 hour
No piggyback files for 'server.domain.com'. Skip processing.
No piggyback files for '192.168.1.21'. Skip processing.
[cpu_tracking] Stop [7f1545a6d400 - Snapshot(process=posix.times_result(user=0.040000000000000036, system=0.0, children_user=0.0, children_system=0.0, elapsed=0.04000000283122063))]
[agent] Success, execution time 2.9 sec | execution_time=2.920 user_time=0.050 system_time=0.010 children_user_time=0.000 children_system_time=0.000 cmk_time_agent=2.860
This is the output from .\check_mk_agent.exe test so as you can see here the powershell script is there but the output is not shown in checkmk webinterface for the server. I have tryed service discovery but it does not show up.
<<<checkmk_agent_plugins_win:sep(0)>>>
pluginsdir C:\ProgramData\checkmk\agent\plugins
localdir C:\ProgramData\checkmk\agent\local
C:\ProgramData\checkmk\agent\plugins\cmk_update_agent.checkmk.py:CMK_VERSION = "2.1.0p26"
C:\ProgramData\checkmk\agent\plugins\windows_updates.vbs:CMK_VERSION = "2.1.0p26"
C:\ProgramData\checkmk\agent\local\plex_check.ps1:CMK_VERSION = "2.1.0p26"
<<<local:sep(0)>>>
0 Plex server - Plex Media Server is running