สำนักวิทยบริการและเทคโนโลยีสารสนเทศ (สวส.)

Office of Academic Resources and Information Technology

สร้างกราฟ Apache2 Template บน Cacti

- ทดสอบบน Ubuntu 14.04 LTS
- MySQL-Server, Apache2, PHP5, phpMyAdmin
- Cacti v0.8.8b

- จุดประสงค์เพื่อจะ Monitoring Apache2 ของเครื่องให้บริการ Web Server โดยเฉพาะ

1. แก้ไขไฟล์ /etc/apache2/mods-enabled/status.conf ของ apache ของเครื่อที่ต้องการให้ Monitoring
ต้องเพิ่ม module status อนุญาตให้เครื่อง cacti เข้าดูดังนี้

        <Location /server-status>
                SetHandler server-status
                Order deny,allow
                Deny from all
                #Require local
                Allow from 172.26.0.xxx
                #Require ip 192.0.2.0/24
        </Location>

        # Keep track of extended status information for each request
        ExtendedStatus On

2. สั่งให้ apache2 ทำงานใหม่
service apache2 restart

3. ทดสอบการเข้าดูสถานะของ apache2 จากเครื่อง cacti
- ติดตั้งโปรแกรมสำหรับใช้ตรวจสอบ apt-get install elinks
- ทดลองกับถ้าที่เปืด apache2 status
elinks --dump http://[ip ของ server]/server-status?auto

ได้ผลประมาณนี้
 Total Accesses: 14552 Total kBytes: 149265 CPULoad: .00952639 Uptime:
   3798502 ReqPerSec: .00383098 BytesPerSec: 40.2389 BytesPerReq: 10503.5
   BusyWorkers: 10 IdleWorkers: 39 Scoreboard:
   _G_____GG_____G_______G__G__..._._W._._.G.._____G________.G..............

4. ติดตั้ง Script Apche2 template ที่ http://forums.cacti.net/viewtopic.php?t=25227
 หรือดาวว์โหลดได้ที่ https://www.dropbox.com/s/4vhragt6lrovb2i/ApacheStats_0.8.2.zip

cd /tmp
wget https://www.dropbox.com/s/4vhragt6lrovb2i/ApacheStats_0.8.2.zip
unzip ApacheStats_0.8.2.zip
cp ApacheStats_0.8.2/ss_apache_stats.php /usr/share/cacti/site/scripts/

5. ดาวโหลด script https://www.dropbox.com/s/4vhragt6lrovb2i/ApacheStats_0.8.2.zip มาไว้ที่เครื่องและแยกไฟล์
- import ไฟล์ cacti_host_template_webserver_-_apache.xml เพื่อสร้าง Template Apache




6. เพิ่มกราฟ Apache ให้กับอุปกรณ์ที่ต้องการ Monitoring




7. สร้างกราฟจาก template




8. ตัวอย่างกราฟ Apache





Referrent : http://www.phuketadmin.org/index.php?topic=7240.0