Created
August 8, 2014 16:16
-
-
Save pmbuko/c7ca70f2ffc5378047ef to your computer and use it in GitHub Desktop.
Custom facter fact to report the primary user, determined by greatest total login time. The paths are for linux. Adjust as necessary.
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
# primary_user.rb | |
Facter.add("primary_user") do | |
setcode do | |
%x{if [ -f /usr/bin/ac ]; then /usr/bin/ac -p | /bin/sort -nk 2 | /bin/awk '/total/{print x};{x=$1}';fi}.chomp | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I love this idea. Thanks, Peter.