Showing posts with label Zabbix. Show all posts
Showing posts with label Zabbix. Show all posts

Monday, October 26, 2020

Zabbix Custom Email Alert

 

Zabbix Custom Email Alert

Features

  • Graphs based on latest data are sent to your Email
  • You can send messages both in private and group email
  • Links to open Graph URL and Event URL.

Configuration / Installation

Zabbix server need to be install, configure and up and running.
  • Put problem.sh, resolved.sh, acknowledged.sh and sendEmail in your AlertScriptsPath directory, the path is set inside your zabbix_server.conf

Script should be execute by zabbix user. Default path of the "alertScriptPath is 

Download all the scripts from Github.  Download Link

  • Set below parameters in problem.sh, resolved.sh, acknowledged.sh files
SENDER="Zabbix-Alert<zabbix-alert@mycompany.com>"
ZBX_URL="https://mycompany.com/zabbix"
USERNAME="Admin" # Zabbix Username
PASSWORD="password" # Zabbix Password

Note: Better to use read only user instead of using admin user.

  • Configure email server details in "sendEmail" client.
  • Add 3 new media as "Zabbix Problem Email" , " Zabbix Resolved Email" and "Zabbix Acknowledged Email" in Zabbix web interface with these settings:

 




  • Create an Action for Email Alert
Add host groups to condition list.


  • Under Operation Tab, Put default subject and default message like this.

Default Subject:  

[{TRIGGER.SEVERITY}] : {TRIGGER.NAME}

Default Message: 

Problem started at {EVENT.TIME} on {EVENT.DATE}
Problem name: {TRIGGER.NAME}
Host: {HOST.NAME}
IP: {HOST.IP}
Severity: {TRIGGER.SEVERITY}

Original Problem ID: {EVENT.ID}
Status:  {EVENT.STATUS}
Trigger ID: {TRIGGER.ID}
Last Value: {ITEM.LASTVALUE}
Item ID: {ITEM.ID}
Item Graphic: [{ITEM.ID1}]

  • Add operation details

  • Then add Recovery Operation 

Default Subject:  

[Resolved] : {TRIGGER.NAME}

Default Message: 

Problem has been resolved at {EVENT.RECOVERY.TIME} on {EVENT.RECOVERY.DATE}
Problem name: {TRIGGER.NAME}
Host: {HOST.NAME}
IP: {HOST.IP}
Severity: {TRIGGER.SEVERITY}

Original Problem ID: {EVENT.ID}
Status:  {EVENT.STATUS}
Trigger ID: {TRIGGER.ID}
Last Value: {ITEM.LASTVALUE}
Item ID: {ITEM.ID}
Item Graphic: [{ITEM.ID1}]

  • Add operation details Recovery

  • Then add Acknowledgement Operation 

Default Subject:  

[Acknowledged] : {TRIGGER.NAME}

Default Message: 

{USER.FULLNAME} user acknowledged problem at {ACK.DATE} {ACK.TIME} with the following message:
{ACK.MESSAGE}

Problem name: {TRIGGER.NAME}
Host: {HOST.NAME}
IP: {HOST.IP}
Severity: {TRIGGER.SEVERITY}
Status:  {EVENT.STATUS}
Original Problem ID: {EVENT.ID}
Last Value: {ITEM.LASTVALUE}

  • Add operation details for Acknowledgement

Sample Email Notifications

Problem Email


Recovery Email



Thursday, October 15, 2020

Zabbix Telegram Alert

Zabbix Telegram Alert

Features
  • Graphs based on latest data are sent directly to your messenger
  • You can send messages both in private and group chats
  • Channels support
  • Saves chatid as a temporary file

Configuration / Installation

Zabbix server need to be install, configure and up and running.
  • Put telegram.sh in your AlertScriptsPath directory, the path is set inside your zabbix_server.conf
Script should be execute by zabbix user. Default path of the "alertScriptPath is 


  • Set script path and log path in telegram.sh file
Script Source code you can download from below link.

"telegram.sh" Download 


  • Configure ZABBIX URL, User/Password and Telegram BOT token in telegram.sh file.
Create a bot in Telegram and get API key: https://core.telegram.org/bots#creating-a-new-bot.
As a best practice create readonly user in Zabbix web interface (for getting graphs from zabbix) 


  • Add new media for Telegram in Zabbix web interface with these settings:


  • Create a Action for Telegram Alert
Add host groups to condition list.


  • Under Operation Tab, Put default subject and default message like this.
Default Subject: 

{TRIGGER.STATUS} {TRIGGER.SEVERITY} {TRIGGER.SEVERITY} : {TRIGGER.NAME}

Default Message: 

Host IP: {HOSTNAME}
Host Name:  {HOST.NAME}
Problem status: {STATUS}
Severity: {TRIGGER.SEVERITY}
Date and Time: {EVENT.DATE} - {EVENT.TIME}
Item Graphic: [{ITEM.ID1}]
Last tested value: {{HOSTNAME}:{TRIGGER.KEY}.last(0)}


  • Under Recovery Operations tab, put default subject and default message like this.
Default Subject: 

{TRIGGER.STATUS} {TRIGGER.SEVERITY} Resolved : {TRIGGER.NAME}

Default Message: 

Host IP: {HOSTNAME}
Host Name:  {HOST.NAME}
Problem status: {STATUS}
Severity: {TRIGGER.SEVERITY}
Date and Time: {EVENT.DATE} - {EVENT.TIME}
Item Graphic: [{ITEM.ID1}]
Last tested value: {{HOSTNAME}:{TRIGGER.KEY}.last(0)}
 

  • Under Acknowledgement Operations tab, put default subject and default message like this.
Default Subject: 

{TRIGGER.STATUS} {TRIGGER.SEVERITY} Acknowledged : {TRIGGER.NAME}

Default Message: 

Host IP: {HOSTNAME}
Host Name:  {HOST.NAME}
Problem status: {STATUS}
Acknowledged Message: {ACK.MESSAGE}
Severity: {TRIGGER.SEVERITY}
Date and Time: {EVENT.DATE} - {EVENT.TIME}
Item Graphic: [{ITEM.ID1}]
Last tested value: {{HOSTNAME}:{TRIGGER.KEY}.last(0)}
 

Sample Output