Monitor apache Virtualhosts real-time activity with apache-top

Posted In Web Server - By Tum. On Wednesday, July 4th, 2012 With 0 Comments

apache web server
การดูแล web server ที่มีการทำ virtual host ด้วย tool พื้นฐาน เช่นคำสั่ง top เพื่อดูโหลดและ apache process อาจจะไม่เพียงพอ เพราะถ้าหากเมื่อไหร่มีการใช้ทรัพยากรจำนวนมากจาก apache เราก็ไม่รู้เลยว่า Virtual host ไหนที่เป็นตัวที่ใช้ทรัพยากรเยอะสุด ดังนั้น apache จึงมี module ที่ใช้สำหรับ monitor status ของแต่ละ Virtual Host เรียกว่า status_module ซึ่งจะบอกว่ามี virutal host ไหนกำลังใช้งานทรัพยากรอะไรบ้างผ่านทางหน้าเวป สำหรับผู้ดูแลบางท่านไม่สะดวกในการเข้าดูสถานะของ web server ผ่านหน้าเวปสามารถใช้ apache-top.py ช่วยในการแสดงสถานะผ่านทาง console ได้ ซึ่งจะแสดงผลคล้ายคำสั่ง top

Apache-top.py เป็น script ที่เขียนโดย python เพื่อนำมาใช้ในการ monitor /server-status ในรูปแบบ top-like interface ซึ่งจะทำให้ผู้ดูแลสามารถ minitor ได้โดยไม่จำเป็นต้องดูข้อมูลเปิดผ่าน browser ให้ยุ่งยาก รายละเอียดข้อมูลที่จะแสดงมี pid ของแต่ละ apache process, virtual host, และ request

วิธีการติดตั้ง status_module

  1. แก้ไขไฟล์ /etc/http/conf/httpd.conf และตรวจสอบค่าต่างๆดังนี้
    • เปิดใช้งาน Status module
      [text]LoadModule status_module modules/mod_status.so[/text]
    • ตั้งค่า ExtendedStatus เป็น On
      [text]ExtendedStatus On[/text]
    • กำหนด URL สำหรับ monitor และ สิทธิการเข้าใช้งาน
      [text]
      <Location /server-status>
      SetHandler server-status
      Order deny,allow
      Deny from all
      Allow from 127.0.0.0/8
      </Location>[/text]
  2. Restart apache service

การใช้งาน Apache-top.py

Download apache-top.py ด้วยคำสั่ง

คำสั่งที่ใช้ monitor

โปรแกรมจะแสดงผลลัพธ์ออกมาดังตัวอย่างด้านล่าง

apache-top-for-monitoring-apache-web-server

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

*