You are on page 1of 7

Panduan Instalasi Nagios 3.

03
Panduan ini digunakan untuk instalasi solaris 10, baik SPARC maupun x86, dengan akses root. Untuk instalasi menggunakan sistem Operasi Linux caranya akan berbeda

Download Source
Nagios-3.03 dan Nagios Plugins-1.4.12 http://www.nagios.org/download/ RRdTool rrdtool-1.2.9 http://oss.oetiker.ch/rrdtool/download.en.html CgiLib http://www.infodrom.org/projects/cgilib/download.php PHP php-5.2.6 http://www.php.net/downloads.php Lightweight CGI Library http://www.infodrom.org/projects/cgilib/download.php cgilib-0.5

PNP4Nagios pnp-0.4.10 http://www.pnp4nagios.org/pnp/start PNP4Nagios dengan Rrdtool dapat menampilkan data performa dan grafik yang menarik.

Konfigurasi Pra Install


Set path root dengan:
export PATH=/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/mysql/bin:/usr/sfw/bin:/usr/cc s/bin:/usr/ucb

Set konfigurasi runtime environment


# crle -u -l /usr/local/lib # crle -u -l /usr/local/ssl/lib

Install paket-paket dari Sunfreeware If pkg-get in not installed on your system http://www.bolthole.com/solaris/pkg-get.html After installing pkg-get Code:
# pkg-get -U

then

download

it

here:

Sunfreeware packages Code:


# pkg-get install autoconf-2.62 bison-2.3 coreutils-6.4 expat-2.0.1 \ flex-2.5.4a fontconfig-2.4.2 freetype-2.3.1 gcc-3.4.6 \ gd-2.0.35 gtk+-1.2.10 jpeg-6b libpng-1.2.29 libtool-1.5.24 \ libiconv-1.9.2 libintl-3.4.0 make-3.81 mysql-5.0.51 \ ncurses-5.6 openssl-0.9.8h pkgconfig-0.20 \ zlib-1.2.3 netsnmp-5.4.1.1 libxml2- 2.6.31

Tambahkan group dan user nagios


# groupadd -g 667 nagios # useradd -d /usr/local/nagios -g nagios -u 666 -s /bin/false nagios

Instalasi Nagios
Ekstrak dan compile nagios
# ./configure \

--prefix=/usr/local/nagios \ --enable-event-broker \ --with-gd-lib=/usr/local/lib \ --with-gd-inc=/usr/local/include \ --with-nagios-user=nagios \ --with-nagios-group=nagios \ --with-command-user=webservd \ --with-command-group=webservd \ --with-checkresult-dir=/usr/local/nagios/tmp/results \ --with-temp-dir=/usr/local/nagios/tmp \ --with-init-dir=/etc/init.d \ --with-lockfile=/usr/local/nagios/var/nagios.lock \ --with-cgiurl=/nagios/cgi-bin \ --with-htmurl=/nagios

Selanjutnya
# # # # # make make make make make all install install-init install-commandmode install-config

Konfigurasi Pasca install


Solaris 10 menggunakan Apache2
# cp /etc/apache2/httpd.conf-example /etc/apache2/httpd.conf

Tambahkan baris berikut pada bagian akhir file http.conf


ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin <Directory "/usr/local/nagios/sbin"> Options ExecCGI AllowOverride None Order allow,deny Allow from all AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user </Directory> Alias /nagios /usr/local/nagios/share <Directory "/usr/local/nagios/share"> Options None AllowOverride None Order allow,deny Allow from all AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user </Directory>

Cek konfigurasi httpd.conf


# /usr/apache2/bin/apachectl configtest Syntax OK

Aktifkan apache2 kemudian periksa


# svcadm enable http

# svcs -a http svcs: -a ignored when used with arguments. STATE STIME FMRI online 12:10:19 svc:/network/http:apache2

Buat file htpasswd.users


# /usr/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.users <username > # New password: # Re-type new password: Adding password for user <username>

Uji coba Nagios


# /etc/init.d/nagios checkconfig Running configuration check...Killed CONFIG ERROR! Check your Nagios configuration.

Apabila anda mendapatkan error seperti ini, artinya library yang dibutuhkan belum ter-link dengan benar. Gunakan perintah crle untuk me-link library yang dibutuhkan
/lib:/usr/lib:/usr/local/lib:/usr/local/ssl/lib

