Simplify $SYS metric generation.

pull/2756/merge
Roger A. Light 3 years ago committed by Roger Light
parent 1787d9b1a7
commit 086a361bcc

@ -78,6 +78,9 @@ int send__disconnect(struct mosquitto *mosq, uint8_t reason_code, const mosquitt
}
}
#if defined(WITH_BROKER) && defined(WITH_SYS_TREE)
metrics__int_inc(mosq_counter_mqtt_disconnect_sent, 1);
#endif
return packet__queue(mosq, packet);
}

@ -59,6 +59,9 @@ int send__pingresp(struct mosquitto *mosq)
{
#ifdef WITH_BROKER
log__printf(NULL, MOSQ_LOG_DEBUG, "Sending PINGRESP to %s", SAFE_PRINT(mosq->id));
# ifdef WITH_SYS_TREE
metrics__int_inc(mosq_counter_mqtt_pingresp_sent, 1);
# endif
#else
log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s sending PINGRESP", SAFE_PRINT(mosq->id));
#endif
@ -69,6 +72,9 @@ int send__puback(struct mosquitto *mosq, uint16_t mid, uint8_t reason_code, cons
{
#ifdef WITH_BROKER
log__printf(NULL, MOSQ_LOG_DEBUG, "Sending PUBACK to %s (m%d, rc%d)", SAFE_PRINT(mosq->id), mid, reason_code);
# ifdef WITH_SYS_TREE
metrics__int_inc(mosq_counter_mqtt_puback_sent, 1);
# endif
#else
log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s sending PUBACK (m%d, rc%d)", SAFE_PRINT(mosq->id), mid, reason_code);
#endif
@ -81,6 +87,9 @@ int send__pubcomp(struct mosquitto *mosq, uint16_t mid, const mosquitto_property
{
#ifdef WITH_BROKER
log__printf(NULL, MOSQ_LOG_DEBUG, "Sending PUBCOMP to %s (m%d)", SAFE_PRINT(mosq->id), mid);
# ifdef WITH_SYS_TREE
metrics__int_inc(mosq_counter_mqtt_pubcomp_sent, 1);
# endif
#else
log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s sending PUBCOMP (m%d)", SAFE_PRINT(mosq->id), mid);
#endif
@ -94,6 +103,9 @@ int send__pubrec(struct mosquitto *mosq, uint16_t mid, uint8_t reason_code, cons
{
#ifdef WITH_BROKER
log__printf(NULL, MOSQ_LOG_DEBUG, "Sending PUBREC to %s (m%d, rc%d)", SAFE_PRINT(mosq->id), mid, reason_code);
# ifdef WITH_SYS_TREE
metrics__int_inc(mosq_counter_mqtt_pubrec_sent, 1);
# endif
#else
log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s sending PUBREC (m%d, rc%d)", SAFE_PRINT(mosq->id), mid, reason_code);
#endif
@ -108,6 +120,9 @@ int send__pubrel(struct mosquitto *mosq, uint16_t mid, const mosquitto_property
{
#ifdef WITH_BROKER
log__printf(NULL, MOSQ_LOG_DEBUG, "Sending PUBREL to %s (m%d)", SAFE_PRINT(mosq->id), mid);
# ifdef WITH_SYS_TREE
metrics__int_inc(mosq_counter_mqtt_pubrel_sent, 1);
# endif
#else
log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s sending PUBREL (m%d)", SAFE_PRINT(mosq->id), mid);
#endif

@ -40,15 +40,18 @@ int handle__packet(struct mosquitto *context)
switch((context->in_packet.command)&0xF0){
case CMD_PINGREQ:
metrics__int_inc(mosq_counter_mqtt_pingreq_received, 1);
rc = handle__pingreq(context);
break;
case CMD_PINGRESP:
rc = handle__pingresp(context);
break;
case CMD_PUBACK:
metrics__int_inc(mosq_counter_mqtt_puback_received, 1);
rc = handle__pubackcomp(context, "PUBACK");
break;
case CMD_PUBCOMP:
metrics__int_inc(mosq_counter_mqtt_pubcomp_received, 1);
rc = handle__pubackcomp(context, "PUBCOMP");
break;
case CMD_PUBLISH:
@ -56,21 +59,26 @@ int handle__packet(struct mosquitto *context)
rc = handle__publish(context);
break;
case CMD_PUBREC:
metrics__int_inc(mosq_counter_mqtt_pubrec_received, 1);
rc = handle__pubrec(context);
break;
case CMD_PUBREL:
metrics__int_inc(mosq_counter_mqtt_pubrel_received, 1);
rc = handle__pubrel(context);
break;
case CMD_CONNECT:
metrics__int_inc(mosq_counter_mqtt_connect_received, 1);
return handle__connect(context);
case CMD_DISCONNECT:
metrics__int_inc(mosq_counter_mqtt_disconnect_received, 1);
rc = handle__disconnect(context);
break;
case CMD_SUBSCRIBE:
metrics__int_inc(mosq_counter_mqtt_subscribe_received, 1);
rc = handle__subscribe(context);
break;
case CMD_UNSUBSCRIBE:
metrics__int_inc(mosq_counter_mqtt_unsubscribe_received, 1);
rc = handle__unsubscribe(context);
break;
#ifdef WITH_BRIDGE
@ -85,6 +93,7 @@ int handle__packet(struct mosquitto *context)
break;
#endif
case CMD_AUTH:
metrics__int_inc(mosq_counter_mqtt_auth_received, 1);
rc = handle__auth(context);
break;
default:

@ -60,6 +60,8 @@ int send__auth(struct mosquitto *context, uint8_t reason_code, const void *auth_
property__write_all(packet, properties, true);
mosquitto_property_free_all(&properties);
metrics__int_inc(mosq_counter_mqtt_auth_sent, 1);
return packet__queue(context, packet);
error:
mosquitto_property_free_all(&properties);

@ -96,6 +96,8 @@ int send__connack(struct mosquitto *context, uint8_t ack, uint8_t reason_code, c
}
mosquitto_property_free_all(&connack_props);
metrics__int_inc(mosq_counter_mqtt_connack_sent, 1);
return packet__queue(context, packet);
}

@ -55,5 +55,7 @@ int send__suback(struct mosquitto *context, uint16_t mid, uint32_t payloadlen, c
packet__write_bytes(packet, payload, payloadlen);
}
metrics__int_inc(mosq_counter_mqtt_suback_sent, 1);
return packet__queue(context, packet);
}

@ -54,5 +54,7 @@ int send__unsuback(struct mosquitto *mosq, uint16_t mid, int reason_code_count,
packet__write_bytes(packet, reason_codes, (uint32_t)reason_code_count);
}
metrics__int_inc(mosq_counter_mqtt_unsuback_sent, 1);
return packet__queue(mosq, packet);
}

Loading…
Cancel
Save