I recently applied a policy to a Smart Group that installs some software and then restarts the computers. Checking the logs, I see the software installed properly but no mention of reboot on any so I am thinking that shutdown or restart doesn't get logged? If not, wondering if there is a custom attribute or something else that I could use to track uptime or last shutdown/restart on these computers or even all managed clients?
Solved
Uptime or Last Shutdown/Restart
Best answer by jhbush
Last Reboot
#!/bin/bash
lastReboot=`who -b | awk '{print $3" "$4}'`
echo "<result>"$lastReboot"</result>"
exit 0
Uptime in Hours
#!/bin/sh
DAYS="days,"
HRS=" hrs"
DAYScheck=$(uptime | awk {'print $4'})
if [ $DAYScheck = "$DAYS" ]; then
result=$(uptime | awk {'print $3.$4.$5'} | sed 's/,/ /g' | sed 's/d/ d/g')
echo "<result>$result$HRS</result>"
else
result=$(uptime | awk {'print $3'} | sed 's/,//g')
echo "<result>$result$HRS</result>"
fi
exit
Hope that helps.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
