(imported comment written by SystemAdmin)
I do use several scripts to address or prevent unresponsive agents in certain (but not all) scenarios. The BESclientHelper is supposed to help, but isn’t effective in several scenarios, corruption in particular.
Note: The following scripts were created and tested on Windows clients only.
Scenario: Agent is reporting and responds to Master Operator actions, but not custom site actions.
An analysis can assist in identifying such agents. Unfortunately, we can’t parse the active client log (which is rather ironic), so we have to settle for previous days logs.
exists lines containing “Site data corrupted” of it of files whose (creation time of it < (now - time interval “1 day”)) of folder (if (exists folder “C:\Program Files\BigFix Enterprise\BES Client”) then (“C:\Program Files\BigFix Enterprise\BES Client__BESData__Global\Logs”) else (if (exists folder “C:\Program Files (x86)\BigFix Enterprise\BES Client”) then (“C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData__Global\Logs”) else (“C:\Program Files\BigFix Enterprise\Enterprise Client__BESData__Global\Logs”)))
Similar properties can also be created for “BigFix could not verify the authenticity of the site content” or others.
In this case, we take the following action as a Master Operator to clear the __BESdata:
if {not exists folder “c:\bad”}
dos md c:\bad
endif
if {not exists folder “c:\temp”}
dos md c:\temp
endif
delete c:\BESData.log
delete c:\temp\cleanup.bat
delete __appendfile
appendfile @echo off
appendfile md “c:\bad{current date}”
appendfile net stop healthservice
appendfile net stop besclienthelper
appendfile net stop besclient
appendfile move /Y “{pathname of parent folder of client & “__BESData”}” “c:\bad{current date}”
appendfile echo %date% %time% > c:\BESData.log
appendfile net start besclient
appendfile net start besclienthelper
appendfile net start healthservice
appendfile exit
copy __appendfile c:\temp\cleanup.bat
dos echo %time% > c:\temp\time.txt
dos at {((preceding text of last “:” of line 1 of it) of file “c:\temp\time.txt” as time_of_day) + time interval “00:02:00”} c:\temp\cleanup.bat /interactive
Scenario: Agent reports, but is unresponsive to MO or custom site actions. Execute the cleanup script above via some other means (interactively, SCOM, etc.).
Scenario: Daily scheduled check to make sure agent is running.
I’ve noticed there are situations in which portions of the agent are corrupt and BESclientHelper is unable to restart the agent. The scripts below are a daily automated attempt to deal with disk corruption that may have occurred in the past day rendering the agent unable to start. The check is scheduled as a local task in the Windows scheduler.
if {not exists folder “c:\windows\sct”}
dos md c:\windows\sct
endif
if {not exists folder “c:\bad”}
dos md c:\bad
endif
if {not exists folder “c:\temp”}
dos md c:\temp
endif
delete c:\windows\sct\BES_clear_sch.bat
delete __appendfile
appendfile @echo off
appendfile for /f %%i in (‘at ^| find “1 Each M T W Th F S Su 7:00 AM c:\windows\sct\BEScheck.bat”’) do at 1 /delete
appendfile for /f %%i in (‘at ^| find “2 Each M T W Th F S Su 7:00 AM c:\windows\sct\BEScheck.bat”’) do at 2 /delete
appendfile for /f %%i in (‘at ^| find “3 Each M T W Th F S Su 7:00 AM c:\windows\sct\BEScheck.bat”’) do at 3 /delete
appendfile for /f %%i in (‘at ^| find “4 Each M T W Th F S Su 7:00 AM c:\windows\sct\BEScheck.bat”’) do at 4 /delete
appendfile for /f %%i in (‘at ^| find “5 Each M T W Th F S Su 7:00 AM c:\windows\sct\BEScheck.bat”’) do at 5 /delete
appendfile for /f %%i in (‘at ^| find “6 Each M T W Th F S Su 7:00 AM c:\windows\sct\BEScheck.bat”’) do at 6 /delete
appendfile for /f %%i in (‘at ^| find “7 Each M T W Th F S Su 7:00 AM c:\windows\sct\BEScheck.bat”’) do at 7 /delete
copy __appendfile c:\windows\sct\BES_clear_sch.bat
waithidden c:\windows\sct\BES_clear_sch.bat
delete c:\windows\sct\BEScheck.bat
delete __appendfile
appendfile @echo off
appendfile c:
appendfile cd\
appendfile cd windows\sct
appendfile del /q check.log
appendfile for /f %%i in (‘tasklist ^| find “BESClient.exe”’) do echo %%i > check.log
appendfile if exist check.log goto END
appendfile start /min BEScleanup.bat
appendfile :END
appendfile exit
copy __appendfile c:\windows\sct\BEScheck.bat
delete c:\windows\sct\BEScleanup.bat
delete __appendfile
appendfile @echo off
appendfile set bad=%date%
appendfile md “c:\bad”
appendfile md “c:\bad%bad%”
appendfile net stop besclienthelper
appendfile move /Y “{pathname of parent folder of client & “__BESData”}” “c:\bad%bad%”
appendfile echo %date% %time% >> c:\windows\sct\BEScheck.log
appendfile net start besclient
appendfile exit
copy __appendfile c:\windows\sct\BEScleanup.bat
dos at 07:00:00 /every:monday,tuesday,wednesday,thursday,friday,saturday,sunday c:\windows\sct\BEScheck.bat /interactive
Notes:
- These scripts may be a bit primative, but they are effective. They automatically catch and remediate quite a few instances of agent corruption without any intervention.
- A simple analysis of the BEScheck.log and BESdata.log will tell you the times and frequencies that auto-remediation is happening.
- Why the old school use of the “at” command? For the interactive switch which seems to be essential in making this work.
- The “Daily Check” is effective when run as a policy action across the enterprise. Once it is scheduled in the local Task Scheduler, it will automatically deal with corrupt dynamic data (__BESdata) that keeps the agent from starting.