实战3 Cacti监控nginx、mysql、mongodb、memcached和php-fpm

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
云数据库 MongoDB,通用型 2核4GB
简介:

在监控方面,两周的心得与大家共勉。

首先说说在线上跑的监控(cacti),两周下来没有也出现问题,日志也没有报错的迹象,绘图,获取数据都是正常的。如下图所示:至于监控,对于cacti来说,绘图是很直观的,一目了然,学会使用cacti,更重要的是要学会看坐标,还有坐标下面更详细的数值。

因为更多的模拟环境搭建是在vmware workstation上安装的,由于虚拟机的特殊性,"快照",会使物理主机与vmware的主机时间造成不一致,因此都采用ntpdate保持时间一致,或者快照恢复后一定要重启机器,都是解决时间不一致的方法

1
2
3
[root@cacti ~] # crontab -e
* /1  * * * *  /usr/sbin/ntpdate  -u asia.pool.ntp.org 
[root@cacti ~] # service crond start

监控的信息: 硬盘(本地硬盘和挂在硬盘)、内存、cpu的负载、终端用户的登陆个数、主机当前的进程数

wKioL1OzZZXwPH2GAALsVBoFPlM089.jpg

wKioL1OzZZ3D3w-AAAU_k72Z7c0100.jpg

wKioL1OzZaWj1vtoAATY-kNkdg4494.jpg

 

接下来就来看看cacti在监控应用层服务方面的功能!

cacti监控nginx

cacti监控mysql

cacti监控mongodb

短信报警附截图

cacti监控memcached

cacti监控php-fpm

一、添加监控nginx监控模板

1、启动nginx的状态监控

编译安装nginx,更多模块功能的启用可以使用

wKioL1Oza7CC2QzRAASGaZ8We9k099.jpg

然后,在编译nginx的时候加入参数--with-http_stub_status_module

2、编辑配置文件nginx.conf,添加如下

wKioL1OzbQ3hXNN2AAEvbDH5AgY828.jpg

3、重启nginx服务

wKioL1OzbUuAg1WRAAEfLmVuR-Y614.jpg

4、访问nginx的状态监控页面

wKiom1OzbfaDFNJ8AADrsdc8uwU890.jpg

5、下载cacti监控nginx的模板

wKiom1Ozb97wmM97AAMmhblm1wo190.jpg

6、模板拷贝、模板导入

注:把模板中以.pl的两文件拷贝到你的cacti目录下的scripts/目录下,然后把以.xml的文件导入到cacti中,导入方法

wKiom1OzcOfS0cXkAAJ2OlTfVdo140.jpg

wKioL1OzcaqikHtRAAcMGdyWvr8294.jpg 

导入成功后如下所示:

wKioL1OzcimgeFejAAKf_Jk4oPI825.jpg

7、测试模板是否能够正常使用

wKiom1Ozc-3z7hkeAAI1g2yMmEc334.jpg

 

二、安装nginx监控

1、安装net-snmp服务

1
[root@lnmp ~] # yum install -y net-snmp net-snmp-utils net-snmp-libs

2、配置snmpd配置文件并测试服务

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
[root@lnmp ~] # cd /etc/snmp/
[root@lnmp snmp] # cp snmpd.conf snmpd.conf.bak
[root@lnmp snmp] # vim snmpd.conf 
#修改
  view    systemview    included   .1.3.6.1.2.1
