xl_young 发表于 2016-9-19 11:47:22

zabbix 监控pm2,使用pm2自带的的插件

pm2-zabbix 安装
原文地址:https://github.com/greatcare/pm2-zabbix

1,需求:npm,node,git

2,安装:
npm install -g pm2-zabbix

3,测试命令:
pm2-zabbix --discover

4,收集数据,开启(debug)server(zabbix服务端IP)
pm2-zabbix --monitor --server 172.16.23.1 --debug
报错:[ ERR ] Periodic sending of process list error: {

设定软连接:
ln -s /usr/local/zabbix/bin/zabbix_sender/usr/bin/
拷贝
cp /usr/local/zabbix/etc/zabbix_agentd.conf.d/pm2-zabbix.conf/etc/zabbix/zabbix_agentd.conf


5,创建 zabbix-agent 的配置文件
vi /usr/local/zabbix/etc/zabbix_agentd.conf.d/pm2-zabbix.conf
# Put this file in /etc/zabbix/zabbix_agentd.d/ and remember to change the sudo -u <user> to use your user name
UserParameter=pm2.processes,sudo -u root pm2-zabbix --discover

# Note that it is advised you test whether sudo works from the zabbix user first, including *without a TTY*.
# If you get a "Value should be a JSON object" error during key discovery, please check your sudoers -
#refer to the example sudoers file for an option that disables the tty requirement.

6,创建sudo用户 zabbix
vi /etc/sudoers.d/pm2-zabbix-sudoers
# Allow the Zabbix user to run pm2-zabbix as any user, without a password.
zabbixALL=(ALL:ALL) NOPASSWD: /usr/bin/pm2-zabbix

# On some systems (notably RHEL and CentOS), sudo is configured to require a tty
#by default, which prevents it from working at all with the Zabbix agent.
# This lifts that default restriction.
Defaults:zabbix !requiretty
7,在zabbix-get服务端测试是否能获取数据
/usr/local/zabbix/bin/zabbix_get -s 172.16.23.31 -p 10050 -k 'pm2.processes'
如果有信息,没有报错即可
8,服务端添加模板


xl_young 发表于 2016-9-19 11:49:17

服务器端模板请下载附件

gnixgnix 发表于 2016-12-19 09:08:52

怎么需要金币阿?

xl_young 发表于 2017-2-22 14:07:48

gnixgnix 发表于 2016-12-19 09:08
怎么需要金币阿?

系统规定的。~~~

shuiqiang 发表于 2017-5-8 16:52:08

第4步cp /usr/local/zabbix/etc/zabbix_agentd.conf.d/pm2-zabbix.conf/etc/zabbix/zabbix_agentd.conf,这个文件 /usr/local/zabbix/etc/zabbix_agentd.conf.d/pm2-zabbix.conf在第五步才创建,第四步是怎么复制的?

shuiqiang 发表于 2017-5-8 17:00:51

另外,我执行zabbix_get -s 192.168.12.41 -k 'pm2.processes'是有返回结果的,但是导入模板后,关于cpu,memory的都取不到值,比如pm2.processes,执行zabbix_get -s 192.168.12.41 -k pm2.processes报错,ZBX_NOTSUPPORTED: Item does not allow parameters.

jokeyone 发表于 2017-6-20 09:35:39

金币不够下载不了。。

jokeyone 发表于 2017-6-20 09:36:16

好贵的附近。。。。。。我要金币

jokeyone 发表于 2017-6-20 09:36:34

说错了。。。好贵的附件。。。。。我要金币。

xl_young 发表于 2017-7-10 20:39:21

shuiqiang 发表于 2017-5-8 17:00
另外,我执行zabbix_get -s 192.168.12.41 -k 'pm2.processes'是有返回结果的,但是导入模板后,关于cpu,m ...

这个是自动发现的
页: [1]
查看完整版本: zabbix 监控pm2,使用pm2自带的的插件