Skip to content

Commit

Permalink
Create Telezabix.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
lexfrei committed Jul 6, 2015
1 parent de2c853 commit 6e433ca
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Telezabix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

# This script implements telegram notification to zabbix
# By Aleksey Sviridkin [email protected]
# https://github.com/lexfrei/Telezabix

# Put this file to AlertScript path (you can find this path in zabbix_server.cfg)

JerardToken="123496961:AAHn8QSg0_ZMMiBIv5ie-49jJSck7RHTWEc" #You can change this token to your own or just use my bot
JerardURL="https://api.telegram.org/bot${JerardToken}"
JerardClient=${1} #You need to set this in "to" field in media settings in your user profile
JerardSubj=${2}
JerardText=${3}

rawurlencode() {
local string="${1}"
local strlen=${#string}
local encoded
unset encoded

for (( pos=0 ; pos<strlen ; pos++ ));
do
c=${string:$pos:1}
case "$c" in
[-_.~a-zA-Z0-9а-яА-Я] )
o="${c}"
;;
* )
printf -v o '%%%02x' "'$c"
;;
esac
encoded+="${o}"
done
echo "${encoded}"
}

curl "${JerardURL}/sendMessage?chat_id=${JerardClient}&text=$(rawurlencode "${JerardSubj}"):%20$(rawurlencode "${JerardText}")%0a%23zabbix%20%23work" 2>/dev/null 1>/dev/null

0 comments on commit 6e433ca

Please sign in to comment.