# 11 监控方案

### 11 Recipes for monitoring

#### General概括

##### Monitoring server availability监控服务器可用性

At least three methods (or combination of all methods) may be used in
order to monitor availability of a
server.可以使用至少三种方法（或所有方法的组合）来监视服务器的可用性。

-   ICMP ping ("icmpping" key)
-   "zabbix\[host,agent,available\]" item
-   trigger function nodata() for monitoring the availability of hosts
    that use active checks only触发函数 nodata()
    以监控只进行主动性检查的主机的有效性

##### Sending alerts via WinPopUps通过WinPopUps发送警告

WinPopUps maybe very useful if you're running Windows OS and want to get
quick notification from Zabbix. It could be good addition for
email-based alert messages. Details about enabling of WinPopUps can be
found at
[http://www.zabbix.com/forum/showthread.php?t=2147.如果你正在运行Windows操作系统，想要从Zabbix获取快讯，WinPopUps可能大有用处。它是基于电子邮件的警告消息的很好补充。关于启用WinPopUps的细节信息，详见](http://www.zabbix.com/forum/showthread.php?t=2147.如果你正在运行Windows操作系统，想要从Zabbix获取快讯，WinPopUps可能大有用处。它是基于电子邮件的警告消息的很好补充。关于启用WinPopUps的细节信息，详见)
<http://www.zabbix.com/forum/showthread.php?t=2147>.

#### Monitoring specific applications监控特定的应用程序

##### AS/400

IBM AS/400 platform can be monitored using SNMP. More information is
available at
<http://publib-b.boulder.ibm.com/Redbooks.nsf/RedbookAbstracts/sg244504.html?Open>.
使用SNMP可以监视IBM AS/400平台，更多信息详见
<http://publib-b.boulder.ibm.com/Redbooks.nsf/RedbookAbstracts/sg244504.html?Open>.

##### MySQL

Several user parameters can be used for the monitoring of MySQL in the
agent configuration file: /usr/local/etc/zabbix\_agentd.conf
在agent配置文件夹/usr/local/etc/zabbix\_agentd.conf中，可以用若干用户参数来监控MySQL

    ### Set of parameters for monitoring MySQL server (v3.23.42 and later)
    ### Change -u and add -p if required
    #UserParameter=mysql.ping,mysqladmin -uroot  ping|grep alive|wc -l
    #UserParameter=mysql.uptime,mysqladmin -uroot status|cut -f2 -d":"|cut -f2 -d" "
    #UserParameter=mysql.threads,mysqladmin -uroot status|cut -f3 -d":"|cut -f2 -d" "
    #UserParameter=mysql.questions,mysqladmin -uroot status|cut -f4 -d":"|cut -f2 -d" "
    #UserParameter=mysql.slowqueries,mysqladmin -uroot status|cut -f5 -d":"|cut -f2 -d" "
    #UserParameter=mysql.qps,mysqladmin -uroot status|cut -f9 -d":"|cut -f2 -d" "
    #UserParameter=mysql.version,mysql -V

-   *mysql.ping*

Check whether MySQL is alive.检查MySQL是否运行正常.

        Result: 0 - not started 1 - alive

-   *mysql.uptime*

Number of seconds MySQL is running.MySQL运行的秒数.

-   *mysql.threads*

Number of MySQL threads.MySQL的线程数量.

-   *mysql.questions*

Number of processed queries.MySQL的线程数量

-   *mysql.slowqueries*

Number of slow queries.处理查询数量

-   *mysql.qps*

Queries per second.慢查询数量

-   *mysql.version*

Version of MySQL. For example: mysql Ver 14.14 Distrib 5.1.53, for
pc-linux-gnu (i686) MySQL的版本. 例如: mysql 14.14版本 Distrib 5.1.53,
for pc-linux-gnu (i686)

For additional information see also the userparameter\_mysql.conf file
in conf/zabbix\_agentd directory.
获取更过信息，请访问conf/zabbix\_agentd目录下的userparameter\_mysql.conf文件

##### Mikrotik routers Mikrotik 路由器

Use SNMP agent provided by Mikrotik. See <http://www.mikrotik.com> for
more information.

##### Windows

Use Zabbix Windows agent included (pre-compiled) into Zabbix
distribution.使用包含(预编译)到Zabbix发行中的Zabbix Windows agent.

##### Tuxedo

Tuxedo command line utilities tmadmin and qmadmin can be used in
definition of a UserParameter in order to return per
server/service/queue performance counters and availability of Tuxedo
resources.在定义一个用户参数时，可以使用Tuxedo Command
Line实用程序tmadmin和qmadmin，以返回每个服务器/服务/队列性能计数器、Tuxedo资源的可用性。

##### Informix

Standard Informix utility **onstat** can be used for monitoring of
virtually every aspect of Informix database. Also, Zabbix can retrieve
information provided by Informix SNMP agent.用标准英孚美的utility
onstat，几乎可以监控Informix数据库的各个方面。而且，Zabbix可以检索由Informix
SNMP agent提供的信息。

#### HP OpenView

Zabbix can be configured to send messages to OpenView server. The
following steps must be performed:通过配置
Zabbix来向OpenView服务器发送消息，必须遵循以下几个步骤：

##### Step 1 步骤 1

Define new media.定义新media.

The media will execute a script which will send required information to
OpenView.media将执行一个向OpenView发送所需信息的脚本。

##### Step 2 步骤 2

Define new user.定义新用户

The user has to be linked with the media. 用户必须与media相连接.

##### Step 3 步骤 3

Configure actions. 配置操作。

Configure actions to send all (or selected) trigger status changes to
the user.配置操作会将所有(或已选择的)状态已修改的触发器发给用户。

##### Step 4 步骤 4

Write media script. 编写media脚本

The script will have the following logic. If trigger is ON, then execute
OpenView command *opcmsg -id application=<application>
msg\_grp=<msg\_grp> object=<object> msg\_text=<text>*.
The command will return unique message ID which has to be stored
somewhere, preferrably in a new table of ZABBIX database. If trigger is
OFF then *opcmack <message id>* has to be executed with message ID
retrieved from the database. 脚本将有如下逻辑操作：如果触发器为ON,
那么执行 OpenView 命令 *opcmsg -id application=<application>
msg\_grp=<msg\_grp> object=<object> msg\_text=<text>*.
该指令将返回唯一的信息ID，该ID必须存储在某处，并在 ZABBIX
数据库的新列表里处于优先位置。如果触发器为OFF，那么 *opcmack <message
id>* 要和从数据库中检索的信息ID一同执行。

Refer to OpenView official documentation for more details about opcmsg
and opcmack. The media script is not given
here.更多关于opcmsg和opcmack的详情，请见OpenView官方文件。
这里没有给出media脚本。
