title: Dtrace script that returns %CPU, %Memory and network in/out aggregated by zone
body: <p>I need a DTrace script that returns CPU usage percentage, memory usage percentage and network input and output bytes used, aggregating the data by zone. Something like this:</p>
  
  <pre><code>ZONE  %CPU %MEM NET_INPUT NET_OUTPUT
  zone1 25%  12%   86012     1294
  zone2 48%  65%   86012     7354
  zone3  8%  14%  268153    68746
  </code></pre>
  
  <p>By now, I am using:</p>
  
  <pre><code>prstat -Z -c -n 1,99999 5 1
  </code></pre>
  
  <p>That return something similar (without network traffic):</p>
  
  <pre><code>Please wait...
     PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP       
   32051 root     1090M 1079M sleep    1    0  12:57:25 0,4% qemu-system-x86/7
  ZONEID    NPROC  SWAP   RSS MEMORY      TIME  CPU ZONE                        
    3228        2 1090M 1079M   2,2%  12:57:25 0,4% 6ce064b6-fec9-4daa-ba2b-0082f73fca73
       0      105 2075M  633M   1,1% 202:56:51 0,4% global                      
    3031        2 2105M 2094M   4,3%  17:04:52 0,3% e32fb987-35f7-4860-a04a-ca26c327d4ba
  (...)
    3411       18   81M   54M   0,1%   0:00:04 0,0% 52120eb6-2e20-4a64-8f7a-235a44d9f100
  Total: 894 processes, 5460 lwps, load averages: 0,53, 0,53, 0,54
  </code></pre>
  
  <p>I need to get the same, but done with DTrace, in order to combine the data with network traffic, and more probes in the future.</p>