Below we have a Custom Fact Script and a Script that can be combined in a monitoring item to assist in reminding users to reboot their devices by giving them a prompt once a day until they restart their device.
How to Create or Edit a Custom Device Fact
Creating and Running Scripts on Your Devices
Custom Fact
#!/bin/sh
promptDateFile="/Library/Addigy/promptDay.txt"
date=$(date +"%a %b %d")
if [ ! -e $promptDateFile ]; then
echo $date > $promptDateFile
fi
if [[ $(cat $promptDateFile) == $date ]]; then
echo 0
exit 0
fi
sh /Library/Addigy/auditor-facts/scripts/uptime_days
Script
#!/bin/bash
# Adjust these variables as they will replace the text in the flags
title="Restart of Device needed"
description="Your device has been online for $(sh /Library/Addigy/auditor-facts/scripts/uptime_days) days and needs a restart. Please make sure to save your work before clicking Restart"
acceptText="Restart"
closeText="Not Now"
timeOut=120
forefront="True"
promptDateFile="/Library/Addigy/promptDay.txt"
date=$(date +"%a %b %d")
echo $date > $promptDateFile
if /Library/Addigy/macmanage/MacManage.app/Contents/MacOS/MacManage action=notify title="${title}" description="${description}" closeLabel="${closeText}" acceptLabel="${acceptText}" timeout="$timeOut" forefront="$forefront"; then
# executes a desired command if the user clicks the Restart label.
echo "Restart label clicked"
(sleep 31 && shutdown -r now)> /dev/null 2>&1 &
(/Library/Addigy/macmanage/MacManage.app/Contents/MacOS/MacManage action=notify description="Device restarting in 30 seconds, please save your work" timeout="29")> /dev/null 2>&1 &
exit 0
else
# executes a desired command if the user clicks the Restart label.
echo "Restart Postponed"
fi
Monitoring Item
After building these out, use the Custom Fact as the alert trigger set to a specific number of days that you'd like this to trigger after. Then, set the Remediation script to the script you saved on the devices page. Here is what the final product will look like: