(CFACT-70) maintenance - refactor usage of kstat to a wrapper

kstat APIs are used by solaris and other systems like free bsd to fetch kernel statistics. This patch refactors the kstat invocations into a simpler wrapper that handles both errors and data retrieval.
Even though `kstat_entry` has a lightweight copy, it's a good habit never to use `auto` in a ranged for.  Prefer using `auto&` or `auto const&` to ensure there's no unintended copying.  Do you mind changing this to `auto const&` even though it technically doesn't matter in this case?  There's one or two places in the existing code that need this change too.