Você está na página 1de 14

Sobre

Zabbix uma ferramenta de monitoramento de ativos computacionais, bastante robusta e expansvel. Neste
artigo ser demonstrado como configur-lo para enviar alertas atravs do telegram, que um aplicativo de
mensagens instantneas disponvel para Android, iOS, Windows Phone, OS X, Gnu/Linux emais.
Ser utilizado o telegram-cli, um software no oficial, escrito em C, que destina-se criar uma interface de linha
de comando para o telegram.

Ambiente
Este procedimento foi testado com servidor zabbix 2.2.x rodando no debian 7 (Wheezy) ou 8 (Jessie). Se voc
no estiver utilizando debian, visite a pgina do telegram-cli para obter instrues de quais bibliotecas instalar.
O commit utilizado foi o 3ced7bb, verso 1.3.1 do telegram-cli.

Dependncias
Afim de sanar as dependncias da compilao, abra um terminal e, como root, execute o comando:
1

# apt-get install libreadline-dev libconfig-dev libssl-dev lua5.2 liblua5.2-dev libevent-dev libjansson-dev make

Instale o pacote git, caso no o tenha.

Baixar e compilar
1

# cd /usr/src

# git clone recursive https://github.com/vysheng/tg.git

# cd tg

# ./configure

# make

A sada ser parecida com esta:


1

root@debian8:/usr/src# git clone recursive https://github.com/vysheng/tg.git

Cloning into 'tg'...

remote: Counting objects: 3513, done.

remote: Total 3513 (delta 0), reused 0 (delta 0), packreused 3513

Receiving objects: 100% (3513/3513), 2.45 MiB | 726.00 KiB/s, done.

Resolving deltas: 100% (2379/2379), done.

Checking connectivity... done.

