Creating a smart group showing Macs with more than 7 days of uptime

howie_isaacks
Valued Contributor

I am trying to create a smart group that will show me Macs that have been booted for more than 7 days. Many times, my team gets support tickets from users that would not have been necessary if they had rebooted their Macs at least once a week. I love that Macs can stay booted for a really long time. My record is 92 days, but to get there, I had to put up with some quirks and minor issues. I just wanted to see how long I could go between reboots. I don't want my users doing this, so I want to create a smart group for Macs that are booted up longer than 7 days, and then display a message asking them to please reboot soon. I have found extension attributes that will show me the up time, or last reboot, but when I go to create the smart group, the operator shows only is, is not, like, and not like. What I need it to show is something like "more than X days ago". Does anyone know how I get this? Maybe I'm using the wrong extension attributes?665ca322552944959cdb1232b800df5b

1 ACCEPTED SOLUTION

talkingmoose
Honored Contributor II

When adding the Extension Attribute, be sure to set the Data Type drop down menu to "Integer" instead of "String. Jamf Pro supports evaluating more than and less than tests with integers and dates.

2f9e7171f8574a468c30e9d55055add7

This lets you choose "more than" or "less than" in your Smart Group.

c0847b5ae9224049a24b702aa12a0c13

For completeness, here's my EA script for uptime:

#!/bin/sh

dayCount=$( uptime | awk -F "(up | days)" '{ print $2 }' )

if ! [ "$dayCount" -eq "$dayCount" ] 2> /dev/null ; then
    dayCount="0"
fi

echo "<result>$dayCount</result>"

exit 0

View solution in original post

2 REPLIES 2

talkingmoose
Honored Contributor II

When adding the Extension Attribute, be sure to set the Data Type drop down menu to "Integer" instead of "String. Jamf Pro supports evaluating more than and less than tests with integers and dates.

2f9e7171f8574a468c30e9d55055add7

This lets you choose "more than" or "less than" in your Smart Group.

c0847b5ae9224049a24b702aa12a0c13

For completeness, here's my EA script for uptime:

#!/bin/sh

dayCount=$( uptime | awk -F "(up | days)" '{ print $2 }' )

if ! [ "$dayCount" -eq "$dayCount" ] 2> /dev/null ; then
    dayCount="0"
fi

echo "<result>$dayCount</result>"

exit 0

View solution in original post

howie_isaacks
Valued Contributor

Thanks @talkingmoose ! I totally forgot about that. I need to work with extension attributes more.