Browse code

xhttp_prom: added prom_counter_dec function

Sergey Safarov authored on 16/09/2021 21:02:21
Showing 1 changed files
... ...
@@ -77,6 +77,10 @@ static int w_prom_counter_inc_l0(struct sip_msg* msg, char *pname, char* pnumber
77 77
 static int w_prom_counter_inc_l1(struct sip_msg* msg, char *pname, char* pnumber, char *l1);
78 78
 static int w_prom_counter_inc_l2(struct sip_msg* msg, char *pname, char* pnumber, char *l1, char *l2);
79 79
 static int w_prom_counter_inc_l3(struct sip_msg* msg, char *pname, char* pnumber, char *l1, char *l2, char *l3);
80
+static int w_prom_counter_dec_l0(struct sip_msg* msg, char *pname, char* pnumber);
81
+static int w_prom_counter_dec_l1(struct sip_msg* msg, char *pname, char* pnumber, char *l1);
82
+static int w_prom_counter_dec_l2(struct sip_msg* msg, char *pname, char* pnumber, char *l1, char *l2);
83
+static int w_prom_counter_dec_l3(struct sip_msg* msg, char *pname, char* pnumber, char *l1, char *l2, char *l3);
80 84
 static int w_prom_gauge_set_l0(struct sip_msg* msg, char *pname, char* pnumber);
81 85
 static int w_prom_gauge_set_l1(struct sip_msg* msg, char *pname, char* pnumber, char *l1);
82 86
 static int w_prom_gauge_set_l2(struct sip_msg* msg, char *pname, char* pnumber, char *l1, char *l2);
... ...
@@ -151,6 +155,14 @@ static cmd_export_t cmds[] = {
151 155
 	 0, ANY_ROUTE},
152 156
 	{"prom_counter_inc", (cmd_function)w_prom_counter_inc_l3, 5, fixup_counter_inc,
153 157
 	 0, ANY_ROUTE},
158
+	{"prom_counter_dec", (cmd_function)w_prom_counter_dec_l0, 2, fixup_counter_inc,
159
+	 0, ANY_ROUTE},
160
+	{"prom_counter_dec", (cmd_function)w_prom_counter_dec_l1, 3, fixup_counter_inc,
161
+	 0, ANY_ROUTE},
162
+	{"prom_counter_dec", (cmd_function)w_prom_counter_dec_l2, 4, fixup_counter_inc,
163
+	 0, ANY_ROUTE},
164
+	{"prom_counter_dec", (cmd_function)w_prom_counter_dec_l3, 5, fixup_counter_inc,
165
+	 0, ANY_ROUTE},
154 166
 	{"prom_gauge_set", (cmd_function)w_prom_gauge_set_l0, 2, fixup_metric_reset,
155 167
 	 0, ANY_ROUTE},
156 168
 	{"prom_gauge_set", (cmd_function)w_prom_gauge_set_l1, 3, fixup_metric_reset,
... ...
@@ -1234,6 +1246,41 @@ static int w_prom_counter_inc_l3(struct sip_msg* msg, char *pname, char* pnumber
1234 1246
 	return w_prom_counter_operation(msg, INCREMENT, pname, pnumber, l1, l2, l3);
1235 1247
 }
1236 1248
 
1249
+/**
1250
+ * @brief Decrement an integer from a counter (no labels)
1251
+ */
1252
+static int w_prom_counter_dec_l0(struct sip_msg* msg, char *pname, char* pnumber)
1253
+{
1254
+	return w_prom_counter_operation(msg, DECREMENT, pname, pnumber, NULL, NULL, NULL);
1255
+}
1256
+
1257
+/**
1258
+ * @brief Decrement an integer from a counter (1 labels)
1259
+ */
1260
+static int w_prom_counter_dec_l1(struct sip_msg* msg, char *pname, char* pnumber,
1261
+								 char *l1)
1262
+{
1263
+	return w_prom_counter_operation(msg, DECREMENT, pname, pnumber, l1, NULL, NULL);
1264
+}
1265
+
1266
+/**
1267
+ * @brief Decrement an integer from a counter (2 labels)
1268
+ */
1269
+static int w_prom_counter_dec_l2(struct sip_msg* msg, char *pname, char* pnumber,
1270
+								 char *l1, char *l2)
1271
+{
1272
+	return w_prom_counter_operation(msg, DECREMENT, pname, pnumber, l1, l2, NULL);
1273
+}
1274
+
1275
+/**
1276
+ * @brief Decrement an integer from a counter (3 labels)
1277
+ */
1278
+static int w_prom_counter_dec_l3(struct sip_msg* msg, char *pname, char* pnumber,
1279
+								 char *l1, char *l2, char *l3)
1280
+{
1281
+	return w_prom_counter_operation(msg, DECREMENT, pname, pnumber, l1, l2, l3);
1282
+}
1283
+
1237 1284
 /**
1238 1285
  * @brief Set a number to a gauge (No labels).
1239 1286
  */