-
Notifications
You must be signed in to change notification settings - Fork 33
/
extfilter-cacti
executable file
·150 lines (108 loc) · 3.2 KB
/
extfilter-cacti
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/sh
stats=/var/run/extFilter_stat
datadir=/var/run/extfilter-stat
rawstats=`cat $stats`
readers_stat=""
workers_packets=""
# names for reader(s)
p_reader_received_packets="allreaders.received_packets"
p_reader_enqueued_packets="allreaders.enqueued_packets"
p_reader_missed_packets="allreaders.missed_packets"
# names for workers
p_allworkers_total_packets="allworkers.total_packets"
p_allworkers_ip_packets="allworkers.ip_packets"
p_allworkers_ipv4_packets="allworkers.ipv4_packets"
p_allworkers_ipv6_packets="allworkers.ipv6_packets"
p_allworkers_total_bytes="allworkers_total_bytes"
p_allworkers_matched_ip_port="allworkers.matched_ip_port"
p_allworkers_matched_ssl="allworkers.matched_ssl"
p_allworkers_matched_ssl_ip="allworkers.matched_ssl_ip"
p_allworkers_matched_domains="allworkers.matched_domains"
p_allworkers_matched_ulrs="allworkers.matched_ulrs"
p_allworkers_active_flows="allworkers.active_flows"
p_allworkers_expired_flows="allworkers.expired_flows"
# default values
reader_received_packets=0
reader_enqueued_packets=0
reader_missed_packets=0
allworkers_total_packets=0
allworkers_ip_packets=0
allworkers_ipv4_packets=0
allworkers_ipv6_packets=0
allworkers_total_bytes=0
allworkers_matched_ip_port=0
allworkers_matched_ssl=0
allworkers_matched_ssl_ip=0
allworkers_matched_domains=0
allworkers_matched_ulrs=0
allworkers_active_flows=0
allworkers_expired_flows=0
for str in $rawstats
do
wdata=`echo $str | cut -f 1 -d "="`
howmuch=`echo $str | cut -f 2 -d "="`
case $wdata in
allworkers*)
case $wdata in
"$p_allworkers_total_packets")
allworkers_total_packets=$howmuch
;;
"$p_allworkers_ip_packets")
allworkers_ip_packets=$howmuch
;;
"$p_allworkers_ipv4_packets")
allworkers_ipv4_packets=$howmuch
;;
"$p_allworkers_matched_ip_port")
allworkers_matched_ip_port=$howmuch
;;
"$p_allworkers_matched_ssl")
allworkers_matched_ssl=$howmuch
;;
"$p_allworkers_matched_ssl_ip")
allworkers_matched_ssl_ip=$howmuch
;;
"$p_allworkers_matched_domains")
allworkers_matched_domains=$howmuch
;;
"$p_allworkers_matched_ulrs")
allworkers_matched_ulrs=$howmuch
;;
esac
;;
allreaders*)
case $wdata in
"$p_reader_received_packets")
reader_received_packets=$howmuch
;;
"$p_reader_enqueued_packets")
reader_enqueued_packets=$howmuch
;;
"$p_reader_missed_packets")
reader_missed_packets=$howmuch
;;
*)
;;
esac
;;
*)
;;
esac
done
if [ ! -d $datadir ]
then
/usr/bin/mkdir $datadir
fi
readers_stat=$p_reader_received_packets":"$reader_received_packets\
" "$p_reader_enqueued_packets":"$reader_enqueued_packets\
" "$p_reader_missed_packets":"$reader_missed_packets
echo $readers_stat > $datadir/readers
workers_packets=$p_allworkers_total_packets":"$allworkers_total_packets\
" "$p_allworkers_ip_packets":"$allworkers_ip_packets\
" "$p_allworkers_ipv4_packets":"$allworkers_ipv4_packets\
" "$p_allworkers_matched_ip_port":"$allworkers_matched_ip_port\
" "$p_allworkers_matched_ssl":"$allworkers_matched_ssl\
" "$p_allworkers_matched_ssl_ip":"$allworkers_matched_ssl_ip\
" "$p_allworkers_matched_domains":"$allworkers_matched_domains\
" "$p_allworkers_matched_ulrs":"$allworkers_matched_ulrs
echo $workers_packets > $datadir/workers