03 / MODEL SYSTEMS AND CHANGES · LESSON 09

Assess simulated OS and hardware facts

Join a fleet inventory to recorded system facts and retain missing coverage.

22 min · learn at your pace

Separate collection from assessment

An operating-system collector might use different commands on macOS, Linux and Windows. An assessment should not need to run those commands itself. Give it a small exported contract: host identity, operating-system label, core count and memory capacity. Then test the assessment with ordinary files.

The supplied tables are simulated fleet data. They do not describe the browser, your phone or the machine hosting this website. The inventory defines which hosts belong in the report. A facts row for an unrelated host must not expand that scope, while an inventory host without facts must remain visible.

Missing is not zero

An observed zero and an absent observation have different meanings. This lesson accepts nonnegative counts as already validated measurements; zero therefore triggers a capacity review. Missing facts instead produce unknown and dashes for the unavailable values. Do not substitute your own browser's system details or a plausible default.

Keep thresholds explicit. Two cores and 4096 MiB meet this exercise's minimum; values below either require review. This is a fictional capacity policy rather than a universal hardware recommendation. A real report should also preserve collection time and provenance so reviewers know whether a fact is current. Later lessons combine these facts with exposure evidence without turning incomplete coverage into a passing assessment.

Try an example.sh
awk -F '\t' 'NR>1 {printf "%s: %s, %s cores\n",$1,$2,$3}' facts.tsv
YOUR TURN

Put it into practice.

inventory.tsv lists unique host IDs under host. facts.tsv has unique host<TAB>os<TAB>cores<TAB>memory_mib rows with validated nonnegative counts. Print host<TAB>os<TAB>cores<TAB>memory_mib<TAB>state, one row per inventory host sorted under LC_ALL=C. Known facts are review if cores<2 or memory_mib<4096, otherwise ok. Missing facts use - in all three fact fields and unknown. Ignore facts-only hosts. Preserve Unicode OS labels and leave sources unchanged.

See an explained solution
One way to solve it.sh
export LC_ALL=C
printf 'host\tos\tcores\tmemory_mib\tstate\n'
awk -F '\t' 'FILENAME==ARGV[1]{if(FNR>1){os[$1]=$2;cores[$1]=$3;memory[$1]=$4}next}
FNR>1 {
 state="unknown";o="-";c="-";m="-"
 if($1 in os){o=os[$1];c=cores[$1];m=memory[$1];state=(c<2 || m<4096 ? "review" : "ok")}
 printf "%s\t%s\t%s\t%s\t%s\n",$1,o,c,m,state
}' facts.tsv inventory.tsv | sort

The inventory controls scope and the facts table supplies only recorded observations. Keeping missing values separate from zero avoids manufacturing hardware evidence, while explicit inclusive minimums make the assessment reproducible.