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
<code>我的部落格已遷移到xdoujiang.com請去那邊和我交流</code>
<code>一、基礎環境說明</code>
<code>1、zabbix官網</code>
<code>www.zabbix.com</code>
<code>2、zabbix介紹</code>
<code>Zabbix is the ultimate enterprise-level software designed </code><code>for</code> <code>monitoring availability</code>
<code>and performance of IT infrastructure components. Zabbix is </code><code>open</code> <code>source</code> <code>and comes at no cost.</code>
<code>3、版本和ip</code>
<code>1)serverA</code>
<code>cat</code> <code>/etc/debian_version</code>
<code>7.8</code>
<code>ifconfig</code><code>|</code><code>awk</code> <code>-</code><code>v</code> <code>RS=</code><code>"Bcast:"</code> <code>'{print $NF}'</code><code>|</code><code>awk</code> <code>-F: </code><code>'/addr/{print $2}'</code>
<code>192.168.1.124</code>
<code>2)serverB</code>
<code>6.0.10</code>
<code>192.168.1.122</code>
<code>4、共安裝三部分内容</code>
<code>1)安裝zabbix-server(1-9)</code>
<code>2)安裝zabbix-web前端(1-3)</code>
<code>3)安裝zabbix-agent(1-10)</code>
<code>5、參考</code>
<code>https:</code><code>//www</code><code>.zabbix.com</code><code>/documentation/2</code><code>.2</code><code>/manual/</code>
<code>zabbix監控系統深度實踐(書)</code>
<code>http:</code><code>//www</code><code>.zabbix.net.cn/(社群)</code>
<code>二、安裝zabbix-server(1-9步驟)serverA</code>
<code>1、下載下傳并解壓zabbix</code>
<code>1)下載下傳</code>
<code>axel -n 10 http:</code><code>//downloads</code><code>.sourceforge.net</code><code>/project/zabbix/ZABBIX</code><code>%20Latest%20Stable</code><code>/2</code><code>.2.9</code><code>/zabbix-2</code><code>.2.9.</code><code>tar</code><code>.gz</code>
<code>2)解壓</code>
<code>tar</code> <code>zxvf zabbix-2.2.9.</code><code>tar</code><code>.gz</code>
<code>2、編譯三部曲(安裝在</code><code>/opt/zabbix</code><code>)</code>
<code>cd</code> <code>zabbix-2.2.9 </code>
<code>1).</code><code>/configure</code> <code>--</code><code>enable</code><code>-server --</code><code>enable</code><code>-agent --with-mysql --with-libxml2 --with-net-snmp --with-openipmi --with-libcurl --with-unixodbc --prefix=</code><code>/opt/zabbix</code>
<code>2)</code><code>make</code>
<code>3)</code><code>make</code> <code>install</code>
<code>編譯參數說明</code>
<code>--</code><code>enable</code><code>-server Turn on build of Zabbix server(支援server)</code>
<code>--</code><code>enable</code><code>-agent Turn on build of Zabbix agent and client utilities(支援agent)</code>
<code>--with-mysql[=ARG] use MySQL client library [default=no],optionally specify path to mysql_config(支援mysql功能)</code>
<code>--with-libxml2[=ARG] use libxml2 client library [default=no],optionally specify path to xml2-config</code>
<code>--with-net-snmp[=ARG] use Net-SNMP package [default=no],optionally specify path to net-snmp-config(支援snmp監控)</code>
<code>--with-openipmi[=DIR] Include OPENIPMI support [default=no].DIR is the OPENIPMI base </code><code>install</code> <code>directory,</code>
<code>default is to search through a number of common places </code><code>for</code> <code>the OPENIPMI files.(支援ipmi)</code>
<code>--with-libcurl[=DIR] use cURL package [default=no], optionally specify path to curl-config</code>
<code>--with-unixodbc[=ARG] use ODBC driver against unixODBC package [default=no],optionally specify</code>
<code>full path to odbc_config binary.</code>
<code>從2.2.0版本開始支援virtual machine監控 編譯的時候加上--with-libxml2 and --with-libcurl</code>
<code>Support of monitoring VMware environments is available </code><code>in</code> <code>Zabbix starting with version 2.2.0.</code>
<code>For virtual machine monitoring to work, Zabbix should be compiled with the --with-libxml2 and --with-libcurl compilation options. </code>
<code>編譯時提示需要安裝的包</code>
<code>1)configure: error: no acceptable C compiler found </code><code>in</code> <code>$PATH</code>
<code>需要安裝apt-get -y </code><code>install</code> <code>gcc</code>
<code>2)configure: error: MySQL library not found</code>
<code>需要安裝apt-get -y </code><code>install</code> <code>libghc6-hsql-mysql-dev</code>
<code>3)configure: error: LIBXML2 library not found</code>
<code>需要安裝apt-get -y </code><code>install</code> <code>libxml2-dev</code>
<code>4)configure: error: unixODBC library not found</code>
<code>需要安裝apt-get -y </code><code>install</code> <code>unixodbc-dev</code>
<code>5)configure: error: Invalid Net-SNMP directory - unable to </code><code>find</code> <code>net-snmp-config</code>
<code>需要安裝apt-get -y </code><code>install</code> <code>libsnmp-dev</code>
<code>6)configure: error: Invalid OPENIPMI directory - unable to </code><code>find</code> <code>ipmiif.h</code>
<code>需要安裝apt-get -y </code><code>install</code> <code>libopenipmi-dev</code>
<code>7)configure: error: Curl library not found</code>
<code>需要安裝apt-get -y </code><code>install</code> <code>libghc6-curl-dev</code>
<code>8)</code><code>make</code><code>指令</code>
<code>需要安裝apt-get -y </code><code>install</code> <code>make</code>
<code>9)編譯完成後将相關指令進行軟連結操作</code>
<code>設定指令的快捷方式(軟連結)</code>
<code>ln</code> <code>-s </code><code>/opt/zabbix/bin/</code><code>* </code><code>/usr/local/bin/</code>
<code>ln</code> <code>-s </code><code>/opt/zabbix/sbin/</code><code>* </code><code>/usr/local/sbin/</code>
<code>ll </code><code>/usr/local/bin</code>
<code>lrwxrwxrwx 1 root staff 26 May 29 08:47 zabbix_get -> </code><code>/opt/zabbix/bin/zabbix_get</code>
<code>lrwxrwxrwx 1 root staff 29 May 29 08:47 zabbix_sender -> </code><code>/opt/zabbix/bin/zabbix_sender</code>
<code>ll </code><code>/usr/local/sbin</code>
<code>lrwxrwxrwx 1 root staff 29 May 29 08:47 zabbix_agent -> </code><code>/opt/zabbix/sbin/zabbix_agent</code>
<code>lrwxrwxrwx 1 root staff 30 May 29 08:47 zabbix_agentd -> </code><code>/opt/zabbix/sbin/zabbix_agentd</code>
<code>lrwxrwxrwx 1 root staff 30 May 29 08:47 zabbix_server -> </code><code>/opt/zabbix/sbin/zabbix_server</code>
<code>3、相關資料庫配置</code>
<code>1)安裝mysql-server</code>
<code>apt-get -y </code><code>install</code> <code>mysql-server-5.5</code>
<code>2)建zabbix庫(root密碼是redhat)</code>
<code>mysql -uroot -p</code><code>"redhat"</code> <code>-S </code><code>/var/run/mysqld/mysqld</code><code>.sock -e </code><code>"create database zabbix character set utf8 collate utf8_bin;"</code>
<code>3)授權(我這邊mysql是監聽在192.168.1.124)</code>
<code>grant all privileges on zabbix.* to zabbix@</code><code>"192.168.1.124"</code> <code>identified by </code><code>'123456'</code><code>;</code>
<code>flush privileges;</code>
<code>4)使用zabbix使用者導入sql語句 按照這個順序來</code>
<code>1)mysql -uzabbix -p</code><code>"123456"</code> <code>-h</code><code>"192.168.1.124"</code> <code>zabbix < </code><code>/root/zabbix-2</code><code>.2.9</code><code>/database/mysql/schema</code><code>.sql</code>
<code>2)mysql -uzabbix -p</code><code>"123456"</code> <code>-h</code><code>"192.168.1.124"</code> <code>zabbix < </code><code>/root/zabbix-2</code><code>.2.9</code><code>/database/mysql/images</code><code>.sql</code>
<code>3)mysql -uzabbix -p</code><code>"123456"</code> <code>-h</code><code>"192.168.1.124"</code> <code>zabbix < </code><code>/root/zabbix-2</code><code>.2.9</code><code>/database/mysql/data</code><code>.sql</code>
<code>4、建立使用者</code>
<code>1)建zabbix組</code>
<code>groupadd zabbix</code>
<code>2)添加zabbix使用者并加入到zabbix組</code>
<code>useradd</code> <code>-s </code><code>/bin/false</code> <code>-g zabbix -m zabbix</code>
<code>5、修改配置讓zabbix server連接配接上mysql</code>
<code>1)先備份下需要修改的檔案</code>
<code>cp</code> <code>/opt/zabbix/etc/zabbix_server</code><code>.conf </code><code>/opt/zabbix/etc/zabbix_server</code><code>.conf.bak</code>
<code>2)修改配置</code>
<code>cat</code> <code>/opt/zabbix/etc/zabbix_server</code><code>.conf |</code><code>egrep</code> <code>-</code><code>v</code> <code>"^$|^#"</code>
<code>ListenPort=10051</code>
<code>LogFile=</code><code>/var/log/zabbix_server/zabbix_server</code><code>.log</code>
<code>PidFile=</code><code>/var/log/zabbix_server/zabbix_server</code><code>.pid</code>
<code>DBHost=192.168.1.124</code>
<code>DBName=zabbix</code>
<code>DBUser=zabbix</code>
<code>DBPassword=123456</code>
<code>ListenIP=192.168.1.124</code>
<code>AlertScriptsPath=${datadir}</code><code>/zabbix/alertscripts</code>
<code>6、修改啟動腳本</code>
<code>1)複制模闆的腳本</code>
<code>cp</code> <code>/root/zabbix-2</code><code>.2.9</code><code>/misc/init</code><code>.d</code><code>/debian/zabbix-server</code> <code>/etc/init</code><code>.d/</code>
<code>2)修改腳本内容</code>
<code>diff</code> <code>/root/zabbix-2</code><code>.2.9</code><code>/misc/init</code><code>.d</code><code>/debian/zabbix-server</code> <code>/etc/init</code><code>.d</code><code>/zabbix-server</code>
<code>10c10</code>
<code>< PID=</code><code>/tmp/</code><code>$NAME.pid</code>
<code>---</code>
<code>> PID=</code><code>/var/log/zabbix_server/</code><code>$NAME.pid</code>
<code>3)給腳本執行權限</code>
<code>chmod</code> <code>+x </code><code>/etc/init</code><code>.d</code><code>/zabbix-server</code>
<code>7、建目錄并做日志切割處理</code>
<code>1)建目錄</code>
<code>mkdir</code> <code>/var/log/zabbix_server</code>
<code>2)把目錄權限交給zabbix</code>
<code>chown</code> <code>zabbix:zabbix </code><code>/var/log/zabbix_server</code> <code>-R</code>
<code>3)日志切割</code>
<code>cat</code> <code>/etc/logrotate</code><code>.d</code><code>/zabbix_server</code>
<code>/var/log/zabbix_server/zabbix_server</code><code>.log{</code>
<code> </code><code>daily</code>
<code> </code><code>rotate 7</code>
<code> </code><code>compress</code>
<code> </code><code>missingok</code>
<code> </code><code>notiempty</code>
<code> </code><code>create 0640 zabbix zabbix</code>
<code> </code><code>shardscripts</code>
<code>}</code>
<code>8、啟動zabbix-server服務</code>
<code>1)</code><code>/etc/init</code><code>.d</code><code>/zabbix-server</code> <code>start</code>
<code>Starting Zabbix server daemon: zabbix_server</code>
<code>2)檢視zabbix_server啟動日志</code>
<code>cat</code> <code>/var/log/zabbix_server/zabbix_server</code><code>.log </code>
<code> </code><code>43736:20150529:095819.674 Starting Zabbix Server. Zabbix 2.2.9 (revision 52686).</code>
<code> </code><code>43736:20150529:095819.674 ****** Enabled features ******</code>
<code> </code><code>43736:20150529:095819.674 SNMP monitoring: YES</code>
<code> </code><code>43736:20150529:095819.674 IPMI monitoring: YES</code>
<code> </code><code>43736:20150529:095819.674 WEB monitoring: YES</code>
<code> </code><code>43736:20150529:095819.675 VMware monitoring: YES</code>
<code> </code><code>43736:20150529:095819.675 Jabber notifications: NO</code>
<code> </code><code>43736:20150529:095819.675 Ez Texting notifications: YES</code>
<code> </code><code>43736:20150529:095819.675 ODBC: YES</code>
<code> </code><code>43736:20150529:095819.675 SSH2 support: NO</code>
<code> </code><code>43736:20150529:095819.675 IPv6 support: NO</code>
<code> </code><code>43736:20150529:095819.675 ******************************</code>
<code> </code><code>43736:20150529:095819.675 using configuration </code><code>file</code><code>: </code><code>/opt/zabbix/etc/zabbix_server</code><code>.conf</code>
<code> </code><code>43736:20150529:095819.686 current database version (mandatory</code><code>/optional</code><code>): 02020000</code><code>/02020001</code>
<code> </code><code>43736:20150529:095819.686 required mandatory version: 02020000</code>
<code> </code><code>43740:20150529:095819.721 server </code><code>#2 started [db watchdog #1]</code>
<code> </code><code>43739:20150529:095819.722 server </code><code>#1 started [configuration syncer #1]</code>
<code> </code><code>43742:20150529:095819.724 server </code><code>#4 started [poller #2]</code>
<code> </code><code>43741:20150529:095819.735 server </code><code>#3 started [poller #1]</code>
<code> </code><code>43743:20150529:095819.739 server </code><code>#5 started [poller #3]</code>
<code> </code><code>43745:20150529:095819.743 server </code><code>#7 started [poller #5]</code>
<code> </code><code>43744:20150529:095819.748 server </code><code>#6 started [poller #4]</code>
<code> </code><code>43749:20150529:095819.756 server </code><code>#8 started [unreachable poller #1]</code>
<code> </code><code>43752:20150529:095819.763 server </code><code>#10 started [trapper #2]</code>
<code> </code><code>43751:20150529:095819.764 server </code><code>#9 started [trapper #1]</code>
<code> </code><code>43755:20150529:095819.774 server </code><code>#11 started [trapper #3]</code>
<code> </code><code>43756:20150529:095819.775 server </code><code>#12 started [trapper #4]</code>
<code> </code><code>43757:20150529:095819.776 server </code><code>#13 started [trapper #5]</code>
<code> </code><code>43761:20150529:095819.781 server </code><code>#14 started [icmp pinger #1]</code>
<code> </code><code>43762:20150529:095819.782 server </code><code>#15 started [alerter #1]</code>
<code> </code><code>43764:20150529:095819.786 server </code><code>#16 started [housekeeper #1]</code>
<code> </code><code>43764:20150529:095819.786 executing housekeeper</code>
<code> </code><code>43766:20150529:095819.799 server </code><code>#17 started [timer #1]</code>
<code> </code><code>43767:20150529:095819.801 server </code><code>#18 started [http poller #1]</code>
<code> </code><code>43771:20150529:095819.815 server </code><code>#20 started [history syncer #1]</code>
<code> </code><code>43774:20150529:095819.823 server </code><code>#22 started [history syncer #3]</code>
<code> </code><code>43773:20150529:095819.825 server </code><code>#21 started [history syncer #2]</code>
<code> </code><code>43770:20150529:095819.827 server </code><code>#19 started [discoverer #1]</code>
<code> </code><code>43778:20150529:095819.837 server </code><code>#23 started [history syncer #4]</code>
<code> </code><code>43764:20150529:095819.842 housekeeper [deleted 0 hist</code><code>/trends</code><code>, 0 items, 0 events, 0 sessions, 0 alarms, 0 audit items </code><code>in</code> <code>0.050062 sec, idle 1 hour(s)]</code>
<code> </code><code>43780:20150529:095819.845 server </code><code>#24 started [escalator #1]</code>
<code> </code><code>43781:20150529:095819.846 server </code><code>#25 started [proxy poller #1]</code>
<code> </code><code>43736:20150529:095819.849 server </code><code>#0 started [main process]</code>
<code> </code><code>43783:20150529:095819.851 server </code><code>#26 started [self-monitoring #1]</code>
<code>3)檢視zabbix-server程序</code>
<code> </code><code>[email protected]:~</code><code># ps aux |grep zabbix</code>
<code>zabbix 43736 0.0 0.3 161016 3552 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code>
<code>zabbix 43739 0.0 0.2 161024 2628 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: configuration syncer [synced configuration </code><code>in</code> <code>0.001632 sec, idle 60 sec]</code>
<code>zabbix 43740 0.0 0.1 161016 1992 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: db watchdog [synced alerts config </code><code>in</code> <code>0.001054 sec, idle 60 sec]</code>
<code>zabbix 43741 0.0 0.3 162840 3276 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: poller </code><code>#1 [got 0 values in 0.000002 sec, idle 5 sec]</code>
<code>zabbix 43742 0.0 0.3 162840 3276 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: poller </code><code>#2 [got 0 values in 0.000003 sec, idle 5 sec]</code>
<code>zabbix 43743 0.0 0.3 162840 3276 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: poller </code><code>#3 [got 0 values in 0.000004 sec, idle 5 sec]</code>
<code>zabbix 43744 0.0 0.3 162840 3276 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: poller </code><code>#4 [got 0 values in 0.000002 sec, idle 5 sec]</code>
<code>zabbix 43745 0.0 0.3 162840 3276 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: poller </code><code>#5 [got 0 values in 0.000003 sec, idle 5 sec]</code>
<code>zabbix 43749 0.0 0.3 162840 3276 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: unreachable poller </code><code>#1 [got 0 values in 0.000004 sec, idle 5 sec]</code>
<code>zabbix 43751 0.0 0.1 161016 1992 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: trapper </code><code>#1 [processed data in 0.000000 sec, waiting for connection]</code>
<code>zabbix 43752 0.0 0.1 161016 1992 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: trapper </code><code>#2 [processed data in 0.000000 sec, waiting for connection]</code>
<code>zabbix 43755 0.0 0.1 161016 1992 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: trapper </code><code>#3 [processed data in 0.000000 sec, waiting for connection]</code>
<code>zabbix 43756 0.0 0.1 161016 1992 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: trapper </code><code>#4 [processed data in 0.000000 sec, waiting for connection]</code>
<code>zabbix 43757 0.0 0.1 161016 1992 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: trapper </code><code>#5 [processed data in 0.000000 sec, waiting for connection]</code>
<code>zabbix 43761 0.0 0.1 161340 2008 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: icmp pinger </code><code>#1 [got 0 values in 0.000006 sec, idle 5 sec]</code>
<code>zabbix 43762 0.0 0.1 161016 1992 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: alerter [sent alerts: 0 success, 0 fail </code><code>in</code> <code>0.000148 sec, idle 30 sec]</code>
<code>zabbix 43764 0.0 0.2 161264 2256 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: housekeeper [deleted 0 hist</code><code>/trends</code><code>, 0 items, 0 events, 0 sessions, 0 alarms, 0 audit items </code><code>in</code> <code>0.050062 sec, idle 1 hour(s)]</code>
<code>zabbix 43766 0.0 0.2 161016 2248 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: timer </code><code>#1 [processed 0 triggers, 0 events in 0.000016 sec, 0 maintenances in 0.000663 sec, idle 30 sec]</code>
<code>zabbix 43767 0.0 0.2 161016 2244 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: http poller </code><code>#1 [got 0 values in 0.000515 sec, idle 5 sec]</code>
<code>zabbix 43770 0.0 0.3 162516 3276 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: discoverer </code><code>#1 [processed 0 rules in 0.000871 sec, idle 60 sec]</code>
<code>zabbix 43771 0.0 0.1 161016 1992 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: </code><code>history</code> <code>syncer </code><code>#1 [synced 0 items in 0.000002 sec, idle 5 sec]</code>
<code>zabbix 43773 0.0 0.1 161016 1992 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: </code><code>history</code> <code>syncer </code><code>#2 [synced 0 items in 0.000001 sec, idle 5 sec]</code>
<code>zabbix 43774 0.0 0.1 161016 1992 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: </code><code>history</code> <code>syncer </code><code>#3 [synced 0 items in 0.000001 sec, idle 5 sec]</code>
<code>zabbix 43778 0.0 0.1 161016 1992 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: </code><code>history</code> <code>syncer </code><code>#4 [synced 0 items in 0.000002 sec, idle 5 sec]</code>
<code>zabbix 43780 0.0 0.1 161016 1992 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: escalator [processed 0 escalations </code><code>in</code> <code>0.000148 sec, idle 3 sec]</code>
<code>zabbix 43781 0.0 0.1 161016 1996 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: proxy poller </code><code>#1 [exchanged data with 0 proxies in 0.000003 sec, idle 5 sec]</code>
<code>zabbix 43783 0.0 0.1 161016 1772 ? S 09:58 0:00 </code><code>/usr/local/sbin/zabbix_server</code><code>: self-monitoring [processed data </code><code>in</code> <code>0.000003 sec, idle 1 sec]</code>
<code>root 43791 0.0 0.0 7836 888 pts</code><code>/1</code> <code>S+ 10:01 0:00 </code><code>grep</code> <code>--color=auto zabbix</code>
<code>4)檢視zabbix監聽端口</code>
<code>netstat</code> <code>-tupnl |</code><code>grep</code> <code>zabbix</code>
<code>tcp 0 0 192.168.1.124:10051 0.0.0.0:* LISTEN 43736</code><code>/zabbix_server</code>
<code>9、将zabbix-server加入到開機啟動</code>
<code>1)使用update-rc.d指令</code>
<code>update-rc.d zabbix-server defaults</code>
<code>2)檢視下是否在開機啟動裡了</code>
<code>runlevel </code>
<code>N 2</code>
<code>ll </code><code>/etc/rc2</code><code>.d/</code>
<code>lrwxrwxrwx 1 root root 23 May 29 10:17 S02zabbix-server -> ..</code><code>/init</code><code>.d</code><code>/zabbix-server</code>
<code>三、安裝zabbix-web前端</code>
<code>1、安裝apache2和php</code>
<code>1)apt-get -y </code><code>install</code> <code>apache2-mpm-worker</code>
<code>2)apt-get -y </code><code>install</code> <code>php5</code>
<code>2、将源碼包裡的網站内容複制到網站目錄下</code>
<code>1)</code><code>mkdir</code> <code>/var/www/zabbix</code>
<code>2)</code><code>cp</code> <code>-a zabbix-2.2.9</code><code>/frontends/php/</code> <code>/var/www/zabbix/</code>
<code>3)</code><code>chown</code> <code>www-data </code><code>/var/www/zabbix/</code> <code>-R</code>
<code>3、使用域名通路的話需要修改windows的hosts檔案(預設情況在C:\Windows\System32\drivers\etc)</code>
<code>http:</code><code>//www</code><code>.testzabbix.com</code><code>/zabbix/</code><code>就出現以下網站了</code>
<a href="http://s3.51cto.com/wyfs02/M01/6E/16/wKiom1VzAQKijcRoAAGA7BbP9XI405.jpg" target="_blank"></a>
<code>1)點php目錄就可以到下一步</code>
<a href="http://s3.51cto.com/wyfs02/M00/6E/16/wKiom1VzAWbgWVJrAANedPhsE4o454.jpg" target="_blank"></a>
<code>2)點next後出現紅字部分</code>
<a href="http://s3.51cto.com/wyfs02/M01/6E/12/wKioL1VzAzzx0E1TAAQQ4SjgDgY891.jpg" target="_blank"></a>
<code>根據紅字提示接下來解決</code>
<code>3)先備份下原配置檔案</code>
<code>cp</code> <code>/etc/php5/apache2/php</code><code>.ini </code><code>/etc/php5/apache2/php</code><code>.ini.bak</code>
<code>4)修改</code><code>/etc/php5/apache2/php</code><code>.ini内容如下</code>
<code>max_execution_time = 300</code>
<code>max_input_time = 300</code>
<code>post_max_size = 16M</code>
<code>date</code><code>.timezone = Asia</code><code>/Shanghai</code>
<code>5)安裝php5-mysql和php5-gd包</code>
<code>apt-get -y </code><code>install</code> <code>php5-mysqlapt-get -y </code><code>install</code> <code>php5-gd</code>
<code>6)上述全部完成後就可以看到下面圖檔了</code>
<a href="http://s3.51cto.com/wyfs02/M00/6E/16/wKiom1VzAtqStxFrAAMtxI0jID8988.jpg" target="_blank"></a>
<code>7)填寫對應的DB資訊</code>
<a href="http://s3.51cto.com/wyfs02/M01/6E/17/wKiom1VzA7Xgl0NKAANGUCTcs4I558.jpg" target="_blank"></a>
<code>8)接下來next</code>
<a href="http://s3.51cto.com/wyfs02/M01/6E/17/wKiom1VzA-bBLRcFAAJD78YQDqo396.jpg" target="_blank"></a>
<code>9)接下來next</code>
<a href="http://s3.51cto.com/wyfs02/M02/6E/12/wKioL1VzBaqivbBsAAKyz_oQbq0177.jpg" target="_blank"></a>
<code>10)接下來next</code>
<a href="http://s3.51cto.com/wyfs02/M02/6E/17/wKiom1VzBDLCHijxAAIm1dZJJVQ359.jpg" target="_blank"></a>
<code>11)預設賬戶(Admin)和密碼zabbix</code>
<a href="http://s3.51cto.com/wyfs02/M00/6E/12/wKioL1VzBe2jiO3pAAJLe6eP3nY027.jpg" target="_blank"></a>
<code>12)登入成功的圖</code>
<a href="http://s3.51cto.com/wyfs02/M01/6E/12/wKioL1VzBm6RuvRKAAVnAcO0qLE993.jpg" target="_blank"></a>
<code>13)更改預設登入zabbix密碼(md5加密的)</code>
<a href="http://s3.51cto.com/wyfs02/M01/6E/17/wKiom1VzBOyQizXbAALfE1q-zFU628.jpg" target="_blank"></a>
<code>先使用openssl md5加密字元串</code><code>echo</code> <code>-n </code><code>"123123"</code><code>|openssl md5</code>
<code>update zabbix.</code><code>users</code> <code>set</code> <code>passwd</code><code>=</code><code>'4297f44b13955235245b2497399d7a93'</code> <code>where userid = 1;</code>
<code>也可以update zabbix.</code><code>users</code> <code>set</code> <code>passwd</code><code>=MD5(</code><code>'123123'</code><code>) where userid=1;</code>
<code>四、安裝zabbix-agent(1-9步驟)(serverB)</code>
<code>1、解壓</code>
<code>2、編譯安裝</code>
<code>cd</code> <code>zabbix-2.2.9</code>
<code>1).</code><code>/configure</code> <code>--</code><code>enable</code><code>-agent --prefix=</code><code>/opt/zabbix</code>
<code>3、軟連結</code>
<code>4、建立zabbix使用者</code>
<code>1)groupadd zabbix</code>
<code>2)</code><code>useradd</code> <code>-s </code><code>/bin/false</code> <code>-g zabbix zabbix</code>
<code>5、配置</code>
<code>cp</code> <code>/opt/zabbix/etc/zabbix_agentd</code><code>.conf </code><code>/opt/zabbix/etc/zabbix_agentd</code><code>.conf.bak</code>
<code>sed</code> <code>-i </code><code>'s!# PidFile=/tmp/zabbix_agentd.pid!PidFile=/var/log/zabbix_agent/zabbix_agentd.pid!g'</code> <code>/opt/zabbix/etc/zabbix_agentd</code><code>.conf</code>
<code>sed</code> <code>-i </code><code>'s!LogFile=/tmp/zabbix_agentd.log!LogFile=/var/log/zabbix_agent/zabbix_agentd.log!g'</code> <code>/opt/zabbix/etc/zabbix_agentd</code><code>.conf</code>
<code>sed</code> <code>-i </code><code>"s/Server=127.0.0.1/Server=192.168.1.124/g"</code> <code>/opt/zabbix/etc/zabbix_agentd</code><code>.conf</code>
<code>sed</code> <code>-i </code><code>"s/# ListenPort=10050/ListenPort=10050/g"</code> <code>/opt/zabbix/etc/zabbix_agentd</code><code>.conf</code>
<code>sed</code> <code>-i </code><code>"s/# ListenIP=0.0.0.0/ListenIP=192.168.1.122/g"</code> <code>/opt/zabbix/etc/zabbix_agentd</code><code>.conf</code>
<code>sed</code> <code>-i </code><code>"s/ServerActive=127.0.0.1/ServerActive=192.168.1.124/g"</code> <code>/opt/zabbix/etc/zabbix_agentd</code><code>.conf</code>
<code>sed</code> <code>-i </code><code>'s!# Include=/usr/local/etc/zabbix_agentd.conf.d/!Include=/opt/zabbix/etc/zabbix_agentd.conf.d/!g'</code> <code>/opt/zabbix/etc/zabbix_agentd</code><code>.conf</code>
<code>cp</code> <code>/root/zabbix-2</code><code>.2.9</code><code>/misc/init</code><code>.d</code><code>/debian/zabbix-agent</code> <code>/etc/init</code><code>.d/</code>
<code>sed</code> <code>-i </code><code>'s!PID=/tmp/$NAME.pid!PID=/var/log/zabbix_agent/$NAME.pid!g'</code> <code>/etc/init</code><code>.d</code><code>/zabbix-agent</code>
<code>6、建立目錄及配置日志輪轉</code>
<code>mkdir</code> <code>/var/log/zabbix_agent</code>
<code>chown</code> <code>zabbix:zabbix </code><code>/var/log/zabbix_agent</code>
<code>cat</code> <code>/etc/logrotate</code><code>.d</code><code>/zabbix_agent</code>
<code>/var/log/zabbix_agent/zabbix_agentd</code><code>.log{</code>
<code>7、啟動zabbix-agent服務</code>
<code>/etc/init</code><code>.d</code><code>/zabbix-agent</code> <code>start</code>
<code>Starting Zabbix agent daemon: zabbix_agentd</code>
<code>8、檢視啟動日志及端口監聽和程序</code>
<code>1)</code><code>cat</code> <code>/var/log/zabbix_agent/zabbix_agentd</code><code>.log </code>
<code>8844:20150607:133047.412 no active checks on server [192.168.1.124:10051]: host [192.168.1.124] not found</code>
<code>8839:20150607:133243.287 Got signal [signal:15(SIGTERM),sender_pid:8864,sender_uid:0,reason:0]. Exiting ...</code>
<code>8839:20150607:133243.293 Zabbix Agent stopped. Zabbix 2.2.9 (revision 52686).</code>
<code>8868:20150607:133243.314 Starting Zabbix Agent [Zabbix server]. Zabbix 2.2.9 (revision 52686).</code>
<code>8868:20150607:133243.315 using configuration </code><code>file</code><code>: </code><code>/opt/zabbix/etc/zabbix_agentd</code><code>.conf</code>
<code>8872:20150607:133243.316 agent </code><code>#3 started [listener #3]</code>
<code>8871:20150607:133243.317 agent </code><code>#2 started [listener #2]</code>
<code>8873:20150607:133243.317 agent </code><code>#4 started [active checks #1]</code>
<code>8870:20150607:133243.318 agent </code><code>#1 started [listener #1]</code>
<code>8869:20150607:133243.318 agent </code><code>#0 started [collector]</code>
<code>8873:20150607:133243.325 no active checks on server [192.168.1.124:10051]: host [Zabbix server] not monitored</code>
<code>2)檢視監聽情況</code>
<code>netstat</code> <code>-tupnl|</code><code>grep</code> <code>zabbix</code>
<code>tcp 0 0 192.168.1.122:10050 0.0.0.0:* LISTEN 8868</code><code>/zabbix_agentd</code>
<code>3)檢視程序</code>
<code>ps</code> <code>-ef |</code><code>grep</code> <code>zabbix</code>
<code>zabbix 8868 1 0 13:32 ? 00:00:00 </code><code>/usr/local/sbin/zabbix_agentd</code>
<code>zabbix 8869 8868 0 13:32 ? 00:00:01 </code><code>/usr/local/sbin/zabbix_agentd</code><code>: collector [idle 1 sec]</code>
<code>zabbix 8870 8868 0 13:32 ? 00:00:00 </code><code>/usr/local/sbin/zabbix_agentd</code><code>: listener </code><code>#1 [waiting for connection]</code>
<code>zabbix 8871 8868 0 13:32 ? 00:00:00 </code><code>/usr/local/sbin/zabbix_agentd</code><code>: listener </code><code>#2 [waiting for connection]</code>
<code>zabbix 8872 8868 0 13:32 ? 00:00:00 </code><code>/usr/local/sbin/zabbix_agentd</code><code>: listener </code><code>#3 [waiting for connection]</code>
<code>zabbix 8873 8868 0 13:32 ? 00:00:00 </code><code>/usr/local/sbin/zabbix_agentd</code><code>: active checks </code><code>#1 [idle 1 sec]</code>
<code>root 8881 1304 0 13:35 pts</code><code>/0</code> <code>00:00:00 </code><code>grep</code> <code>--color=auto zabbix</code>
<code>9、将zabbix-agent加入到開機啟動</code>
<code>update-rc.d zabbix-agent defaults</code>
<code>10、測試</code>
<code>1)zabbix_get是一個用來與zabbix agent通信并從zabbix agent擷取所需資訊的程式。</code>
<code>zabbix_get -s 192.168.1.122 -p 10050 -k </code><code>"system.cpu.load[all,avg1]"</code>
<code>0.070000</code>
<code>-s --host <host name or IP> Specify host name or IP address of a host</code>
<code>-p --port <port number> Specify port number of agent running on the host. Default is 10050</code>
<code>-k --key <key of metric> Specify key of item to retrieve value </code><code>for</code>
<code>2)使用telnet指令</code>
<code>telnet 192.168.1.122 10050</code>
<code>Trying 192.168.1.122...</code>
<code>Connected to 192.168.1.122.</code>
<code>Escape character is </code><code>'^]'</code><code>.</code>
<code>Connection closed by foreign host.</code>
本文轉自 xdoujiang 51CTO部落格,原文連結:http://blog.51cto.com/7938217/1659042,如需轉載請自行聯系原作者