[root@lnmp snmp] # service snmpd start
正在启动 snmpd:                                           [确定]
[root@lnmp snmp] # snmpnetstat -v 2c -c public -Can -Cp tcp localhost
Active Internet (tcp) Connections (including servers)
Proto Local Address          Remote Address         (state)
tcp   *.22                   *.*                   LISTEN
tcp   *.80                   *.*                   LISTEN
tcp   *.3306                 *.*                   LISTEN
tcp   127.0.0.1.199          *.*                   LISTEN
tcp   127.0.0.1.3306         127.0.0.1.34893       ESTABLISHED
tcp   127.0.0.1.3306         127.0.0.1.34894       ESTABLISHED
tcp   127.0.0.1.3306         127.0.0.1.34895       ESTABLISHED
tcp   127.0.0.1.3306         127.0.0.1.34899       ESTABLISHED
tcp   127.0.0.1.3306         127.0.0.1.34900       ESTABLISHED
tcp   127.0.0.1.3306         127.0.0.1.34901       ESTABLISHED
tcp   127.0.0.1.3306         127.0.0.1.34907       ESTABLISHED
tcp   127.0.0.1.3306         127.0.0.1.34908       ESTABLISHED
tcp   127.0.0.1.3306         127.0.0.1.34909       ESTABLISHED
tcp   127.0.0.1.9000         *.*                   LISTEN
tcp   172.16.3.164.22        172.16.3.127.51102    ESTABLISHED
tcp   172.16.3.164.22        172.16.3.127.51230    ESTABLISHED

3、添加远程监控主机

wKiom1OzdpyxiWsJAAMM5RvKZEA775.jpg

wKioL1Ozdm6Af6G8AAWaaTvVICY823.jpg

wKiom1Ozdp3xWekJAALmSyC-ui0757.jpg

4、添加nginx的监控模板

wKioL1OzdyfCbRP2AAcBLsjexys441.jpg

wKiom1Ozd0Tgb70OAAR_FNwPD94138.jpg

wKiom1Ozd5ej7963AALHCMaLcbM946.jpg

5、启用监控主机模板,如nginx

wKioL1Ozd7_gqmHTAATSTFF3bGs396.jpg

wKiom1OzeDLC_nFXAAMMWmSZKaE916.jpg

wKioL1OzeAOTr36nAAT1aFOd3WA579.jpg

 6、创建graphs组为Remote Host,并将nginx加入到这个组中。

wKioL1OzeenSUZd8AAGq_xAXIUg527.jpg

wKiom1OzehehyhMBAAJa1ruCAs0541.jpg

wKioL1OzeemSSs3HAANUFAJt1Ec607.jpg

wKiom1OzehiBA-aYAAOdYgASP3M028.jpg

wKioL1OzeemS3gfgAAMw2XPYyeE707.jpg

6、监控nginx状态如下,等一会看看是否能绘图

wKioL1Ozemng1eTGAAThaZs_Tr8463.jpg

三、apache自带的ab压力测试工具,来测试队绘图是否有影响

