X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Ftcpconns.c;h=8c93405eb57286fe3ce7a012809c57cd32f498a7;hb=745ba17db2b2c1868667734d1317e1ee1d0b68ae;hp=da916950e301c5a705fdfe5c18c80b48b336d4a3;hpb=3fae5596643f1e361eb18c3d65448f8bc02fdd80;p=collectd.git diff --git a/src/tcpconns.c b/src/tcpconns.c index da916950..8c93405e 100644 --- a/src/tcpconns.c +++ b/src/tcpconns.c @@ -58,6 +58,7 @@ */ #include "collectd.h" + #include "common.h" #include "plugin.h" @@ -295,7 +296,6 @@ static void conn_prepare_vl (value_list_t *vl, value_t *values) { vl->values = values; vl->values_len = 1; - sstrncpy (vl->host, hostname_g, sizeof (vl->host)); sstrncpy (vl->plugin, "tcpconns", sizeof (vl->plugin)); sstrncpy (vl->type, "tcp_connections", sizeof (vl->type)); } @@ -304,7 +304,6 @@ static void conn_submit_port_entry (port_entry_t *pe) { value_t values[1]; value_list_t vl = VALUE_LIST_INIT; - int i; conn_prepare_vl (&vl, values); @@ -314,7 +313,7 @@ static void conn_submit_port_entry (port_entry_t *pe) ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance), "%"PRIu16"-local", pe->port); - for (i = 1; i <= TCP_STATE_MAX; i++) + for (int i = 1; i <= TCP_STATE_MAX; i++) { vl.values[0].gauge = pe->count_local[i]; @@ -329,7 +328,7 @@ static void conn_submit_port_entry (port_entry_t *pe) ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance), "%"PRIu16"-remote", pe->port); - for (i = 1; i <= TCP_STATE_MAX; i++) + for (int i = 1; i <= TCP_STATE_MAX; i++) { vl.values[0].gauge = pe->count_remote[i]; @@ -344,13 +343,12 @@ static void conn_submit_port_total (void) { value_t values[1]; value_list_t vl = VALUE_LIST_INIT; - int i; conn_prepare_vl (&vl, values); sstrncpy (vl.plugin_instance, "all", sizeof (vl.plugin_instance)); - for (i = 1; i <= TCP_STATE_MAX; i++) + for (int i = 1; i <= TCP_STATE_MAX; i++) { vl.values[0].gauge = count_total[i]; @@ -362,12 +360,10 @@ static void conn_submit_port_total (void) static void conn_submit_all (void) { - port_entry_t *pe; - if (port_collect_total) conn_submit_port_total (); - for (pe = port_list_head; pe != NULL; pe = pe->next) + for (port_entry_t *pe = port_list_head; pe != NULL; pe = pe->next) conn_submit_port_entry (pe); } /* void conn_submit_all */ @@ -1016,7 +1012,6 @@ static int conn_read (void) static int conn_read (void) { int size; - int i; int nconn; void *data; struct netinfo_header *header; @@ -1058,7 +1053,7 @@ static int conn_read (void) nconn = header->size; conn = (struct netinfo_conn *)(data + sizeof(struct netinfo_header)); - for (i=0; i < nconn; conn++, i++) + for (int i = 0; i < nconn; conn++, i++) { conn_handle_ports (conn->srcport, conn->dstport, conn->tcp_state); }