💾 Archived View for makeworld.space › files › jetforce-stats.sh captured on 2021-12-03 at 14:04:38.

View Raw

More Information

➡️ Next capture (2023-01-29)

-=-=-=-=-=-=-

#!/usr/bin/env bash

echo -e '20 text/gemini\r\n'
echo
if  [[ "$QUERY_STRING" == "" ]]; then
    echo '# Server Stats'
    echo
    echo 'As far as I can tell, this is the first Gemini server stats page!'
    echo
    echo 'These stats apply to past 7 days, I think.'
    echo
    echo '```'
    echo "Total visits, to all pages:       $(zgrep -a jetforce /var/log/daemon.log* | awk -F' ' '{ print $6 }' | grep '^[0-9]' | wc -l)"
    echo "Number of unique visitors:        $(zgrep -a jetforce /var/log/daemon.log* | awk -F' ' '{ print $6 }' | grep '^[0-9]' | sort | uniq | wc -l)" 
    echo "Jetforce server last started at:  $(systemctl show jetforce.service -p ExecMainStartTimestamp | cut -b 24-)"
    echo "Overall server:                   $(uptime -p)"
    echo '```'
    echo
    echo "=> ../one-liners.gmi Visit my one-liners page to see how these are generated."
    echo
    echo 'Note that these stats include robots or crawlers.'
else
    echo "# Stats for string \"$QUERY_STRING\""
    echo
    echo 'Unfortunately, it seems like these stats are currently somewhat broken. The real numbers are potientially much higher.'
    echo
    echo 'These stats apply to past 7 days, I think.'
    echo
    echo '```'
    echo "Total visits:               $(zgrep -a jetforce /var/log/daemon.log* | grep $QUERY_STRING | awk -F' ' '{ print $6 }' | grep '^[0-9]' | wc -l)"
    echo "Number of unique visitors:  $(zgrep -a jetforce /var/log/daemon.log* | grep $QUERY_STRING | awk -F' ' '{ print $6 }' | grep '^[0-9]' | sort | uniq | wc -l)" 
    echo '```'
    echo
    echo 'Note that these stats include robots or crawlers.'
fi