want local zone TCP kstats in the global zone
The "tcp" module provides a kstat of class "mib2" that's particularly interesting. See INTRO-361. There appears to be one such kstat for each TCP stack, which generally means one such kstat for each zone. However, the local zone ones aren't visible to the global zone.
From the GZ:
# kstat -p -m tcp -c mib2 -s attemptFails tcp:0:tcp:attemptFails 1
From a local zone on the same system:
$ kstat -p -m tcp -c mib2 -s attemptFails tcp:0:tcp:attemptFails 16
Note that these things are obviously measuring different things, and I assume the GZ kstat is showing the stats for the GZ's TCP stack while the local zone one is showing the stats for the local zone TCP stack. For work we're doing, we'd need the local-zone kstats available in the global zone. The trick will be naming them, since as we saw above the names of these kstats in the local zone exactly matches that in the GZ, and it's possible that we can't change the naming of the existing kstats because too many tools depend on them. I'm not sure about that.
For what it's worth, the "link" module kstats do something like what we want:
From the global zone:
[root@headnode (coal:0) ~]# kstat -p -m link -s rbytes link:0:e1000g0:rbytes 87353654 link:0:e1000g1:rbytes 416794441 ... link:0:z24_net0:rbytes 232662551
From the "ca" zone:
# kstat -p -m link -s rbytes link:0:ca0:rbytes 109146563
Notice that the global zone can see all zones' NICs, while each zone can only see its own. And the kstats are named differently inside the local zone than the are in the GZ. The one thing I'd change is that it would be nice if we could more easily pull out the zonename from the kstat identifier because otherwise we have to maintain our own zoneid/zonename mapping.