@@ -28,6 +28,15 @@ class SysInfo {
2828 OSDeleteFile (psTempScri pt )
2929 }
3030
31+ // Method to get device mod el
32+ func model () {
33+ // Get model info from modelIn fo
34+ modelIn fo = modelInfo ()
35+
36+ // Return the model in fo
37+ return modelIn fo
38+ }
39+
3140 // Method to get the hostna me
3241 func hostname () {
3342 // Execute command to get hostname
@@ -437,17 +446,45 @@ class SysInfo {
437446 return networkIn fo
438447 }
439448
440- // Method to get device mod el
441- func model () {
442- // Get model info from modelIn fo
443- modelIn fo = modelInfo ()
449+ private
444450
445- // Return the model in fo
446- return modelIn fo
447- }
451+ // Helper function to get device mod el
452+ func modelInfo () {
453+ // Initialize model
454+ mod el = "Unknown"
448455
449- private
456+ // Check if the OS is Windows
457+ if (isWindows ()) {
458+ // Get the device model from winSysInfo List
459+ if (!isNull (winSysIn fo [:mod el ])) {
460+ mod el = winSysIn fo [:mod el ]
461+ }
462+ elseif (isLinux ()) // If the OS is Linux
463+ // Define a list of dmi file pat hs
464+ dmiPat hs = [
465+ "/sys/class/dmi/id/product_name" ,
466+ "/sys/class/dmi/id/product_version" ,
467+ "/sys/class/dmi/id/board_name"
468+ ]
469+
470+ // Loop through each dmi path to get the mod el
471+ for path in dmiPat hs {
472+ if (fexists (pa th )) {
473+ fileConte nt = trim (readFile (pa th ))
474+ if (!isNull (fileConte nt ) and len (fileConte nt ) > 0 ) {
475+ mod el = substr (fileConte nt , nl, "" )
476+ return mod el
477+ }
478+ }
479+ }
480+ elseif (isFreeBSD ()) // If the OS is FreeBSD
481+ mod el = trim (systemCmd ("sysctl -n hw.model" ))
482+ }
450483
484+ // Return the model
485+ return mod el
486+ }
487+
451488 // Helper function to get osInfo
452489 func osInfo () {
453490 // Initialize the OS info li st
@@ -955,43 +992,6 @@ class SysInfo {
955992 return networkIn fo
956993 }
957994
958- // Helper function to get device mod el
959- func modelInfo () {
960- // Initialize model
961- mod el = "Unknown"
962-
963- // Check if the OS is Windows
964- if (isWindows ()) {
965- // Get the device model from winSysInfo List
966- if (!isNull (winSysIn fo [:mod el ])) {
967- mod el = winSysIn fo [:mod el ]
968- }
969- elseif (isLinux ()) // If the OS is Linux
970- // Define a list of dmi file pat hs
971- dmiPat hs = [
972- "/sys/class/dmi/id/product_name" ,
973- "/sys/class/dmi/id/product_version" ,
974- "/sys/class/dmi/id/board_name"
975- ]
976-
977- // Loop through each dmi path to get the mod el
978- for path in dmiPat hs {
979- if (fexists (pa th )) {
980- fileConte nt = trim (readFile (pa th ))
981- if (!isNull (fileConte nt ) and len (fileConte nt ) > 0 ) {
982- mod el = substr (fileConte nt , nl, "" )
983- return mod el
984- }
985- }
986- }
987- elseif (isFreeBSD ()) // If the OS is FreeBSD
988- mod el = trim (systemCmd ("sysctl -n hw.model" ))
989- }
990-
991- // Return the model
992- return mod el
993- }
994-
995995 // Helper function to parse ip addr output (For Lin ux )
996996 func parseIpAddr (outp ut ) {
997997 // Initialize interfaces li st
0 commit comments