QoL updates
Remove offline entries for devices detected online on another address Remove entries older than 2 weeks
This commit is contained in:
1 parent
f9ecad13a6
commit
e93bd777af
2 files changed
+60
-6
No files matched your search
+13
-3
@@ -3,8 +3,6 @@
|
||||
# check for nmap and jq
|
||||
# check for root
|
||||
|
||||
starttime="$(date '+%Y-%m-%d %H:%M:%S')"
|
||||
|
||||
if [ -f arpscan.json ]
|
||||
then
|
||||
tempjson=$(jq '.ips += {} | .ips=(.ips|to_entries|map_values(.value.online=false)|from_entries)' arpscan.json)
|
||||
@@ -21,8 +19,17 @@ jsonescape() {
|
||||
jq -Rs . < <(printf "%s" "${1}")
|
||||
}
|
||||
|
||||
starttime="$(jsonescape "$(date '+%Y-%m-%dT%H:%M:%SZ')")"
|
||||
|
||||
foundhost() {
|
||||
tempjson=$(jq "$(jsonescape "${1}") as \$ip|.ips[\$ip].mac=$(jsonescape "${2}")|.ips[\$ip].online=true|.ips[\$ip].lastseen=$(jsonescape "${starttime}")" <<< "${tempjson}")
|
||||
local currentip
|
||||
local mac
|
||||
currentip="$(jsonescape "${1}")"
|
||||
mac="$(jsonescape "${2}")"
|
||||
# remove all offline entries for this MAC
|
||||
tempjson=$(jq ".ips |= with_entries(if .value.mac==${mac} and .value.online==false then empty else . end)" <<< "${tempjson}")
|
||||
# add entry
|
||||
tempjson=$(jq "${currentip} as \$ip|.ips[\$ip].mac=${mac}|.ips[\$ip].online=true|.ips[\$ip].lastseen=${starttime}" <<< "${tempjson}")
|
||||
}
|
||||
|
||||
doscan() {
|
||||
@@ -111,6 +118,9 @@ do
|
||||
fi
|
||||
done
|
||||
|
||||
# remove old entries
|
||||
tempjson=$(jq ".ips |= with_entries(if (${starttime}|fromdate)-(.value.lastseen|fromdate)>(14*24*60*60) then empty else . end)" <<< "${tempjson}")
|
||||
|
||||
## make sure the MAC vendor and device/port fields exist
|
||||
#tempjson="$(jq '.macvendor+={}|.devices+=[]' <<< "${tempjson}")"
|
||||
if [ ! -f macvendor.json ]
|
||||
|
||||
Reference in new issue
Block a user