การติดตั้ง NRPE บน Ubuntu 14.04

เพื่อไม่ให้เสียเวลามาเริ่มกันเลยครับ วิธีการติดตั้ง Nrpe บน Ubuntu 14.04 1) ทำการติดตั้งโปรแกรม nrpe (มองว่าเป็น server ให้ nagios มาเรียกเพื่อดึงค่า) ดังนี้ sudo apt-get install -y nagios-nrpe-server 2) ทำการแก้ config /etc/nagios/nrpe.cfg เพื่อใส่ชื่อเครื่องที่อนุญาตให้มาดึงค่าได้ ดังนี้ sudo nano /etc/nagios/nrpe.cfg … # # NOTE: This option is ignored if NRPE is running under either inetd or xinetd allowed_hosts=127.0.0.1,monitor 3) จากนั้นทำการ Restart nrpe ดังนี้ sudo /etc/init.d/nagios-nrpe-server restart 4) ให้กลับไปดูใน web nagios จะพบว่ามีการแสดงข้อมูลในส่วนของ nrpe (ในกรณีที่สร้าง service nrpe เรียบร้อยแล้ว) ยกตัวอย่างวิธีการเพิ่ม Plugin ให้กับ nrpe บน Ubuntu 14.04 plugin ที่ให้มายังไม่มีในส่วนของการ monitor memory โดยให้สร้างใน path /usr/lib/nagios/plugins/ และทำการสร้าง command เพิ่มเติมในไฟล์ /etc/nagios/nrpe.cfg ประมาณนี้ cd /usr/lib/nagios/plugins sudo wget http://ftp.psu.ac.th/pub/psu-monitor/check_mem.sh sudo chmod ugo+x check_mem.sh sudo nano /etc/nagios/nrpe.cfg … command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200 command[check_mem]=/usr/lib/nagios/plugins/check_mem.sh 85 95

Read More »

วิธีการตั้งค่า NRPE เพื่อใช้งานกับ NagiosQL บน Ubuntu 14.04 LTS

สำหรับการใช้งาน NRPE ต้องทำการติดตั้ง Nagios และ NagiosQL มาก่อนดังนี้ Nagios : http://sysadmin.psu.ac.th/2014/07/23/nagios-ubuntu1404/ NagiosQL : http://sysadmin.psu.ac.th/2014/07/23/nagiosql-ubuntu/ Setup NagiosQL : http://sysadmin.psu.ac.th/2014/07/23/setup-nagiosql-ubuntu/ วิธีการติดตั้ง Nrpe และการตั้งค่าบน NagiosQL 1) ทำการติดตั้งโปรแกรม nrpe ดังนี้ sudo apt-get install -y nagios-nrpe-plugin 2) ทำการ Login เข้า Web NagiosQL โดยจะยกตัวอย่างการเพิ่ม nrpe เกี่ยวกับการ Check Load Linux 3) ทำการเพิ่ม command ใหม่ดังนี้ Commands -> Definitions Command : check_linux_load Command line : $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_load Command type : check command 4) ทำการเพิ่มข้อมูล Service ให้กับ Host ชื่อ Linux-Server Supervision -> Services 5) ทำการตั้งค่า Service โดยคราวนี้จะเลือก Add Service เพิ่มเข้าไปใน Host groups linux-server แทน เมื่อเพิ่มเครื่องเข้าไปใน Host groups จะได้ service นี้ติดไปด้วยเสมอ (เป็นการบังคับว่าต้องลง nrpe agent ไม่งั้นจะฟ้องว่า service down) 6) ทำการเพิ่ม เครื่อง Linux-Server ใน Host Groups -> linux servers โดยให้เอา localhost ออกจาก Host Groups ด้วย (กันความสับสน) 7) จากนั้นทำ Save และทดสอบ เข้าไป Restart Nagios Tools -> Nagios control -> Check Written configuration files 8) หลังจากนั้นทดสอบเข้า web nagios ดูจะพบว่า Service CPU Load เพิ่มขึ้นมาเรียบร้อยแล้ว ตอนนี้ยังไม่สามารถใช้งานได้ต้องทำการลง Agent ที่เครื่อง Linux ปลายทางก่อนซึ่งจะอยู่ในหัวข้อต่อไป ในส่วนของ Windows วิธีการจะคล้าย ๆ กัน ต่างกันที่ Command ซึ่งจะเป็นการเรียกเพื่อรันโปรแกรมที่อยู่ปลายทาง ซึ่งแต่ละ Command อาจต้องใส่ argument ซึ่งบาง command สามารถแก้ที่ตัวปลายทางได้เลย ทำให้ command เดียวกันแต่ตั้งค่า warning critical ที่แตกต่างได้ แล้วแต่ปลายทางจะตั้ง

