3 # Synfig Crash Monitor script
4 # Copyright (c) 2009 Konstantin Dmitriev
5 # This package is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation; either version 2 of
8 # the License, or (at your option) any later version.
10 # This package is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
20 echo "Synfig Crash Monitor is a tool to collect statistics about synfig crashes. All information is collected locally in ~/.synfig/cph directory."
22 echo `date +%H:%M` "Synfig Crash Monitor started."
29 [ ! -d ~/.synfig/cph ] && mkdir -p ~/.synfig/cph || true
34 if [[ $STARTED != 0 ]]; then
35 if [[ $CRASH == 0 ]]; then
36 echo `date +%H:%M` "Synfig exited normally. Session time: $RUNTIME."
38 echo `date +%H:%M` "Crash detected. Version $VERSION.$RELEASE.$BRANCH, session time: $RUNTIME."
40 if [ -e ~/.synfig/cph/log ]; then
42 CURRENTDATE=`date +%Y-%m-%d`
43 LOGMODDATE=`stat -c %y ~/.synfig/cph/log`
44 LOGMODDATE=${LOGMODDATE%% *}
45 if [[ $LOGMODDATE != $CURRENTDATE ]]; then
50 echo $VERSION/$BRANCH/$RELEASE $RUNTIME $CRASH >> ~/.synfig/cph/log
60 echo `date +%H:%M` 'Dumping stats for previous session...'
61 LOGMODDATE=`stat -c %y ~/.synfig/cph/log`
62 LOGMODDATE=${LOGMODDATE%% *}
67 for VER in $VERSIONS; do
68 if [[ $VER == ${LINE%% *} ]]; then
73 [[ $FOUND == 0 ]] && VERSIONS="$VERSIONS ${LINE%% *}"
74 done < ~/.synfig/cph/log
75 echo " Logged versions: ${VERSIONS}"
76 for VER in $VERSIONS; do
77 #generating random record ID
78 ID=$( echo `date` `ps` | md5sum | md5sum )
80 #summarizing time and counting crashes
84 if [[ ${LINE%% *} == $VER ]]; then
85 TIMECOUNT=`expr $TIMECOUNT + $(echo $LINE| cut -f 2 -d ' ')` || true
86 CRASHCOUNT=`expr $CRASHCOUNT + $(echo $LINE| cut -f 3 -d ' ')` || true
88 done < ~/.synfig/cph/log
89 echo " $LOGMODDATE $ID $VER $TIMECOUNT $CRASHCOUNT"
90 echo "$LOGMODDATE $ID $VER $TIMECOUNT $CRASHCOUNT" >> ~/.synfig/cph/stats
92 rm -f ~/.synfig/cph/log
99 if ( ps -f -u `whoami`|egrep "synfigstudio$" >/dev/null ) ; then
100 #synfigstudio process exist
101 if [[ $STARTED == 0 ]]; then
105 P=$(ps -f -u `whoami`|egrep "synfigstudio$"| tr -s ' '| cut -d ' ' -f 8)
111 VERSION=`$P/synfig --info|head -n 1|cut -d '-' -f 2`
112 RELEASE=`$P/synfig --info|egrep "Development version:"|cut -d ' ' -f 3`
113 BRANCH=`$P/synfig --info|egrep "Branch:"|cut -d ' ' -f 2-3`
114 if [[ $BRANCH == '(no branch)' ]]; then
115 BRANCH=`$P/synfig --info|egrep "Revision ID:"|cut -d ' ' -f 3`
117 echo `date +%H:%M` "Synfig $VERSION.$RELEASE.$BRANCH started."
118 echo `date +%H:%M` "Assuming Synfig installed in $P."
120 let RUNTIME=$RUNTIME+1
123 #no synfigstudio process exist
124 if [[ $STARTED == 1 ]]; then
126 if [ -e ~/.synfig/fifo ]; then