Ad Widget

Collapse

Issues Keeping Zabbix Agent Running On Windows 10

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shoemocker
    Junior Member
    • Oct 2019
    • 7

    #1

    Issues Keeping Zabbix Agent Running On Windows 10

    Hello Everyone!

    I have been using Zabbix 5.4 (latest version) on our Linux servers and Windows server and everything has been absolutely fantastic.

    However I noticed on Windows desktops like Windows 10, the agent just stops running after X amount of time if no user is logged in.

    When I log in to see what is going on I find that the Zabbix agent service is just stopped, so I turn it back on.

    If I stay logged into that machine, the Zabbix agent stays up and data is pulled from the Zabbix Server.

    However, the second I log off, after X amount of time, the Zabbix agent just stops again and alerts go off.

    Is there something special we need to do on the desktop versions of Windows to keep the agent running regardless of someone being logged in or not?

    Thank you in advanced for all your help!

    Michael
  • niveastn
    Member
    • Oct 2021
    • 82

    #2
    Hi there!

    Is there something special we need to do on the desktop versions of Windows to keep the agent running regardless of someone being logged in or not?
    No, not really. But from my own experience with win 10, it has lots of new security functionalities, that mess with a few services (not letting them start, starting with error, blocking a few parts...)
    Please increase debug and send us the log.
    In the agent file, change line DebugLevel to DebugLevel=5, restart service, send us the file after aa few minutes collecting, then change it back to DebugLevel=3, otherwise is going to kill your disk space.
    Last edited by niveastn; 12-11-2021, 16:22. Reason: typos

    Comment

    • shoemocker
      Junior Member
      • Oct 2019
      • 7

      #3
      Turns out the issue was related to the default power options on Windows 10. It is set to balanced so it was actually putting the machine to sleep. This was not a Zabbix issue and a machine misconfiguration issue. After setting power options to High Performance everything is working great again!

      Comment

      • mrportatoes
        Junior Member
        • Mar 2023
        • 6

        #4
        Yeas ago, I was having this issue and the comments shoemocker mentioned pointed me in the right direction. Unfortunately, in our environment we were not permitted to adjust our power config for endpoints. So as part of our install scrip, I have incorporated the following which adds a scheduled task, only to laptops and attempts to restart the Zabbix service on wake. To be honest, I haven't gone back to see if this is still a problem in Win11 but wanted to share it a just in case it helps someone down the road.


        Code:
        #Due to the power settings applied to laptops, the Zabbix service fails to start when the laptop wakes up from sleep/hibernation.
        #This scheduled task will only be created for laptops and start the Zabbix service when the device wakes.
        #Get Chassis Type​
        $enclosureType = (Get-CimInstance -ClassName CIM_Chassis).ChassisTypes
        If ($enclosureType[0] -eq 12 -or $enclosureType[0]-eq 21)
        {} #Ignore Docking Stations
        else {
            switch ($enclosureType[0]) {
            {$_ -in "8", "9", "10", "11", "12", "14", "18", "21","30", "31", "32"} {$DeviceType = "Laptop"}
            {$_ -in "3", "4", "5", "6", "7", "13", "15", "16", "35", "36"} {$DeviceType = "Desktop"}
            Default {$DeviceType = "Error: The value of $enclosureType is unknown" }
            }
        }
        if ("Laptop" -eq $DeviceType) {
            # Check if the task exists
            $taskName = "Start_Zabbix_Service_on_Wake"
            if (Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue) {
                write-log "The task '$taskName' already exists."
            } else {
                $ActionScript = {
                    $ServiceName = 'Zabbix Agent 2'
          
                    # Check if the service is running
                    $service = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
                    if ($service -eq $null -or $service.Status -ne 'Running') {
                        # Start the service if it's not running
                        Start-Service -Name $ServiceName
                    } else { Write-Output "Zabbix Agent 2 service is already running"
                    }
                }
                #Create the "trigger on event" for the scheduled task
                $CIMTriggerClass = Get-CimClass -ClassName MSFT_TaskEventTrigger -Namespace Root/Microsoft/Windows/TaskScheduler:MSFT_TaskEventTrigger
                $Trigger = New-CimInstance -CimClass $CIMTriggerClass -ClientOnly
                $Trigger.Subscription = @"
        <QueryList><Query Id="0" Path="System"><Select Path="System">*[System[(EventID=1) or (EventID=107)]]</Select></Query></QueryList>
        "@
                $Trigger.Enabled = $True
                #Create Scheduled Task
                $Action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument $ActionScript
                $Settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
                $RunUnder = New-ScheduledTaskPrincipal -UserID "NT AUTHORITY\SYSTEM" -LogonType ServiceAccount -RunLevel Highest
                Register-ScheduledTask -TaskName $taskName -Action $Action -Settings $Settings -Trigger $trigger -Principal $RunUnder
            }
        }​

        Note the logging does rely on a write-log function. An example of this can be found here: https://www.powershellgallery.com/pa...CWrite-Log.ps1
        or you can simply remove those lines...

        Comment

        Working...