40-zabbix.html
15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>4. zabbix监测系统 — watchmen 1.0 documentation</title>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="5. 修订历史" href="99-history.html" />
<link rel="prev" title="3. elk日志系统" href="30-elk.html" />
<script src="_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="index.html" class="icon icon-home"> watchmen
</a>
<div class="version">
1.0
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="10-summary.html">1. 概述</a></li>
<li class="toctree-l1"><a class="reference internal" href="20-ansible.html">2. ansible集群管理工具</a></li>
<li class="toctree-l1"><a class="reference internal" href="30-elk.html">3. elk日志系统</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">4. zabbix监测系统</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#id1">4.1. 安装</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#docker">4.1.1. 使用docker安装/运行方式(建议使用此方式)</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id2">4.1.2. 本地安装/运行方式(坑多)</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#id5">4.2. 配置</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#zabbix-agent">4.2.1. zabbix_agent配置</a></li>
<li class="toctree-l3"><a class="reference internal" href="#zabbix-proxy">4.2.2. zabbix_proxy配置</a></li>
<li class="toctree-l3"><a class="reference internal" href="#zabbix-server">4.2.3. zabbix_server配置</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#id6">4.3. 使用</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#quick-start">4.3.1. quick start</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="99-history.html">5. 修订历史</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">watchmen</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> »</li>
<li>4. zabbix监测系统</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/40-zabbix.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="zabbix">
<h1>4. zabbix监测系统<a class="headerlink" href="#zabbix" title="Permalink to this headline">¶</a></h1>
<div class="section" id="id1">
<h2>4.1. 安装<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h2>
<div class="section" id="docker">
<h3>4.1.1. 使用docker安装/运行方式(建议使用此方式)<a class="headerlink" href="#docker" title="Permalink to this headline">¶</a></h3>
<p>离线安装包: <a class="reference external" href="smb://192.168.9.1">smb://192.168.9.1</a>/公共模块/繁星/繁星二代/自检系统/(zabbix_agent_proxy_tx1、zabbix_docker)</p>
<p>有docker离线包zabbix_docker,拷贝到有docker的主机上,加载镜像:</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>docker load < postgres9.6.docker.images
<span class="c1"># 屏幕会返回镜像的id,假设是:id-1</span>
<span class="c1"># 给镜像命名</span>
docker tag id-1 postgres:9.6
<span class="c1"># 下面两个镜像不需要命名,如果load后运行docker images 发现名字和版本都是none,则手动命名</span>
docker load < zabbix-server-pgsql.docker.images
<span class="c1"># docker tag id-2 zabbix/zabbix-server-pgsql:ubuntu-3.4.13</span>
docker load < zabbix-web-nginx-pgsql.docker.images
<span class="c1"># docker tag id-3 zabbix/zabbix-web-nginx-pgsql:ubuntu-3.4.13</span>
<span class="c1"># 加载完毕,docker images应该能显示</span>
root@user-ubuntu:~/zabbix_docker# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
zabbix/zabbix-web-nginx-pgsql ubuntu-3.4.13 bf422197fafe <span class="m">4</span> weeks ago <span class="m">254</span> MB
zabbix/zabbix-server-pgsql ubuntu-3.4.13 af4434f6332b <span class="m">4</span> weeks ago <span class="m">224</span> MB
postgres <span class="m">9</span>.6 4023a747a01a <span class="m">20</span> months ago <span class="m">265</span> MB
</pre></div>
</div>
</div>
<div class="section" id="id2">
<h3>4.1.2. 本地安装/运行方式(坑多)<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h3>
<p><a href="#id3"><span class="problematic" id="id4">**</span></a>此方法不同的机器上可能遇到不同的问题,下面的说明只能作为参考。 **</p>
<p>我用网上说的apt-get方式装,无法成功。web界面使用不正常,所以采用源码方式装。zabbix-3.4.13.tar.gz</p>
<p>环境依赖安装按照以下步骤:
<a class="reference external" href="https://blog.csdn.net/yannanxiu/article/details/54924198">https://blog.csdn.net/yannanxiu/article/details/54924198</a></p>
<p>zabbix-proxy zabbix-server zabbix-front-php 用源码安装,参考:
<a class="reference external" href="https://www.zabbix.com/documentation/3.4/zh/manual/installation/install">https://www.zabbix.com/documentation/3.4/zh/manual/installation/install</a></p>
<p>数据库安装,建立zabbix用户,建立zabbix数据库,运行zabbix-3.4.13/database/postgresql/中的3个脚本。命令行:</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>su postgres
createdb zabbix
createuser -SDRP zabbix
su root
cat ./zabbix-3.4.13/zabbix-3.4.13/database/postgresql/<span class="o">{</span>schema,images,data<span class="o">}</span>.sql.gz <span class="p">|</span> psql -h <span class="m">127</span>.0.0.1 zabbix postgres
</pre></div>
</div>
<p>或者带界面的postgres客户端做也行。自行选择</p>
<p>zabbix-fornt(web界面)</p>
<p># 从源码拷贝到apache2
sudo cp -r zabbix-3.4.13/frontends/php/ /var/www/html/zabbix</p>
<ul class="simple">
<li>zabbix_sender报错</li>
</ul>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>root@tegra-ubuntu:/home/ubuntu# zabbix_sender -s <span class="s2">"192.168.5.198"</span> -z <span class="s2">"192.168.5.133"</span> -k <span class="s2">"keytrtest"</span> -o <span class="s2">"1133"</span>
info from server: <span class="s2">"processed: 0; failed: 1; total: 1; seconds spent: 0.000026"</span>
这里failed: 1说明失败了。
</pre></div>
</div>
<p>注意看item的type必须是Zabbix trapper</p>
<p>server主动获取,在zabbix_agent.conf增加的item的type是Zabbix trapper</p>
</div>
</div>
<div class="section" id="id5">
<h2>4.2. 配置<a class="headerlink" href="#id5" title="Permalink to this headline">¶</a></h2>
<div class="section" id="zabbix-agent">
<h3>4.2.1. zabbix_agent配置<a class="headerlink" href="#zabbix-agent" title="Permalink to this headline">¶</a></h3>
<p><strong>需要在系统配置开机启动</strong></p>
<p>zabbix_agentd安装包是在tx1上编译的。zabbix_agent_proxy_tx1的install.sh会将配置文件拷贝到
/usr/local/etc/zabbix_agent.conf</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span><span class="c1"># 填写主节点ip</span>
<span class="nv">Server</span><span class="o">=</span><span class="m">192</span>.168.5.177
<span class="nv">ServerActive</span><span class="o">=</span><span class="m">192</span>.168.5.177
<span class="c1"># 主节点运行的是proxy,在默认情况下这样填写</span>
<span class="nv">Hostname</span><span class="o">=</span>Zabbix proxy
<span class="nv">AllowRoot</span><span class="o">=</span><span class="m">1</span>
</pre></div>
</div>
<p>修改完重启进程</p>
</div>
<div class="section" id="zabbix-proxy">
<h3>4.2.2. zabbix_proxy配置<a class="headerlink" href="#zabbix-proxy" title="Permalink to this headline">¶</a></h3>
<p><strong>需要在系统配置开机启动</strong></p>
<p>zabbix_proxy安装包是在tx1上编译的。zabbix_agent_proxy_tx1的install.sh会将配置文件拷贝到
/usr/local/etc/zabbix_proxy.conf</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span><span class="c1"># zabbix_server主机ip</span>
<span class="nv">Server</span><span class="o">=</span><span class="m">192</span>.168.9.133
<span class="c1"># 需和zabbix_agent配置的Hostname对应</span>
<span class="nv">Hostname</span><span class="o">=</span>Zabbix proxy
<span class="c1"># zabbix_proxy数据库目录,如果是使用install.sh脚本安装的,会放在/root/UserApp下。</span>
<span class="nv">DBName</span><span class="o">=</span>/root/UserApp/zabbix_proxy.db
<span class="c1"># 多长间隔从zabbix_server拉取配置(秒)</span>
<span class="nv">ConfigFrequency</span><span class="o">=</span><span class="m">120</span>
<span class="nv">AllowRoot</span><span class="o">=</span><span class="m">1</span>
</pre></div>
</div>
</div>
<div class="section" id="zabbix-server">
<h3>4.2.3. zabbix_server配置<a class="headerlink" href="#zabbix-server" title="Permalink to this headline">¶</a></h3>
<p><strong>需要在系统配置开机启动</strong></p>
<p>zabbix_server在docker运行,在每次启动容器的时候会将必要参数传入,zabbix_docker/dockerrun_zabbix.sh已写好,运行即可</p>
</div>
</div>
<div class="section" id="id6">
<h2>4.3. 使用<a class="headerlink" href="#id6" title="Permalink to this headline">¶</a></h2>
<p>访问路径: <a class="reference external" href="http://ip:9210">http://ip:9210</a></p>
<p>第一次运行会有一些额外步骤,按照提示下一步即可</p>
<div class="section" id="quick-start">
<h3>4.3.1. quick start<a class="headerlink" href="#quick-start" title="Permalink to this headline">¶</a></h3>
<p>添加proxy,注意Proxy name必须和 zabbix_proxy配置中的Hostname相同。其他配置默认即可。点add添加成功</p>
<img alt="_images/zabbix-01.png" src="_images/zabbix-01.png" />
<p>添加host,Configuration->Hosts->Create host</p>
<img alt="_images/zabbix-02.png" src="_images/zabbix-02.png" />
<p>红框都是需要填写修改的。Groups可以自己建,给设备分组。Monitored by proxy必须选择正确的proxy代理</p>
<img alt="_images/zabbix-03.png" src="_images/zabbix-03.png" />
<p>点Template配置模板,模板决定了有哪些监测项。select选择一个模板,模板后续我们会自己创建,这里先选择Template OS Linux,包含了很多linux的监测项
点小add后再点大add</p>
<img alt="_images/zabbix-04.png" src="_images/zabbix-04.png" />
<p>添加成功</p>
<p>Dashboard可以浏览状态、报警等,Edit dashboard可以自定义。比如Problems中提示我的主机掉线了。</p>
<img alt="_images/zabbix-05.png" src="_images/zabbix-05.png" />
<p>如果想有目的的查询监测项状态,可以打开Monitoring->Lastest data。可以在过滤条件选择感兴趣的主机和检测项组
可以看到最后的值,可以点Graph看数值历史折线图。</p>
<img alt="_images/zabbix-06.png" src="_images/zabbix-06.png" />
<img alt="_images/zabbix-07.png" src="_images/zabbix-07.png" />
<p>这是最基本的使用,后续添加如何自定义监测项,利用api批量添加主机、动态管理监测项等功能。</p>
</div>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="99-history.html" class="btn btn-neutral float-right" title="5. 修订历史" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="30-elk.html" class="btn btn-neutral" title="3. elk日志系统" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2018, liuhang.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'1.0',
LANGUAGE:'None',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>