모니터링 구축( Munin ) 설치 및 설정하기

이메일을 통한 Smartctl알림 설정과 SSH원격접속을 통해 디스크의 상태등을 알아볼 수 있지만

Munin이라는 패키지를 이용해서 웹사이트를 이용해서 실시간으로 NAS를 모니터링할 수 있다.

이를 이용하기 위해서

apt-get install munin munin-node

명령어를 통해서 패키지를 설치해준다. 그 후,

sudo vim /etc/munin/munin.conf

명령어를 통해 munin설정파일을 열어준 뒤,

dbdir /var/lib/munin
htmldir /var/cache/munin/www
logdir /var/log/munin
rundir /var/run/munin

부분의 주석을 제거해 준다.

graph_strategy cgi
html_strategy cgi
cgiurl_graph /cgi-bin/munin-cgi-graph

그래프 확대기능을 이용하려면 위의 코드를 추가해준다.

자세한 설정은 Munin optimalization on Debian를 참고하기 바란다.

그 후,

sudo /etc/apache2/sites-available/munin.conf

를 통해 apache conf파일을 생성한 뒤

<VirtualHost *:80>
 ServerName <도메인 이름>
 ServerAlias munin
 Alias /static /var/cache/munin/www/static
 Alias /munin /var/cache/munin/www
 Documentroot /var/cache/munin/www

 <Directory "/var/cache/munin/www/">
 Order allow,deny
 Allow from all
 AllowOverride None
 options FollowSymLinks SymLinksIfOwnerMatch
 AuthUserFile webdav.pwd
 AuthName "WebDAV"
 AuthType Basic
 require user <유저이름>
 </Directory>

 <IfModule !mod_rewrite.c>
 # required because we serve out of the cgi directory and URLs are relative
 Alias /munin-cgi/munin-cgi-html/static /var/cache/munin/www/static
 RedirectMatch ^/$ /munin-cgi/munin-cgi-html/
 </IfModule>

 <IfModule mod_rewrite.c>
 # Rewrite rules to serve traffic from the root instead of /munin-cgi
 RewriteEngine On

 RewriteRule ^/(.*)/static/(.*) /static/$2 [L,R]

 # Static files
 RewriteRule ^/favicon.ico /var/cache/munin/www/static/favicon.ico [L]
 RewriteRule ^/static/(.*) /var/cache/munin/www/static/$1 [L]

 # HTML
 RewriteRule ^(/.*\.html)?$ /munin-cgi/munin-cgi-html/$1 [PT]

 # Images
 RewriteRule ^/munin-cgi/munin-cgi-graph/(.*) /$1
 RewriteCond %{REQUEST_URI} !^/static
 RewriteRule ^/(.*.png)$ /munin-cgi/munin-cgi-graph/$1 [L,PT]
 </IfModule>

 # Ensure we can run (fast)cgi scripts
 ScriptAlias /munin-cgi/munin-cgi-graph /usr/lib/munin/cgi/munin-cgi-graph
 <Location /munin-cgi/munin-cgi-graph>
 Options +ExecCGI
 <IfModule mod_fcgid.c>
 SetHandler fcgid-script
 </IfModule>
 <IfModule mod_fastcgi.c>
 SetHandler fastcgi-script
 </IfModule>
 <IfModule !mod_fastcgi.c>
 <IfModule !mod_fcgid.c>
 SetHandler cgi-script
 </IfModule>
 </IfModule>
 Order allow,deny
 Allow from all
 AllowOverride None
 Options FollowSymLinks SymLinksIfOwnerMatch
 AuthUserFile webdav.pwd
 AuthName "WebDAV"
 AuthType Basic
 require user <유저이름>

 # Replace above with "Require all granted" if running apache 2.4
 </Location>

 ScriptAlias /munin-cgi/munin-cgi-html /usr/lib/munin/cgi/munin-cgi-html
 <Location /munin-cgi/munin-cgi-html>
 Options +ExecCGI
 <IfModule mod_fcgid.c>
 SetHandler fcgid-script
 </IfModule>
 <IfModule mod_fastcgi.c>
 SetHandler fastcgi-script
 </IfModule>
 <IfModule !mod_fastcgi.c>
 <IfModule !mod_fcgid.c>
 SetHandler cgi-script
 </IfModule>
 </IfModule>
 Order allow,deny
 Allow from all
 AllowOverride None
 Options FollowSymLinks SymLinksIfOwnerMatch
 AuthUserFile webdav.pwd
 AuthName "WebDAV"
 AuthType Basic
 require user <유저이름>

 # Replace above with "Require all granted" if running apache 2.4
 </Location>

 <IfModule !mod_rewrite.c>
 <Location /munin-cgi/munin-cgi-html/static>
 # this needs to be at the end to override the above sethandler directives
 Options -ExecCGI
 SetHandler None
 </Location>
 </IfModule>
</VirtualHost>

을 추가해준뒤 저장한다.

AuthUserFile webdav.pwd
AuthName “WebDAV”
AuthType Basic
require valid-user

인 부분이 있는데 이는 이전에 WebDAV라는 Passwd파일을 생성했기때문에

그를 이용해 적용했지만 만약 WebDAV를 건너뛰었거나 새로운 계정을 통해 접속하고 싶다면

이 곳을 참고해 새로 생성하기 바란다.

그 후

sudo a2ensite munin.conf
sudo /etc/init.d/apache2 restart

명령어를 통해서 munin을 활성화 시켜준뒤 아파치를 재시작시켜준다.

그 후  HTTPS설정을 추가적으로 해주면 모든 설정이 완료된다.

[ezcc]

 

답글 남기기

이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.