Output perintah crle Periksa ulang library yang dibutuhkan nagios </code> # ldd /usr/local/nagios/bin/nagios libm.so.2 /lib/libm.so.2 libpthread.so.1 /lib/libpthread.so.1 libltdl.so.3 (file not found) librt.so.1 /lib/librt.so.1 libglib-2.0.so.0 /usr/lib/libglib-2.0.so.0 libc.so.1 /lib/libc.so.1 libaio.so.1 /lib/libaio.so.1 libmd.so.1 /lib/libmd.so.1 </code> Perhatikan bagian file not found setelah kita gunakan perintah crle, coba periksa kembali
# ldd /usr/local/nagios/bin/nagios libm.so.2 => /lib/libm.so.2 libpthread.so.1 => /lib/libpthread.so.1 libltdl.so.3 => /usr/local/lib/libltdl.so.3 librt.so.1 => /lib/librt.so.1 libc.so.1 => /lib/libc.so.1 libdl.so.1 => /usr/lib/libdl.so.1 libgcc_s.so.1 => /usr/local/lib/libgcc_s.so.1 libaio.so.1 => /lib/libaio.so.1 libmd.so.1 => /lib/libmd.so.1

Kemudian periksa kembali konfigurasi nagios


# /etc/init.d/nagios checkconfig Running configuration check... OK.

Mulai service nagios


# /etc/init.d/nagios start -n Starting nagios: done.

Periksa log nagios


# tail /usr/local/nagios/var/nagios.log [1214068735] Nagios 3.0.2 starting... (PID=13222) [1214068735] Local time is Sat Jun 21 12:18:55 CDT 2008

[1214068735] LOG VERSION: 2.0 [1214068735] Finished daemonizing... (New PID=13223) [1214068735] Error: Could not create external command file '/usr/local/nagios/var/rw/nagios.cmd' as named pipe: (13) -> Permission denied. If this file already exists and you are sure that another copy of Nagios is not running, you should delete this file. [1214068735] Bailing out due to errors encountered while trying to initialize the external command file... (PID=13223)

Ternyata pada log, menunjukkan nagios gagal memasukkan user nagios kedalam group webservd
# usermod -G webservd nagios

berjalan.

Kita

harus

Hal ini dikarenakan webservd memiliki hak akses pada folder rw, sehingga dapat menjalankan perintah dari web
# pwd /usr/local/nagios/var # ls -al total 64 drwxrwxr-x 4 nagios drwxr-xr-x 9 root drwxrwxr-x 2 nagios -rw-r--r-1 nagios -rw-r--r-1 nagios -rw-r--r-1 nagios drwxrwsr-x 2 webservd -rw-rw-r-1 nagios

nagios 512 Jun 21 12:21 . root 512 Jun 21 12:04 .. nagios 512 Jun 21 12:03 archives nagios 6 Jun 21 12:19 nagios.lock nagios 755 Jun 21 12:19 nagios.log nagios 12943 Jun 21 12:19 objects.cache webservd 512 Jun 21 12:19 rw nagios 13165 Jun 21 12:21 status.dat

# tail /usr/local/nagios/var/nagios.log [1214068797] Nagios 3.0.2 starting... (PID=13237) [1214068797] Local time is Sat Jun 21 12:19:57 CDT 2008 [1214068797] LOG VERSION: 2.0

Sekarang nagios dan apache2 sudah berjalan dengan baik Sekarang kita mencoba mengakses gui nagios http://no_ip/nagios. Apabila muncul pesan berikut; via web. Contoh;

Web Page Banner It appears as though you do not have permission to view information for any of the hosts you requested... If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI and check the authorization options in your CGI configuration file. It tells us what to do.. Mod the cgi file..

Artinya user belum memiliki hak akses untuk melihat informasi pada web nagios. Untuk memberikan akses tersebut edit file berikut;
# vi /usr/local/nagios/etc/cgi.cfg

Kemudian masukkan username yang dapat mengakses halaman web nagios Selanjutnya refresh browser anda.

Compile nagios-plugin
Download nagios plugin yang terbaru dari sourceforge.com
# wget http://internap.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins1.4.12.tar.gz

mysql juga harus telah dikonfigurasi dengan baik agar proses kompile dapat berjalan dengan baik
# ./configure \ --prefix=/usr/local/nagios \ --with-nagios-user=nagios \ --with-nagios-group=nagios \ --with-cgiurl=/nagios/cgi-bin \ --with-openssl=/usr/local/ssl \ --with-mysql=/usr/local/mysql/bin/mysql_config \ --with-snmpget-command=/usr/local/bin/snmpget \ --with-snmpgetnext-command=/usr/local/bin/snmpgetnetxt # make # make install

