1# Demo on how to extract the first "model name" field from /proc/cpuinfo 2# into a variable. 3# Can be used for inventory information in CFEngine Nova and above. 4 5body common control 6{ 7 bundlesequence => { "inventory" }; 8} 9 10### 11 12bundle common inventory 13{ 14 vars: 15 "cpuinfo" string => execresult("/bin/grep \"model name\" /proc/cpuinfo", "noshell"); 16 17 got_model_name:: 18 "cpu" string => "$(myarray[1])"; 19 20 classes: 21 22 "got_model_name" expression => regextract( 23 "model\s+name\s+:\s+([^\n]*)\n?.*", 24 "$(cpuinfo)", 25 "myarray" 26 ); 27 28 reports: 29 got_model_name:: 30 "model name is \"$(myarray[1])\""; 31 32 !got_model_name:: 33 "Did not match CPU model name"; 34} 35 36