Sponsored Content
Top Forums Shell Programming and Scripting Shell script - Asterisk logs report Post 302969013 by bigbrobg on Thursday 17th of March 2016 12:56:04 PM
Old 03-17-2016
Shell script - Asterisk logs report

Dear all,
I start to build script(s) for few tasks, and I'll use log files to complete the following:


Code:
1) when ringnoanswer for a particular operator hits count 10 for waittime > 14000 send mail alert with summary of calls
2) per queue - exitwithtimout > 1 in any hour, then send mail alert.
3)  7am each morning mail report showing count for each operator that was  logged in 
the previous day (i.e. midnight to midnight from day before)   with total ringnowanswer > 14000 wait time.


So I have plan to use cron tasks, and bash scripts with queue_log grep for EXITEMPTY, EXITWITHTIMEOUT, RINGNOANSWER, operator name and queue number.
Well, that is just plan for now. Please if you have any ideas, could you please share.. ? May be there is easier way to do this.. I have zabbix already, and data needed is there in sql database. May be there is a way to pull the needed data from there?
thanks in advance
OS: CentOS
Asterisk 11.18.0

---------- Post updated at 12:56 PM ---------- Previous update was at 04:35 AM ----------

My first step is created user "select" for mysql and the following:
Code:
mysql -u select -D zabbix -e "select clock,value from history_log" > /tmp/text.log

The output is:

Code:
1458182176      1458182148|1458182143.44543|1111|NAME NAME|RINGNOANSWER|4000
1458183289      1458183261|1458183252.44657|1111|NAME NAME|RINGNOANSWER|9000
1458183410      1458183393|1458183388.44682|1111|NAME NAME|RINGNOANSWER|4000
1458183621      1458183596|1458183592.44700|1111|NAME NAME|RINGNOANSWER|4000

So I believe my next step should be to make unix time into readable, may be using:
awk '{ print strftime("%c", $0); }'

I have no idea how to grep only with waittime > 14000 (this is last value after RINGNOANSWER), and how to add them into new text file (may be using cron and update text file with new results instead to rewrite the file every time). After that to check if there is NAME > 10, and if true to send mail with output. This may be will lead to new problem - duplicate emails, so may be when NAME > 10 is true, on email to clear the text file.

Please .. someone.. give idea

Last edited by jim mcnamara; 03-17-2016 at 11:06 PM..
 

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 10:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy