From: git Date: Wed, 13 May 2026 12:10:32 +0000 (-0400) Subject: change exit code for errors with $SERVER, fix log concatenation order X-Git-Url: https://git.datadissipation.net/?a=commitdiff_plain;h=e6467fd31804b787d75a19c0a413532e5dfe1ce2;p=logtools.git change exit code for errors with $SERVER, fix log concatenation order --- diff --git a/chckip b/chckip index e4d409d..eca2128 100755 --- 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 diff --git a/countbytes b/countbytes index e2691af..07793dd 100755 --- a/countbytes +++ b/countbytes @@ -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}' diff --git a/countconn b/countconn index f79f791..d433fb8 100755 --- 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" diff --git a/esearchlog b/esearchlog index 5d2fe27..228c0da 100755 --- a/esearchlog +++ b/esearchlog @@ -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 "$@" diff --git a/searchlog b/searchlog index a6bd11d..c88ebca 100755 --- 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 "$@"