Read More »

การติดตั้งและการตั้งค่าเบื้องต้น NagiosGraph บน Ubuntu 14.04 LTS

สำหรับการติดตั้ง NagiosGraph ต้องทำการติดตั้ง Nagios และ NagiosQL มาก่อนดังนี้ Nagios : http://sysadmin.psu.ac.th/2014/07/23/nagios-ubuntu1404/ NagiosQL : http://sysadmin.psu.ac.th/2014/07/23/nagiosql-ubuntu/ Setup NagiosQL : http://sysadmin.psu.ac.th/2014/07/23/setup-nagiosql-ubuntu/ วิธีการติดตั้ง Nagios Graph 1) ทำการติดตั้งโปรแกรม Perl-GD Perl-RRDs และ Perl-Nagios รวมถึงโปรแกรม rrdtool ดังนี้ sudo apt-get install -y rrdtool libgd-perl librrds-perl libnagios-object-perl 2) ทำการ Download  โปรแกรม NagiosGraph ดังนี้ cd /usr/src sudo wget http://downloads.sourceforge.net/project/nagiosgraph/nagiosgraph/1.5.1/nagiosgraph-1.5.1.tar.gz 3) จากนั้นทำการแตกไฟล์ออกมาด้วยคำสั่ง sudo tar -xvzf nagiosgraph-1.5.1.tar.gz 4) จากนั้นทำการตรวจสอบความพร้อมก่อนติดตั้งด้วยคำสั่ง cd nagiosgraph-1.5.1 sudo ./install.pl –check-prereq 5) ถ้าไม่มี Error อะไรให้ทำการติดตั้งโดยใช้คำสั่ง sudo ./install.pl –install 6) Enter ไปเรื่อย ๆ ก็จะเสร็จสิ้นกระบวนการติดตั้ง (แต่ยังต้องมีการตั้งค่า nagios ต่อไป) วิธีการตั้งค่า Config nagios เพื่อเปิดใช้งานตัวเก็บ Log 1) ทำการเปิด NagiosQL ขึ้นมา หรือทำการแก้ไขไฟล์ /etc/nagios3/nagios.cfg 2) ทำการแก้ไขไฟล์ของ nagios ให้มาเรียก configuration ของ nagiosql ดังนี้ Tools -> Nagios config -> Nagios main configuration file 3) เพิ่มข้อความบรรทัดสุดท้ายดังนี้ # process nagios performance data using nagiosgraph process_performance_data=1 service_perfdata_file=/tmp/perfdata.log service_perfdata_file_template=$LASTSERVICECHECK$||$HOSTNAME$||$SERVICEDESC$||$SERVICEOUTPUT$||$SERVICEPERFDATA$ service_perfdata_file_mode=a service_perfdata_file_processing_interval=30 service_perfdata_file_processing_command=process-service-perfdata-for-nagiosgraph 4) จากนั้นทำการ Save ข้อมูลและสั่ง Restart nagios ดังรูป Tools -> Nagios control -> Check Written configuration files 5) เราสามารถตรวจสอบการทำงานได้ดังนี้ (กด Ctrl-C เพื่อยกเลิกการทำงาน) sudo tail -f /tmp/perfdata.log 6) ถ้ามีการเคลื่อนไหวของข้อมูลถือว่าใช้งานได้ วิธีการตั้งค่า services ผ่าน NagiosQL 1) ทำการแก้ไขข้อมูล Service Template ดังนี้ Supervision -> Service templates 2) ทำการแก้ไข Action URL เพื่อให้สามารถคลิกดูกราฟได้จากหน้า Nagios ดังนี้ Action URL : /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$ 3) ทำการเพิ่ม command ใหม่ดังนี้ Commands -> Definitions Command : process-service-perfdata-for-nagiosgraph Command line : /usr/local/nagiosgraph/bin/insert.pl 4) จากนั้นทำการ Save ข้อมูลและสั่ง Restart nagios เหมือนเดิม Tools -> Nagios control -> Check Written configuration files วิธีการตั้งค่า Apache Site 1) ทำการ copy site config ดังนี้

