Tag: gui

  • วิธีการตั้งค่าและการใช้งาน 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 จะปรากฎข้อความดังรูป

    2014-07-23_200526

    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). By default
    # Nagios will *not* check for external commands, just to be on the
    # cautious side. If you want to be able to use the CGI command interface
    # you will have to enable this.
    # Values: 0 = disable commands, 1 = enable commands
    
    check_external_commands=1
    
    ...

    7) จากนั้นทำการ save config โดยการกดปุ่ม Save ตามรูป

    2014-07-23_203407

    8) เนื่องจาก Nagios มี config ของตัวเองอยู่แล้ว ให้ทำการ Import Data ของ Nagios มาไว้ด้วยดังนี้

    8.1) ทำการ Import Data จาก /etc/nagios3/conf.d ซึ่งได้ตั้งค่า Import directory ไว้แล้วตามข้อ 1)

    Tools -> Data import -> Configuration Import

    – จากนั้นทำการ กดปุ่ม Import ดังรูป

    8.2) ทำการ Import Data จาก /etc/nagios-plugins/config ซึ่งต้องทำการตั้งค่า Import directory ใหม่ดังรูป

    – จากนั้นทำการ กดปุ่ม Import ดังรูป

    Administrator -> Config targets -> Configuration directories

    2014-07-23_204140– จากนั้นกลับไป Import Data อีกครั้งดังนี้

    Tools -> Data import -> Configuration Import

    – จากนั้นทำการ กดปุ่ม Import ดังรูป

    2014-07-23_204610

    9) จากนั้นทำการ Save ข้อมูลจากฐานข้อมูลทั้งหมดลง config file และทำการทดสอบ config และสั่ง Restart nagios ดังรูป

    Tools -> Nagios control -> Check Written configuration files

    2014-07-23_214921

    10) ทดสอบเข้า web nagios เพื่อตรวจสอบผลการ Import configuration

    การตั้งค่า Alert mail

    1) ทำการแก้ไข Contact name : nagiosadmin

    Alerting -> Contact data

    2014-07-23_222435

    2) ทำการเพิ่มข้อมูลดังรูป โดยรายละเอียกที่ต้องการให้ส่งสามารถเลือกได้ที่ Host command และ Service command สำหรับ profile default ของ nagiosadmin จะส่งทั้งหมด

    2014-07-23_222616

    การเพิ่ม Host

    1) ทำการเพิ่มข้อมูล Host

    Supervision -> Host

    2014-07-23_223609

    2) ทำการตั้งค่าทั่วไปและทำการเลือก Host Template ทำให้เราไม่ต้องตั้งค่าเยอะ เพราะจะ Inherite มาจาก Template

    2014-07-23_224822

    3) ทำการตั้งค่าในกรณีที่ต้องการแสดงข้อมูลเพิ่มเติมในกรณีเครื่องมีปัญหาให้ติดต่อใคร

    2014-07-23_224927
    4) จากนั้นทำ Save และทดสอบ เข้าไป Restart Nagios

    Tools -> Nagios control -> Check Written configuration files

    จะพบว่าในขั้นตอน Check configuration files มีข้อความฟ้องเป็น Warning ว่า Linux-Server ยังไม่มี Service ให้ทำการเพิ่ม Service ให้กับ Host ในขั้นตอนต่อไป

    การเพิ่ม Service

    1) ทำการเพิ่มข้อมูล Service ให้กับ Host ชื่อ Linux-Server

    Supervision -> Services

    2014-07-23_230036

    2) ทำการตั้งค่าทั่วไปและทำการเลือก Service Template เพื่อดึงค่าต่าง (Monitor Period, Retry, Interval ฯลฯ) โดยเฉพาะเมื่อติดตั้ง NagiosGraph จะทำที่ Template ที่เดียวจะสามารถขึ้น Graph ให้กับทุก Service โดยไม่ต้องไปไล่ใส่ทุก Service

    2014-07-23_230809

    3) จากนั้นทำ Save และทดสอบ เข้าไป Restart Nagios

    Tools -> Nagios control -> Check Written configuration files

    จะพบว่าจะไม่มี Warning ฟ้องแล้ว ให้ลองใช้งานดูครับ ตัว NagiosQL จริง ๆ ก็คือเป็นแค่ Web ที่เขียน config แทนที่เราจะต้องแก้ไขด้วยมือ Function การใช้งานก็เหมือน Nagios ปกติแต่จะสบายกว่าในกรณีที่มีเครื่องเยอะ ๆ แล้วจะติดใจครับ ^ ^