Restoring SQL queries from /var/log/asterisk/messages log-files.
One of customers had problem with Asterisk CEL due to insufficient HDD space left on Asterisk server. To extract SQL queries from messages, I used these sequence:
- cd /var/log/asterisk/
- grep "cel_odbc.c: Insert failed on" messages | awk '{$1=$2=$3=$4=$5=$6=$7=$8=$9=$10=$11=""; print $0}' > messages_last
- removing all sequences of more than 1 white-spaces (previous command created 11 whitespace sequence):
- tr -s " " < messages_last > messages_truncated
- remove one white space left before INSERT statement:
- sed -i 's/^ *//' messages_truncated
- append ";" to the end of each line:
- sed -i 's/$/;/' messages_truncated
- execute queries from the file:
- mysql -u root -p asterisk
- SOURCE /var/log/asterisk/messages_truncated
- or
- mysql -u root -p asterisk < /var/log/asterisk/messages_truncated
No comments:
Post a Comment