#! /bin/sh
# 
# Copyright (c) 2007 University of Utah and the Flux Group.
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
# 
# clean_logonui - Kill the logonui.exe task periodically.  It is instantly
# restarted by Windows, but is "cleaned out" in the process.
# 
# This works around the 15-second "sawtooth" pattern that shows up in the load
# average.  lsass.exe is run by logonui.exe and eats the whole CPU for a time
# proportional to the number of users in the Administrators group (local_roots
# in the project), possibly re-checking their authentication.  This only shows
# up after a reboot where the accounts are already set up, so the first boot
# was always clean.
# 
# On a slow machine, in a project like tbres with many local_roots, it eats
# 75% of the CPU.  The CPU usage slowly grows over time, so we repeat the dose
# of medicine every few minutes.

while true; do
    taskkill /F /IM logonui.exe 
    sleep 300
done

  
