Sponsored Content
Top Forums Shell Programming and Scripting Shell script - Asterisk logs report Post 302969299 by bigbrobg on Monday 21st of March 2016 09:56:19 AM
Old 03-21-2016
These are my three scripts-like running every hour with cron.


RINGNOANSWER:

Code:
mysql -u select -D zabbix -e "select clock,value from history_log where itemid=25143;" |
        grep -v -e endpoint -e ADDMEMBER -e REMOVEMEMBER -e '|0' | 
        grep RINGNOANSWER > "/tmp/ringnoanswer.txt"

wait

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-NOC_queue|/g;
        s/|1112|/|1112-Support_level_1|/g;
        s/|1113|/|1113-Support_level_2|/g' > /var/log/asterisk_agents_log/ringnoanswer.log

-------
Output:
Sun 20 Mar 2016 10:12:57 PM EDT|Sun 20 Mar 2016 10:13:21 PM EDT|1111-NOC_queue|John Inlall|RINGNOANSWER|20000
Sun 20 Mar 2016 10:40:38 PM EDT|Sun 20 Mar 2016 10:41:23 PM EDT|1111-NOC_queue|Ethan Milyon|RINGNOANSWER|20000
Mon 21 Mar 2016 07:45:18 AM EDT|Mon 21 Mar 2016 07:45:39 AM EDT|1111-NOC_queue|Peter Hill|RINGNOANSWER|20000
------
*waittime is the latest one (20000)

EXITWITHTIMEOUT:

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

wait

cat /tmp/exitwithtimeout.txt | awk -F '[ |]'  'BEGIN {OFS="|"} { print strftime("%c|", $2) strftime("%c|", $1) $3,$5,$8; }' |
        sed 's/|1111|/|1111-NOC_queue|/g;
        s/|1112|/|1112-Support_level_1|/g;
        s/|1113|/|1113-Support_level_2|/g' > /var/log/asterisk_agents_log/exitwithtimeout.log

-----
Output:
Mon 21 Mar 2016 07:45:18 AM EDT|Mon 21 Mar 2016 07:46:08 AM EDT|1113-Support_level_2|EXITWITHTIMEOUT|30
Mon 21 Mar 2016 08:25:23 AM EDT|Mon 21 Mar 2016 08:26:11 AM EDT|1113-Support_level_2|EXITWITHTIMEOUT|30
-----

EXITEMPTY:

Code:
mysql -u select -D zabbix -e "select clock,value from history_log where itemid=25161;" |
        grep -v -e endpoint -e ADDMEMBER -e REMOVEMEMBER -e '|02' | 
        grep EXITEMPTY > "/tmp/exitempty.txt"

wait

cat /tmp/exitempty.txt | awk -F '[ |]'  'BEGIN {OFS="|"} { print strftime("%c|", $2) strftime("%c|", $1) $3,$5; }' |
        sed 's/|1111|/|1111-NOC_queue|/g;
        s/|1112|/|1112-Support_level_1|/g;
        s/|1113|/|1113-Support_level_2|/g' > /var/log/asterisk_agents_log/exitempty.log

-----
Output:
Wed 16 Mar 2016 07:53:17 PM EDT|Wed 16 Mar 2016 07:53:31 PM EDT|1112-Support_level_1|EXITEMPTY
Sat 19 Mar 2016 09:43:26 PM EDT|Sat 19 Mar 2016 09:44:38 PM EDT|1112-Support_level_1|EXITEMPTY
-----

Now I'm wondering how to improve them, and how to do the following:

- when RINGNOANSWER for a particular operator hits count 10 for WAITTIME > 14000. alert with summary of calls
- if EXITWITHTIMEOUT > 1 per each queue, in any hour - alert with mail including queues with this issue
- at 7am each morning, send mail report showing count for each operator that was logged in the previous day (ie midnight to midnight from day before)
with total RINGNOANSWER > 14000 "waittime"


And I am stuck..

Last edited by bigbrobg; 03-21-2016 at 11:20 AM..
 

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 06:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy