home
/
code
/
khome.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
fbcc6a5
)
Revise terminology and calc avg staleness
author
Siraaj Khandkar
<siraaj@khandkar.net>
Thu, 7 Oct 2021 15:33:05 +0000
(11:33 -0400)
committer
Siraaj Khandkar
<siraaj@khandkar.net>
Thu, 7 Oct 2021 15:33:05 +0000
(11:33 -0400)
home/bin/arp-recon
patch
|
blob
|
blame
|
history
diff --git
a/home/bin/arp-recon
b/home/bin/arp-recon
index
bee996d
..
e53d2ea
100755
(executable)
--- a/
home/bin/arp-recon
+++ b/
home/bin/arp-recon
@@
-67,8
+67,8
@@
status() {
local -r log_file="$1"
(
local -r log_file="$1"
(
- echo 'mac ip
last first
freq dist'
- echo '--- -- ----
--
--- ---- ----'
+ echo 'mac ip
staleness_cur staleness_avg age
freq dist'
+ echo '--- -- ----
--------- -------------
--- ---- ----'
sort -n -k 1 "$log_file" \
| awk -v now="$(date '+%s')" \
'
sort -n -k 1 "$log_file" \
| awk -v now="$(date '+%s')" \
'
@@
-77,6
+77,7
@@
status() {
mac = $2
ip = $3
mac = $2
ip = $3
+ interval[mac, ip, intervals[mac, ip]++] = ts - seen_last[mac, ip]
freq[mac, ip]++
if (!seen_last[mac, ip] || ts > seen_last[mac, ip] ) seen_last[mac, ip] = ts
if (!seen_first[mac, ip] || ts < seen_first[mac, ip]) seen_first[mac, ip] = ts
freq[mac, ip]++
if (!seen_last[mac, ip] || ts > seen_last[mac, ip] ) seen_last[mac, ip] = ts
if (!seen_first[mac, ip] || ts < seen_first[mac, ip]) seen_first[mac, ip] = ts
@@
-87,14
+88,19
@@
status() {
split(key, macip, SUBSEP)
mac = macip[1]
ip = macip[2]
split(key, macip, SUBSEP)
mac = macip[1]
ip = macip[2]
-
last
= now - seen_last[mac, ip]
-
first
= now - seen_first[mac, ip]
+
staleness_cur
= now - seen_last[mac, ip]
+
age
= now - seen_first[mac, ip]
dist = 100 * (freq[mac, ip] / NR)
dist = 100 * (freq[mac, ip] / NR)
+ intervals_sum = 0
+ for (i=1; i<=intervals[mac, ip]; i++)
+ intervals_sum += interval[mac, ip, i]
+ staleness_avg = intervals_sum / intervals[mac, ip]
print \
mac, \
ip, \
print \
mac, \
ip, \
- sprintf("%d", last), \
- sprintf("%d", first), \
+ sprintf("%d", staleness_cur), \
+ sprintf("%d", staleness_avg), \
+ sprintf("%d", age), \
freq[mac, ip], \
sprintf("%d", dist)
}
freq[mac, ip], \
sprintf("%d", dist)
}
This page took
0.029018 seconds
and
4
git commands to generate.