ตรวจอุปกรณ์ผ่าน php script

ping
ping
มีโอกาสเขียน script ตรวจอุปกรณ์ในเครื่องข่าย ว่าตอบสนองมาดีหรือไม่ ด้วยภาษา php กับ apache บน server ซึ่งก่อนหน้านี้บน windows ก็ใช้ ping -n 1 ได้ แต่มาวันนี้ย้ายไปบน redhat5 ต้องเปลี่ยนเป็น ping -c 1 โดย script แสดงผลด้วยภาพ ต่ออุปกรณ์ 1 รายการ ทำให้ต้องใช้ gd library ซึ่ง redhat5 ที่ engineer ลงไว้ไม่ได้ติดตั้ง php-gd จึงต้อง download แล้วติดตั้งด้วย #rpm -i php-gd.5.1.6-23.2-el5_3.rpm แล้วปรับ code ให้ตรวจ server ว่าเป็น os แบบใด ก็ใช้ ping แบบนั้น
$getping =  shell_exec(“ping -c 1 ” . $ip);
$getping =  shell_exec(“ping -n 1 ” . $ip);
$out = split(“\n”,$getping);

Author: บุรินทร์ รุจจนพันธุ์

I am Lecturer, Developer, Researcher, Columnist, Writer, Photographer, and Webmaster - L@mpang man

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.