Read More »

วิธีการตั้งค่าและการใช้งาน NagiosQL บน Ubuntu 14.04 LTS

สามารถอ่านวิธีติดตั้ง NagiosQL บน Ubuntu 14.04 LTS ได้ที่ http://sysadmin.psu.ac.th/2014/07/23/nagiosql-ubuntu/ หลังจากการติดตั้งจะต้องมีการตั้งค่าให้สามารถควบคุม Nagios ได้ดังนี้ วิธีการตั้งค่า Nagiosql configuration 1) หลังจาก Login ให้ทำการเข้าไปแก้ไข config path ดังนี้ Administrator -> Config targets -> Configuration directories Nagios base directory -> /etc/nagios3 Import Directory -> /etc/nagios3/conf.d Nagios command file -> /var/lib/nagios3/rw/nagios.cmd Nagios binary file -> /usr/sbin/nagios3 Nagios process file -> /var/run/nagios3/nagios3.pid Nagios config file -> /etc/nagios3/nagios.cfg 2) จากนั้นทำการ save config โดยการกดปุ่ม Save ตามรูป 3) หลังจากทำการ save จะปรากฎข้อความดังรูป 4) ทำการแก้ไขไฟล์ของ nagios ให้มาเรียก configuration ของ nagiosql (ยกเว้น nagios config, cgi config ที่ยังใช้ของ nagios อยู่ เนื่องจากเป็น config ของโปรแกรม nagios) Tools -> Nagios config -> Nagios main configuration file 5) ทำการเพิ่มข้อความดังภาพ … log_file=/var/log/nagios3/nagios.log cfg_file=/etc/nagiosql/contacttemplates.cfg cfg_file=/etc/nagiosql/contactgroups.cfg cfg_file=/etc/nagiosql/contacts.cfg cfg_file=/etc/nagiosql/timeperiods.cfg cfg_file=/etc/nagiosql/commands.cfg cfg_file=/etc/nagiosql/hostgroups.cfg cfg_file=/etc/nagiosql/servicegroups.cfg cfg_dir=/etc/nagiosql/hosts cfg_dir=/etc/nagiosql/services cfg_file=/etc/nagiosql/hosttemplates.cfg cfg_file=/etc/nagiosql/servicetemplates.cfg cfg_file=/etc/nagiosql/servicedependencies.cfg cfg_file=/etc/nagiosql/serviceescalations.cfg cfg_file=/etc/nagiosql/hostdependencies.cfg cfg_file=/etc/nagiosql/hostescalations.cfg cfg_file=/etc/nagiosql/hostextinfo.cfg cfg_file=/etc/nagiosql/serviceextinfo.cfg # Commands definitions #cfg_file=/etc/nagios3/commands.cfg # Debian also defaults to using the check commands defined by the debian # nagios-plugins package #cfg_dir=/etc/nagios-plugins/config # Debian uses by default a configuration directory where nagios3-common, # other packages and the local admin can dump or link configuration # files into. #cfg_dir=/etc/nagios3/conf.d … 6) ทำการแก้ค่า check_external_command จาก 0 เป็น 1 ดังนี้ … # EXTERNAL COMMAND OPTION # This option allows you to specify whether or not Nagios should check # for external commands (in the command file defined below).

