概述
zabbix Server 4.0 监控Nginx
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
一.安装Nginx
1>.安装EPEL YUM源
[root@node102.yinzhengjie.org.cn ~]# yum -y install epel-release Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.njupt.edu.cn * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Package epel-release-7-11.noarch already installed and latest version Nothing to do [root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# yum repolist Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.njupt.edu.cn * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com repo id repo name status base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,019 epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,139 extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 413 updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 1,840 zabbix/x86_64 Zabbix Official Repository - x86_64 106 zabbix-non-supported/x86_64 Zabbix Official Repository non-supported - x86_64 4 repolist: 25,521 [root@node102.yinzhengjie.org.cn ~]#
2>.使用yum方式安装NGINX
[root@node102.yinzhengjie.org.cn ~]# yum -y install nginx-all-modules.noarch Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.njupt.edu.cn * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package nginx-all-modules.noarch 1:1.12.2-2.el7 will be installed --> Processing Dependency: nginx-mod-http-geoip = 1:1.12.2-2.el7 for package: 1:nginx-all-modules-1.12.2-2.el7.noarch --> Processing Dependency: nginx-mod-http-image-filter = 1:1.12.2-2.el7 for package: 1:nginx-all-modules-1.12.2-2.el7.noarch --> Processing Dependency: nginx-mod-http-perl = 1:1.12.2-2.el7 for package: 1:nginx-all-modules-1.12.2-2.el7.noarch --> Processing Dependency: nginx-mod-http-xslt-filter = 1:1.12.2-2.el7 for package: 1:nginx-all-modules-1.12.2-2.el7.noarch --> Processing Dependency: nginx-mod-mail = 1:1.12.2-2.el7 for package: 1:nginx-all-modules-1.12.2-2.el7.noarch --> Processing Dependency: nginx-mod-stream = 1:1.12.2-2.el7 for package: 1:nginx-all-modules-1.12.2-2.el7.noarch --> Running transaction check ---> Package nginx-mod-http-geoip.x86_64 1:1.12.2-2.el7 will be installed --> Processing Dependency: nginx for package: 1:nginx-mod-http-geoip-1.12.2-2.el7.x86_64 ---> Package nginx-mod-http-image-filter.x86_64 1:1.12.2-2.el7 will be installed --> Processing Dependency: gd for package: 1:nginx-mod-http-image-filter-1.12.2-2.el7.x86_64 --> Processing Dependency: libgd.so.2()(64bit) for package: 1:nginx-mod-http-image-filter-1.12.2-2.el7.x86_64 ---> Package nginx-mod-http-perl.x86_64 1:1.12.2-2.el7 will be installed --> Processing Dependency: perl >= 5.006001 for package: 1:nginx-mod-http-perl-1.12.2-2.el7.x86_64 --> Processing Dependency: perl(:MODULE_COMPAT_5.16.3) for package: 1:nginx-mod-http-perl-1.12.2-2.el7.x86_64 --> Processing Dependency: perl(Exporter) for package: 1:nginx-mod-http-perl-1.12.2-2.el7.x86_64 --> Processing Dependency: perl(XSLoader) for package: 1:nginx-mod-http-perl-1.12.2-2.el7.x86_64 --> Processing Dependency: perl(constant) for package: 1:nginx-mod-http-perl-1.12.2-2.el7.x86_64 --> Processing Dependency: perl(strict) for package: 1:nginx-mod-http-perl-1.12.2-2.el7.x86_64 --> Processing Dependency: perl(warnings) for package: 1:nginx-mod-http-perl-1.12.2-2.el7.x86_64 --> Processing Dependency: libperl.so()(64bit) for package: 1:nginx-mod-http-perl-1.12.2-2.el7.x86_64 ---> Package nginx-mod-http-xslt-filter.x86_64 1:1.12.2-2.el7 will be installed --> Processing Dependency: libxslt.so.1(LIBXML2_1.0.11)(64bit) for package: 1:nginx-mod-http-xslt-filter-1.12.2-2.el7.x86_64 --> Processing Dependency: libxslt.so.1(LIBXML2_1.0.18)(64bit) for package: 1:nginx-mod-http-xslt-filter-1.12.2-2.el7.x86_64 --> Processing Dependency: libexslt.so.0()(64bit) for package: 1:nginx-mod-http-xslt-filter-1.12.2-2.el7.x86_64 --> Processing Dependency: libxslt.so.1()(64bit) for package: 1:nginx-mod-http-xslt-filter-1.12.2-2.el7.x86_64 ---> Package nginx-mod-mail.x86_64 1:1.12.2-2.el7 will be installed ---> Package nginx-mod-stream.x86_64 1:1.12.2-2.el7 will be installed --> Running transaction check ---> Package gd.x86_64 0:2.0.35-26.el7 will be installed --> Processing Dependency: libjpeg.so.62(LIBJPEG_6.2)(64bit) for package: gd-2.0.35-26.el7.x86_64 --> Processing Dependency: libjpeg.so.62()(64bit) for package: gd-2.0.35-26.el7.x86_64 --> Processing Dependency: libfontconfig.so.1()(64bit) for package: gd-2.0.35-26.el7.x86_64 --> Processing Dependency: libXpm.so.4()(64bit) for package: gd-2.0.35-26.el7.x86_64 --> Processing Dependency: libX11.so.6()(64bit) for package: gd-2.0.35-26.el7.x86_64 ---> Package libxslt.x86_64 0:1.1.28-5.el7 will be installed ---> Package nginx.x86_64 1:1.12.2-2.el7 will be installed --> Processing Dependency: nginx-filesystem = 1:1.12.2-2.el7 for package: 1:nginx-1.12.2-2.el7.x86_64 --> Processing Dependency: nginx-filesystem for package: 1:nginx-1.12.2-2.el7.x86_64 --> Processing Dependency: libprofiler.so.0()(64bit) for package: 1:nginx-1.12.2-2.el7.x86_64 ---> Package perl.x86_64 4:5.16.3-294.el7_6 will be installed --> Processing Dependency: perl(Socket) >= 1.3 for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Scalar::Util) >= 1.10 for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl-macros for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(threads::shared) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(threads) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Time::Local) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Time::HiRes) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Storable) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Socket) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Scalar::Util) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Pod::Simple::XHTML) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Pod::Simple::Search) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Getopt::Long) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Filter::Util::Call) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(File::Temp) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(File::Spec::Unix) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(File::Spec::Functions) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(File::Spec) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(File::Path) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Cwd) for package: 4:perl-5.16.3-294.el7_6.x86_64 --> Processing Dependency: perl(Carp) for package: 4:perl-5.16.3-294.el7_6.x86_64 ---> Package perl-Exporter.noarch 0:5.68-3.el7 will be installed ---> Package perl-constant.noarch 0:1.27-2.el7 will be installed ---> Package perl-libs.x86_64 4:5.16.3-294.el7_6 will be installed --> Running transaction check ---> Package fontconfig.x86_64 0:2.13.0-4.3.el7 will be installed --> Processing Dependency: fontpackages-filesystem for package: fontconfig-2.13.0-4.3.el7.x86_64 --> Processing Dependency: dejavu-sans-fonts for package: fontconfig-2.13.0-4.3.el7.x86_64 ---> Package gperftools-libs.x86_64 0:2.6.1-1.el7 will be installed ---> Package libX11.x86_64 0:1.6.5-2.el7 will be installed --> Processing Dependency: libX11-common >= 1.6.5-2.el7 for package: libX11-1.6.5-2.el7.x86_64 --> Processing Dependency: libxcb.so.1()(64bit) for package: libX11-1.6.5-2.el7.x86_64 ---> Package libXpm.x86_64 0:3.5.12-1.el7 will be installed ---> Package libjpeg-turbo.x86_64 0:1.2.90-6.el7 will be installed ---> Package nginx-filesystem.noarch 1:1.12.2-2.el7 will be installed ---> Package perl-Carp.noarch 0:1.26-244.el7 will be installed ---> Package perl-File-Path.noarch 0:2.09-2.el7 will be installed ---> Package perl-File-Temp.noarch 0:0.23.01-3.el7 will be installed ---> Package perl-Filter.x86_64 0:1.49-3.el7 will be installed ---> Package perl-Getopt-Long.noarch 0:2.40-3.el7 will be installed --> Processing Dependency: perl(Pod::Usage) >= 1.14 for package: perl-Getopt-Long-2.40-3.el7.noarch --> Processing Dependency: perl(Text::ParseWords) for package: perl-Getopt-Long-2.40-3.el7.noarch ---> Package perl-PathTools.x86_64 0:3.40-5.el7 will be installed ---> Package perl-Pod-Simple.noarch 1:3.28-4.el7 will be installed --> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.28-4.el7.noarch --> Processing Dependency: perl(Encode) for package: 1:perl-Pod-Simple-3.28-4.el7.noarch ---> Package perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 will be installed ---> Package perl-Socket.x86_64 0:2.010-4.el7 will be installed ---> Package perl-Storable.x86_64 0:2.45-3.el7 will be installed ---> Package perl-Time-HiRes.x86_64 4:1.9725-3.el7 will be installed ---> Package perl-Time-Local.noarch 0:1.2300-2.el7 will be installed ---> Package perl-macros.x86_64 4:5.16.3-294.el7_6 will be installed ---> Package perl-threads.x86_64 0:1.87-4.el7 will be installed ---> Package perl-threads-shared.x86_64 0:1.43-6.el7 will be installed --> Running transaction check ---> Package dejavu-sans-fonts.noarch 0:2.33-6.el7 will be installed --> Processing Dependency: dejavu-fonts-common = 2.33-6.el7 for package: dejavu-sans-fonts-2.33-6.el7.noarch ---> Package fontpackages-filesystem.noarch 0:1.44-8.el7 will be installed ---> Package libX11-common.noarch 0:1.6.5-2.el7 will be installed ---> Package libxcb.x86_64 0:1.13-1.el7 will be installed --> Processing Dependency: libXau.so.6()(64bit) for package: libxcb-1.13-1.el7.x86_64 ---> Package perl-Encode.x86_64 0:2.51-7.el7 will be installed ---> Package perl-Pod-Escapes.noarch 1:1.04-294.el7_6 will be installed ---> Package perl-Pod-Usage.noarch 0:1.63-3.el7 will be installed --> Processing Dependency: perl(Pod::Text) >= 3.15 for package: perl-Pod-Usage-1.63-3.el7.noarch --> Processing Dependency: perl-Pod-Perldoc for package: perl-Pod-Usage-1.63-3.el7.noarch ---> Package perl-Text-ParseWords.noarch 0:3.29-4.el7 will be installed --> Running transaction check ---> Package dejavu-fonts-common.noarch 0:2.33-6.el7 will be installed ---> Package libXau.x86_64 0:1.0.8-2.1.el7 will be installed ---> Package perl-Pod-Perldoc.noarch 0:3.20-4.el7 will be installed --> Processing Dependency: perl(parent) for package: perl-Pod-Perldoc-3.20-4.el7.noarch --> Processing Dependency: perl(HTTP::Tiny) for package: perl-Pod-Perldoc-3.20-4.el7.noarch ---> Package perl-podlators.noarch 0:2.5.1-3.el7 will be installed --> Running transaction check ---> Package perl-HTTP-Tiny.noarch 0:0.033-3.el7 will be installed ---> Package perl-parent.noarch 1:0.225-244.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================================================================================================================== Package Arch Version Repository Size ================================================================================================================================================================================================================================== Installing: nginx-all-modules noarch 1:1.12.2-2.el7 epel 16 k Installing for dependencies: dejavu-fonts-common noarch 2.33-6.el7 base 64 k dejavu-sans-fonts noarch 2.33-6.el7 base 1.4 M fontconfig x86_64 2.13.0-4.3.el7 base 254 k fontpackages-filesystem noarch 1.44-8.el7 base 9.9 k gd x86_64 2.0.35-26.el7 base 146 k gperftools-libs x86_64 2.6.1-1.el7 base 272 k libX11 x86_64 1.6.5-2.el7 base 606 k libX11-common noarch 1.6.5-2.el7 base 164 k libXau x86_64 1.0.8-2.1.el7 base 29 k libXpm x86_64 3.5.12-1.el7 base 55 k libjpeg-turbo x86_64 1.2.90-6.el7 base 134 k libxcb x86_64 1.13-1.el7 base 214 k libxslt x86_64 1.1.28-5.el7 base 242 k nginx x86_64 1:1.12.2-2.el7 epel 530 k nginx-filesystem noarch 1:1.12.2-2.el7 epel 17 k nginx-mod-http-geoip x86_64 1:1.12.2-2.el7 epel 23 k nginx-mod-http-image-filter x86_64 1:1.12.2-2.el7 epel 26 k nginx-mod-http-perl x86_64 1:1.12.2-2.el7 epel 36 k nginx-mod-http-xslt-filter x86_64 1:1.12.2-2.el7 epel 26 k nginx-mod-mail x86_64 1:1.12.2-2.el7 epel 54 k nginx-mod-stream x86_64 1:1.12.2-2.el7 epel 76 k perl x86_64 4:5.16.3-294.el7_6 updates 8.0 M perl-Carp noarch 1.26-244.el7 base 19 k perl-Encode x86_64 2.51-7.el7 base 1.5 M perl-Exporter noarch 5.68-3.el7 base 28 k perl-File-Path noarch 2.09-2.el7 base 26 k perl-File-Temp noarch 0.23.01-3.el7 base 56 k perl-Filter x86_64 1.49-3.el7 base 76 k perl-Getopt-Long noarch 2.40-3.el7 base 56 k perl-HTTP-Tiny noarch 0.033-3.el7 base 38 k perl-PathTools x86_64 3.40-5.el7 base 82 k perl-Pod-Escapes noarch 1:1.04-294.el7_6 updates 51 k perl-Pod-Perldoc noarch 3.20-4.el7 base 87 k perl-Pod-Simple noarch 1:3.28-4.el7 base 216 k perl-Pod-Usage noarch 1.63-3.el7 base 27 k perl-Scalar-List-Utils x86_64 1.27-248.el7 base 36 k perl-Socket x86_64 2.010-4.el7 base 49 k perl-Storable x86_64 2.45-3.el7 base 77 k perl-Text-ParseWords noarch 3.29-4.el7 base 14 k perl-Time-HiRes x86_64 4:1.9725-3.el7 base 45 k perl-Time-Local noarch 1.2300-2.el7 base 24 k perl-constant noarch 1.27-2.el7 base 19 k perl-libs x86_64 4:5.16.3-294.el7_6 updates 688 k perl-macros x86_64 4:5.16.3-294.el7_6 updates 44 k perl-parent noarch 1:0.225-244.el7 base 12 k perl-podlators noarch 2.5.1-3.el7 base 112 k perl-threads x86_64 1.87-4.el7 base 49 k perl-threads-shared x86_64 1.43-6.el7 base 39 k Transaction Summary ================================================================================================================================================================================================================================== Install 1 Package (+48 Dependent packages) Total download size: 16 M Installed size: 50 M Downloading packages: (1/49): dejavu-sans-fonts-2.33-6.el7.noarch.rpm | 1.4 MB 00:00:03 (2/49): fontconfig-2.13.0-4.3.el7.x86_64.rpm | 254 kB 00:00:00 (3/49): fontpackages-filesystem-1.44-8.el7.noarch.rpm | 9.9 kB 00:00:00 (4/49): gd-2.0.35-26.el7.x86_64.rpm | 146 kB 00:00:00 (5/49): gperftools-libs-2.6.1-1.el7.x86_64.rpm | 272 kB 00:00:00 (6/49): libX11-1.6.5-2.el7.x86_64.rpm | 606 kB 00:00:00 (7/49): libX11-common-1.6.5-2.el7.noarch.rpm | 164 kB 00:00:00 (8/49): libXau-1.0.8-2.1.el7.x86_64.rpm | 29 kB 00:00:00 (9/49): libXpm-3.5.12-1.el7.x86_64.rpm | 55 kB 00:00:00 (10/49): libjpeg-turbo-1.2.90-6.el7.x86_64.rpm | 134 kB 00:00:00 (11/49): libxcb-1.13-1.el7.x86_64.rpm | 214 kB 00:00:00 (12/49): libxslt-1.1.28-5.el7.x86_64.rpm | 242 kB 00:00:00 (13/49): nginx-all-modules-1.12.2-2.el7.noarch.rpm | 16 kB 00:00:00 (14/49): nginx-mod-http-image-filter-1.12.2-2.el7.x86_64.rpm | 26 kB 00:00:00 (15/49): nginx-mod-http-perl-1.12.2-2.el7.x86_64.rpm | 36 kB 00:00:00 (16/49): nginx-mod-http-geoip-1.12.2-2.el7.x86_64.rpm | 23 kB 00:00:00 (17/49): dejavu-fonts-common-2.33-6.el7.noarch.rpm | 64 kB 00:00:04 (18/49): nginx-mod-http-xslt-filter-1.12.2-2.el7.x86_64.rpm | 26 kB 00:00:00 (19/49): nginx-filesystem-1.12.2-2.el7.noarch.rpm | 17 kB 00:00:00 (20/49): nginx-1.12.2-2.el7.x86_64.rpm | 530 kB 00:00:00 (21/49): nginx-mod-mail-1.12.2-2.el7.x86_64.rpm | 54 kB 00:00:00 (22/49): perl-Carp-1.26-244.el7.noarch.rpm | 19 kB 00:00:00 (23/49): perl-Exporter-5.68-3.el7.noarch.rpm | 28 kB 00:00:00 (24/49): perl-File-Path-2.09-2.el7.noarch.rpm | 26 kB 00:00:00 (25/49): perl-File-Temp-0.23.01-3.el7.noarch.rpm | 56 kB 00:00:00 (26/49): perl-Filter-1.49-3.el7.x86_64.rpm | 76 kB 00:00:00 (27/49): perl-Getopt-Long-2.40-3.el7.noarch.rpm | 56 kB 00:00:00 (28/49): perl-HTTP-Tiny-0.033-3.el7.noarch.rpm | 38 kB 00:00:00 (29/49): perl-PathTools-3.40-5.el7.x86_64.rpm | 82 kB 00:00:00 (30/49): nginx-mod-stream-1.12.2-2.el7.x86_64.rpm | 76 kB 00:00:00 (31/49): perl-Pod-Perldoc-3.20-4.el7.noarch.rpm | 87 kB 00:00:00 (32/49): perl-Pod-Simple-3.28-4.el7.noarch.rpm | 216 kB 00:00:00 (33/49): perl-Pod-Usage-1.63-3.el7.noarch.rpm | 27 kB 00:00:00 (34/49): perl-Pod-Escapes-1.04-294.el7_6.noarch.rpm | 51 kB 00:00:00 (35/49): perl-Scalar-List-Utils-1.27-248.el7.x86_64.rpm | 36 kB 00:00:00 (36/49): perl-Socket-2.010-4.el7.x86_64.rpm | 49 kB 00:00:00 (37/49): perl-Storable-2.45-3.el7.x86_64.rpm | 77 kB 00:00:00 (38/49): perl-Text-ParseWords-3.29-4.el7.noarch.rpm | 14 kB 00:00:00 (39/49): perl-Encode-2.51-7.el7.x86_64.rpm | 1.5 MB 00:00:00 (40/49): perl-Time-HiRes-1.9725-3.el7.x86_64.rpm | 45 kB 00:00:00 (41/49): perl-Time-Local-1.2300-2.el7.noarch.rpm | 24 kB 00:00:00 (42/49): perl-constant-1.27-2.el7.noarch.rpm | 19 kB 00:00:00 (43/49): perl-libs-5.16.3-294.el7_6.x86_64.rpm | 688 kB 00:00:00 (44/49): perl-macros-5.16.3-294.el7_6.x86_64.rpm | 44 kB 00:00:00 (45/49): perl-parent-0.225-244.el7.noarch.rpm | 12 kB 00:00:00 (46/49): perl-threads-1.87-4.el7.x86_64.rpm | 49 kB 00:00:00 (47/49): perl-threads-shared-1.43-6.el7.x86_64.rpm | 39 kB 00:00:00 (48/49): perl-podlators-2.5.1-3.el7.noarch.rpm | 112 kB 00:00:00 (49/49): perl-5.16.3-294.el7_6.x86_64.rpm | 8.0 MB 00:00:02 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 2.2 MB/s | 16 MB 00:00:07 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : fontpackages-filesystem-1.44-8.el7.noarch 1/49 Installing : dejavu-fonts-common-2.33-6.el7.noarch 2/49 Installing : dejavu-sans-fonts-2.33-6.el7.noarch 3/49 Installing : fontconfig-2.13.0-4.3.el7.x86_64 4/49 Installing : 1:perl-parent-0.225-244.el7.noarch 5/49 Installing : perl-HTTP-Tiny-0.033-3.el7.noarch 6/49 Installing : perl-podlators-2.5.1-3.el7.noarch 7/49 Installing : perl-Pod-Perldoc-3.20-4.el7.noarch 8/49 Installing : perl-Text-ParseWords-3.29-4.el7.noarch 9/49 Installing : 1:perl-Pod-Escapes-1.04-294.el7_6.noarch 10/49 Installing : perl-Encode-2.51-7.el7.x86_64 11/49 Installing : perl-Pod-Usage-1.63-3.el7.noarch 12/49 Installing : 4:perl-libs-5.16.3-294.el7_6.x86_64 13/49 Installing : 4:perl-macros-5.16.3-294.el7_6.x86_64 14/49 Installing : 4:perl-Time-HiRes-1.9725-3.el7.x86_64 15/49 Installing : perl-Exporter-5.68-3.el7.noarch 16/49 Installing : perl-constant-1.27-2.el7.noarch 17/49 Installing : perl-Time-Local-1.2300-2.el7.noarch 18/49 Installing : perl-Socket-2.010-4.el7.x86_64 19/49 Installing : perl-Carp-1.26-244.el7.noarch 20/49 Installing : perl-Storable-2.45-3.el7.x86_64 21/49 Installing : perl-PathTools-3.40-5.el7.x86_64 22/49 Installing : perl-Scalar-List-Utils-1.27-248.el7.x86_64 23/49 Installing : 1:perl-Pod-Simple-3.28-4.el7.noarch 24/49 Installing : perl-File-Temp-0.23.01-3.el7.noarch 25/49 Installing : perl-File-Path-2.09-2.el7.noarch 26/49 Installing : perl-threads-shared-1.43-6.el7.x86_64 27/49 Installing : perl-threads-1.87-4.el7.x86_64 28/49 Installing : perl-Filter-1.49-3.el7.x86_64 29/49 Installing : perl-Getopt-Long-2.40-3.el7.noarch 30/49 Installing : 4:perl-5.16.3-294.el7_6.x86_64 31/49 Installing : libX11-common-1.6.5-2.el7.noarch 32/49 Installing : gperftools-libs-2.6.1-1.el7.x86_64 33/49 Installing : libXau-1.0.8-2.1.el7.x86_64 34/49 Installing : libxcb-1.13-1.el7.x86_64 35/49 Installing : libX11-1.6.5-2.el7.x86_64 36/49 Installing : libXpm-3.5.12-1.el7.x86_64 37/49 Installing : libxslt-1.1.28-5.el7.x86_64 38/49 Installing : 1:nginx-filesystem-1.12.2-2.el7.noarch 39/49 Installing : libjpeg-turbo-1.2.90-6.el7.x86_64 40/49 Installing : gd-2.0.35-26.el7.x86_64 41/49 Installing : 1:nginx-mod-http-geoip-1.12.2-2.el7.x86_64 42/49 Installing : 1:nginx-mod-http-xslt-filter-1.12.2-2.el7.x86_64 43/49 Installing : 1:nginx-mod-stream-1.12.2-2.el7.x86_64 44/49 Installing : 1:nginx-mod-mail-1.12.2-2.el7.x86_64 45/49 Installing : 1:nginx-mod-http-image-filter-1.12.2-2.el7.x86_64 46/49 Installing : 1:nginx-1.12.2-2.el7.x86_64 47/49 Installing : 1:nginx-mod-http-perl-1.12.2-2.el7.x86_64 48/49 Installing : 1:nginx-all-modules-1.12.2-2.el7.noarch 49/49 Verifying : perl-HTTP-Tiny-0.033-3.el7.noarch 1/49 Verifying : fontconfig-2.13.0-4.3.el7.x86_64 2/49 Verifying : perl-threads-shared-1.43-6.el7.x86_64 3/49 Verifying : 4:perl-Time-HiRes-1.9725-3.el7.x86_64 4/49 Verifying : 1:nginx-mod-http-geoip-1.12.2-2.el7.x86_64 5/49 Verifying : perl-Exporter-5.68-3.el7.noarch 6/49 Verifying : perl-constant-1.27-2.el7.noarch 7/49 Verifying : perl-PathTools-3.40-5.el7.x86_64 8/49 Verifying : 1:nginx-mod-http-xslt-filter-1.12.2-2.el7.x86_64 9/49 Verifying : dejavu-fonts-common-2.33-6.el7.noarch 10/49 Verifying : fontpackages-filesystem-1.44-8.el7.noarch 11/49 Verifying : 1:nginx-mod-stream-1.12.2-2.el7.x86_64 12/49 Verifying : libjpeg-turbo-1.2.90-6.el7.x86_64 13/49 Verifying : 1:perl-parent-0.225-244.el7.noarch 14/49 Verifying : 4:perl-libs-5.16.3-294.el7_6.x86_64 15/49 Verifying : perl-File-Temp-0.23.01-3.el7.noarch 16/49 Verifying : 1:perl-Pod-Simple-3.28-4.el7.noarch 17/49 Verifying : 1:nginx-all-modules-1.12.2-2.el7.noarch 18/49 Verifying : libxcb-1.13-1.el7.x86_64 19/49 Verifying : perl-Time-Local-1.2300-2.el7.noarch 20/49 Verifying : 4:perl-macros-5.16.3-294.el7_6.x86_64 21/49 Verifying : perl-Socket-2.010-4.el7.x86_64 22/49 Verifying : libXpm-3.5.12-1.el7.x86_64 23/49 Verifying : perl-Text-ParseWords-3.29-4.el7.noarch 24/49 Verifying : 1:nginx-filesystem-1.12.2-2.el7.noarch 25/49 Verifying : perl-Carp-1.26-244.el7.noarch 26/49 Verifying : libxslt-1.1.28-5.el7.x86_64 27/49 Verifying : libX11-1.6.5-2.el7.x86_64 28/49 Verifying : perl-Storable-2.45-3.el7.x86_64 29/49 Verifying : dejavu-sans-fonts-2.33-6.el7.noarch 30/49 Verifying : 1:nginx-mod-mail-1.12.2-2.el7.x86_64 31/49 Verifying : perl-Scalar-List-Utils-1.27-248.el7.x86_64 32/49 Verifying : gd-2.0.35-26.el7.x86_64 33/49 Verifying : 1:perl-Pod-Escapes-1.04-294.el7_6.noarch 34/49 Verifying : perl-Pod-Usage-1.63-3.el7.noarch 35/49 Verifying : perl-Encode-2.51-7.el7.x86_64 36/49 Verifying : 1:nginx-1.12.2-2.el7.x86_64 37/49 Verifying : perl-Pod-Perldoc-3.20-4.el7.noarch 38/49 Verifying : perl-podlators-2.5.1-3.el7.noarch 39/49 Verifying : libXau-1.0.8-2.1.el7.x86_64 40/49 Verifying : perl-File-Path-2.09-2.el7.noarch 41/49 Verifying : perl-threads-1.87-4.el7.x86_64 42/49 Verifying : gperftools-libs-2.6.1-1.el7.x86_64 43/49 Verifying : libX11-common-1.6.5-2.el7.noarch 44/49 Verifying : perl-Filter-1.49-3.el7.x86_64 45/49 Verifying : perl-Getopt-Long-2.40-3.el7.noarch 46/49 Verifying : 1:nginx-mod-http-perl-1.12.2-2.el7.x86_64 47/49 Verifying : 4:perl-5.16.3-294.el7_6.x86_64 48/49 Verifying : 1:nginx-mod-http-image-filter-1.12.2-2.el7.x86_64 49/49 Installed: nginx-all-modules.noarch 1:1.12.2-2.el7 Dependency Installed: dejavu-fonts-common.noarch 0:2.33-6.el7 dejavu-sans-fonts.noarch 0:2.33-6.el7 fontconfig.x86_64 0:2.13.0-4.3.el7 fontpackages-filesystem.noarch 0:1.44-8.el7 gd.x86_64 0:2.0.35-26.el7 gperftools-libs.x86_64 0:2.6.1-1.el7 libX11.x86_64 0:1.6.5-2.el7 libX11-common.noarch 0:1.6.5-2.el7 libXau.x86_64 0:1.0.8-2.1.el7 libXpm.x86_64 0:3.5.12-1.el7 libjpeg-turbo.x86_64 0:1.2.90-6.el7 libxcb.x86_64 0:1.13-1.el7 libxslt.x86_64 0:1.1.28-5.el7 nginx.x86_64 1:1.12.2-2.el7 nginx-filesystem.noarch 1:1.12.2-2.el7 nginx-mod-http-geoip.x86_64 1:1.12.2-2.el7 nginx-mod-http-image-filter.x86_64 1:1.12.2-2.el7 nginx-mod-http-perl.x86_64 1:1.12.2-2.el7 nginx-mod-http-xslt-filter.x86_64 1:1.12.2-2.el7 nginx-mod-mail.x86_64 1:1.12.2-2.el7 nginx-mod-stream.x86_64 1:1.12.2-2.el7 perl.x86_64 4:5.16.3-294.el7_6 perl-Carp.noarch 0:1.26-244.el7 perl-Encode.x86_64 0:2.51-7.el7 perl-Exporter.noarch 0:5.68-3.el7 perl-File-Path.noarch 0:2.09-2.el7 perl-File-Temp.noarch 0:0.23.01-3.el7 perl-Filter.x86_64 0:1.49-3.el7 perl-Getopt-Long.noarch 0:2.40-3.el7 perl-HTTP-Tiny.noarch 0:0.033-3.el7 perl-PathTools.x86_64 0:3.40-5.el7 perl-Pod-Escapes.noarch 1:1.04-294.el7_6 perl-Pod-Perldoc.noarch 0:3.20-4.el7 perl-Pod-Simple.noarch 1:3.28-4.el7 perl-Pod-Usage.noarch 0:1.63-3.el7 perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 perl-Socket.x86_64 0:2.010-4.el7 perl-Storable.x86_64 0:2.45-3.el7 perl-Text-ParseWords.noarch 0:3.29-4.el7 perl-Time-HiRes.x86_64 4:1.9725-3.el7 perl-Time-Local.noarch 0:1.2300-2.el7 perl-constant.noarch 0:1.27-2.el7 perl-libs.x86_64 4:5.16.3-294.el7_6 perl-macros.x86_64 4:5.16.3-294.el7_6 perl-parent.noarch 1:0.225-244.el7 perl-podlators.noarch 0:2.5.1-3.el7 perl-threads.x86_64 0:1.87-4.el7 perl-threads-shared.x86_64 0:1.43-6.el7 Complete! [root@node102.yinzhengjie.org.cn ~]#
3>.开启Nginx的监控并启用该服务
[root@node102.yinzhengjie.org.cn ~]# cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf-`date +%F` [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# cat /etc/nginx/nginx.conf user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; include /etc/nginx/conf.d/*.conf; server { listen 80 default_server; listen [::]:80 default_server; server_name _; root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { } #注意,下面一段是开启Nginx的监控! location /nginx_status { stub_status on; access_log off; allow 172.30.1.0/24; deny all; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } } [root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# systemctl start nginx [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# systemctl status nginx ● nginx.service - The nginx HTTP and reverse proxy server Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled) Active: active (running) since Tue 2019-05-07 08:53:00 PDT; 4s ago Process: 13320 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS) Process: 13316 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS) Process: 13314 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS) Main PID: 13322 (nginx) CGroup: /system.slice/nginx.service ├─13322 nginx: master process /usr/sbin/nginx ├─13323 nginx: worker process └─13324 nginx: worker process May 07 08:53:00 node102.yinzhengjie.org.cn systemd[1]: Starting The nginx HTTP and reverse proxy server... May 07 08:53:00 node102.yinzhengjie.org.cn nginx[13316]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok May 07 08:53:00 node102.yinzhengjie.org.cn nginx[13316]: nginx: configuration file /etc/nginx/nginx.conf test is successful May 07 08:53:00 node102.yinzhengjie.org.cn systemd[1]: Started The nginx HTTP and reverse proxy server. [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# netstat -lnpt | grep 80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 13322/nginx: master tcp6 0 0 :::80 :::* LISTEN 13322/nginx: master [root@node102.yinzhengjie.org.cn ~]#
二.zabbix监控Nginx配置
1>.编写zabbix端的配置文件
[root@node102.yinzhengjie.org.cn ~]# grep Include /etc/zabbix/zabbix_agentd.conf | grep -v ^# Include=/etc/zabbix/zabbix_agentd.d/*.conf [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# cat /etc/zabbix/zabbix_agentd.d/nginx_monitor.conf UserParameter=NGINX_STATUS[*],/etc/zabbix/zabbix_agentd.d/nginx_monitor.sh $1 [root@node102.yinzhengjie.org.cn ~]#
2>.编写Nginx的监控脚本
[root@node102.yinzhengjie.org.cn ~]# cat /etc/zabbix/zabbix_agentd.d/nginx_monitor.sh NGINX_PORT=80 NGINX_COMMAND=$1 nginx_active(){ /usr/bin/curl -s "http://127.0.0.1:"$NGINX_PORT"/nginx_status/" |awk '/Active/ {print $NF}' } nginx_reading(){ /usr/bin/curl -s "http://127.0.0.1:"$NGINX_PORT"/nginx_status/" |awk '/Reading/ {print $2}' } nginx_writing(){ /usr/bin/curl -s "http://127.0.0.1:"$NGINX_PORT"/nginx_status/" |awk '/Writing/ {print $4}' } nginx_waiting(){ /usr/bin/curl -s "http://127.0.0.1:"$NGINX_PORT"/nginx_status/" |awk '/Waiting/ {print $6}' } nginx_accepts(){ /usr/bin/curl -s "http://127.0.0.1:"$NGINX_PORT"/nginx_status/" |awk 'NR==3 {print $1}' } nginx_handled(){ /usr/bin/curl -s "http://127.0.0.1:"$NGINX_PORT"/nginx_status/" |awk 'NR==3 {print $2}' } nginx_requests(){ /usr/bin/curl -s "http://127.0.0.1:"$NGINX_PORT"/nginx_status/" |awk 'NR==3 {print $3}' } case $NGINX_COMMAND in active) nginx_active; ;; reading) nginx_reading; ;; writing) nginx_writing; ;; waiting) nginx_waiting; ;; accepts) nginx_accepts; ;; handled) nginx_handled; ;; requests) nginx_requests; ;; *) echo $"USAGE:$0 {active|reading|writing|waiting|accepts|handled|requests}" esac [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]#
[root@node102.yinzhengjie.org.cn ~]# ll /etc/zabbix/zabbix_agentd.d/nginx_monitor.sh -rw-r--r-- 1 root root 1147 May 7 09:06 /etc/zabbix/zabbix_agentd.d/nginx_monitor.sh [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# chmod +x /etc/zabbix/zabbix_agentd.d/nginx_monitor.sh [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# ll /etc/zabbix/zabbix_agentd.d/nginx_monitor.sh -rwxr-xr-x 1 root root 1147 May 7 09:06 /etc/zabbix/zabbix_agentd.d/nginx_monitor.sh [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]#
3>.重启zabbix agent端的服务
[root@node102.yinzhengjie.org.cn ~]# systemctl restart zabbix-agent [root@node102.yinzhengjie.org.cn ~]# [root@node102.yinzhengjie.org.cn ~]# systemctl status zabbix-agent ● zabbix-agent.service - Zabbix Agent Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2019-05-07 09:10:49 PDT; 3min 49s ago Process: 14645 ExecStop=/bin/kill -SIGTERM $MAINPID (code=exited, status=0/SUCCESS) Process: 14648 ExecStart=/usr/sbin/zabbix_agentd -c $CONFFILE (code=exited, status=0/SUCCESS) Main PID: 14650 (zabbix_agentd) CGroup: /system.slice/zabbix-agent.service ├─14650 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf ├─14651 /usr/sbin/zabbix_agentd: collector [idle 1 sec] ├─14652 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection] ├─14653 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection] ├─14654 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection] └─14655 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec] May 07 09:10:49 node102.yinzhengjie.org.cn systemd[1]: Stopped Zabbix Agent. May 07 09:10:49 node102.yinzhengjie.org.cn systemd[1]: Starting Zabbix Agent... May 07 09:10:49 node102.yinzhengjie.org.cn systemd[1]: Started Zabbix Agent. [root@node102.yinzhengjie.org.cn ~]#
4>.
5>.
参考链接:https://www.cnblogs.com/lovelinux199075/p/8990538.html
转载于:https://www.cnblogs.com/yinzhengjie/p/10829047.html
最后
以上就是鳗鱼白羊为你收集整理的zabbix Server 4.0 监控Nginx的全部内容,希望文章能够帮你解决zabbix Server 4.0 监控Nginx所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复