misc: Fix python scripts shebang line
[vpp.git] / src / vpp / stats / stats.md
index d66c31b..8671f56 100644 (file)
@@ -1,4 +1,4 @@
-# Statistics
+# Statistics {#stats_doc}
 
 In VPP most things are measured and counted. There are counters for interface statistics, like RX, TX counters, packet drops, and so on. Every node has a set of per-node counters, one set of error counters, like TTL exceeded, or packet to big or out-of-buffers. And a set of performance counters, like number of clocks, vectors, calls and suspends.
 
@@ -36,7 +36,7 @@ typedef struct {
 ```
 
 #### Writer
-On the VPP side there is a single writer (controlled by a spinlock). When the writer starts it sets in_progress=1, continues with the update of the data-structues, and when done, bumps epoch++ and sets in_progress=0.
+On the VPP side there is a single writer (controlled by a spinlock). When the writer starts it sets in_progress=1, continues with the update of the data-structures, and when done, bumps epoch++ and sets in_progress=0.
 
 #### Readers
 If in_progress=1, there is no point continuing, so reader sits spinning on the in_progress flag until it is 0. Then it sets start_epoch = epoch and continues copying out the counter data it is interested in, while doing strict boundary checks on all offsets / pointers. When the reader is done, it checks if in_progress=1 or if epoch != start_epoch. If either of those are true is discards the data read.
@@ -61,9 +61,9 @@ A new client library can either wrap the C library (libvppapiclient.so) or it ca
 ### Python
 
 ```
-#!/usr/bin/env python
+#!/usr/bin/env python3
 from vpp_papi.vpp_stats import VPPStats
-stats = VPPStats('/var/run/stats.socks')
+stats = VPPStats('/run/vpp/stats.sock')
 dir = stats.ls(['^/if', '/err/ip4-input', '/sys/node/ip4-input'])
 counters = stats.dump(dir)
 
@@ -82,7 +82,7 @@ int main (int argc, char **argv) {
   vec_add1(patterns, "^/if");
   vec_add1(patterns, "ip4-input");
 
-  int rv = stat_segment_connect("/var/run/stats.sock");
+  int rv = stat_segment_connect(STAT_SEGMENT_SOCKET_FILE);
   uint32_t *dir = stat_segment_ls(patterns);
   stat_segment_data_t *res = stat_segment_dump(dir);
 
@@ -106,7 +106,8 @@ int main (int argc, char **argv) {
       break;
 
       case STAT_DIR_TYPE_ERROR_INDEX:
-        fformat (stdout, "%llu %s\n", res[i].error_value, res[i].name);
+        for (j = 0; j < vec_len (res[i].error_vector); j++)
+          fformat (stdout, "[@%d] %llu %s\n", j, res[i].error_vector[j], res[i].name);
       break;
 
       case STAT_DIR_TYPE_SCALAR_INDEX: