Sponsored Content
Top Forums Shell Programming and Scripting Shell script - Asterisk logs report Post 302969128 by bigbrobg on Friday 18th of March 2016 04:54:48 PM
Old 03-18-2016
Thanks Jim. I'll try with AWK and will reply with results.

May be someone will ask why I'm not using logs directly from Asterisk. Well the pbx server is on different machine, and it's not possible to do so. At least for now. That's why I'm using zabbix mysql base.

@Jim - quotes like 1111 are for queues. Each queue have his own name, but sadly in logs I have only queue number, so I have to add name. In logs I have 1111, and I need to change it to 1111-name... like 1111-queue_support_team.. and so on.
I know it's not good the way I did it. I'm newbie with this things...., that's why I'm asking you guys... Smilie

---------- Post updated at 02:12 PM ---------- Previous update was at 08:58 AM ----------

Thanks to Jim for pointing me to right direction.. now I have this for exitwithtimeout:

1. mysql pull data
Code:
mysql -u select -D zabbix -e "select clock,value from history_log;" | grep -v -e endpoint -e ADDMEMBER -e REMOVEMEMBER -e '|02' |  grep EXITWITHTIMEOUT > "/tmp/exitwithtimeout.txt"

before text format:

Code:
1458314962      1458314937|1458314907.591|1111|NONE|EXITWITHTIMEOUT|1|1|30

first column is zabbix time, not needed. Second column is end time (why, don't ask, asterisk thing I think), third column is start time.

2. text format:
Code:
cat /tmp/exitwithtimeout.txt | awk -F '[ |]'  'BEGIN {OFS="|"} { print strftime("%c|", $2) strftime("%c|", $1) $3,$5,$8; }' | sed 's/|1111|/|1111-Support_team_queue|/g' > exitwithtimeout.log

final result:
Code:
Fri 18 Mar 2016 11:28:27 AM EDT|Fri 18 Mar 2016 11:29:22 AM EDT|1111-Support_team_queue|EXITWITHTIMEOUT|30

Good thing - first step is done. I have data and formatted text, and I will do that for other two log files.

Now I have to think how to include only waittime > 14000 into final result, and how to track particular
queue for exitwithtimout > 1 in any hour. WAITTIME and EXITWITHTIMEOUT are part from different files - WAITTIME is from RINGNOANSWER, and queues are in all three,
but I need only from EXITWITHTIMEOUT.

WAITTIME is last one in this output (raw, before text format):
Code:
1458220872 1458220872|1458220852.47158|1111|John Wright|RINGNOANSWER|20000

Queue in EXITWITHTIMEOUT is 4th in log file (raw output before text formatting):

Code:
1458314937  1458314937|1458314907.591|1111|NONE|EXITWITHTIMEOUT|1|1|30

---------- Post updated at 04:54 PM ---------- Previous update was at 02:12 PM ----------

Well.. the answer how to include only > 14000 maybe is :
Code:
awk -F '[|]' -v x=14000 '$6 > x' /tmp/ringnoanswer.txt

and included with things above:
Code:
cat /tmp/ringnoanswer.txt | awk -F '[|]'  'BEGIN {OFS="|" } {print strftime("%c|", $2) strftime("%c|", $1) $3,$4,$5,$6;'} | 
                    awk -F '[|]' -v x=14000 '$6 > x' | sed 's/|1111|/|1111-Support_team_queue|/g'  > ringnoanswer.log

Moderator's Comments:
Mod Comment Please use CODE tags (not ICODE tags) for full line and multi-line sample input, sample output, and code segments.

Last edited by bigbrobg; 03-19-2016 at 07:30 PM.. Reason: Change ICODE tags to CODE tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to view logs of a server

Please share a shell script to collect logs of a server (like cpu utilization, memory etc) for a perticular time interval by giving date, time and server name as input. (1 Reply)
Discussion started by: abhishek27
1 Replies

2. Shell Programming and Scripting

Use asterisk in shell script bash

Hello, I am trying to save in a file a single "*" but its not working... look what i am doing... FILE="/home/teste/a.txt" ...BEGIN... ASTERISK="*" echo "STRING $ASTERISK STRING" >> $FILE ...END... when i do it, the result is a list of all files of the current... (4 Replies)
Discussion started by: diogooute
4 Replies

3. Shell Programming and Scripting

help with a shell script that greps an error from the logs

Hello everyone. I wrote the following script but the second part is not excecuting. It is not sending the notification by email if the error occurs. the send mail is working so i think the errorr should be in the if statement LOGDIR=/logs/out LOG=`date "+%Y%m%d"`.LOG-FILE.out #the log file ... (11 Replies)
Discussion started by: adak2010
11 Replies

4. Shell Programming and Scripting

Need to develop a script to create a report reading multiple server logs

I am currently trying to develop a script to connect to mulltiple servers, reading specifc data from log files on the servers and append the data from each file into a single tab delimited row. So, at the end I am planning to have a report with all the extracted data with each row per server. I am... (5 Replies)
Discussion started by: scriptingnewbie
5 Replies

5. Shell Programming and Scripting

Shell Script for GC Logs

Hi, I have a strange situation here, I want to archive gc.logs file, generated by a java application, the strange thing about gc.log file is is doesn't have any time/date stamp appended to it unlike other logs (catalina/access/error) and one more strange thing is when ever the application is... (6 Replies)
Discussion started by: Neeryan
6 Replies

6. Shell Programming and Scripting

Help with extract application logs through shell script in performance testing

Hi Experts, I am new to shell.How to extract logs (Web,APP,Database) using shell in performance testing? Need for webserver logs,app server logs and d/b logs code. Thanks in advance Sree (3 Replies)
Discussion started by: sree vasu
3 Replies

7. Shell Programming and Scripting

Managing logs in shell script

Hi, I need write a shell script which should be executed from the crontab every day. This shell script is running several other shell scripts , and each one of them is writing to its log file. Few of the the shell script are also connecting using ssh to some other users on remote machine , do... (1 Reply)
Discussion started by: Yoav
1 Replies

8. Shell Programming and Scripting

Help with Shell Script to View Logs

Hi I'm very new to unix shell scripting. Im also new here in this forum. I'm a SQL Server DBA but I'm slowly learning Oracle and Sybase DB. Our Oracle and Sybase are on Unix platforms. Im slowly learning Linux Admin and Shell Scripting to automate tasks. I'm writing a script to view DB error... (4 Replies)
Discussion started by: Ricky777
4 Replies

9. Shell Programming and Scripting

Shell script for capturing FTP logs

I have a script #!/bin/bash HOST=ftp.example.com USER=ftpuser PASSWORD=P@ssw0rd ftp -inv $HOST <<EOF user $USER $PASSWORD cd /path/to/file mput *.html bye EOF the script executes sucessfully I need to capture the FTP logs to a logfile should contain FTP Login successful ... (1 Reply)
Discussion started by: rajeshas83
1 Replies

10. Shell Programming and Scripting

If I ran perl script again,old logs should move with today date and new logs should generate.

Appreciate help for the below issue. Im using below code.....I dont want to attach the logs when I ran the perl twice...I just want to take backup with today date and generate new logs...What I need to do for the below scirpt.............. 1)if logs exist it should move the logs with extention... (1 Reply)
Discussion started by: Sanjeev G
1 Replies
All times are GMT -4. The time now is 03:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy