This discussion covers how to configure ControlUp to restart a server with the CU Agent when no users are on, including removing it from maintenance mode after reboot. Suggested actions include using a trigger that checks for session count and maintenance mode, and separate scripts for Reboot and Disable Maintenance mode. The benefits of using this method compared to scripts are explained.
Read the entire ‘Configuring ControlUp for Automatic Reboot and Maintenance Mode Removal’ thread below:
Is there a way to modify the "Restart computer with CU Agent" script so that it only executes where there are 0 users on the server?
I’m sure it can be done but what are you trying to ultimately do?
Are you wanting to run this on a trigger?
Yes. We’ve done this. There’s something in general purpose servers display that will show you how many people are logged on. You can then specify this in a trigger. We do it to put machines into maintenance mode when there’s no users online
☝️Thats exactly why I ask…
The problem if you don’t do it this way, the trigger will fire, run the script, check that a user is on and quit. The trigger would never refire depending on what the original trigger was.
I’ll take a look at ours and see what we did
Yes – we want this to run on a machine where we bleed users off a server that is in maintenance mode
Basically we have an Event Log trigger that when it hits, it performs the following:
- places server into Maintenance Mode
- logs off disconnected users
We want the third action to be reboot the server when no users are left on it
That would need to be broken up into a couple triggers/actions.
The final reboot one could be something like If XD Maintencance Mode = True and User Sessions = 0 and uptime > 1 hour then reboot machine with cuagent.
Thanks!
Would there be a way to take it out of maintenance after automatically?
Is that something you would really want to automate? Like what if you need to keep it in maintenance mode?
Basically we would want to place the server back into production after the reboot
But true – it is something we can do manually
Why does it need to be a separate trigger/script?
I have a script process that when launched via management system:
- Creates a HyperV Checkpoint
- Puts server in Citrix Maintenance mode.
- Puts server in monitoring downtime mode (no alerts)
- (Does not log out disconnected sessions, but I am now thinking of adding that)
- Monitors sessions until there are no users logged in.
- Disables maintenance mode.
- Reboots the server.
Could you base this off the "User Logged Off" trigger? The checks would then be on session count and in-maintenance-mode.
@member The concern I would have is that the script has to sit in a loop while waiting for the server to clear, and that a script is relatively opaque compared to configurations that are easy to see for anyone else on your team. Separating it into individual triggers for each step will reduce load, get rid of the risk of something interrupting the script, and make it easier for someone else to validate what it’s supposed to do on your team (I’m remembering GPO vs. script design decisions in various customer environments from my consulting days- GPO was always the cleaner option because we could identify everything that was happening much more quickly if there was an issue).
I’d probably put the first 4 steps into a single script, then use a trigger to do the fifth and fire off a script (or a pair of them) to reboot and disable maintenance mode.
Continue reading and comment on the thread ‘Configuring ControlUp for Automatic Reboot and Maintenance Mode Removal’. Not a member? Join Here!
Categories: All Archives, ControlUp Edge DX, ControlUp Scripts & Triggers