2010-12-03 07:29:36 +01:00
#!/bin/sh
set -e -u
LIMIT = 10000
usage( ) {
echo " usage: $0 [--limit <n>] "
2011-12-07 03:50:04 +01:00
exit 1
2010-12-03 07:29:36 +01:00
}
while [ $# -gt 0 ] ; do
case $1 in
--limit)
LIMIT = $2
shift
; ;
*) usage
; ;
esac
shift
done
QUERY = "WHERE NOT -NTOTAL = sum_array(nperdevice)"
2013-02-04 15:08:39 +01:00
echo -n " Device (pid) count: $( pidof xwords | wc | awk '{print $2}' ) "
echo " ; relay pid[s]: $( pidof xwrelay) "
2010-12-03 07:29:36 +01:00
echo "Row count:" $( psql -t xwgames -c " select count(*) FROM games $QUERY ; " )
2013-08-28 16:28:37 +02:00
echo "SELECT dead as d,connname,cid,room,lang as lg,clntVers as cv ,ntotal as t,nperdevice as nPerDev,nsents as snts, seeds,devids,tokens,ack, mtimes " \
2010-12-03 07:29:36 +01:00
" FROM games $QUERY ORDER BY NOT dead, connname LIMIT $LIMIT ; " \
| psql xwgames
2012-11-03 18:58:01 +01:00
echo "SELECT connname, hid, devid, count(*), sum(msglen) " \
2013-08-28 16:28:37 +02:00
"FROM msgs where connname in (SELECT connname from games where not games.dead group by connname) " \
"OR devid IN (SELECT unnest(devids) from games where not games.dead) " \
" GROUP BY connname, hid, devid ORDER BY connname LIMIT $LIMIT ; " \
2012-11-03 18:58:01 +01:00
| psql xwgames
2013-08-28 16:28:37 +02:00
echo " SELECT * FROM devices WHERE id IN (select UNNEST(devids) FROM games $QUERY ) ORDER BY id LIMIT $LIMIT ; " \
2012-09-12 04:07:16 +02:00
| psql xwgames