Zabbix Telephone Alarm V1

Source: Internet
Author: User

Recently decided to cancel the night shift personnel, the night alarm using robot phone notification. Summing up a few cases, there are questions please also pointed out that the hope can also give you a more ideas.

V1 do too rough, expect the beginning of the V2

First, with whose service

I did not pay much attention to the cost, mainly is to see which simple.

Domestic:

Asked a few domestic cloud platform customer service, they all need the company's business license, I directly chose to give up

Foreign:

Nexmo, this is what we use now, the first time to successfully make a phone call with him, and then directly choose him. The introduction of his online also a lot, we can go to see, direct call, do not need to provide them with redundant information, payment is also supported PayPal, so very convenient

Second, the idea

1, Zabbix end:

The content that meets the alarm condition is sent to the server log by action.

2. Content Processing

Text the contents of the alarm, and finally, in the form of curl, access the phone URL

3. Judging the interface

An intermediate interface, this interface will be sent over the content to judge, in 30 minutes, the same host group of hosts, will not be two times alarm, because if it is a large-scale alarm, it is likely to blow your phone

Third, the specific optimization and operation

1, Zabbix end:

In the Zabbix action to make a division of the content that needs to be alerted, we here only to "high" level will trigger the content

The "Default message" is critical, and he can help me simplify my work on text.

2. Content Processing

The content of the issued to format, the extra space to clean out;

Cat ${logs_path}ss.log | awk-vstart= $start _time-vend= $end _time-f ' ^ ' start<=$1 && $1<=end {print $} ' | awk ' {gsub (/\r[[:blank:]]|[ [: Blank:]] /, "")}1 ' > ${alertlogs_path}format$ (date + "%y%m%d%h%m"). Log

Through the post-cut log, view the Triggerid, from the Zabbix database proposed GroupID;

for triggerid in $ (awk  -F ^  ' {print $2} '  /usr/local/zabbix_ora/alertscripts/alertshell_dir/alertlog_dir/ format$ (date + "%y%m%d%h%m") .log )
do
su - oracle <<!
Sqlplus  -s user/[email protected] $IP: 1521/zabbix << eof
Set heading  off
Set feedback off
set pagesize 0
Set verify off
set  Termout off
spool ${alertlogs_path}groupid$ (date + "%y%m%d%h%m"). Log append
Select   ' ${triggerid}^ ' | | groupid from hosts_groups where hostid =  (select hostid from  items where itemid =   (select itemid from functions where  triggerid =  $triggerid));
Spool off
EOF
Exit
!
Done

Outputs the same lines of text and trigger as in group;

Awk-f ' ^ ' nr==fnr{a[$2]=$0;next}{print a[$1] "^" $ ${path}format$ "(date +"%y%m%d%h%m "). Log ${path}groupid$ (date +"%Y %m%d%h%m "). Log | awk ' {gsub (/[[:blank:]]/, "", $ $);p rint} ' > ${path}formatmethod.log

Converts log to an executable statement and executes the

Cat/dev/null > transitionkey.sh
For line in ' Cat ${path}formatmethod.log '
Do
echo "${line}" | awk-f ^ ' {print ' curl ' \ ' $URL = "$" &alertgroupnumber= "$6" &alertsummary= "$4" &alertdetail= "$ $" & Alertaction=t ' \ ' "} ' >> transitionkey.sh
Done

Zabbix Telephone Alarm V1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.