View Full Version : SQL Question
Aug 2, 2013, 02:35 PM
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?
Aug 2, 2013, 03:29 PM
Just split it into a few parts:
$ sysctl machdep.cpu.brand_string
machdep.cpu.brand_string: Intel(R) Core(TM) i5-2467M CPU @ 1.60GHz
$ echo $HOSTNAME
$ sysctl hw.model
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.
mysql -e "use database_name; insert into table_name values (...);"
Aug 3, 2013, 12:56 AM
Another source for the data is:
$ 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.