remove GNU-specific `sort -V`, fix log concatenation order for {,e}searchlog master
authorgit <redacted>
Sun, 17 May 2026 12:14:20 +0000 (08:14 -0400)
committergit <redacted>
Sun, 17 May 2026 12:14:20 +0000 (08:14 -0400)
chckip
countbytes
countconn
esearchlog
searchlog

diff --git a/chckip b/chckip
index eca2128666fe0229260992a3757b1a3fb74157d3..1754c5179ec24966d041017b32853181ef8a1762 100755 (executable)
--- a/chckip
+++ b/chckip
@@ -12,4 +12,4 @@ err() {
 # there's no way for only one printf to fail
 [ -z "$SERVER" ] && SERVER=$(which > /dev/null 2>&1 apache2 && printf "apache2" || which > /dev/null 2>&1 nginx && printf "nginx" || err)
 
 # there's no way for only one printf to fail
 [ -z "$SERVER" ] && SERVER=$(which > /dev/null 2>&1 apache2 && printf "apache2" || which > /dev/null 2>&1 nginx && printf "nginx" || err)
 
-{ cat /var/log/"$SERVER"/access.log /var/log/"$SERVER"/access.log.1; gzip -cd $(ls /var/log/"$SERVER"/access.log.*.gz | sort -V); } | grep -a "$@" | awk '{print $1}' | sort | uniq | xargs -L 1 host
+{ cat /var/log/"$SERVER"/access.log /var/log/"$SERVER"/access.log.1; gzip -cd $(ls /var/log/"$SERVER"/access.log.*.gz | sed 's/.*\.\([0-9]*\)\.gz/\1 &/' | sort -n | cut -d' ' -f2-); } | grep -a "$@" | awk '{print $1}' | sort | uniq | xargs -L 1 host
index a0f3acbd3354819474758df31f2d2f5602db1755..0c39d0e0f9a93e66cd6efd055406c58dbc254d09 100755 (executable)
@@ -12,4 +12,4 @@ err() {
 # there's no way for only one printf to fail
 [ -z "$SERVER" ] && SERVER=$(which > /dev/null 2>&1 apache2 && printf "apache2" || which > /dev/null 2>&1 nginx && printf "nginx" || err)
 
 # there's no way for only one printf to fail
 [ -z "$SERVER" ] && SERVER=$(which > /dev/null 2>&1 apache2 && printf "apache2" || which > /dev/null 2>&1 nginx && printf "nginx" || err)
 
-{ cat /var/log/"$SERVER"/access.log /var/log/"$SERVER"/access.log.1; gzip -cd $(ls /var/log/"$SERVER"/access.log.*.gz | sort -V); } | grep -a "$@" | awk 'match($0, /" [0-9]{3} [0-9]+ "/) { matchp = substr($0, RSTART, RLENGTH); split(matchp, nums, " "); n+=nums[3] } END { y=0; split("B K M G T", units); while (n >= 1024 && y < 4) { n /= 1024; y++; } if (y == 0) { print n } else if (n < 10) {printf "%.1f%c\n", n, units[y+1] } else { printf "%d%c\n", n, units[y+1]} }'
+{ cat /var/log/"$SERVER"/access.log /var/log/"$SERVER"/access.log.1; gzip -cd $(ls /var/log/"$SERVER"/access.log.*.gz | sed 's/.*\.\([0-9]*\)\.gz/\1 &/' | sort -n | cut -d' ' -f2-); } | grep -a "$@" | awk 'match($0, /" [0-9]{3} [0-9]+ "/) { matchp = substr($0, RSTART, RLENGTH); split(matchp, nums, " "); n+=nums[3] } END { y=0; split("B K M G T", units); while (n >= 1024 && y < 4) { n /= 1024; y++; } if (y == 0) { print n } else if (n < 10) {printf "%.1f%c\n", n, units[y+1] } else { printf "%d%c\n", n, units[y+1]} }'
index d433fb81c9d1971583af4af7f2450a1fd8ecca35..1784f34f410560213fb89a06780ddecd1156e94b 100755 (executable)
--- a/countconn
+++ b/countconn
@@ -37,4 +37,4 @@ done
 
 CURDAY=$(tail -n1 /var/log/"$SERVER"/access.log | grep -oE "[0-9]{2}/.*/[0-9]{4}:")
 
 
 CURDAY=$(tail -n1 /var/log/"$SERVER"/access.log | grep -oE "[0-9]{2}/.*/[0-9]{4}:")
 
-{ cat /var/log/"$SERVER"/access.log /var/log/"$SERVER"/access.log.1; gzip -cd $(ls /var/log/"$SERVER"/access.log.*.gz | sort -V); } | awk -v curday="$CURDAY" '$0 ~ curday { if (match($0, /[0-9]{2}\/.*\/[0-9]{4}:[0-9]{2}:[0-9]{2}:[0-9]{2}/)) { print substr($0, RSTART, RLENGTH) } next } { exit }' | cut $CUTCMD | uniq -c | tail -n"$TAILN"
+{ cat /var/log/"$SERVER"/access.log /var/log/"$SERVER"/access.log.1; gzip -cd $(ls /var/log/"$SERVER"/access.log.*.gz | sed 's/.*\.\([0-9]*\)\.gz/\1 &/' | sort -n | cut -d' ' -f2-); } | awk -v curday="$CURDAY" '$0 ~ curday { if (match($0, /[0-9]{2}\/.*\/[0-9]{4}:[0-9]{2}:[0-9]{2}:[0-9]{2}/)) { print substr($0, RSTART, RLENGTH) } next } { exit }' | cut $CUTCMD | uniq -c | tail -n"$TAILN"
index 228c0daec3a476c3904cb5497dcb6fcfe494960a..a9cc280967c93382611b623b734dfe01d07f9339 100755 (executable)
@@ -12,4 +12,4 @@ err() {
 # there's no way for only one printf to fail
 [ -z "$SERVER" ] && SERVER=$(which > /dev/null 2>&1 apache2 && printf "apache2" || which > /dev/null 2>&1 nginx && printf "nginx" || err)
 
 # there's no way for only one printf to fail
 [ -z "$SERVER" ] && SERVER=$(which > /dev/null 2>&1 apache2 && printf "apache2" || which > /dev/null 2>&1 nginx && printf "nginx" || err)
 
-{ cat /var/log/"$SERVER"/error.log /var/log/"$SERVER"/error.log.1; gzip -cd $(ls /var/log/"$SERVER"/error.log.*.gz | sort -V); } | grep --color=auto -a "$@"
+{ gzip -cd $(ls /var/log/"$SERVER"/error.log.*.gz | sed 's/.*\.\([0-9]*\)\.gz/\1 &/' | sort -rn | cut -d' ' -f2-); cat /var/log/"$SERVER"/error.log.1 /var/log/"$SERVER"/error.log; } | grep --color=auto -a "$@"
index c88ebcab7a8d44f946968da4b47a9cfecfd4f518..3ede69346109bb71724a0873e0aad9f54997b81a 100755 (executable)
--- a/searchlog
+++ b/searchlog
@@ -12,4 +12,4 @@ err() {
 # there's no way for only one printf to fail
 [ -z "$SERVER" ] && SERVER=$(which > /dev/null 2>&1 apache2 && printf "apache2" || which > /dev/null 2>&1 nginx && printf "nginx" || err)
 
 # there's no way for only one printf to fail
 [ -z "$SERVER" ] && SERVER=$(which > /dev/null 2>&1 apache2 && printf "apache2" || which > /dev/null 2>&1 nginx && printf "nginx" || err)
 
-{ cat /var/log/"$SERVER"/access.log /var/log/"$SERVER"/access.log.1; gzip -cd $(ls /var/log/"$SERVER"/access.log.*.gz | sort -V); } | grep --color=auto -a "$@"
+{ gzip -cd $(ls /var/log/"$SERVER"/access.log.*.gz | sed 's/.*\.\([0-9]*\)\.gz/\1 &/' | sort -rn | cut -d' ' -f2-); cat /var/log/"$SERVER"/access.log.1 /var/log/"$SERVER"/access.log; } | grep --color=auto -a "$@"