Monitoring Nginx, Apache, MySQL, and Memcache using Cacti in Ubuntu

Source: Internet
Author: User
1: cacti monitoring mysql: monitored end: $ sudoapt-getinstallsnmpd $ sudovim/etc/snmp/snmd. conf # agentAddressudp: 127.0.0.1: 161 // comment out this line of agentAddress

1: cacti monitoring mysql:

Monitored end:
$ Sudo apt-get install snmpd
$ Sudo vim/etc/snmp/snmd. conf
# AgentAddress udp: 127.0.0.1: 161 // comment out this line
AgentAddress udp: 161, udp6: [: 1]: 161 // enable this line. Modify the listening address as needed.
$ Sudo/etc/init. d/snmpd restart

$ Mysql-uroot-p ***** // ensure that the mysql service is properly used.
Mysql> grant all on *. * to cacti@192.168.1. % identified by 'cacti ';
// Create a user that allows the monitoring client to obtain the relevant status through cacti access. The permissions, user names, and ip addresses can be modified as needed.

Monitoring end:
$ Wget http://mysql-cacti-templates.googlecode.com/files/better-cacti-templates-1.1.8.tar.gz
$ Tar zxvf better-cacti-templates-1.1.8.tar.gz
$ Cp ~ /Better-cacti-templates-1.1.8/scripts/ss_get_mysql_stats.php/usr/local/cacti/scripts/
$ Sudo vim/usr/local/cacti/scripts/ss_get_mysql_stats.php // modify the following:
$ Mysql_user = 'cacti ';
$ Mysql_pass = 'cacti'; // The user password here is the user cacti created by the monitored mysql.
Log onto the cacti page in the browser and select Import Templates Import template cacti_host_template_x_mysql_server_ht_0.8.6i-sver1.1.8.xml.

2: cacti monitors apache
Monitored end:
$ Sudo apt-get install snmpd
$ Sudo vim/etc/snmp/snmd. conf
# AgentAddress udp: 127.0.0.1: 161 // comment out this line
AgentAddress udp: 161, udp6: [: 1]: 161 // enable this line. Modify the listening address as needed.
$ Sudo/etc/init. d/snmpd restart

$ Sudo vim/etc/apache2/mod-enabled/status. conf
// Make sure that your apache server can be accessed normally. Ubuntu enables the status module by default, so you only need to modify this configuration file

SetHandler server-status
Order deny, allow
Deny from all
Allow from 192.168.1.0/24 // modify the access restriction as needed

$ Sudo/etc/init. d/apache2 restart
Test: Enter http: // apache_server_IP/server-status in the browser. If the status information is displayed

Monitoring end:
Apache template: http://forums.cacti.net/download/file.php? Id = 18576
$ Unzip ApacheStats_0.8.2.zip
$ Cp ApacheStats_0.8.2/ss_apache_stats.php/usr/local/cacti/scripts/
Log on to the cacti page in the browser and select Import Templates Import template cacti_host_template_webserver _-_ apache. xml.

3: cacti monitors nginx
Operations on the monitored end:
$ Sudo apt-get install snmpd
$ Sudo vim/etc/snmp/snmd. conf
# AgentAddress udp: 127.0.0.1: 161 // comment out this line
AgentAddress udp: 161, udp6: [: 1]: 161 // enable this line. Modify the listening address as needed.
$ Sudo/etc/init. d/snmpd restart


$ Sudo vim/etc/nginx/sites-enabled/default // ensure the nginx service and modify the nginx configuration file to add the following:
Location/nginx_status {
Stub_status on;
# Disable access_log if requared
Access_log off;
# Allow XX. YY. AA. ZZ;
# Deny all; // Similarly, access control depends on your needs
}
$ Sudo/etc/init. d/nginx restart
Test: Access http: // nginx_server_IP/nginx_status to access the Nginx running status page.

Monitoring operations:
: Http://forums.cacti.net/download/file.php? Id = 12676 & sid = 98a76c5c52e106554396dae69d6eca1a
$ Tar zxvf cacti-nginx.tar.gz
$ Cd cacti-nginx
$ Cp get_nginx_clients_status.pl get_nginx_socket_status.pl/usr/local/cacti/scripts/
$ Cd/usr/local/cacti/scripts/
$ Chmod 0755 get_nginx_socket_status.pl
$ Chmod 0755 get_nginx_clients_status.pl

Test:
$ Get_nginx_clients_status.pl http: // 192.168.1.222/nginx_status
// The displayed content is equivalent to that on the nginxstatus page. If no (LWP: UserAgent not found) is displayed, the perl-related components are incomplete.
Solution:
$ Sudo apt-get install libwww. perl

Import template:
Import to cacti cacti_graph_template_nginx_clients_stat.xml and cacti_graph_template_nginx_sockets_stat.xml

4: cacti monitors memcached
Monitored end:
$ Sudo apt-get install snmpd
$ Sudo vim/etc/snmp/snmd. conf
# AgentAddress udp: 127.0.0.1: 161 // comment out this line
AgentAddress udp: 161, udp6: [: 1]: 161 // enable this line. Modify the listening address as needed.
$ Sudo/etc/init. d/snmpd restart
The memcache service on the monitored end does not require specific configuration. Only memcache can provide services normally and the monitored address and port can be accessed by the monitoring end.

Monitoring end:
Because the template uses python to obtain data, you need to install the python environment and the python memcached client.
$ Wget ftp://ftp.tummy.com/pub/python-memcached/python-memcached-1.48.tar.gz
$ Tar xzvf python-memcached-1.45.tar.gz
$ Python-memcached-1.48 cd
$ Sudo python setup. py install // if the following error is reported
Traceback (most recent call last ):
File "setup. py", line 3, in
From setuptools import setup
ImportError: No module named setuptool
$ Sudo apt-get install python-setuptools // run this command
$ Sudo python setup. py install // run this command again

$ Wget http://content.dealnews.com/dealnews/developers/cacti-memcached-1.0.tar.gz
$ Tar zxvf cacti-memcached-1.0.tar.gz
$ Cacti-memcached-1.0 cd
$ Sudo cp memcached/usr/local/cacti/scripts

Test
/Usr/bin/python/usr/local/cacti/scripts/memcached IP address // If data cannot be obtained normally, check the address and port of the memcache listener on the server.

Import Template
Import Templates --> Import Template from Local File // Import xml and save

The above settings are only for the default port 11211, but when your port is not 11211 but another port, make the following changes:
Console --- Data Input Methods -- Memcached-Statistics
Find the Input String value python /Scripts/memcached. py
Change to: python /Scripts/memcached. py-p 11200 // Change the port to 11200 as needed.

The above are the configurations of the specific monitoring end and the monitored end. After the configuration is complete, you must add the corresponding host, add the corresponding template, and create images on the cacti interface. The operations are not described here.

Related Article

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.