Skip to content

Commit

Permalink
Log throttling info
Browse files Browse the repository at this point in the history
Fixes #73
  • Loading branch information
bviktor committed Mar 7, 2023
1 parent 834fb6e commit 5364c24
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 3 deletions.
3 changes: 3 additions & 0 deletions roles/install/files/check-log-throttling
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

/bin/grep -m 1 'messages lost due to rate-limiting' /var/log/messages | awk -F'[()]' '{print $2}'
1 change: 1 addition & 0 deletions roles/install/files/kf2-sudo
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
%steam ALL=NOPASSWD: /usr/bin/firewall-cmd --get-log-denied
%steam ALL=NOPASSWD: /usr/bin/firewall-cmd --set-log-denied=all
%steam ALL=NOPASSWD: /usr/bin/firewall-cmd --set-log-denied=off
%steam ALL=NOPASSWD: /usr/local/bin/check-log-throttling
8 changes: 8 additions & 0 deletions roles/install/tasks/firewalld.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,11 @@
/var/log/firewalld-denied.log
/var/log/firewalld-denied-kf2.log
retention: 7

- name: Install wrapper script for checking log throttling status
copy:
src: check-log-throttling
dest: /usr/local/bin/check-log-throttling
owner: root
group: root
mode: '0755'
1 change: 1 addition & 0 deletions roles/install/tasks/steam.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- glibc.i686
- libstdc++.i686
- nss-softokn-freebl.i686
- which
when: ansible_os_family == 'RedHat'

- name: Install Steam dependencies
Expand Down
5 changes: 5 additions & 0 deletions roles/uninstall/tasks/firewalld.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@
file:
path: /etc/logrotate.d/firewalld-denied
state: absent

- name: Remove log throttling checker wrapper script
file:
path: /usr/local/bin/check-log-throttling
state: absent
50 changes: 47 additions & 3 deletions share/killinuxfloor
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,48 @@ function apply_systemd_config ()
fi
}

function get_os_id ()
{
grep '^ID=' /etc/os-release | awk -F'=' '{ print $2}' | tr -d '"'
}

function check_log_throttling ()
{
RET=0
which check-log-throttling &> /dev/null && RET=1 || true
if [ ${RET} -ne 1 ]
then
return
fi

OS_ID=$(get_os_id)

case "${OS_ID}" in
fedora|almalinux)
:
;;

*)
return
;;
esac

printf "%-18.18s" "Log throttled:"

LOG_LIMIT=$(sudo /usr/local/bin/check-log-throttling)

if [ "${LOG_LIMIT}" != '' ]
then
echo -e "${FG_RED}yes${COLOR_RESET}"
printf "%-18.18s" "Log limits:"
echo -e "${LOG_LIMIT}"
else
echo -e "${FG_GREEN}no"
fi

echo -en "${COLOR_RESET}"
}

function get_ddos_stats ()
{
if [ ! -f "${DDOS_LOG}" ]
Expand All @@ -1228,9 +1270,9 @@ function get_ddos_stats ()
LOG_SIZE=$(du -h ${DDOS_LOG} | awk '{ print $1 }')
fi

echo -e "${FG_GREEN}-----------------------------${COLOR_RESET}"
echo -e "${BG_GREEN}Today's DDoS stats: ${COLOR_RESET}"
echo -e "${FG_GREEN}-----------------------------${COLOR_RESET}"
echo -e "${FG_GREEN}-----------------------------------------------------${COLOR_RESET}"
echo -e "${BG_GREEN}Today's DDoS stats: ${COLOR_RESET}"
echo -e "${FG_GREEN}-----------------------------------------------------${COLOR_RESET}"

printf "%-18.18s" "Denied packets:"
if [ ${ATTACK_COUNT} -eq 0 ]
Expand Down Expand Up @@ -1261,6 +1303,8 @@ function get_ddos_stats ()
fi
echo -e "${LOG_SIZE}${COLOR_RESET}"

check_log_throttling

echo
}

Expand Down

0 comments on commit 5364c24

Please sign in to comment.