watch_activities 1.18 KB
Newer Older
1 2
#!/bin/sh

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
function show_help ( )
{
  script_name=`basename $0`
  echo """
  Usage:
    $script_name <mysql_opt> [interval seconds]
  Interval is default 5.
  mysql_opt are default mysql command line options.
  Put them in quotes if more than one option is passed.

  Typical usage:
    $script_name erp5
    $script_name \"-h remotehost -u user erp5remote\" 3
  """
}

MYSQL_OPT=$1
INTERVAL=$2

if [ "$MYSQL_OPT" == "" ] ; then
  show_help
24 25 26
  exit 1
fi

27 28 29 30 31 32 33 34 35 36 37 38
if [ "$INTERVAL" == "" ] ; then
  INTERVAL=5
fi

SELECT="""
SELECT count(path) AS message, method_id, processing, processing_node FROM message GROUP BY method_id, processing, processing_node;
SELECT count(path) AS message_queue, method_id, processing, processing_node FROM message_queue GROUP BY method_id, processing, processing_node;
SELECT count(path) AS message, processing, processing_node FROM message GROUP BY processing, processing_node;
SELECT count(path) AS message_queue, processing, processing_node FROM message_queue GROUP BY processing, processing_node;
SELECT count(path) AS message_count FROM message;
SELECT count(path) AS message_queue_count FROM message_queue;
"""
39

40
watch -n $INTERVAL "mysql $MYSQL_OPT --disable-pager -t -e '$SELECT' "