Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bigMAC28

macrumors member
Original poster
Apr 16, 2012
91
0
Chicago
Hi guys,

Is it possible to write a script that pulls basic computer info (Name,PC Model Number, Processor speed) that will run when a machine is imaged using pxe boot, then update the database using said information?
 
Just split it into a few parts:

Code:
$ sysctl machdep.cpu.brand_string
machdep.cpu.brand_string: Intel(R) Core(TM) i5-2467M CPU @ 1.60GHz

$ echo $HOSTNAME
Bill-iMac.local

$ sysctl hw.model
hw.model: MacBookAir4,1

I'll leave it up to you to decide how you want to put that into a SQL database. Store them as variables in a bash script and then just upload them with an INSERT statement, running from a MySQL command prompt.
Code:
mysql -e "use database_name; insert into table_name values (...);"
 
Another source for the data is:

Code:
$ system_profiler SPHardwareDataType SPSoftwareDataType

It is possible to write code to do this when a machine PXE boots. You'll need to work out where to host the database. This is probably easiest to achieve by creating a custom Linux boot image and then deploy that image on a PXE server. But this is quite a bit more work than just writing a script.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.