Zabbix method of adding Node.js monitoring _node.js

Source: Internet
Author: User
Tags centos cpu usage


At present, there are Pm2-zabbix tools on the Internet to achieve Zabbix monitoring node.js alarm, GitHub address.



Characteristics:



Automatic discovery of node.js processes through PM2 management.



Reports Nodes.js process status, CPU usage, memory footprint, and whether the process is restarted.



Monitor the PM2 Daemon's own state, resource footprint, and PID changes.



A Zabbix monitoring item template is provided that is easy to install.



1.node.js Server Installation Pm2-zabbix


NPM install-g Pm2-zabbix


To test the automatic discovery feature is normal:


Pm2-zabbix--discover


A similar output indicates a successful installation:

{'
data ': [
{
#PROCESS_ID} ': ' qb_node-0 ',
' {#PROCESS_NAME} ': ' Qb_node '
},
{
' {# PROCESS_ID} ": Qb_node-1",
"{#PROCESS_NAME}": "Qb_node"
},
{
"{#PROCESS_ID}": "Qb_node-2",
' {#PROCESS_NAME} ': ' Qb_node '
},
{
' {#PROCESS_ID} ': ' qb_node-3 ',
' {#PROCESS_NAME} ': ' Qb_node '
}
]
}


2. Cloning code

 Git clonehttps://github.com/greatcare/pm2-zabbix.git

 



3.Zabbix Web Admin Background import template file Pm2-zabbix/install/zabbix-server/pm2-zabbix.template.xml



4.node.js Server Add service, select according to server operating system version, and modify service run user and Node.js user with PM2 start consistent



Rhel/centos 7 Series:


CP pm2-zabbix/install/init/systemd/pm2-zabbix.service/usr/lib/systemd/system/


Modify the target file Pm2-zabbix.service file content user entry:



User=root



Rhel/centos 6 or 5 series:


CP pm2-zabbix/install/init/sysv/pm2-zabbix/etc/init.d/


Modify the target file Pm2-zabbix file content daemon_user:



Daemon_user=root



5. New soft connection, according to their own server to modify the soft connection to the real file path


Mkdir-p/etc/zabbix
ln-s/app/zabbix/etc/zabbix_agentd.conf/etc/zabbix/zabbix_agentd.conf
ln-s/App/ Zabbix/bin/zabbix_sender/usr/bin/zabbix_sender
ln-s ' which node '/usr/bin/node
ln-s ' which Pm2-zabbix '/usr/ Local/bin/pm2-zabbix


6. Start Pm2-zabbix Service



Rhel/centos 7 Series:



Systemctl Start Pm2-zabbix



Rhel/centos 6 or 5 series:



Service Start Pm2-zabbix



7. Modify the Zabbix agent configuration file zabbix_agentd.conf and add additional configuration


Include=/app/zabbix/etc/zabbix_agentd.conf.d/*.conf


8. Copy Zabbix Agent Configuration


CP pm2-zabbix/install/zabbix-agent/pm2-zabbix.conf/app/zabbix/etc/zabbix_agentd.conf.d/pm2.conf


9. Modify configuration pm2.conf Content sudo-u user and 4th step consistent, colleagues modify Pm2-zabbix path


Userparameter=pm2.processes,sudo-u Root/usr/local/bin/pm2-zabbix--discover


10. Server Terminal Execution Program Visudo add sudo configuration


Zabbix all= (All:all) nopasswd:/usr/local/bin/pm2-zabbix Defaults:zabbix!requiretty


11. Restart Node.js Server Zabbix Agent service


/etc/init.d/zabbix_agentd restart


12.Zabbix Web Admin Settings node.js Server add link Template App PM2 template PM2 Daemon CPU Utilization PM2 Daemon memory Footprint PM2 Managed node process instance CPU Usage PM2 managed node process instance memory footprint



The above is a small set to introduce the Zabbix add Node.js monitoring method, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.