Submodule 'tgl' (https://github.com/vysheng/tgl.git) registered for path 'tgl'

Cloning into 'tgl'...

10

remote: Counting objects: 702, done.

11

remote: Total 702 (delta 0), reused 0 (delta 0), packreused 702

12

Receiving objects: 100% (702/702), 685.69 KiB | 697.00 KiB/s, done.

13

Resolving deltas: 100% (490/490), done.

14

Checking connectivity... done.

15

Submodule path 'tgl': checked out 'b3dcce35110f5c995366318c2886065287815d09'

16

Submodule 'tl-parser' (https://github.com/vysheng/tl-parser) registered for path 'tl-parser'

17

Cloning into 'tl-parser'...

18

remote: Counting objects: 32, done.

19

remote: Total 32 (delta 0), reused 0 (delta 0), packreused 32

20

Unpacking objects: 100% (32/32), done.

21

Checking connectivity... done.

22

Submodule path 'tgl/tl-parser': checked out 'ec8a8ed7a4f22428b83e21a9d3b5815f7a6f3bd9'

23

root@debian8:/usr/src# cd tg

24

root@debian8:/usr/src/tg# ./configure

25

checking for gcc... gcc

26

checking whether the C compiler works... yes

27

checking for C compiler default output file name... a.out

28

checking for suffix of executables...

29

checking whether we are cross compiling... no

30

checking for suffix of object files... o

31

checking whether we are using the GNU C compiler... yes

32

checking whether gcc accepts g... yes

33

checking for gcc option to accept ISO C89... none needed

34

checking for sqrt in lm... yes

35

checking for library containing clock_gettime... none required

36

checking for library containing backtrace... none required

37

checking for event_base_new in levent... yes

38

checking how to run the C preprocessor... gcc E

39

checking for grep that handles long lines and e... /bin/grep

40

checking for egrep... /bin/grep E

41

checking for ANSI C header files... yes

42

checking for sys/types.h... yes

43

checking for sys/stat.h... yes

44

checking for stdlib.h... yes

45

checking for string.h... yes

46

checking for memory.h... yes

47

checking for strings.h... yes

48

checking for inttypes.h... yes

49

checking for stdint.h... yes

50

checking for unistd.h... yes

51

checking event2/event.h usability... yes

52

checking event2/event.h presence... yes

53

checking for event2/event.h... yes

54

checking for pkgconfig... /usr/bin/pkgconfig

55

checking whether compiling and linking against OpenSSL works... yes

56

checking if zlib is wanted... yes

57

checking for inflateEnd in lz... yes

58

checking zlib.h usability... yes

59

checking zlib.h presence... yes

60

checking for zlib.h... yes

61

checking for rl_save_prompt in lreadline... yes

62

checking for libconfig... enabled

63

checking for config_init in lconfig... yes

64

checking for liblua... enabled

65

checking for lua... /usr/bin/lua

66

checking if /usr/bin/lua is a Lua interpreter... yes

67

checking for lua version... 5.2

68

checking for lua platform... unknown

69

checking for lua script directory... ${prefix}/share/lua/5.2

70

checking for lua module directory... ${exec_prefix}/lib/lua/5.2

71

checking if LUA_VERSION is defined... yes

72

checking lua.h usability... no

73

checking lua.h presence... no

74

checking for lua.h... no

75

checking lualib.h usability... no

76

checking lualib.h presence... no

77

checking for lualib.h... no

78

checking lauxlib.h usability... no

79

checking lauxlib.h presence... no

80

checking for lauxlib.h... no

81

checking luaconf.h usability... no

82

checking luaconf.h presence... no

83

checking for luaconf.h... no

84

checking for Lua headers in... /usr/include/lua5.2

85

checking lua.h usability... yes

86

checking lua.h presence... yes

87

checking for lua.h... yes

88

checking lualib.h usability... yes

89

checking lualib.h presence... yes

90

checking for lualib.h... yes

91

checking lauxlib.h usability... yes

92

checking lauxlib.h presence... yes

93

checking for lauxlib.h... yes

94

checking luaconf.h usability... yes

95

checking luaconf.h presence... yes

96

checking for luaconf.h... yes

97

checking for Lua header version... 5.2

98

checking if Lua header version matches 5.2 yes

99

checking if LUA_VERSION is defined... yes

100

checking for library containing exp... none required

101

checking for library containing dlopen... ldl

102

checking for library containing lua_load... llua5.2

103

checking for libjansson... enabled

104

checking for json_array_set_new in ljansson... yes

105

checking progname... default

106

checking execinfo.h usability... yes

107

checking execinfo.h presence... yes

108

checking for execinfo.h... yes

109

checking fcntl.h usability... yes

110

checking fcntl.h presence... yes

111

checking for fcntl.h... yes

112

checking malloc.h usability... yes

113

checking malloc.h presence... yes

114

checking for malloc.h... yes

115

checking netdb.h usability... yes

116

checking netdb.h presence... yes

117

checking for netdb.h... yes

118

checking for stdlib.h... (cached) yes

119

checking for string.h... (cached) yes

120

checking for unistd.h... (cached) yes

121

checking arpa/inet.h usability... yes

122

checking arpa/inet.h presence... yes

123

checking for arpa/inet.h... yes

124

checking mach/mach.h usability... no

125

checking mach/mach.h presence... no

126

checking for mach/mach.h... no

127

checking netinet/in.h usability... yes

128

checking netinet/in.h presence... yes

129

checking for netinet/in.h... yes

130

checking sys/file.h usability... yes

131

checking sys/file.h presence... yes

132

checking for sys/file.h... yes

133

checking sys/socket.h usability... yes

134

checking sys/socket.h presence... yes

135

checking for sys/socket.h... yes

136

checking termios.h usability... yes

137

checking termios.h presence... yes

138

checking for termios.h... yes

139

checking for size_t... yes

140

checking for uid_t in sys/types.h... yes

141

checking for inline... inline

142

checking for stdlib.h... (cached) yes

143

checking for GNU libc compatible malloc... yes

144

checking for stdlib.h... (cached) yes

145

checking for GNU libc compatible realloc... yes

146

checking for alarm... yes

147

checking for endpwent... yes

148

checking for memset... yes

149

checking for memmove... yes

150

checking for mkdir... yes

151

checking for select... yes

152

checking for socket... yes

153

checking for strdup... yes

154

checking for strndup... yes

155

checking for uname... yes

156

checking for __builtin_bswap32... yes

157

configure: creating ./config.status

158

config.status: creating Makefile

159

config.status: creating config.h

160

root@debian8:/usr/src/tg# make

161

cat tgl/scheme.tl tgl/encrypted_scheme.tl tgl/binlog.tl tgl/append.tl tgl/mtproto.tl > auto/scheme.tl

162

gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2

163

DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe

164

pointer ggdb Wnounusedparameter fPIC iquote./tgl/tlparser c MP MD MF dep/tlparser.d MQ objs/tl

165

parser.o o objs/tlparser.otgl/tlparser/tlparser.c

166

gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2

167

DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe

168

pointer ggdb Wnounusedparameter fPIC iquote./tgl/tlparser c MP MD MF dep/tlc.d MQ objs/tlc.o

169

o objs/tlc.o tgl/tlparser/tlc.c

170

gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2

171

DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe

172

pointer ggdb Wnounusedparameter fPIC iquote./tgl/tlparser c MP MD MF dep/crc32.d

173

MQ objs/crc32.o o objs/crc32.o tgl/tlparser/crc32.c

174

gcc objs/tlparser.o objs/tlc.o objs/crc32.o L/usr/local/lib L/usr/lib L/usr/lib rdynamic ggdblevent ljansson

175

lconfig lz levent lm lreadline llua5.2 ldl lssl lcrypto o bin/tlparser

176

bin/tlparser e auto/scheme.tlo auto/scheme.tl

177

gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2

178

DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe

179

pointer ggdb Wnounusedparameter fPIC iquote ./tgl cMP MD MF dep/generate.d MQ objs/generate.o

180

o objs/generate.o tgl/generate.c

181

gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2

182

DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe

183

pointer ggdb Wnounusedparameter fPIC iquote ./tgl cMP MD MF dep/tools.d MQ objs/tools.o

184

o objs/tools.o tgl/tools.c

185

gcc objs/generate.o objs/tools.o L/usr/local/lib L/usr/lib L/usr/lib rdynamic ggdb leventljansson lconfig lz

186

levent lm lreadline llua5.2 ldl lssl lcrypto o bin/generate

187

bin/generate g skipheader auto/scheme.tlo > auto/autoskip.h || rm auto/autoskip.h

188

bin/generate g fetchheader auto/scheme.tlo > auto/autofetch.h || rm auto/autofetch.h

189

bin/generate g storeheader auto/scheme.tlo > auto/autostore.h || rm auto/autostore.h

190

bin/generate g autocompleteheader auto/scheme.tlo > auto/autoautocomplete.h || rmauto/autoautocomplete.h

191

bin/generate g typesheader auto/scheme.tlo > auto/autotypes.h || rm auto/autotypes.h

192

gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2

193

DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe

194

pointer ggdb Wnounusedparameter fPIC c MP MD MFdep/main.d MQ objs/main.o o objs/main.o main.c

195

gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2

196

DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe

197

pointer ggdb Wnounusedparameter fPIC c MP MD MFdep/loop.d MQ objs/loop.o o objs/loop.o loop.c

198

gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2

199

DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe

200

pointer ggdb Wnounusedparameter fPIC c MP MD MFdep/interface.d MQ objs/interface.o

201

o objs/interface.o interface.c

202

gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2

203

DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe

204

pointer ggdb Wnounusedparameter fPIC c MP MD MFdep/luatg.d MQ objs/luatg.o o objs/luatg.o lua

205

tg.c

206

gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2

207

DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe

208

pointer ggdb Wnounusedparameter fPIC c MP MD MFdep/jsontg.d MQ objs/jsontg.o o objs/json

209

tg.o jsontg.c

210

bin/tlparser E auto/scheme.tl 2> auto/scheme2.tl || ( cat auto/scheme2.tl && rm auto/scheme2.tl&& false )

211

awk f ./tgl/gen_constants_h.awk < auto/scheme2.tl > auto/constants.h

212

bin/generate g fetchdsheader auto/scheme.tlo > auto/autofetchds.h || rm auto/autofetchds.h

213

bin/generate g freedsheader auto/scheme.tlo > auto/autofreeds.h || rm auto/autofreeds.h

214

bin/generate g storedsheader auto/scheme.tlo > auto/autostoreds.h || rm auto/autostoreds.h

215

bin/generate g printdsheader auto/scheme.tlo > auto/autoprintds.h || rm auto/autoprintds.h

216

gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2

217

DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe

218

pointer ggdb Wnounusedparameter fPIC iquote ./tgl cMP MD MF dep/mtprotocommon.d

219

MQ objs/mtprotocommon.o o objs/mtprotocommon.otgl/mtprotocommon.c

220

gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2

221

DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe

222

223

pointer ggdb Wnounusedparameter fPIC iquote ./tgl cMP MD MF dep/mtprotoclient.d MQ objs/mtproto

224

client.o o objs/mtprotoclient.otgl/mtprotoclient.c

225

gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2

226

DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe

227

pointer ggdb Wnounusedparameter fPIC iquote ./tgl cMP MD MF dep/queries.d MQ objs/queries.o

228

o objs/queries.o tgl/queries.c

229

gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2

230

DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe

231

pointer ggdb Wnounusedparameter fPIC iquote ./tgl cMP MD MF dep/structures.d MQ objs/structures.o

232

o objs/structures.o tgl/structures.c

233

gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2

234

DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe

235

pointer ggdb Wnounusedparameter fPIC iquote ./tgl cMP MD MF dep/binlog.d MQ objs/binlog.o

236

o objs/binlog.o tgl/binlog.c

237

gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2

238

DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe

239

pointer ggdb Wnounusedparameter fPIC iquote ./tgl cMP MD MF dep/tgl.d MQ objs/tgl.o


o objs/tgl.o tgl/tgl.c
gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2
DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe
pointer ggdb Wnounusedparameter fPIC iquote ./tgl cMP MD MF dep/updates.d MQ objs/updates.o
o objs/updates.o tgl/updates.c
gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2
DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe
pointer ggdb Wnounusedparameter fPIC iquote ./tgl cMP MD MF dep/tglnet.d MQ objs/tglnet.o
o objs/tglnet.o tgl/tglnet.c
gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2
DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe
pointer ggdb Wnounusedparameter fPIC iquote ./tgl cMP MD MF dep/tgltimers.d MQ objs/tgltimers.o
o objs/tgltimers.o tgl/tgltimers.c
gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2
DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe
pointer ggdb Wnounusedparameter fPIC iquote ./tgl cMP MD MF dep/tgmimetypes.d MQ objs/tg
mimetypes.o o objs/tgmimetypes.otgl/tgmimetypes.c
gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2
DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe

pointer ggdb Wnounusedparameter fPIC iquote ./tgl cMP MD MF dep/mtprotoutils.d MQ objs/mtproto


utils.o o objs/mtprotoutils.otgl/mtprotoutils.c
bin/generate g skip auto/scheme.tlo > auto/autoskip.c || rm auto/autoskip.c
gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2
DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe
pointer ggdb Wnounusedparameter fPIC iquote ./tgl cMP MD MF dep/autoskip.d MQ objs/autoskip.o
o objs/auto/autoskip.o auto/autoskip.c
bin/generate g fetch auto/scheme.tlo > auto/autofetch.c || rm auto/autofetch.c
gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2
DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe
pointer ggdb Wnounusedparameter fPIC iquote ./tgl cMP MD MF dep/autofetch.d MQ objs/auto
fetch.o o objs/auto/autofetch.o auto/autofetch.c
bin/generate g store auto/scheme.tlo > auto/autostore.c || rm auto/autostore.c
gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2
DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe
pointer ggdb Wnounusedparameter fPIC iquote ./tgl cMP MD MF dep/autostore.d MQ objs/auto
store.o o objs/auto/autostore.o auto/autostore.c
bin/generate g autocomplete auto/scheme.tlo > auto/autoautocomplete.c || rmauto/autoautocomplete.c
gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2
DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe
pointer ggdb Wnounusedparameter fPIC iquote ./tgl cMP MD MF dep/autoautocomplete.d
MQ objs/autoautocomplete.o oobjs/auto/autoautocomplete.o auto/autoautocomplete.c
bin/generate g types auto/scheme.tlo > auto/autotypes.c || rm auto/autotypes.c
gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2
DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe
pointer ggdb Wnounusedparameter fPIC iquote ./tgl cMP MD MF dep/autotypes.d MQ objs/auto
types.o o objs/auto/autotypes.o auto/autotypes.c
bin/generate g fetchds auto/scheme.tlo > auto/autofetchds.c || rm auto/autofetchds.c
gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2
DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe
pointer ggdb Wnounusedparameter fPIC iquote ./tgl cMP MD MF dep/autofetchds.d MQ objs/auto
fetchds.o o objs/auto/autofetchds.oauto/autofetchds.c
bin/generate g freeds auto/scheme.tlo > auto/autofreeds.c || rm auto/autofreeds.c
gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2
DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe

pointer ggdb Wnounusedparameter fPIC iquote ./tgl cMP MD MF dep/autofreeds.d MQ objs/autofree


ds.o o objs/auto/autofreeds.oauto/autofreeds.c
bin/generate g storeds auto/scheme.tlo > auto/autostoreds.c || rm auto/autostoreds.c
gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2
DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe
pointer ggdb Wnounusedparameter fPIC iquote ./tgl cMP MD MF dep/autostoreds.d MQ objs/auto
storeds.o o objs/auto/autostoreds.oauto/autostoreds.c
bin/generate g printds auto/scheme.tlo > auto/autoprintds.c || rm auto/autoprintds.c
gcc I. I. I./tgl g O2 I/usr/local/include I/usr/include I/usr/includeI/usr/include/lua5.2
DHAVE_CONFIG_H Wall Wextra Werror Wnodeprecateddeclarationsfnostrictaliasing fnoomitframe
pointer ggdb Wnounusedparameter fPIC iquote ./tgl cMP MD MF dep/autoprintds.d MQ objs/auto
printds.o o objs/auto/autoprintds.oauto/autoprintds.c
rm f libs/libtgl.a && ar ruv libs/libtgl.a objs/mtprotocommon.o objs/mtproto
client.o objs/queries.oobjs/structures.o objs/binlog.o objs/tgl.o objs/updates.o objs/tglnet.o objs/tgltimers.oobjs/tg
mimetypes.o objs/mtprotoutils.o objs/tools.o objs/auto/autoskip.o objs/auto/autofetch.oobjs/auto/auto
store.o objs/auto/autoautocomplete.o objs/auto/autotypes.oobjs/auto/autofetchds.o objs/auto/autofree
ds.o objs/auto/autostoreds.oobjs/auto/autoprintds.o
ar: creating libs/libtgl.a
a objs/mtprotocommon.o
a objs/mtprotoclient.o
a objs/queries.o
a objs/structures.o
a objs/binlog.o
a objs/tgl.o
a objs/updates.o
a objs/tglnet.o
a objs/tgltimers.o
a objs/tgmimetypes.o
a objs/mtprotoutils.o
a objs/tools.o
a objs/auto/autoskip.o
a objs/auto/autofetch.o
a objs/auto/autostore.o
a objs/auto/autoautocomplete.o
a objs/auto/autotypes.o
a objs/auto/autofetchds.o

a objs/auto/autofreeds.o
a objs/auto/autostoreds.o
a objs/auto/autoprintds.o
gcc objs/main.o objs/loop.o objs/interface.o objs/luatg.o objs/jsontg.o libs/libtgl.a L/usr/local/libL/usr/lib
L/usr/lib rdynamic ggdb levent ljansson lconfig lz levent lm lreadline llua5.2 ldllssl lcrypto
o bin/telegramcli
root@debian8:/usr/src/tg#

Configurando
Copiando e criando os arquivos necessrios.
1

# mkdir zabbix

# cp bin/telegram-cli zabbix/

# cp tg-server.pub zabbix/

# cd zabbix

Crie o arquivo telegram.config com o seguinte contedo:


1
2

default_profile = "zabbix";

zabbix = {

config_directory = "/usr/src/tg/zabbix/";

#test = false;

#msg_num = true;

#binlog_enabled = true;

#log_level = 2;

};

Execute o telegram-cli. Voc ser redirecionado para o console da ferramenta, indicado por um > no incio de
cada linha.
1

# ./telegram-cli rsa-key tg-server.pub config telegram.config

change_user_group: can't find the user telegramd to switch to

Telegram-cli version 1.3.1, Copyright (C) 2013-2015 Vitaly Valtman

Telegram-cli comes with ABSOLUTELY NO WARRANTY; for details type `show_license'.

This is free software, and you are welcome to redistribute it

under certain conditions; type `show_license' for details.

Telegramcli uses libtgl version 2.0.1

[/usr/src/tg/zabbix//downloads] create

>

Pode-se digitar help para ver todos os comandos disponveis.


Neste momento necessrio aguardar at que o texto phone number aparea. Quando isso ocorrer, digite o
nmero de telefone que est cadastrado no telegram, no formato +55 (prefixo para o Brasil) seguido do DDD e
nmero. Exemplo:
1

phone number: +551122223333

code ('call' for phone call): 35620

User Tobias Sette updated username

User Tobias Sette updated photo

User Tobias Sette online (was online [2015/05/20 06:55:30])

Um detalhe interessante: o cdigo tambm pode ser recebido pelo aplicativo instalado no celular e na verso
para desktop, bastando ter um deles instalado e aberto.
Execute os comandos contact_list e dialog_list para que o telegram-cli carregue sua lista de contatos e as
conversas atuais.
Caso voc queira que o zabbix envie a mensagem para um determinado usurio, executeuser_infoseguido do
nome do contato conforme est na sua agenda. Se, por outro lado, voc quiser enviar para um grupo,
execute chat_info seguido do nome do grupo. Observe que a tecla TAB pode ser utilizada para autocompletar
as palavras.
Exemplos:
1

> user_info Tobias_Sette

User Tobias Sette updated photo

User Tobias Sette updated name

User Tobias Sette @usuarioTal (#1234567):

real name: Tobias Sette

phone: 551122223333

online (was online [2015/05/03 07:16:54])

> chat_info Empresa_123

Chat Empresa 123 updated admin

Chat Empresa 123 updated members

Chat Empresa 123 (id 1234567) members:

Usuario Tal invited by Tobias Sette at [2015/05/14 02:48:45]

Tobias Sette invited by Tobias Sette at [2015/05/14 02:48:45] admin

User Tobias Sette offline (was online [2015/05/14 02:53:59])

Nota: nos nomes de contatos e grupos, espaos so transformados em underscore (_), cerquilhas (#) em
arrobas (@) e contatos com mesmo nome tem um #1 acrescentado ao nome (exemplo: Gnu#1, Gnu#2).
Perceba que na quarta linha de cada exemplo exibido o cdigo do usurio ou grupo, 1234567 nestes casos.
Guarde este nmero, ele ser utilizado mais a frente, na interface do Zabbix.
Agora o telegram-cli est configurado para utilizar a sua conta. Podemos sair do console dele
digitandosafe_quit.

Integrando ao zabbix

Para enviar uma mensagem, necessrio iniciar o binrio telegram-cli, esperar que ele conecte rede e envie
a mensagem. Nos meus testes isso levou cerca de 7-10 segundos. Utilizo h cerca de trs meses e funciona
bem nos ambientes que tenho, inclusive o envio simultneo de mensagens.
Para fazer este processo, criaremos um script em /usr/src/tg/zabbix/telegram_standalone.sh com o seguinte
contedo:
1
2
3
4
5

#!/bin/bash

# See

# https://github.com/gnumoksha/zabbix_utils/blob/master/gnu%2Blinux/alertscripts/

MAIN_DIRECTORY="/usr/src/tg/zabbix/"

# Is better use: user#user_id. For example: user#141213

10

USER=$1

11

SUBJECT=$2

12

TEXT=$3

13

cd $MAIN_DIRECTORY

14

if [[ $? ne 0 ]]; then

15

echo "Error to enter in the main directory"

16

exit 1

17

fi

18

./telegramcli k tgserver.pub c telegram.config WR U zabbix e "msg $USER $SUBJECT" || exit 1

19

exit 0

Usando o comando chmod +x telegram_standalone.sh, aplique permisses de execuo ao script.


Altere o dono do diretrio do telegram-cli e atribua um shell ao usurio zabbix:
1

# chown -R zabbix: /usr/src/tg/

# usermod shell /bin/bash zabbix

Inclua uma linha com o texto AlertScriptsPath=/usr/src/tg/zabbix/ no arquivo de configurao do servidor zabbix
(e.g. /etc/zabbix/zabbix_server.conf). Aps isso, reinicie o servidor.
Na interface web do Zabbix, v em Administrao -> Tipos de mdia. Na lateral direita, clique no botoCriar tipo
de mdia e preencha conforme a imagem.

Agora v em Administrao -> Usurios, selecione o usurio que receber as notificaes via telegram, clique
na aba Mdia e, por fim, clique em adicionar. Preencha de forma parecida com a da imagem.

Repare que no campo Enviar para utilizado o cdigo que obtemos anteriormente, precedido do
textouser# para usurios ou chat# para grupos.
Est feito. Para testar voc pode criar uma trigger do tipo {Zabbix server:agent.ping.last(0)}=1 e marcar a
opo Gerao de mltiplos eventos de INCIDENTE.
Muito obrigado ao Vitaly Valtman pelo belo software e por ceder parte do seu tempo ao esclarecimento de
dvidas.

Referncia
https://github.com/vysheng/tg/blob/master/README.md

Histrico
03/05/2015 verso inicial
11/05/2015 adicionada a dica do @grfgabriel de como enviar os alertas para um grupo
14/05/2015 adicionado mais detalhes sobre o envio para grupos
20/05/2015 atualizado da verso 1.2.0 (commit) para a verso 1.3.1 (commit) do telegram-cli
FONTE: http://tobias.ws/blog/zabbix-com-notificacoes-pelo-telegram/#more-356