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 `date +%H:%M` "Synfig Crash Monitor started."
27 [ ! -d ~/.synfig/cph ] && mkdir -p ~/.synfig/cph || true
32 if [[ $STARTED != 0 ]]; then
33 if [[ $CRASH == 0 ]]; then
34 echo `date +%H:%M` "Synfig exited normally. Session time: $RUNTIME."
36 echo `date +%H:%M` "Crash detected. Version $VERSION.$RELEASE.$BRANCH, session time: $RUNTIME."
38 if [ -e ~/.synfig/cph/log ]; then
40 CURRENTDATE=`date +%Y-%m-%d`
41 LOGMODDATE=`stat -c %y ~/.synfig/cph/log`
42 LOGMODDATE=${LOGMODDATE%% *}
43 if [[ $LOGMODDATE != $CURRENTDATE ]]; then
48 echo $VERSION/$BRANCH/$RELEASE $RUNTIME $CRASH >> ~/.synfig/cph/log
58 echo `date +%H:%M` 'Dumping stats for previous session...'
59 LOGMODDATE=`stat -c %y ~/.synfig/cph/log`
60 LOGMODDATE=${LOGMODDATE%% *}
65 for VER in $VERSIONS; do
66 if [[ $VER == ${LINE%% *} ]]; then
71 [[ $FOUND == 0 ]] && VERSIONS="$VERSIONS ${LINE%% *}"
72 done < ~/.synfig/cph/log
73 echo " Logged versions: ${VERSIONS}"
74 for VER in $VERSIONS; do
75 #generating random record ID
76 ID=$( echo `date` `ps` | md5sum | md5sum )
78 #summarizing time and counting crashes
82 if [[ ${LINE%% *} == $VER ]]; then
83 TIMECOUNT=`expr $TIMECOUNT + $(echo $LINE| cut -f 2 -d ' ')` || true
84 CRASHCOUNT=`expr $CRASHCOUNT + $(echo $LINE| cut -f 3 -d ' ')` || true
86 done < ~/.synfig/cph/log
87 echo " $LOGMODDATE $ID $VER $TIMECOUNT $CRASHCOUNT"
88 echo "$LOGMODDATE $ID $VER $TIMECOUNT $CRASHCOUNT" >> ~/.synfig/cph/stats
90 rm -f ~/.synfig/cph/log
97 if ( ps -f -u `whoami`|egrep "synfigstudio$" >/dev/null ) ; then
98 #synfigstudio process exist
99 if [[ $STARTED == 0 ]]; then
103 P=$(ps -f -u `whoami`|egrep "synfigstudio$"| tr -s ' '| cut -d ' ' -f 8)
110 echo " Assuming synfig installed in $P."
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`
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."
119 let RUNTIME=$RUNTIME+1
122 #no synfigstudio process exist
123 if [[ $STARTED == 1 ]]; then
125 if [ -e ~/.synfig/fifo ]; then