Re, Je suis heureux de vous présenter la V0.0.6 de certShow.sh
Usage: ${0##*/} [OPTIONS] <IP ADDRESS|HOST|FILE> [IP ADDRESS|HOST|FILE] ... -p Integer Max number of concurrent parallel process to run ($maxProc) -f String Time format string ('$timeFmt') -d Integer Number of days left before warning ($warnDays) + -n Float Nice: delay in seconds between requests (implie "-p 1") -a Show alternatives names -e Show error stats -s Show all stats -q Quiet (Don't show line with status ok) + -u Use Unicode symbols -h Show this help Le Thu, Apr 10, 2025 at 10:54:02AM +0200, Marc SCHAEFER via gull a écrit : > > Un commentaire: j'utilise un IDS, et donc la parallélisation des > connexions pourrait le trigger. Je vais donc utiliser -p 1 (bon, > des requêtes successives pourraient aussi le trigger, on verra). Ajouté l'option "-n <float delay in seconds>" (implie "-p 1"). > > # $ cat /pathTo/siteList.txt | xargs /pathTo/certShow.sh -q > > Je suggère: > > xargs < /pathTo/siteList.txt /pathTo/certShow.sh -q Tu as raison: "avoid useless cat". J'avais initialement écrit: /pathTo/certShow.sh -q $(</pathTo/siteList.txt) mais c'est un bashism In fine, j'ai ajouté la possibilité de lire la liste par stdin /pathTo/certShow.sh -q www.domain1.com </pathTo/siteList.txt > Une remarque: tu utilises des points de code unicode graphiques lors de > l'affichage étendu... > une option --fancy-output pour activer ça ? J'ai ajouté l'option "-u Use Unicode symbols". Du coup, une ligne crontab pourrait ressembler à: '10 7 * * * /pathTo/certShow.sh -qn 30 </pathTo/siteList.txt' Merci Marc pour tes commentaires! --- les diffs: --- certShow.sh 2025-04-10 09:21:52.000000000 +0200 +++ certShow.sh 2025-04-10 13:12:25.000000000 +0200 @@ -3,3 +3,3 @@ # (C) 2022-2025 F-Hauri - http://www.f-hauri.ch -# Version: 0.0.5 -- Last update: Thu Apr 10 09:21:52 CEST 2025 +# Version: 0.0.6 -- Last update: Thu Apr 10 13:12:25 CEST 2025 # Licensed under terms of LGPL v3. www.gnu.org @@ -15,4 +15,4 @@ -: "${maxProc:=10} ${timeFmt:=%F} ${warnDays:=14} ${showAlt:=false} - ${showAllStats:=false} ${showErrStats:=false} ${quiet:=false}" +: "${maxProc:=10} ${timeFmt:=%F} ${warnDays:=14} ${showAlt:=false} ${delay=0} + ${showAllStats:=false} ${showErrStats:=false} ${quiet:=false} ${fancy:=false}" @@ -24,2 +24,3 @@ -d Integer Number of days left before warning ($warnDays) + -n Float Nice: delay in seconds between requests (implie "-p 1") -a Show alternatives names @@ -28,2 +29,3 @@ -q Quiet (Don't show line with status ok) + -u Use Unicode symbols -h Show this help @@ -35,9 +37,9 @@ local -A 'iStrs=([p]=maxProc [f]=timeFmt [d]=warnDays [a]=showAlt - [s]=showAllStats [e]=showErrStats [q]=quiet )' - while getopts "aehqsd:f:p:" opt; do + [n]=delay [u]=fancy [s]=showAllStats [e]=showErrStats [q]=quiet )' + while getopts "aehqsud:f:n:p:" opt; do case $opt in - [dfp] ) + [dfpn] ) # shellcheck disable=SC2154 # Referenced but not assigned. printf -v "${iStrs["$opt"]}" %s "$OPTARG" ;; - [aeqs] ) printf -v "${iStrs["$opt"]}" %s true ;; + [aeqsu] ) printf -v "${iStrs["$opt"]}" %s true ;; h ) usage;exit 0 ;; @@ -68,3 +70,4 @@ [[ -v x509[subject] ]] || { - printf -- '%d|--|--|\U274C\UFE0F|--|--|%s|--|--\n' "$3" "$2" >&$col + printf -- '%d|--|--|%b|--|--|%s|--|--\n' "$3" "${symbol[BAD]}" \ + "$2" >&$col return 4 @@ -78,11 +81,10 @@ altline=${alts[*]} - # WARN: \\U26A0\\UFE0F, OK: \\U2705, BAD: \\U274C if (( (dates[1]-EPOCHSECONDS) / 86400 < 0 )) ; then - printf -v sign '\U274C\UFE0F' + printf -v sign %b "${symbol[BAD]}" rescode=2 elif(( (dates[1]-EPOCHSECONDS) / 86400 < warnDays )); then - printf -v sign '\U26A0\UFE0F' + printf -v sign %b "${symbol[WARN]}" rescode=1 else - printf -v sign '\U2705\UFE0F' + printf -v sign %b "${symbol[OK]}" fi @@ -134,2 +136,6 @@ unset "spids[pid]" + case $delay in + 0 | '' | . | *[!0-9.]* | *.*.* ) ;; + * ) sleep $delay ;; + esac } @@ -167,2 +173,15 @@ local pos=1 arg + if read -t 0 _; then + mapfile -t stdin2Arry + set -- "$@" "${stdin2Arry[@]}" + fi + if $fancy; then + declare -A symbol='([WARN]="\U26A0\UFE0F" [OK]="\U2705" [BAD]="\U274C")' + else + declare -A symbol='([WARN]="!" [OK]="-" [BAD]="X")' + fi + case $delay in + 0 | '' | . | *[!0-9.]* | *.*.* ) ;; + * ) maxProc=1 ;; + esac for arg; do @@ -182,4 +201,4 @@ else - printf -- '%d|--|--|\U274C\UFE0F|--|--|%s|--|--\n' \ - $((pos++)) "$arg" >&$col + printf -- '%d|--|--|%b|--|--|%s|--|--\n' $((pos++)) \ + "${symbol[BAD]}" "$arg" >&$col res_8_list+=(0.0000s "$arg") -- Félix Hauri - <fe...@f-hauri.ch> - http://www.f-hauri.ch _______________________________________________ gull mailing list gull@forum.linux-gull.ch https://forum.linux-gull.ch/mailman/listinfo/gull