add logging helper script and update historyDownload script
This commit is contained in:
parent
8bfa91fd91
commit
9e3cdc25e9
|
@ -51,5 +51,9 @@ same as historyDownload, just that its designed for running on the storage serve
|
||||||
## backupSync.sh
|
## backupSync.sh
|
||||||
shell script that can be launched with backup.js to sync to a storage server after every backup. It uses rsync which is much faster than ftp, sftp or any other methode
|
shell script that can be launched with backup.js to sync to a storage server after every backup. It uses rsync which is much faster than ftp, sftp or any other methode
|
||||||
|
|
||||||
|
## liveLog.sh
|
||||||
|
shell script that watches the pixel.log file and outputs the stats of the current IPs placing there
|
||||||
|
Usage: `./liveLog.sh LOGFILE CANVASID STARTX_STARTY ENDX_ENDY`
|
||||||
|
|
||||||
## pp-center\*.png
|
## pp-center\*.png
|
||||||
center logo of pixelplanet
|
center logo of pixelplanet
|
||||||
|
|
|
@ -68,8 +68,13 @@ async def get_area(x, y, w, h, start_date, end_date):
|
||||||
cnt += 1
|
cnt += 1
|
||||||
#frames.append(image.copy())
|
#frames.append(image.copy())
|
||||||
image.save('./timelapse/t%s.png' % (cnt))
|
image.save('./timelapse/t%s.png' % (cnt))
|
||||||
async with session.get('https://pixelplanet.fun/api/history?day=%s&id=%s' % (iter_date, canvas_id)) as resp:
|
while True:
|
||||||
time_list = json.loads(await resp.text())
|
async with session.get('https://pixelplanet.fun/api/history?day=%s&id=%s' % (iter_date, canvas_id)) as resp:
|
||||||
|
try:
|
||||||
|
time_list = json.loads(await resp.text())
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
print('Couldn\'t decode json for day %s, trying again' % (iter_date))
|
||||||
i = 0
|
i = 0
|
||||||
for time in time_list:
|
for time in time_list:
|
||||||
i += 1
|
i += 1
|
||||||
|
|
75
utils/liveLog.sh
Executable file
75
utils/liveLog.sh
Executable file
|
@ -0,0 +1,75 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# this script parses the pixellogs live and shows which IPs are currently active in
|
||||||
|
# a given area and where they placed their last pixel
|
||||||
|
# Usage: ./liveLog.sh LOGFILE CANVASID STARTX_STARTY ENDX_ENDY
|
||||||
|
LOGFILE=$1
|
||||||
|
CANVAS=$2
|
||||||
|
STARTCOORDS=$3
|
||||||
|
ENDCOORDS=$4
|
||||||
|
STARTX=`echo ${STARTCOORDS} | sed 's/_.*$//'`
|
||||||
|
STARTY=`echo ${STARTCOORDS} | sed 's/^.*_//'`
|
||||||
|
ENDX=`echo ${ENDCOORDS} | sed 's/_.*$//'`
|
||||||
|
ENDY=`echo ${ENDCOORDS} | sed 's/^.*_//'`
|
||||||
|
|
||||||
|
if [ "$#" -ne 4 ]
|
||||||
|
then
|
||||||
|
echo " Usage: ./liveLog.sh LOGFILE CANVASID STARTX_STARTY ENDX_ENDY"
|
||||||
|
echo ""
|
||||||
|
echo "this script parses the pixellogs live and shows which IPs are currently active in "
|
||||||
|
echo "a given area and where they placed their last pixel"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
parse_log()
|
||||||
|
{
|
||||||
|
while read -r -a args
|
||||||
|
do
|
||||||
|
CAN=${args[2]}
|
||||||
|
X=${args[3]}
|
||||||
|
Y=${args[4]}
|
||||||
|
if [ "$CAN" -eq "$CANVAS" -a "$X" -ge "$STARTX" -a "$X" -le "$ENDX" -a "$Y" -ge "$STARTY" -a "$Y" -le "$ENDY" ]
|
||||||
|
then
|
||||||
|
IP=${args[0]}
|
||||||
|
CLR=${args[6]}
|
||||||
|
printf "%-40s | %-18s | %5s\n" "$IP" "$X,$Y" "$CLR"
|
||||||
|
fi
|
||||||
|
done <&0
|
||||||
|
}
|
||||||
|
|
||||||
|
declare -A ACTIVEIPS
|
||||||
|
parse_log_active_ips()
|
||||||
|
{
|
||||||
|
while read -r -a args
|
||||||
|
do
|
||||||
|
CAN=${args[2]}
|
||||||
|
X=${args[3]}
|
||||||
|
Y=${args[4]}
|
||||||
|
if [ "$CAN" -eq "$CANVAS" -a "$X" -ge "$STARTX" -a "$X" -le "$ENDX" -a "$Y" -ge "$STARTY" -a "$Y" -le "$ENDY" ]
|
||||||
|
then
|
||||||
|
IP=${args[0]}
|
||||||
|
if [ -z "${ACTIVEIPS[$IP]}" ]
|
||||||
|
then
|
||||||
|
CNT=0
|
||||||
|
else
|
||||||
|
CNT=`echo ${ACTIVEIPS[$IP]} | sed 's/ .*//'`
|
||||||
|
fi
|
||||||
|
CNT=$((${CNT} + 1))
|
||||||
|
CLR=${args[6]}
|
||||||
|
ACTIVEIPS[$IP]="$CNT $IP $X,$Y $CLR"
|
||||||
|
print_active_ips | sort -rV
|
||||||
|
fi
|
||||||
|
done <&0
|
||||||
|
}
|
||||||
|
|
||||||
|
print_active_ips()
|
||||||
|
{
|
||||||
|
clear
|
||||||
|
for IP in "${!ACTIVEIPS[@]}"
|
||||||
|
do
|
||||||
|
printf "%-7s | %-40s | %-18s | %5s\n" ${ACTIVEIPS[$IP]}
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
tail -f ${LOGFILE} | parse_log_active_ips
|
Loading…
Reference in New Issue
Block a user