Read More »

การติดตั้ง NagiosQL บน Ubuntu 14.04 LTS

สำหรับการติดตั้ง NagiosQL ต้องการทำการติดตั้ง PHP5 และ Mysql-Server ก่อนครับ วิธีการติดตั้ง PHP5, MySQL 5.5 1) ทำการติดตั้ง Apache ผ่าน apt-get ดังนี้ครับ sudo apt-get install -y php5 mysql-server php5-mysql 2) จะปรากฎข้อความถามว่าจะให้ตั้งรหัสผ่าน root ให้ใส่รหัสผ่านที่ต้องการ 3) จากนั้นให้สั่ง Restart Apache ตามปกติ sudo service apache2 restart 4) ทำการแก้ไขไฟล์ /etc/php5/apache2/php.ini เพื่อแก้ไข timezone ดังนี้ sudo nano /etc/php5/apache2/php.ini 5) ทำการเพิ่มข้อความในส่วนของ [Date] ดังนี้ (ประมาณบรรทัดที่  879) [Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone ;date.timezone = date.timezone = Asia/Bangkok 6) จากนั้นให้สั่ง Restart Apache อีกครั้ง sudo service apache2 restart ขั้นตอนการเตรียมการติดตั้ง NagiosQL 1) ทำการ Download โปรแกรม 3 File ดังนี้ cd /usr/src Download Nagios 3.2.0 Main File sudo wget http://downloads.sourceforge.net/project/nagiosql/nagiosql/NagiosQL%203.2.0/nagiosql_320.tar.gz Nagios 3.2.0 Service Pack 1 sudo wget http://downloads.sourceforge.net/project/nagiosql/nagiosql/NagiosQL%203.2.0/nagiosql_320_service_pack_1_additional_fixes_only.zip Nagios 3.2.0 Service Pack 2 sudo wget http://downloads.sourceforge.net/project/nagiosql/nagiosql/NagiosQL%203.2.0/nagiosql_320_service_pack_2_additional_fixes_only.zip 2) ทำการแตกไฟล์ทั้ง 3 ไฟล์ ดังนี้ sudo tar -xvzf nagiosql_320.tar.gz sudo unzip nagiosql_320_service_pack_1_additional_fixes_only.zip sudo unzip nagiosql_320_service_pack_2_additional_fixes_only.zip 3) ทำการสร้าง folder nagiosql และ copy ไฟล์ทั้งหมดไปใส่ดังนี้ sudo mkdir /var/www/html/nagiosql sudo cp -R /usr/src/nagiosql32/* /var/www/html/nagiosql/ sudo cp -R /usr/src/NagiosQL_3.2.0_SP1/* /var/www/html/nagiosql/ sudo cp -R /usr/src/NagiosQL_3.2.0_SP2/* /var/www/html/nagiosql/ 4) ทำการสร้าง directory สำหรับ เก็บ config ไฟล์ดังนี้ sudo mkdir /etc/nagiosql sudo mkdir /etc/nagiosql/hosts sudo mkdir /etc/nagiosql/services sudo mkdir /etc/nagiosql/backup sudo mkdir /etc/nagiosql/backup/hosts sudo mkdir /etc/nagiosql/backup/services 5) ทำการแก้ Permission และ Owner ในแต่ละ Folder ดังนี Nagios configuration sudo chgrp www-data /etc/nagios3 sudo chgrp -R www-data /var/lib/nagios3 sudo chgrp -R www-data /var/run/nagios3 sudo chgrp

Read More »