fix(crowdsec-dashboard): Move to Security menu and fix stats display
- Move CrowdSec from Services to Security & Access menu
- Fix get_decisions() to return {"decisions":[]} not {"alerts":[]}
- Fix active_bans to use local_decisions count instead of parsing
unreliable metrics output
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
7236449223
commit
fce6307c7e
@ -60,9 +60,9 @@ get_decisions() {
|
|||||||
local output
|
local output
|
||||||
output=$(run_cscli decisions list -o json)
|
output=$(run_cscli decisions list -o json)
|
||||||
if [ -z "$output" ] || [ "$output" = "null" ]; then
|
if [ -z "$output" ] || [ "$output" = "null" ]; then
|
||||||
echo '{"alerts":[]}'
|
echo '{"decisions":[]}'
|
||||||
else
|
else
|
||||||
echo "{\"alerts\":$output}"
|
echo "{\"decisions\":$output}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2233,12 +2233,15 @@ get_overview() {
|
|||||||
json_add_int "alerts_24h" "${alerts_count:-0}"
|
json_add_int "alerts_24h" "${alerts_count:-0}"
|
||||||
json_add_int "bouncer_count" "${bouncers_count:-0}"
|
json_add_int "bouncer_count" "${bouncers_count:-0}"
|
||||||
|
|
||||||
|
# Active bans = local decisions (IPs being actively blocked by local scenarios)
|
||||||
|
# Use local_decisions count which is already calculated above
|
||||||
|
json_add_int "active_bans" "${local_decisions:-0}"
|
||||||
|
|
||||||
# Bouncer effectiveness stats (packets/bytes dropped vs processed)
|
# Bouncer effectiveness stats (packets/bytes dropped vs processed)
|
||||||
local dropped_packets=0
|
local dropped_packets=0
|
||||||
local dropped_bytes=0
|
local dropped_bytes=0
|
||||||
local processed_packets=0
|
local processed_packets=0
|
||||||
local processed_bytes=0
|
local processed_bytes=0
|
||||||
local active_bans=0
|
|
||||||
if [ "$cs_running" = "1" ]; then
|
if [ "$cs_running" = "1" ]; then
|
||||||
# Parse Total line from Bouncer Metrics table
|
# Parse Total line from Bouncer Metrics table
|
||||||
# Format: | Total | 16.00k | 13.72k | 231 | 356.19k | 6.02k |
|
# Format: | Total | 16.00k | 13.72k | 231 | 356.19k | 6.02k |
|
||||||
@ -2246,14 +2249,12 @@ get_overview() {
|
|||||||
totals=$(run_cscli metrics 2>/dev/null | grep -E '^\|.*Total' | sed 's/|//g')
|
totals=$(run_cscli metrics 2>/dev/null | grep -E '^\|.*Total' | sed 's/|//g')
|
||||||
if [ -n "$totals" ]; then
|
if [ -n "$totals" ]; then
|
||||||
# Convert k/M suffixes to numbers
|
# Convert k/M suffixes to numbers
|
||||||
active_bans=$(echo "$totals" | awk '{gsub(/k$/,"",$2); gsub(/M$/,"",$2); if($2~/\./){$2=$2*1000}; print int($2)}')
|
|
||||||
dropped_bytes=$(echo "$totals" | awk '{v=$3; gsub(/k$/,"",v); gsub(/M$/,"",v); if(v~/\./){v=v*1000}; print v}')
|
dropped_bytes=$(echo "$totals" | awk '{v=$3; gsub(/k$/,"",v); gsub(/M$/,"",v); if(v~/\./){v=v*1000}; print v}')
|
||||||
dropped_packets=$(echo "$totals" | awk '{print $4}')
|
dropped_packets=$(echo "$totals" | awk '{print $4}')
|
||||||
processed_bytes=$(echo "$totals" | awk '{v=$5; gsub(/k$/,"",v); gsub(/M$/,"",v); if(v~/\./){v=v*1000}; if(v=="-")v=0; print v}')
|
processed_bytes=$(echo "$totals" | awk '{v=$5; gsub(/k$/,"",v); gsub(/M$/,"",v); if(v~/\./){v=v*1000}; if(v=="-")v=0; print v}')
|
||||||
processed_packets=$(echo "$totals" | awk '{v=$6; gsub(/k$/,"",v); gsub(/M$/,"",v); if(v~/\./){v=v*1000}; if(v=="-")v=0; print v}')
|
processed_packets=$(echo "$totals" | awk '{v=$6; gsub(/k$/,"",v); gsub(/M$/,"",v); if(v~/\./){v=v*1000}; if(v=="-")v=0; print v}')
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
json_add_int "active_bans" "${active_bans:-0}"
|
|
||||||
json_add_string "dropped_packets" "${dropped_packets:-0}"
|
json_add_string "dropped_packets" "${dropped_packets:-0}"
|
||||||
json_add_string "dropped_bytes" "${dropped_bytes:-0}"
|
json_add_string "dropped_bytes" "${dropped_bytes:-0}"
|
||||||
json_add_string "processed_packets" "${processed_packets:-0}"
|
json_add_string "processed_packets" "${processed_packets:-0}"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"admin/secubox/services/crowdsec": {
|
"admin/secubox/security/crowdsec": {
|
||||||
"title": "CrowdSec",
|
"title": "CrowdSec",
|
||||||
"order": 10,
|
"order": 10,
|
||||||
"action": {
|
"action": {
|
||||||
@ -9,7 +9,7 @@
|
|||||||
"acl": ["luci-app-crowdsec-dashboard"]
|
"acl": ["luci-app-crowdsec-dashboard"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/secubox/services/crowdsec/overview": {
|
"admin/secubox/security/crowdsec/overview": {
|
||||||
"title": "Overview",
|
"title": "Overview",
|
||||||
"order": 5,
|
"order": 5,
|
||||||
"action": {
|
"action": {
|
||||||
@ -17,7 +17,7 @@
|
|||||||
"path": "crowdsec-dashboard/overview"
|
"path": "crowdsec-dashboard/overview"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/secubox/services/crowdsec/wizard": {
|
"admin/secubox/security/crowdsec/wizard": {
|
||||||
"title": "Setup Wizard",
|
"title": "Setup Wizard",
|
||||||
"order": 10,
|
"order": 10,
|
||||||
"action": {
|
"action": {
|
||||||
@ -25,7 +25,7 @@
|
|||||||
"path": "crowdsec-dashboard/wizard"
|
"path": "crowdsec-dashboard/wizard"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/secubox/services/crowdsec/decisions": {
|
"admin/secubox/security/crowdsec/decisions": {
|
||||||
"title": "Decisions",
|
"title": "Decisions",
|
||||||
"order": 20,
|
"order": 20,
|
||||||
"action": {
|
"action": {
|
||||||
@ -33,7 +33,7 @@
|
|||||||
"path": "crowdsec-dashboard/decisions"
|
"path": "crowdsec-dashboard/decisions"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/secubox/services/crowdsec/alerts": {
|
"admin/secubox/security/crowdsec/alerts": {
|
||||||
"title": "Alerts",
|
"title": "Alerts",
|
||||||
"order": 30,
|
"order": 30,
|
||||||
"action": {
|
"action": {
|
||||||
@ -41,7 +41,7 @@
|
|||||||
"path": "crowdsec-dashboard/alerts"
|
"path": "crowdsec-dashboard/alerts"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/secubox/services/crowdsec/bouncers": {
|
"admin/secubox/security/crowdsec/bouncers": {
|
||||||
"title": "Bouncers",
|
"title": "Bouncers",
|
||||||
"order": 40,
|
"order": 40,
|
||||||
"action": {
|
"action": {
|
||||||
@ -49,7 +49,7 @@
|
|||||||
"path": "crowdsec-dashboard/bouncers"
|
"path": "crowdsec-dashboard/bouncers"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/secubox/services/crowdsec/waf": {
|
"admin/secubox/security/crowdsec/waf": {
|
||||||
"title": "WAF/AppSec",
|
"title": "WAF/AppSec",
|
||||||
"order": 45,
|
"order": 45,
|
||||||
"action": {
|
"action": {
|
||||||
@ -57,7 +57,7 @@
|
|||||||
"path": "crowdsec-dashboard/waf"
|
"path": "crowdsec-dashboard/waf"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/secubox/services/crowdsec/metrics": {
|
"admin/secubox/security/crowdsec/metrics": {
|
||||||
"title": "Metrics",
|
"title": "Metrics",
|
||||||
"order": 50,
|
"order": 50,
|
||||||
"action": {
|
"action": {
|
||||||
@ -65,7 +65,7 @@
|
|||||||
"path": "crowdsec-dashboard/metrics"
|
"path": "crowdsec-dashboard/metrics"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin/secubox/services/crowdsec/settings": {
|
"admin/secubox/security/crowdsec/settings": {
|
||||||
"title": "Settings",
|
"title": "Settings",
|
||||||
"order": 90,
|
"order": 90,
|
||||||
"action": {
|
"action": {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user