Tag: nagiosgraph

  • การติดตั้งและการตั้งค่าเบื้องต้น 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

    2014-07-23_214921

    5) เราสามารถตรวจสอบการทำงานได้ดังนี้ (กด Ctrl-C เพื่อยกเลิกการทำงาน)

    sudo tail -f /tmp/perfdata.log

    6) ถ้ามีการเคลื่อนไหวของข้อมูลถือว่าใช้งานได้

    วิธีการตั้งค่า services ผ่าน NagiosQL

    1) ทำการแก้ไขข้อมูล Service Template ดังนี้

    Supervision -> Service templates

    2014-07-24_040615

    2) ทำการแก้ไข Action URL เพื่อให้สามารถคลิกดูกราฟได้จากหน้า Nagios ดังนี้

    Action URL : /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$

    2014-07-24_041023

    3) ทำการเพิ่ม command ใหม่ดังนี้

    Commands -> Definitions

    2014-07-24_045128

    Command : process-service-perfdata-for-nagiosgraph
    Command line : /usr/local/nagiosgraph/bin/insert.pl

    2014-07-24_045234

    4) จากนั้นทำการ Save ข้อมูลและสั่ง Restart nagios เหมือนเดิม

    Tools -> Nagios control -> Check Written configuration files

    วิธีการตั้งค่า Apache Site

    1) ทำการ copy site config ดังนี้

    sudo cp /usr/local/nagiosgraph/etc/nagiosgraph-apache.conf /etc/apache2/sites-available/

    2) ทำการ enable site ขึ้นมาดังนี้

    sudo a2ensite nagiosgraph-apache

    3) เนื่องจากเป็น Apache ใหม่จำเป็นต้องเพิ่ม Require all granted ใน Site config ดังนี้

    sudo nano /etc/apache2/sites-available/nagiosgraph-apache.conf
    # enable nagiosgraph CGI scripts
    ScriptAlias /nagiosgraph/cgi-bin "/usr/local/nagiosgraph/cgi"
    <Directory "/usr/local/nagiosgraph/cgi">
     Options ExecCGI
     AllowOverride None
     Order allow,deny
     Allow from all
     Require all granted
    # AuthName "Nagios Access"
    # AuthType Basic
    # AuthUserFile NAGIOS_ETC_DIR/htpasswd.users
    # Require valid-user
    </Directory>
    # enable nagiosgraph CSS and JavaScript
    Alias /nagiosgraph "/usr/local/nagiosgraph/share"
    <Directory "/usr/local/nagiosgraph/share">
     Options None
     AllowOverride None
     Order allow,deny
     Allow from all
      Require all granted
    </Directory>

    3) จากนั้นให้สั่ง Restart Apache ตามปกติ

    sudo service apache2 restart

    4) หลังจากนั้นทดสอบเข้า web nagios ดูจะพบว่ามี icon เพิ่มขึ้นมาดังนี้ (อาจต้องรอสักพัก เพราะการสร้าง graph ใหม่จะมีรอบการสร้าง)

    2014-07-24_050329

    – หน้าตาโปรแกรม

    2014-07-24_050346

    จบแล้วครับสำหรับการติดตั้ง NagiosGraph ดีเลยมีทั้ง Monitor มีทั้ง Graph ในตัว เอาไว้ดูยามฉุกเฉินครับ

  • 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
    บทความเพิ่มเติม
    ยังไม่มี