diff --git a/exec/coroipcs.c b/exec/coroipcs.c index b64c5a95..29655ba3 100644 --- a/exec/coroipcs.c +++ b/exec/coroipcs.c @@ -1546,15 +1546,27 @@ static void coroipcs_init_conn_stats ( { char conn_name[CS_MAX_NAME_LENGTH]; char proc_name[CS_MAX_NAME_LENGTH]; + char int_str[4]; if (conn->client_pid > 0) { - if (pid_to_name (conn->client_pid, proc_name, sizeof(proc_name))) - snprintf (conn_name, sizeof(conn_name), "%s:%d:%d", proc_name, conn->client_pid, conn->fd); - else - snprintf (conn_name, sizeof(conn_name), "%d:%d", conn->client_pid, conn->fd); - } else - snprintf (conn_name, sizeof(conn_name), "%d", conn->fd); - + if (pid_to_name (conn->client_pid, proc_name, sizeof(proc_name))) { + snprintf (conn_name, sizeof(conn_name), + "%s:%s:%d:%d", proc_name, + short_service_name_get(conn->service, int_str, 4), + conn->client_pid, conn->fd); + } else { + snprintf (conn_name, sizeof(conn_name), + "proc:%s:%d:%d", + short_service_name_get(conn->service, int_str, 4), + conn->client_pid, + conn->fd); + } + } else { + snprintf (conn_name, sizeof(conn_name), + "proc:%s:pid:%d", + short_service_name_get(conn->service, int_str, 4), + conn->fd); + } conn->stats_handle = api->stats_create_connection (conn_name, conn->client_pid, conn->fd); api->stats_update_value (conn->stats_handle, "service_id", &conn->service, sizeof(conn->service)); diff --git a/exec/util.c b/exec/util.c index a3c2b878..9f31dfb5 100644 --- a/exec/util.c +++ b/exec/util.c @@ -44,6 +44,7 @@ #include #include +#include #include #include #include @@ -51,6 +52,52 @@ LOGSYS_DECLARE_SUBSYS ("MAIN"); +struct service_names { + const char *c_name; + int32_t c_val; +}; + +static struct service_names servicenames[] = +{ + { "EVS", EVS_SERVICE }, + { "CLM", CLM_SERVICE }, + { "AMF", AMF_SERVICE }, + { "CKPT", CKPT_SERVICE }, + { "EVT", EVT_SERVICE }, + { "LCK", LCK_SERVICE }, + { "MSG", MSG_SERVICE }, + { "CFG", CFG_SERVICE }, + { "CPG", CPG_SERVICE }, + { "CMAN", CMAN_SERVICE }, + { "PCMK", PCMK_SERVICE }, + { "CONFDB", CONFDB_SERVICE }, + { "QUORUM", QUORUM_SERVICE }, + { "PLOAD", PLOAD_SERVICE }, + { "TMR", TMR_SERVICE }, + { "VOTEQUORUM", VOTEQUORUM_SERVICE }, + { "NTF", NTF_SERVICE }, + { "AMF", AMF_V2_SERVICE }, + { "TST", TST_SV1_SERVICE }, + { "TST", TST_SV2_SERVICE }, + { "MON", MON_SERVICE }, + { "WD", WD_SERVICE }, + { NULL, -1 } +}; + +const char * short_service_name_get(uint32_t service_id, + char *buf, size_t buf_size) +{ + uint32_t i; + + for (i = 0; servicenames[i].c_name != NULL; i++) { + if (service_id == servicenames[i].c_val) { + return (servicenames[i].c_name); + } + } + snprintf(buf, buf_size, "%d", service_id); + return buf; +} + /* * Compare two names. returns non-zero on match. */ diff --git a/exec/util.h b/exec/util.h index 0df192cf..a3bb47c1 100644 --- a/exec/util.h +++ b/exec/util.h @@ -97,4 +97,10 @@ void _corosync_out_of_memory_error (void) __attribute__((noreturn)); extern char *getcs_name_t (cs_name_t *name); extern void setcs_name_t (cs_name_t *name, char *str); extern int cs_name_tisEqual (cs_name_t *str1, char *str2); +/** + * Get the short name of a service from the service_id. + */ +const char * short_service_name_get(uint32_t service_id, + char *buf, size_t buf_size); + #endif /* UTIL_H_DEFINED */