Posted on 06-01-2012 05:09 AM
I would like to add an extension attribute for computer type, meaning Laptop, Server or Desktop. Obviously this could be a dumb drop down, but it would be great if there was a way to do it via computer model. Does anyone know if there is there a way that I could get an extension attribute to read the "Model" field in the hardware section of a computer in the JSS, then check against a list of what is considered a laptop or desktop, then mark the computer as such? This would obviously be a script that would have to run against the model of the computer that is captured during a Recon.
I have traditionally just used Smart Groups with model is like or not like, but it would be really helpful to have this as a piece of data embedded in each JSS entry.
Would be very helpful. Or, maybe someone knows another easy way to add this data to the JSS.
Another way to do this would be to do a search models that match all the different laptop models in the school, or "model like MacBook", then if bulk edit of an extension attribute drop down was possible…I would love the option of "bulk edit field..." in the "take action on..." menu, where you could bulk edit any field you want. But I already made a feature request for that here: https://jamfnation.jamfsoftware.com/featureRequest.html?id=150
Thanks all.
Posted on 06-01-2012 05:39 AM
i just whipped up this to use as an extension attribute. does that work for you?
Posted on 06-01-2012 05:57 AM
technically, i didn't need to define methods there. could be simpler, like this:
#!/usr/bin/ruby
model = %x(system_profiler SPHardwareDataType).match(/Model Identifier: .+$/).to_s.split(":").last.strip
if model =~ /(Air|Book)/
puts "<result>Laptop</result>"
elsif model =~ /(iMac|MacPro|Mini)/
puts "<result>Desktop</result>"
end
Posted on 06-01-2012 07:38 AM
Interesting idea. I just incorporated that into the naming convention:
<dept>-<machine type>-<location>
So I would have something like GFX-MacPro05-NT305A, which would represent Mac Pro # 5 in the Graphics Dept, at desk NT305A.
</trivia>
Posted on 06-01-2012 08:12 AM
Lately I've been trying to use ioreg in scripts to get basic computer info when possible as opposed to invoking system_profiler. Even when specifying a particular DataType system_profiler is a bit resource heavy. ioreg is near instant in what it returns. It may not seem like much of a difference, but we have dozens of EA's being pulled each time, so every little bit counts.
(As an aside, its becoming more and more important that we be able to choose what gets updated on each recon submission on a more granular basis. If you agree, vote up this FR: https://jamfnation.jamfsoftware.com/featureRequest.html?id=18)
Something like this will pull the model info (along with some extras characters (",<,>) that need to be cleaned up if you intended to use it for actual naming, etc)
ioreg -c IOPlatformExpertDevice | awk '/model/{ print $NF }'
I imagine it could be sent through some of the same ruby commands as above, but I don't know much about ruby scripting so I'm not sure.
Posted on 06-01-2012 08:28 AM
Recon already captures this information. You can filter by "Model" under Hardware Information.
I have three Smart Groups:
All laptops = Model like Book
All Desktops = Model not like Book + Model not like XServe
All Servers = Model like XServe
These meet my needs but may need to be tweaked if you're running Mac Pro server hardware. I don't have any of those and can't tell you how those models get reported.
Posted on 06-01-2012 08:39 AM
Recon already captures this information. You can filter by "Model" under Hardware Information.
Yes, true, but he stated in his second paragraph-
I have traditionally just used Smart Groups with model is like or not like, but it would be really helpful to have this as a piece of data embedded in each JSS entry.
so, sounds like having it as an actual field just displaying "Laptop" "Desktop" or "Server" would be useful to the OP for whatever reason.
Posted on 06-01-2012 08:45 AM
Yep, I see that now. Apologies for not understanding the whole question first.
Jay, can you elaborate on what you're wanting to accomplish with something like this? Also, what do you mean by "would be really helpful to have this as a piece of data embedded in each JSS entry"?
Posted on 06-01-2012 08:49 AM
william is right. i posted the stuff above as an example if you needed that sort of thing.
mike, you might try this to get the chopped model name only. i don't know if it's any quicker, and the awk statement could definitely be written more elegantly.
ioreg -c IOPlatformExpertDevice | awk '/model/ { gsub(/([|"=<>])/,""); sub(/model /,""); sub(/ +/,""); print}'
Posted on 03-30-2013 06:21 PM
For what it's worth I like using cut instead of complex awk statements, this works well for me for cleaning this query up:
ioreg -c IOPlatformExpertDevice | grep model | cut -d" -f4