วิธีการตั้งค่าและการใช้งาน 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 »

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

มาเริ่มขั้นตอนการติดตั้งกันเลยครับ โดยก่อนจะติดตั้ง Nagios ต้องทำการติดตั้ง Apache2 ก่อนนะครับ วิธีการติดตั้ง Apache2 Web Server 1) ทำการติดตั้ง Apache ผ่าน apt-get ดังนี้ครับ sudo apt-get install -y apache2 2) ติดตั้ง SSL ให้พิมพ์คำสั่งเพื่อเปิด site ดังนี้ sudo a2enmod ssl sudo a2ensite default-ssl 3) จากนั้นให้สั่ง Restart Apache ตามปกติ sudo service apache2 restart วิธีการติดตั้ง Nagios 1) ติดตั้ง Nagios ดังนี้ sudo apt-get -y install nagios3 2) จะปรากฎหน้าต่างถามเกี่ยวกับการตั้งค่าส่งเมล์ให้เลือกใช้เป็น Internet with smarthost เพื่อส่งเมล์ผ่าน mail relay ดังรูป 3) จะปรากฎหน้าต่างถามว่าจะใส่ email ผู้ส่งว่าอะไรก็ให้ใส่ไปครับ ไม่ต้องมีอยู่จริงก็ได้ครับ 4) ในหน้าต่างต่อไปจะให้ใส่ว่าจะให้ Relay ไปยัง Mail Server ใดให้ใส่ mail server ที่ต้องการ relay 5) จากนั้นจะให้ตั้งรหัสผ่าน ทำการตั้งรหัสผ่านตามที่ต้องการ (User ตั้งต้นชื่อ nagiosadmin) 6) ทำการตั้งรหัสผ่านเพิ่มเติมได้ที่ไฟล์ /etc/nagios3/htpasswd.users ยกตัวอย่างการเพิ่ม  User ชื่อ workshop (ไม่เกี่ยวข้องกับ user ของระบบใช้เข้า web nagios เท่านั้น) ดังนี้ sudo htpasswd /etc/nagios3/htpasswd.users workshop จะปรากฎข้อความให้ใส่รหัสผ่านดังนี้ New password: Re-type new password: Adding password for user workshop 7) สามารถตรวจสอบไฟล์ได้โดยคำสั่ง sudo cat /etc/nagios3/htpasswd.users 8) ทดสอบเปิด Website ดูดังนี้ http://localhost/nagios3 9) จะปรากฎหน้าต่างให้กรอก username และ password ให้กรอกไปตามที่ตั้งไว้ วิธีการ Logout คือปิด browser เท่านั้น 10) จะปรากฎหน้าแรกของ Nagios วิธีการให้ Redirect ไปยัง SSL อัตโนมัติเพื่อความปลอดภัยของรหัสผ่าน 1) ทำเปลี่ยนชื่อไฟล์ หน้า default เก่าของ apache จาก index.html เป็น index.html.ori ดังนี้ sudo mv /var/www/html/index.html /var/www/html/index.html.ori 2) สร้างไฟล์ /var/www/html/index.html ใหม่ ดังนี้ sudo nano /var/www/html/index.html 3) เพิ่มข้อความในไฟล์ดังนี้ (วิธีการ save ให้กด Ctrl-X แล้วกด y แล้ว enter) โดยการใช้งานจริงให้แทนที่ localhost ด้วยชื่อเครื่องจริง <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”> <html> <head> <title>Auto Redirect to nagios</title> <meta http-equiv=”REFRESH” content=”0;url=https://localhost/nagios3″></HEAD> <BODY> Please Wait….. </BODY> </HTML> 4) ทดสอบเปิด Website อีกรอบดังนี้ จะเห็นได้ว่าระบบจะ redirect

Read More »

WorkShop : Server Monitoring

“อาว Server ตายตอนไหนไม่เห็นจะรู้เลย โหลดเยอะละม้าง หรือไม่ก็แรมหมด เสถียรไหมไม่รู้สิ อาวเมื่อคืน disk หมดหรอกเหรอ สงสัย Backup อยู่ม้าง” ถ้าเรามีระบบ Monitor ที่ดีพบคงสามารถตอบคำถามเหล่านี้ได้ง่ายขึ้น และไม่ต้องเจอเหตุการณ์เดิม ๆ ซ้ำ ๆ อีกต่อไป มาถึงอีก 1 workshop เคยเขียนไปแล้วรอบหนึ่ง แต่ตอนนั้นสอนแค่ครึ่งวัน ได้แค่ลง Nagiosql ยังไม่ได้ทำอะไรเป็นชิ้นเป็นอันสักเท่าไหร่ รอบนี้เลยจัดเต็ม 2 วัน ถ้ามีเนื้อหาผิดพลาดประการใดแจ้งได้เลยครับ เดี๋ยวจะแก้ไขให้ครับ (งานร้อน ^.^) Workshop Outline ftp://ftp.psu.ac.th/pub/psu-monitor/workshop-outline.pdf VirtualBox Installation เครื่องที่ใช้ในการทดสอบ (Oracle VM VirtualBox) *แนะนำให้เปิดกับโปรแกรม version ล่าสุด Monitor ** User : workshop , Password : 123456 Linux-Server ** User : monitor , Password : 123456 MS-Server ** User : administrator, Password : 123456 รายละเอียด URL Monitor Linux-Server MS-Server http://ftp.psu.ac.th/pub/psu-monitor/workshop.ova โดยจะแบ่งเป็น 11 ตอนโดยแยกเป็น 11 Blog ดังนี้ ตอนที่ ชื่อตอน ตอนที่ 1 การติดตั้งและการตั้งค่าเบื้องต้น Nagios บน Ubuntu 14.04 LTS ตอนที่ 2 การติดตั้ง NagiosQL บน Ubuntu 14.04 LTS ตอนที่ 3 วิธีการตั้งค่าและการใช้งาน NagiosQL บน Ubuntu 14.04 LTS ตอนที่ 4 การติดตั้งและการตั้งค่าเบื้องต้น NagiosGraph บน Ubuntu 14.04 LTS ตอนที่ 5 วิธีการตั้งค่า NRPE เพื่อใช้งานกับ NagiosQL บน Ubuntu 14.04 LTS ตอนที่ 6 การติดตั้ง NRPE บน Ubuntu 14.04 ตอนที่ 7 การติดตั้ง NRPE บน Windows 2012 R2 ตอนที่ 8 การติดตั้งโปรแกรมและการตั้งค่าเบื้องต้น Cacti บน Ubuntu 14.04 LTS ตอนที่ 9 การติดตั้ง snmpd และการตั้งค่า shorewall บน Ubuntu 14.04 LTS ตอนที่ 10 การติดตั้ง snmp service และการตั้งค่า firewall บน Windows 2012 R2 ตอนที่ 11 เรียนรู้วิธีการใช้งาน Cacti เพื่อ Monitor Server บทความเพิ่มเติม ยังไม่มี  

Read More »