วิธีการเขียน Script ตรวจสอบ Server Performance สำหรับเครื่อง Linux Server

ขอนำเสนอ PHP Script และ Terminal linux program สำหรับใช้ Monitor Server Performance สำหรับ Ubuntu Linux ดังนี้ คำสั่งตรวจสอบ Hostname hostname -A วิธีตรวจสอบ Traffic จาก ifconfig ด้วย PHP5 Script <?php //Net Traffic exec(“ifconfig | grep ‘RX bytes'”,$net); $neteth0 = explode(“:”,$net[0]); $netin1 = explode(” “,$neteth0[1]); $netin = $netin1[0]; $netout1 = explode(” “,$neteth0[2]); $netout = $netout1[0]; unset($net); unset($neteth0); unset($netin1); unset($netout1); … Read more

การสร้างระบบ Load Balance Web Server ด้วยวิธีการ URL Redirect

เราสามารถสร้างระบบ Load Balance Web Server ด้วยวิธีการ URL Redirect โดยสามารถสร้างด้วยภาษาใดก็ได้ แต่จะขอยกตัวอย่างด้วยภาษา PHP ได้ง่าย ๆ ดังนี้ ตัวอย่างไฟล์ server-status ที่ได้ทำการ monitor web server มาเรียบร้อยแล้ว webserver1.testlab UP webserver2.testlab DOWN – เราสามารถใช้คำสั่งดึงไฟล์เพื่อคัดเฉพาะ Web Server ที่สามารถใช้งานได้จริง ๆ ดังนี้ exec(“cat /tmp/server-status | grep UP”,$redirect); – จากนั้นจะทำการ นำรายการ server ทั้งหมดซึ่งอยู่ในตัวแปร $redirect มาทำการสุ่ม ดังนี้ $random = rand(0,(count($redirect)-1); – ก็จะทำเอาเลข server ที่ random ได้ไปเข้ากระบวนการ Redirect … Read more

การตรวจสอบสถานะการให้บริการ Web Server ด้วย WGET และสร้าง Shell Script เพื่อตรวจสอบอัตโนมัติ

ขอนำเสนอวิธีการตรวจสอบสถานะการให้บริการด้วยคำสั่ง wget และการสร้าง Shell Script เพื่อให้ทำงานได้อย่างอัตโนมัติ การตรวจสอบสถานะการให้บริการด้วย WGET วิธีติดตั้ง wget สำหรับ ubuntu 14.04 สามารถติดตั้งโดยใช้คำสั่ง (โดยปกติจะลงมาให้อยู่แล้ว) # sudo apt-get install -y wget วิธีติดตั้ง wget สำหรับ windows สามารถ Download ได้ที่ http://downloads.sourceforge.net/project/gnuwin32/wget/1.11.4-1/wget-1.11.4-1-setup.exe สามารถเปิด command prompt รันได้ที่ path นี้ (ยกตัวอย่างจาก windows 64 bit) C:\Users\xxx>cd C:\Program Files (x86)\GnuWin32\bin C:\Program Files (x86)\GnuWin32\bin>wget SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc syswgetrc = C:\Program Files (x86)\GnuWin32/etc/wgetrc wget: … Read more