Browse code

pike Add counter for blocked IP addresses

Olle E. Johansson authored on 03/04/2013 19:55:47
Showing 3 changed files
... ...
@@ -154,6 +154,9 @@ static int pike_init(void)
154 154
 	register_timer( clean_routine , 0, 1 );
155 155
 	register_timer( swap_routine , 0, time_unit );
156 156
 
157
+	/* Register counter */
158
+	pike_counter_init();
159
+
157 160
 	return 0;
158 161
 error3:
159 162
 	destroy_ip_tree();
... ...
@@ -43,6 +43,7 @@
43 43
 #include "../../timer.h"
44 44
 #include "../../ip_addr.h"
45 45
 #include "../../resolve.h"
46
+#include "../../counters.h"
46 47
 #include "ip_tree.h"
47 48
 #include "pike_funcs.h"
48 49
 #include "timer.h"
... ...
@@ -55,6 +56,13 @@ extern struct list_link* timer;
55 56
 extern int               timeout;
56 57
 extern int               pike_log_level;
57 58
 
59
+counter_handle_t blocked;
60
+
61
+void pike_counter_init()
62
+{
63
+	counter_register(&blocked, "pike", "blocked_ips", 0, 0, 0, "Counter of blocked IP addresses", 0);
64
+}
65
+
58 66
 
59 67
 
60 68
 int pike_check_req(struct sip_msg *msg, char *foo, char *bar)
... ...
@@ -154,6 +162,7 @@ int pike_check_req(struct sip_msg *msg, char *foo, char *bar)
154 162
 		if (flags&NEWRED_NODE) {
155 163
 			LM_GEN1( pike_log_level,
156 164
 				"PIKE - BLOCKing ip %s, node=%p\n",ip_addr2a(ip),node);
165
+			counter_inc(blocked);
157 166
 			return -2;
158 167
 		}
159 168
 		return -1;
... ...
@@ -28,6 +28,7 @@
28 28
 #include "../../locking.h"
29 29
 
30 30
 
31
+void pike_counter_init(void);
31 32
 int  pike_check_req(struct sip_msg *msg, char *foo, char *bar);
32 33
 void clean_routine(unsigned int, void*);
33 34
 void swap_routine(unsigned int, void*);