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."
21 echo "All information is collected locally in ~/.synfig/cph directory."
23 echo `date +%H:%M` "Synfig Crash Monitor started."
31 [ ! -d ~/.synfig/cph ] && mkdir -p ~/.synfig/cph || true
36 if [[ $STARTED != 0 ]]; then
37 if [[ $CRASH == 0 ]]; then
38 echo `date +%H:%M` "Synfig exited normally. Session time: $RUNTIME."
40 echo `date +%H:%M` "Crash detected. Version $VERSION.$RELEASE.$BRANCH, session time: $RUNTIME."
42 if [ -e ~/.synfig/cph/log ]; then
44 CURRENTDATE=`date +%Y-%m-%d`
45 LOGMODDATE=`stat -c %y ~/.synfig/cph/log`
46 LOGMODDATE=${LOGMODDATE%% *}
47 if [[ $LOGMODDATE != $CURRENTDATE ]]; then
52 echo $VERSION/$BRANCH/$RELEASE/$REVISION_ID $RUNTIME $CRASH >> ~/.synfig/cph/log
62 echo `date +%H:%M` 'Dumping stats for previous session...'
63 LOGMODDATE=`stat -c %y ~/.synfig/cph/log`
64 LOGMODDATE=${LOGMODDATE%% *}
69 for VER in $VERSIONS; do
70 if [[ $VER == ${LINE%% *} ]]; then
75 [[ $FOUND == 0 ]] && VERSIONS="$VERSIONS ${LINE%% *}"
76 done < ~/.synfig/cph/log
77 echo " Logged versions: ${VERSIONS}"
78 for VER in $VERSIONS; do
79 #generating random record ID
80 ID=$( echo `date` `ps` | md5sum | md5sum )
82 #summarizing time and counting crashes
86 if [[ ${LINE%% *} == $VER ]]; then
87 TIMECOUNT=`expr $TIMECOUNT + $(echo $LINE| cut -f 2 -d ' ')` || true
88 CRASHCOUNT=`expr $CRASHCOUNT + $(echo $LINE| cut -f 3 -d ' ')` || true
90 done < ~/.synfig/cph/log
91 echo " $LOGMODDATE $ID $VER $TIMECOUNT $CRASHCOUNT"
92 echo "$LOGMODDATE $ID $VER $TIMECOUNT $CRASHCOUNT" >> ~/.synfig/cph/stats
94 rm -f ~/.synfig/cph/log
101 export PS=$(ps -f -u `whoami`)
102 if ( ( echo "$PS" |egrep "synfigstudio$" >/dev/null ) || ( echo "$PS" | egrep "synfigstudio " >/dev/null ) ) ; then
103 #synfigstudio process exist
104 if [[ $STARTED == 0 ]]; then
108 if ( echo "$PS" |egrep "synfigstudio$" >/dev/null ) ; then
109 P=$( echo "$PS" |egrep "synfigstudio$"| tr -s ' '| cut -d ' ' -f 8)
111 P=$( echo "$PS" |egrep "synfigstudio "| tr -s ' '| cut -d ' ' -f 8)
118 VERSION=`$P/synfig --info|head -n 1|cut -d '-' -f 2`
119 RELEASE=`$P/synfig --info|egrep "Revision:"|cut -d ' ' -f 2`
120 BRANCH=`$P/synfig --info|egrep "Branch:"|cut -d ' ' -f 2-3`
121 REVISION_ID=`$P/synfig --info|egrep "Revision ID:"|cut -d ' ' -f 3`
122 if [[ $BRANCH == '(no branch)' ]]; then
125 echo `date +%H:%M` "Synfig $VERSION.$RELEASE.$BRANCH.$REVISION_ID started."
126 echo `date +%H:%M` "Assuming Synfig installed in $P."
128 let RUNTIME=$RUNTIME+1
131 #no synfigstudio process exist
132 if [[ $STARTED == 1 ]]; then
134 if [ -e ~/.synfig/fifo ]; then