pulling model, serial number, netgate device ID from CLI
-
When I initially SSH in, the very first line before it shows the menu is:
Netgate 3100 - Serial: XXXXXXXXXXX - Netgate Device ID: yyyyyyyyyyyyyyyyy
I can grab that and parse it, but I'm wondering if there's a better way to descretely grab those 3 pieces of information to store as variables for an asset inventory project I'm working on. We also have some non-netgate devices I'd like to be able to capture model/serial information on if possible.
-
On 23.05, you can get some info out of the nodes under
sysctl dev.netgate
for exampledev.netgate.model
But if you look at the source of
/etc/rc.banner
which draws the top lines of the menu, you can find the functions which fetch the other info. Some of it comes fromkenv
. -
@jimp super helpful - just what I needed! I'm a powershell guy and here's where I landed on this in case anyone else is in the same boat:
$hardwareModelRaw = & "$env:ProgramFiles\putty\plink.exe" admin@$pfSenseIP -pw $pfSensePW -batch -hostkey $pfSenseHostKey 'sysctl dev.netgate.desc' $pos = $hardwareModelRaw.indexof(": ") $hardwareModel = $hardwareModelRaw.substring($pos+2) $pfSerialNumber = & "$env:ProgramFiles\putty\plink.exe" admin@$pfSenseIP -pw $pfSensePW -batch -hostkey $pfSenseHostKey '/bin/kenv -q uboot.boardsn'