Parcourir la source

Shellscript to find race conditions in the periodic task system.

Ask Solem il y a 15 ans
Parent
commit
e8e2ec544d
1 fichiers modifiés avec 53 ajouts et 0 suppressions
  1. 53 0
      contrib/periodic-task-runtimes.sh

+ 53 - 0
contrib/periodic-task-runtimes.sh

@@ -0,0 +1,53 @@
+#!/bin/bash
+#---------------------------------------------------------------------------#
+# 
+# Tool to find race conditions in the Periodic Task system.
+# Outputs times of all runs of a certain task (by searching for task name
+# using a search query).
+#
+# Usage:
+#   
+#   $ bash periodic-task-runtimes.sh query host1 [host2 ... hostN]
+#
+# Example usage:
+#
+#   $ bash periodic-task-runtimes.sh refresh_all_feeds host1 host2 host3
+#
+# The output is sorted.
+#
+#---------------------------------------------------------------------------#
+
+USER="root"
+CELERYD_LOGFILE="/var/log/celeryd.log"
+
+query="$1"
+shift
+hosts="$*"
+
+usage () {
+    echo "$(basename $0) task_name_query host1 [host2 ... hostN]"
+    exit 1
+}
+
+[ -z "$query" -o -z "$hosts" ] && usage
+
+
+get_processed_date_for_task () {
+    host="$1"
+    ssh "$USER@$host" "
+        grep '$query' $CELERYD_LOGFILE | \
+            grep 'processed:' | \
+            perl -nle'
+                /^\[(.+?): INFO/; print \$1' | \
+            sed 's/\s*$//'
+    "
+}
+
+get_processed_for_all_hosts () {
+    for_hosts="$*"
+    for host in $for_hosts; do
+        get_processed_date_for_task $host
+    done
+}
+
+get_processed_for_all_hosts $hosts | sort