Check to see that are plugins are there: Code: # ls /usr/local/nagios/libexec check_apt check_file_age check_load check_ntp_peer check_rpc check_udp check_breeze check_flexlm check_log check_ntp_time check_sensors check_ups check_by_ssh check_ftp check_mailq check_nwstat check_simap check_users check_clamd check_hpjd check_mrtg check_oracle check_smtp check_wave check_cluster check_http check_mrtgtraf check_overcr check_snmp negate check_dig check_ifoperstatus check_nagios check_pgsql check_spop urlize check_disk check_ifstatus check_nntp check_ping check_ssh utils.pm check_disk_smb check_imap check_nntps check_pop check_ssmtp utils.sh check_dns check_ircd check_nt check_procs check_tcp check_dummy check_jabber check_ntp check_real check_time Compile php (note: php will not compile in a sparse root zone) Code: # ./configure \ prefix=/usr/local \ with-apxs2=/usr/apache2/bin/apxs \ withopenssl=/usr/local/ssl \ with-gd=/usr/local \ with-jpeg-dir=/usr/local \ withpng-dir=/usr/local \ with-freetype-dir=/usr/local \ with-zlib=/usr/local \ withpear Looks like everything configured ok.. # make # make test (states that I may have found a bug in PHP) # make install Add to /etc/apache2/httpd.conf Quote: LoadModule php5_module libexec/libphp5.so DirectoryIndex index.html index.html.var index.php AddType application/x-httpd-php .php Check apache2 Code: # /usr/apache2/bin/apachectl configtest [Sat Jun 21 20:12:06 2008] [warn] module php5_module is already loaded, skipping Syntax OK Install rrdtool I tried the sunfreeware package 1.3.0 but it was missing something at the end could not find a path (which existed) So went back to 1.2.9 Rrdtool (this version) uses cgilib-0.5.tar.gz Add to Makefile Code: CC=gcc then # make # cp libcgi.a /usr/local/lib # cp cgi.h /usr/local/include Rrdtool 1.2.9 Code:

# ./configure # make # make install Pnp4nagios Code: # ./configure \ prefix=/usr/local/nagios \ with-nagios-user=nagios \ withnagios-group=nagios \ with-rrdtool=/usr/local/rrdtool-1.2.9/bin/rrdtool Change the permissions if needed # chown -R nagios:nagios /usr/local/nagios/var/rrd # make all # make install # make install-init # make-nstall-config Now make changes to the nagios.cfg Quote: process_performance_data=0 to process_performance_data=1 Change

Uncomment #host_perfdata_command=process-host-perfdata #service_perfdata_command=process-service-perfdata Change #host_perfdata_file=/tmp/host-perfdata #service_perfdata_file=/tmp/service-perfdata to host_perfdata_file=/usr/local/nagios/tmp/host-perfdata service_perfdata_file=/usr/local/nagios/tmp/service-perfdata Commands.cfg Comment out # 'process-host-perfdata' command definition ##define command{ ## command_name process-host-perfdata ## command_line /usr/bin/printf %b $LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTAT TEMPT$\t$HOSTSTATETYPE$ \t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA $\n /usr/local/nagios/var/host-perfdata.out ## } # 'process-service-perfdata' command definition ##define command{ ## command_name process-service-perfdata ## command_line /usr/bin/printf %b $LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$S ERVICESTATE$\t$SERVICEA TTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME $\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERF DATA$\n >> /usr/l ocal/nagios/var/service-perfdata.out ## } Add define command{ command_name process-host-perfdata command_line /usr/local/nagios/libexec/process_perfdata.pl -d HOSTPERFDATA } define command{ command_name process-service-perfdata command_line /usr/local/nagios/libexec/process_perfdata.pl } Edit templates.cfg Add to generic-host HOST Template host=$HOSTNAME$ action_url /nagios/pnp/index.php?

Add to generic-servic Sevice Template action_url /nagios/pnp/index.php? host=$HOSTNAME$&srv=$SERVICEDESC$ In /usr/local/nagios/etc/pnp Code: # cp rra.cfg-sample rra.cfg # cp process_perfdata.cfg-sample process_perfdata.cfg # cp npcd.cfg-sample npcd.cfg

Change permissions on the nagios tmp directory # chown -R nagios:nagios /usr/local/nagios/tmp You now have a very basic setup of Nagios running on a Solaris 10 box. The configuration file is locahost.cfg Use the localhost.cfg as a starting point to make other *.cfg files Note: Check_swap check_local_procs do not work out of the box.. Diterjemahkan dari http://daemonforums.org/showthread.php?p=10481

You might also like