change exit code for errors with $SERVER, fix log concatenation order
authorgit <redacted>
Wed, 13 May 2026 12:10:32 +0000 (08:10 -0400)
committergit <redacted>
Wed, 13 May 2026 12:10:32 +0000 (08:10 -0400)
chckip
countbytes
countconn
esearchlog
searchlog

diff --git a/chckip b/chckip
index e4d409dbface9265f75f8ea6d6303559d604107a..eca2128666fe0229260992a3757b1a3fb74157d3 100755 (executable)
--- a/chckip
+++ b/chckip
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-trap "exit 2" USR1
+trap "exit 1" USR1
 
 err() {
         printf "error: server not detected, needs to be set manually\n" >&2
@@ -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)
 
-{ zcat /var/log/"$SERVER"/access.log.*.gz; cat /var/log/"$SERVER"/access.log /var/log/"$SERVER"/access.log.1; } | 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 | sort -V); } | grep -a "$@" | awk '{print $1}' | sort | uniq | xargs -L 1 host
index e2691af509b3f272cdc36063da016bda9afae160..07793dd490ec213ae2d6c0e828d6297241b0019f 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-trap "exit 2" USR1
+trap "exit 1" USR1
 
 err() {
         printf "error: server not detected, needs to be set manually\n" >&2
@@ -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)
 
-{ zcat /var/log/"$SERVER"/access.log.*.gz; cat /var/log/"$SERVER"/access.log /var/log/"$SERVER"/access.log.1; } | grep --color=auto -a "$@" | awk 'match($0, /\" [0-9]{3} [0-9]+ \"/) { matchp = substr($0, RSTART, RLENGTH); split(matchp, nums, " "); n+=nums[3] } END {print n}'
+{ 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 {print n}'
index f79f791d838dc2f1678e2305dd6f8be20d369494..d433fb81c9d1971583af4af7f2450a1fd8ecca35 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}:")
 
-{ cat /var/log/"$SERVER"/access.log /var/log/"$SERVER"/access.log.1; gzip -cd /var/log/"$SERVER"/access.log.*.gz; } | 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 | 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"
index 5d2fe2718fe08c71162c4880c1a322f9813329f3..228c0daec3a476c3904cb5497dcb6fcfe494960a 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-trap "exit 2" USR1
+trap "exit 1" USR1
 
 err() {
         printf "error: server not detected, needs to be set manually\n" >&2
@@ -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)
 
-{ zcat /var/log/"$SERVER"/error.log.*.gz; cat /var/log/"$SERVER"/error.log /var/log/"$SERVER"/error.log.1; } | grep --color=auto -a "$@"
+{ 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 "$@"
index a6bd11daf91a5437df5d5b9e4798d5366871fb73..c88ebcab7a8d44f946968da4b47a9cfecfd4f518 100755 (executable)
--- a/searchlog
+++ b/searchlog
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-trap "exit 2" USR1
+trap "exit 1" USR1
 
 err() {
         printf "error: server not detected, needs to be set manually\n" >&2
@@ -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)
 
-{ zcat /var/log/"$SERVER"/access.log.*.gz; cat /var/log/"$SERVER"/access.log /var/log/"$SERVER"/access.log.1; } | grep --color=auto -a "$@"
+{ 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 "$@"