1、ab测试1000的并发量

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
[root@cacti ~]# ab -c  1000  -n  1000     #反复的多测试几次
This  is  ApacheBench, Version  2.3  <$Revision:  655654  $>
Copyright  1996  Adam Twiss, Zeus Technology Ltd, http: //www.zeustech.net/
Licensed to The Apache Software Foundation, http: //www.apache.org/
Benchmarking  172.16 . 3.164  (be patient)
Completed  100  requests
Completed  200  requests
Completed  300  requests
Completed  400  requests
Completed  500  requests
Completed  600  requests
^[[ACompleted  700  requests
Completed  800  requests
Completed  900  requests
Completed  1000  requests
Finished  1000  requests
Server Software:        nginx
Server Hostname:         172.16 . 3.164
Server Port:             80
Document Path:          /index.html
Document Length:         186  bytes
Concurrency Level:       1000
Time taken  for  tests:    1.307  seconds
Complete requests:       1000
Failed requests:         265
    (Connect:  0 , Receive:  0 , Length:  265 , Exceptions:  0 )
Write errors:            0
Non-2xx responses:       735
Total transferred:       41371480  bytes
HTML transferred:        41190245  bytes
Requests per second:     765.32  [#/sec] (mean)
Time per request:        1306.640  [ms] (mean)
Time per request:        1.307  [ms] (mean, across all concurrent requests)
Transfer rate:           30920.40  [Kbytes/sec] received
Connection Times (ms)
               min  mean[+/-sd] median   max
Connect:       114   123    6.2     122      135
Processing:    134   368  312.1     158     1079
Waiting:       101   227  143.7     157      570
Total:         259   492  316.0     273     1200
Percentage of the requests served within a certain time (ms)
   50 %     273
   66 %     613
   75 %     769
   80 %     866
   90 %    1033
   95 %    1113
   98 %    1188
   99 %    1196
  100 %    1200  (longest request)
[root@cacti ~]# ab -c  1000  -n  1000  http: //172.16.3.164/index.html
This  is  ApacheBench, Version  2.3  <$Revision:  655654  $>
Copyright  1996  Adam Twiss, Zeus Technology Ltd, http: //www.zeustech.net/
Licensed to The Apache Software Foundation, http: //www.apache.org/
Benchmarking  172.16 . 3.164  (be patient)
Completed  100  requests
Completed  200  requests
Completed  300  requests
Completed  400  requests
Completed  500  requests
Completed  600  requests
Completed  700  requests
Completed  800  requests
Completed  900  requests
Completed  1000  requests
Finished  1000  requests
Server Software:        nginx
Server Hostname:         172.16 . 3.164
Server Port:             80
Document Path:          /index.html
Document Length:         186  bytes
Concurrency Level:       1000
Time taken  for  tests:    1.329  seconds
Complete requests:       1000
Failed requests:         205
    (Connect:  0 , Receive:  0 , Length:  205 , Exceptions:  0 )
Write errors:            0
Non-2xx responses:       795
Total transferred:       32081560  bytes
HTML transferred:        31906265  bytes
Requests per second:     752.26  [#/sec] (mean)
Time per request:        1329.324  [ms] (mean)
Time per request:        1.329  [ms] (mean, across all concurrent requests)
Transfer rate:           23568.11  [Kbytes/sec] received
Connection Times (ms)
               min  mean[+/-sd] median   max
Connect:       116   123    6.1     121      144
Processing:    120   348  306.9     159     1079
Waiting:        91   255  181.6     158      670
Total:         251   471  305.9     277     1203
Percentage of the requests served within a certain time (ms)
   50 %     277
   66 %     392
   75 %     704
   80 %     790
   90 %    1016
   95 %    1101
   98 %    1141
   99 %    1192
  100 %    1203  (longest request)

2、查看状态监控页面

wKioL1Oze8vR6y9_AAD2_kMnI9c590.jpg

又反复的多次压力测试的结果

wKiom1OzfSOBdaVAAADkdBqHauo370.jpg

3、cacti状态监控图

wKioL1OzhMTAM9owAAQUNyqgpV0318.jpg

 

 

cacti监控mysql

1、下载cacti监控mysql的模板

下载地址:http://code.google.com/p/mysql-cacti-templates/

软件:better-cacti-templates-1.1.8.tar.gz

2、解压模板

1
2
3
4
5
6
7
8
9
10
11
12
[root@cacti ~]# ll better-cacti-templates- 1.1 . 8 .tar.gz 
-rw-r--r--.  1  root root  275805  7 月    2  13 : 25  better-cacti-templates- 1.1 . 8 .tar.gz
[root@cacti ~]# tar xf better-cacti-templates- 1.1 . 8 .tar.gz 
[root@cacti ~]# cd better-cacti-templates- 1.1 . 8
[root@cacti better-cacti-templates- 1.1 . 8 ]# ll scripts/
总用量  108
-rw-rw-r--.  1  cactiuser cactiuser  52856  1 月   23  2011  ss_get_by_ssh.php
-rw-rw-r--.  1  cactiuser cactiuser  53624  1 月   23  2011  ss_get_mysql_stats.php
[root@cacti scripts]# cd / var /www/html/cacti0. 88 /scripts/
[root@cacti scripts]# chmod  755  ss_get_
ss_get_by_ssh.php       ss_get_mysql_stats.php  
[root@cacti scripts]# chmod  755  ss_get_*

3、修改监控mysql响应的php脚本

1
2
3
4
5
6
7
8
9
[root@cacti ~]# cd better-cacti-templates- 1.1 . 8 /scripts/
[root@cacti scripts]# vim ss_get_mysql_stats.php 
$mysql_user =  'cactiuser' ;  #被监控mysql的账户
$mysql_pass =  'cactiuser' ;  #被监控mysql账户的密码
$mysql_port =  3306 ;
$mysql_ssl  = FALSE;   # Whether to  use  SSL to connect to MySQL.
$heartbeat  =  '' ;      # db.tbl  in  case  you  use  mk-heartbeat from Maatkit.
$cache_dir  =  '/tmp' ;  # If  set this  uses caching to avoid multiple calls.
$poll_time  =  300 ;     # Adjust to match your polling interval.

4、导入监控mysql的模板,如下图

选择导入mysql监控模板

wKiom1OznRjDDLgyAAdN8D9xKis118.jpg

导入成功如下:

wKiom1OznUSCrlNlAAXBexlGQtE964.jpg

 

5、添加mysql监控模板到被监控主机

wKiom1OznoaB1aiHAANmLewW_6s433.jpg

wKiom1OznofQClHDAAVLboE3PpU567.jpg

wKioL1OznljTA4sXAAN92qwhTXw200.jpg

wKioL1OznljBFYC7AAS5ZLL7zgA940.jpg

wKiom1OznofDYg_wAAUgEDF3k2Q900.jpg

wKioL1OznlnTiIXiAAVpH_euj0c834.jpg

 6、被监控的mysql服务器需要创建监控用户

注:让cacti所在机器能够访问MySQL服务器的状态信息,必须拥有”process”权限。如果要监控InnoDB状态,还必须有”SUPER”权限。

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
[root@lnmp ~] # mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection  id  is 29
Server version: 5.5.33-log MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and /or  its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and /or  its
affiliates. Other names may be trademarks of their respective
owners.
Type  'help;'  or  '\h'  for  help. Type  '\c'  to  clear  the current input statement.
mysql> grant all privileges on *.* to cactiuser@ "%"  identified by  "cactiuser" ;
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to cactiuser@ "localhost"  identified by  "cactiuser" ;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> \q
Bye
[root@lnmp ~] # mysql -ucactiuser -pcactiuser
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection  id  is 30
Server version: 5.5.33-log MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and /or  its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and /or  its
affiliates. Other names may be trademarks of their respective
owners.
Type  'help;'  or  '\h'  for  help. Type  '\c'  to  clear  the current input statement.
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| live               |
| mysql              |
| performance_schema |
| psp                |
test                |
| vms2_1             |
| zqcms              |
| zqvms              |
+--------------------+
9 rows  in  set  (0.04 sec) 
mysql> \q
Bye

7、监控主机测试是否能够远程登陆mysql

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
[root@cacti scripts]# mysql -ucactiuser -pcactiuser -h  172.16 . 3.164
Welcome to the MySQL monitor.  Commands end  with  ; or \g.
Your MySQL connection id  is  33
Server version:  5.5 . 33 -log MySQL Community Server (GPL)
Copyright (c)  2000 2013 , Oracle and/or its affiliates. All rights reserved.
Oracle  is  a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type  'help;'  or  '\h'  for  help. Type  '\c'  to clear the current input statement.
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| live               |
| mysql              |
| performance_schema |
| psp                |
| test               |
| vms2_1             |
| zqcms              |
| zqvms              |
+--------------------+
9  rows  in  set  ( 0.00  sec)
mysql> \q
Bye

7、查看监控绘图

wKioL1OzoFrD0c-HAAUe_5a6HTI981.jpg

稍等一下,看是否能获取到mysql的数据

 wKiom1Ozo8CCN7EBAAUweRBOEQ4530.jpg

cacti监控mongodb

cacti服务器地址:172.16.3.154

mongodb服务器地址:172.16.3.188

 一、ssh双机互联

因为cacti监控mongodb是需要登录到mongodb的服务端运行mongo的状态获取命令,所以需要ssh连接登录。所以需要配置非交互式帐号密码登录。这里采用公私钥模式。

先在监控服务器生成一对公私钥。

1、监控端和被监控端主机名互相解析

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
#ON Cacti
[root@cacti ~] # cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.3.188 mongodb
172.16.3.154 cacti.org 
#ON mongodb
[root@mongodb ~] # cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.3.188 mongodb
172.16.3.154 cacti.org
#ON Test
[root@cacti ~] # ping cacti.org
PING cacti.org (172.16.3.154) 56(84) bytes of data.
64 bytes from cacti.org (172.16.3.154): icmp_seq=1 ttl=64  time =0.023 ms
64 bytes from cacti.org (172.16.3.154): icmp_seq=2 ttl=64  time =0.032 ms
64 bytes from cacti.org (172.16.3.154): icmp_seq=3 ttl=64  time =0.038 ms
^C
--- cacti.org  ping  statistics ---
3 packets transmitted, 3 received, 0% packet loss,  time  2270ms
rtt min /avg/max/mdev  = 0.023 /0 .031 /0 .038 /0 .006 ms
You have new mail  in  /var/spool/mail/root
[root@cacti ~] # ping mongodb
PING mongodb (172.16.3.188) 56(84) bytes of data.
64 bytes from mongodb (172.16.3.188): icmp_seq=1 ttl=64  time =0.633 ms
64 bytes from mongodb (172.16.3.188): icmp_seq=2 ttl=64  time =0.295 ms
64 bytes from mongodb (172.16.3.188): icmp_seq=3 ttl=64  time =0.171 ms
64 bytes from mongodb (172.16.3.188): icmp_seq=4 ttl=64  time =0.274 ms
64 bytes from mongodb (172.16.3.188): icmp_seq=5 ttl=64  time =0.234 ms
^C
--- mongodb  ping  statistics ---
5 packets transmitted, 5 received, 0% packet loss,  time  4631ms
rtt min /avg/max/mdev  = 0.171 /0 .321 /0 .633 /0 .162 ms

2、配置ssh公私钥无需密码登录:

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
[root@cacti ~]# ssh-keygen 
Generating  public / private  rsa key pair.
Enter file  in  which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty  for  no passphrase): 
Enter same passphrase again: 
Your identification has been saved  in  /root/.ssh/id_rsa.
Your  public  key has been saved  in  /root/.ssh/id_rsa.pub.
The key fingerprint  is :
6e: 41 : 27 :2e:ff:fc: 09 : 00 : 42 : 13 :7f: 14 : 95 :dc:da:8d root@cacti.org
The key's randomart image  is :
+--[ RSA  2048 ]----+
|    +.  o+.o     |
|   . o .  o .    |
|    . o + .o o   |
|     . = o. E .  |
|      . S        |
|       + o       |
|        + .      |
|       . o . .   |
|          o.o    |
+-----------------+ 
[root@cacti ~]# cd /root/.ssh/
[root@cacti .ssh]# ll
总用量  8
-rw-------.  1  root root  1675  7 月    2  16 : 01  id_rsa     #公钥
-rw-r--r--.  1  root root   396  7 月    2  16 : 01  id_rsa.pub #私钥
[root@cacti .ssh]# chmod  600  *
[root@cacti .ssh]# ll
总用量  8
-rw-------.  1  root root  1675  7 月    2  16 : 01  id_rsa
-rw-------.  1  root root   396  7 月    2  16 : 01  id_rsa.pub
[root@cacti .ssh]# scp id_rsa mongodb:/root/
id_rsa                                                       100 1675      1 .6KB/s    00 : 00   
[root@cacti .ssh]# scp id_rsa.pub mongodb:/root/
id_rsa.pub                                                   100 %   396      0 .4KB/s    00 : 00 
#ON mongodb
[root@mongodb ~]# cat id_rsa.pub >> .ssh/authorized_keys 
#测试是否远程无密码登陆mongodb数据库
[root@cacti ~]# ssh mongodb
Last login: Wed Jul   2  16 : 10 : 31  2014  from cacti.org
[root@mongodb ~]# hostname
mongodb

3、配置监控脚本

拷贝模板中ssh的配置文件

1
2
3
4
5
6
7
8
[root@cacti ~]# cd better-cacti-templates- 1.1 . 8 /scripts/
[root@cacti scripts]# ll ss_get_by_ssh.php 
-rw-rw-r--.  1  cactiuser cactiuser  52856  1 月   23  2011  ss_get_by_ssh.php  #这个脚本需要放在cacti服务器端
[root@cacti scripts]# cp ss_get_by_ssh.php / var /www/html/cacti0. 88 /scripts/
[root@cacti ~]# cd / var /www/html/cacti0. 88 /scripts/
[root@cacti scripts]# chmod  755  ss_get_by_ssh.php
[root@cacti scripts]# ll ss_get_by_ssh.php 
-rwxr-xr-x.  1  root root  52846  7 月    2  14 : 49  ss_get_by_ssh.php

修改ssh的模板文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@cacti scripts]# vim ss_get_by_ssh.php 
# ============================================================================
$ssh_user   =  'root' ;                          # SSH username  
$ssh_port   =  22 ;                               # SSH port
$ssh_iden   =  '-i /root/.ssh/id_rsa' ;  # SSH identity
$ssh_tout   =  10 ;                               # SSH connect timeout
$nc_cmd     =  'nc -C -q1' ;                      # How to invoke netcat
$cache_dir  =  '/tmp' ;  # If  set this  uses caching to avoid multiple calls.
$poll_time  =  300 ; # Adjust to match your polling interval.
$use_ss     = FALSE; # Whether to  use  the script server or not
$use_ssh    = TRUE;  # Whether to connect via SSH or not ( default  yes).
$debug      = FALSE; # Define whether you want debugging behavior.
$debug_log  = FALSE; # If $debug_log  is  a filename, it'll be used. 
注释:ssh连接远程主机的用户,公钥的路径,缓存的路径和目录;大约在 39 行后

还可以修改默认的端口号,如下

1
2
3
4
5
6
7
8
9
   51  # Parameters  for  specific graphs can be specified here, or  in  the .cnf file.
   52  $status_server =  'localhost' ;             # Which server to query
   53  $status_url    =  '/server-status' ;        # Where Apache status lives
   54  $http_user     =  '' ;
   55  $http_pass     =  '' ;
   56  $memcache_port =  11211 ;                   # Which port memcached listens on
   57  $redis_port    =  6379 ;                    # Which port redis listens on
   58                                            # How to  get  openvz stats
   59  $openvz_cmd    =  'cat /proc/user_beancounters' ;

如果是mongodb不是正常端口启动,则需要这样修改。找到以下字段,添加红色字段,这里注意mongo这个命令一定要找对。

1
2
3
function  mongodb_cmdline ( $options ) { 
return  “echo \”db._adminCommand({serverStatus: 1 , repl: 1 })\” | /usr/local/mongo/mongodb/bin/mongo –port  10000 ″; 
}

以上配置完成后,保存退出

然后用命令测试是否有数据输出

1
2
3
[root@cacti ~]# php / var /www/html/cacti0. 88 /scripts/ss_get_by_ssh.php --type mongodb --host  172.16 . 3.188  --items c,de,df,dg,dh,di,dj,dk,dl,dm,dn, do ,dp,dq,dr,ds,dt,du
#如果有以下输出。表示是正常的
de: 83886080  df: 479199232  dg: 2  dh: 2  di: 0  dj: 0  dk: 39  dl: 1  dm: 0  dn: 0  do : 1  dp: 75  dq: 0  dr: 0  ds: 0  dt

4、添加mongodb模板

wKioL1Ozw2LRoftsAAb3Lz2KV-I071.jpg

wKioL1Ozw2OTjUqtAAbyiGB6Swc173.jpg

wKiom1Ozw5KTegMQAAL8NZI3NoI452.jpg

wKioL1Ozw2OhCdPwAAO8EzvYmSs251.jpg

5、cacti监控mongodb起始图,如下

 wKiom1OzxEXx5pW0AAHyucq3Cmo621.jpg

 稍等片刻,刷新页面,如下

wKioL1OzxD3jqrmlAAUsLoHlsbA912.jpg

 

短信报警附截图

wKioL1Ozx4mAkUjuAAdLMIer7I0019.jpg

 

cacti监控memcached

可以参考这个博文:http://storysky.blog.51cto.com/628458/251870

 wKiom1O1Du-y3FoAAATExtce8Fc402.jpg

 

 

cacti监控php-fpm

暂时还没有完成,模板导入后不绘图,正在研究中。。。。。。

 

 







     本文转自zys467754239 51CTO博客,原文链接:http://blog.51cto.com/467754239/1433409,如需转载请自行联系原作者





相关实践学习
MongoDB数据库入门
MongoDB数据库入门实验。
快速掌握 MongoDB 数据库
本课程主要讲解MongoDB数据库的基本知识,包括MongoDB数据库的安装、配置、服务的启动、数据的CRUD操作函数使用、MongoDB索引的使用(唯一索引、地理索引、过期索引、全文索引等)、MapReduce操作实现、用户管理、Java对MongoDB的操作支持(基于2.x驱动与3.x驱动的完全讲解)。 通过学习此课程,读者将具备MongoDB数据库的开发能力,并且能够使用MongoDB进行项目开发。 &nbsp; 相关的阿里云产品:云数据库 MongoDB版 云数据库MongoDB版支持ReplicaSet和Sharding两种部署架构,具备安全审计,时间点备份等多项企业能力。在互联网、物联网、游戏、金融等领域被广泛采用。 云数据库MongoDB版(ApsaraDB for MongoDB)完全兼容MongoDB协议,基于飞天分布式系统和高可靠存储引擎,提供多节点高可用架构、弹性扩容、容灾、备份回滚、性能优化等解决方案。 产品详情: https://www.aliyun.com/product/mongodb
相关文章
|
7月前
|
关系型数据库 MySQL PHP
PHP 原生操作 Mysql
PHP 原生操作 Mysql
81 0
|
7月前
|
关系型数据库 MySQL 数据库连接
PHP 原生连接 Mysql
PHP 原生连接 Mysql
107 0
|
7月前
|
关系型数据库 MySQL Unix
PHP MySql 安装与连接
PHP MySql 安装与连接
125 0
|
3月前
|
关系型数据库 MySQL PHP
|
3天前
|
PHP
web简易开发——通过php与HTML+css+mysql实现用户的登录,注册
web简易开发——通过php与HTML+css+mysql实现用户的登录,注册
|
7月前
|
关系型数据库 MySQL 数据库连接
PHP 原生操作 Mysql 增删改查案例
PHP 原生操作 Mysql 增删改查案例
87 0
|
2月前
|
监控 关系型数据库 MySQL
PHP与MySQL的结合:实现局域网上网行为监控软件的数据库管理
在当今信息化时代,网络安全日益成为重要的话题。为了有效监控和管理局域网上网行为,开发一个基于PHP和MySQL的数据库管理系统是一个理想的选择。本文将介绍如何结合PHP和MySQL,开发一款简单而高效的局域网上网行为监控软件,并重点关注数据库管理方面的实现。
184 0

推荐镜像

更多