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

howie_isaacks
Valued Contributor II

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
Moderator
Moderator

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

3 REPLIES 3

talkingmoose
Moderator
Moderator

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

Hi William, I found your information online and I saw on the Jamf community platform how you share great solutions to people. I am reaching out to you because I just failed my Jamf 200 TEST and I can remembers some questions which made me fail the test, and I was wondering if you are available for a paid 1-2hrs session to just go over the questions with you, hopefully you virtual instances of JAMF for practical purpose, please let me know if this is possible, I really appreciate !

My email: Born2rebuild@gmail.com I look forward to hearing back from you either on here or via my email, thanks again

 

 

howie_isaacks
Valued Contributor II

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