nginx + Nagios ã®ã¤ã³ã¹ãã¼ã«(å¾ç·¨)
åç·¨ã«ç¶ããä»åã¯Nagiosã®Webã³ã³ã½ã¼ã«è¡¨ç¤ºã«å¿
è¦ãªè¨å®ããã¦ããã¾ãã
configureã¹ã¯ãªãããå®è¡ããæã«è¡¨ç¤ºããã¦ããããã«ã/nagiosã¸ã®ã¨ã¤ãªã¢ã¹ãè¨å®ãã¾ãã
ããã§ãã
Web Interface Options: ------------------------ HTML URL: http://localhost/nagios/ CGI URL: http://localhost/nagios/cgi-bin/ Traceroute (used by WAP): /bin/traceroute
nginxã®ã³ã³ãã£ã°ã«ä¸è¨ã®éã追è¨ãã¾ãã
$ sudo vi /etc/nginx/conf.d/default.conf server { .... .... .... location /nagios { alias /usr/local/nagios/share; index index.php; auth_basic "Nagios Access"; auth_basic_user_file /usr/local/nagios/etc/htpasswd.users; } }
Basicèªè¨¼è¨å®
Basicèªè¨¼ã®ãã¹ã¯ã¼ããã¡ã¤ã«ãä½æãã¾ãã
ãªããããã§è¨å®ããã¦ã¼ã¶IDã«ã¤ãã¦ã¯Webã³ã³ã½ã¼ã«ã§ã®ã¢ã¯ã»ã¹å¶å¾¡ã«ç¨ãã¾ãã
# sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin New password: Re-type new password: Adding password for user nagiosadmin
ã¡ãªã¿ã«ããã£ã¹ããªãã¥ã¼ã·ã§ã³ã®ãã¼ã¸ã§ã³ã«ãã£ã¦ã¯ããã©ã«ãã§Cryptã使ã£ãæå·åããããã®ã§æ°ãã¤ãã¦ãã ããã
é·ããã¹ã¯ã¼ããè¨å®ãã¦ã9æåç®ããã¯å¹æãããã¾ããã
â»Fedora16ã§ã¯MD5ãããã©ã«ãã«ãªã£ã¦ããã®ã§åé¡ããã¾ãã
PHPé¢é£ã®è¨å®
nginxã¯ããã©ã«ãã®ã¾ã¾ã§ã¯PHPãå¦çãã¦ãããªãã®ã§ãphp-fpmã使ã£ã¦è¨å®ãã¦ã¿ã¾ãã
user, groupãapacheã«ãªã£ã¦ããã®ã§nginxã¸ã¨æ¸ãæãã¾ãã
$ sudo vi /etc/php-fpm.d/www.conf user = nginx ; RPM: Keep a group allowed to write in log dir. group = nginx
次ã«nginxã®è¨å®ãå¤æ´ãã¾ãã
$ sudo vi /etc/nginx/conf.d/default.conf location ~ ^/nagios/(.*\.php)$ { alias /usr/local/nagios/share/$1; include /etc/nginx/fastcgi.conf; fastcgi_pass 127.0.0.1:9000; auth_basic "Nagios Access"; auth_basic_user_file /usr/local/nagios/etc/htpasswd.users; }
å¾ã¯php-fpmã®èµ·åãnginxã®åèµ·åãå®æ½ãã¾ãã
$ sudo systemctl start php-fpm.service $ sudo systemctl restart nginx.service
ãã©ã¦ã¶ã§ http://IPã¢ãã¬ã¹/nagios/ ã¸ã¢ã¯ã»ã¹ããã¨Webã³ã³ã½ã¼ã«ã表示ãããããã«ãªãã¾ãã
CGIé¢é£ã®è¨å®
CGIã®å®è¡ã«ã¯spawn-fcgiã¨fcgiwrapãç¨ãã¾ãã
ã¾ãã¯fcgiwrapãã¤ã³ã¹ãã¼ã«ãã¾ãã
$ git clone git://github.com/gnosek/fcgiwrap.git $ cd fcgiwrap $ autoreconf -i $ ./configure && make && sudo make install
ç¶ãã¦spawn-fcgiã®è¨å®ããã¾ãã
$ sudo vi /etc/sysconfig/spawn-fcgi FCGI_SOCKET=/var/run/fcgiwrap.socket FCGI_PROGRAM=/usr/local/sbin/fcgiwrap FCGI_USER=nginx FCGI_GROUP=nginx FCGI_EXTRA_OPTIONS="-M 0700" OPTIONS="-u $FCGI_USER -g $FCGI_GROUP -s $FCGI_SOCKET -S $FCGI_EXTRA_OPTIONS -F 1 -P /var/run/spawn-fcgi.pid -- $FCGI_PROGRAM"
spawn-fcgiãèµ·åãã¦
$ sudo systemctl start spawn-fcgi.service
nginxã«è¨å®ã追å ãã¦
$ sudo vi /etc/nginx/conf.d/default.conf location ~ ^/nagios/(.*\.cgi)$ { root /usr/local/nagios/sbin/; rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break; fastcgi_param AUTH_USER $remote_user; fastcgi_param REMOTE_USER $remote_user; include /etc/nginx/fastcgi.conf; fastcgi_pass unix:/var/run/fcgiwrap.socket; auth_basic "Nagios Access"; auth_basic_user_file /usr/local/nagios/etc/htpasswd.users; }
nginxãåèµ·åãã¦çµããã
$ sudo systemctl restart nginx.service
ããã§ã²ã¨éãã®è¨å®ãçµããã¾ããã
èªåèµ·åè¨å®
æå¾ã«nginx, php-fpm, spawn-fcgiã®èªåèµ·åè¨å®ããã¾ãã
$ sudo systemctl enable nginx.service php-fpm.service spawn-fcgi.service $ sudo chkconfig nagios on
nagiosã®ã¿chkconfigãç¨ãã¦ãã¾ãããä»ãchkconfigã§åé¡ããã¾ããã
native serviceã§ã¯ãªãã¨ãããã¨ã§çµå±ã¯chkconfigãå®è¡ããã¾ãã
nginx.service is not a native service, redirecting to /sbin/chkconfig. Executing /sbin/chkconfig nginx on
ããã§nginx + Nagios ãç¨ããç£è¦ãµã¼ãã®æ§ç¯ãã§ãã¾ããã
ä»å¾ã¯ç£è¦ã§åå¾ãããã¼ã¿ã®ã°ã©ãåãNagiosè¨å®ã®ã«ã¹ã¿ãã¤ãºãç£è¦è¨å®çã«ã¤ãã¦æ¸ãã¦ãããã¨æãã¾ãã