diff options
author | Ole Troan <ot@cisco.com> | 2018-08-31 00:29:48 +0200 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2018-09-02 16:13:57 +0000 |
commit | 732021070fa0c731896ab3e29f802d3834c72ab7 (patch) | |
tree | d7ecbd4e4c986333b1ba59db931f0e3283da2195 /src/vpp-api/client | |
parent | 855e26868ff8b9e6d00ca4d69ce6c9fdc0f2e121 (diff) |
STATS: Python binding to access VPP statistics and counters.
from vpp_papi.vpp_stats import VPPStats
s = VPPStats(socketname='/var/run/stats.sock')
c = s.ls('/if/rx')
counters = s.dump(c)
print(s.set_error_str())
Change-Id: I203ebe60b0c9ee5742aadc737c0f29051757959d
Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/vpp-api/client')
-rw-r--r-- | src/vpp-api/client/libvppapiclient.map | 2 | ||||
-rw-r--r-- | src/vpp-api/client/stat_client.c | 23 | ||||
-rw-r--r-- | src/vpp-api/client/stat_client.h | 9 |
3 files changed, 26 insertions, 8 deletions
diff --git a/src/vpp-api/client/libvppapiclient.map b/src/vpp-api/client/libvppapiclient.map index 81391ea7687..f51b92403da 100644 --- a/src/vpp-api/client/libvppapiclient.map +++ b/src/vpp-api/client/libvppapiclient.map @@ -21,5 +21,7 @@ VPPAPICLIENT_18.10 { stat_segment_dump; stat_segment_data_free; stat_segment_heartbeat; + stat_segment_string_vector; + stat_segment_vec_len; local: *; }; diff --git a/src/vpp-api/client/stat_client.c b/src/vpp-api/client/stat_client.c index d7d20452583..ad7078ea745 100644 --- a/src/vpp-api/client/stat_client.c +++ b/src/vpp-api/client/stat_client.c @@ -112,7 +112,7 @@ stat_segment_register (u8 * stats[]) p = hash_get_mem (sm->counter_vector_by_name, stats[i]); if (p == 0) { - fprintf (stderr, "WARN: %s not in directory!", stats[i]); + fprintf (stderr, "WARN: %s not in directory!\n", stats[i]); continue; } vec_add2 (cached_pointer_vec, cp, 1); @@ -183,7 +183,7 @@ maybe_update_cached_pointers (stat_segment_cached_pointer_t * cached_pointers) p = hash_get_mem (sm->counter_vector_by_name, cp->name); if (p == 0) { - fprintf (stderr, "WARN: %s not in directory!", cp->name); + fprintf (stderr, "WARN: %s not in directory!\n", cp->name); continue; } cp->ep = (stat_segment_directory_entry_t *) (p[0]); @@ -351,7 +351,7 @@ stat_segment_dump (u8 * stats[]) p = hash_get_mem (sm->counter_vector_by_name, stats[i]); if (p == 0) { - fprintf (stderr, "WARN: %s not in directory!", stats[i]); + fprintf (stderr, "WARN: %s not in directory!\n", stats[i]); continue; } /* Collect counter */ @@ -363,6 +363,23 @@ stat_segment_dump (u8 * stats[]) return res; } +/* Wrapper for accessing vectors from other languages */ +int +stat_segment_vec_len (void *vec) +{ + return vec_len (vec); +} + +/* Create a vector from a string (or add to existing) */ +u8 ** +stat_segment_string_vector (u8 ** string_vector, char *string) +{ + u8 *name = 0; + name = vec_dup ((u8 *) string); + vec_add1 (string_vector, (u8 *) name); + return string_vector; +} + /* * fd.io coding-style-patch-verification: ON * diff --git a/src/vpp-api/client/stat_client.h b/src/vpp-api/client/stat_client.h index 5f076686fdd..73e91b1881b 100644 --- a/src/vpp-api/client/stat_client.h +++ b/src/vpp-api/client/stat_client.h @@ -42,16 +42,15 @@ typedef struct int stat_segment_connect (char *socket_name); void stat_segment_disconnect (void); - u8 **stat_segment_ls (u8 ** pattern); stat_segment_data_t *stat_segment_dump (u8 ** counter_vec); - stat_segment_cached_pointer_t *stat_segment_register (u8 ** counter_vec); -stat_segment_data_t *stat_segment_collect (stat_segment_cached_pointer_t *); /* Collects registered counters */ - +/* Collects registered counters */ +stat_segment_data_t *stat_segment_collect (stat_segment_cached_pointer_t *); void stat_segment_data_free (stat_segment_data_t * res); - f64 stat_segment_heartbeat (void); +u8 **stat_segment_string_vector (u8 ** string_vector, char *string); +int stat_segment_vec_len (void *vec); #endif /* included_stat_client_h */ |