-
-
Save malroy/3505737 to your computer and use it in GitHub Desktop.
Casper Extension Attribute for number of Days of Uptime - https://jamfnation.jamfsoftware.com/editPost.html?id=19177&pid=4058&type=d
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Commands required by this script | |
declare -x awk="/usr/bin/awk" | |
declare -x sysctl="/usr/sbin/sysctl" | |
declare -x perl="/usr/bin/perl" | |
declare -xi DAY=86400 | |
declare -xi EPOCH="$($perl -e "print time")" | |
declare -xi UPTIME="$($sysctl kern.boottime | | |
$awk -F'[= ,]' '/sec/{print $6;exit}')" | |
declare -xi DIFF="$(($EPOCH - $UPTIME))" | |
if [ $DIFF -le $DAY ] ; then | |
echo "<result>1</result>" | |
else | |
echo "<result>$(($DIFF / $DAY))</result>" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment