วิธีติดตั้ง zabbix บนเครื่อง FreeNas Server Login to the FreeNAS using SSH ให้ทำการแก้ไขไฟล์ /usr/local/etc/pkg/repos/local.conf nano -w /usr/local/etc/pkg/repos/local.conf จาก local: { url: "file:///usr/ports/packages", enabled: yes} แก้ไข เป็น local: { url: "file:///usr/ports/packages", enabled: false} จากนั้นให้ทำการแก้ไขไฟล์ /usr/local/etc/pkg/repos/FreeBSD.conf nano -w /usr/local/etc/pkg/repos/FreeBSD.conf จาก FreeBSD: { enabled: no} แก้ไขเป็น FreeBSD: { url: "pkg+http://mirror.sg.gs/freebsd-pkg/${ABI}/quarterly", url: "pkg+http://mirror.sg.gs/freebsd-pkg/${ABI}/latest", enabled: yes }จากนั้นให้ RUN pkg update แล้ว RUN root@freenas1:~ # pkg search zabbixroot@freenas2:~ # pkg search zabbix py38-pyzabbix-1.0.0 Zabbix API Python Library zabbix3-agent-3.0.32 Enterprise-class open source distributed monitoring (agent) LTS zabbix3-frontend-3.0.32 Enterprise-class open source distributed monitoring (frontend) LTS zabbix3-java-3.0.32_1 Enterprise-class open source distributed monitoring (java) LTS zabbix3-libzbxpgsql-1.1.0_3 Zabbix agent module for comprehensive monitoring of PostgreSQL servers zabbix3-proxy-3.0.32 Enterprise-class open source distributed monitoring (proxy) LTS zabbix3-server-3.0.32 Enterprise-class open source distributed monitoring (server) LTS zabbix4-agent-4.0.30 Enterprise-class open source distributed monitoring (agent) LTS zabbix4-frontend-4.0.30 Enterprise-class open source distributed monitoring (frontend) LTS zabbix4-java-4.0.30 Enterprise-class open source distributed monitoring (java) LTS zabbix4-proxy-4.0.30 Enterprise-class open source distributed monitoring (proxy) LTS zabbix4-server-4.0.30 Enterprise-class open source distributed monitoring (server) LTS zabbix5-agent-5.0.15 Enterprise-class open source distributed monitoring (agent) LTS zabbix5-frontend-5.0.15 Enterprise-class open source distributed monitoring (frontend) LTS zabbix5-java-5.0.15 Enterprise-class open source distributed monitoring (java) LTS zabbix5-proxy-5.0.15 Enterprise-class open source distributed monitoring (proxy) LTS zabbix5-server-5.0.15 Enterprise-class open source distributed monitoring (server) LTS zabbix52-agent-5.2.7 Enterprise-class open source distributed monitoring (agent) zabbix52-frontend-5.2.7 Enterprise-class open source distributed monitoring (frontend) zabbix52-java-5.2.7 Enterprise-class open source distributed monitoring (java) zabbix52-proxy-5.2.7 Enterprise-class open source distributed monitoring (proxy) zabbix52-server-5.2.7 Enterprise-class open source distributed monitoring (server) zabbix54-agent-5.4.4 Enterprise-class open source distributed monitoring (agent) zabbix54-frontend-5.4.4 Enterprise-class open source distributed monitoring (frontend) zabbix54-java-5.4.4 Enterprise-class open source distributed monitoring (java) zabbix54-proxy-5.4.4 Enterprise-class open source distributed monitoring (proxy) zabbix54-server-5.4.4 Enterprise-class open source distributed monitoring (server) จากนั้น ให้เลือก package ที่จะทำการ install pkg install zabbix4-agent-4.0.30 เมื่อทำการ install เสร็จแล้ว ให้ทำการเพิ่ม config ใน /etc/rc.conf nano -w /etc/rc.conf # Enable zabbix agentzabbix_agentd_enable="YES" จากนั้นให้ทำการแก้ไข zabbix config cp /etc/local/zabbix4/zabbix_agentd.conf.sample /etc/local/zabbix4/zabbix_agentd.conf nano -w /etc/local/zabbix4/zabbix_agentd.confโดยดำเนินการแก้ไขในส่วนของServer=203.78.103.9ServerActive=203.78.103.9Hostname=[Servername]EnableRemoteCommands=1 เมื่อแก้ไขค่า config แล้วให้ทำการ start zabbix agent ขึ้นมา cd /var/runmkdir zabbixchown zabbix:zabbix zabbixservice -e | grep zabbixservice zabbix_agentd startถ้ามี error /etc/rc.d/zabbix_agentd: ERROR: get_pidfile_from_conf: /usr/local/etc/zabbix3/zabbix_agentd.conf does not exist (zabbix_agentd) ให้ไปแก้ไขไฟล์ /etc/rc.d/zabbix_agentd nano -w /etc/rc.d/zabbix_agentd : ${zabbix_agentd_config:=/usr/local/etc/zabbix3/${name}.conf} ไปเป็น : ${zabbix_agentd_config:=/usr/local/etc/zabbix4/${name}.conf} เสร็จแล้ว ให้ login ไป ที่ https://ezazbweb1.ezyadmin.com/zabbix แล้วให้ทำการ add host เข้าไปแบบ manual ครับ
หากต้องการใช้วิธีการดังกล่าวต้องตรวจสอบข้อมูลให้ครบถ้วนดังนี้1. จะใช้ข้อมูลในการ Clear queue mail ดังกล่าวต่อเมื่อมีปริมาณสูงมากๆ เช่นตั้งแต่ 500,000 queue เป็นต้นไป2. ในระหว่างขั้นตอนการดำเนินการตลอดจนเสร็จสิ้นต้องแน่ใจว่า Service exim ไม่ Start ขึ้นมา "เด็ดขาด"3. ต้องทำการ Confirm กับลูกค้าว่าสามารถดำเนินการลบได้ทั้งหมดหรือไม่ ปัญหา ไม่สามารถทำการ Clear queue mail ปริมาณมากๆออกจาก Server ได้ วิธีการแก้ไข 1. Access SSH เข้าไปที่ Server ที่ต้องการ 2. ทำการ Stop service exim : /etc/init.d/exim stop [root@vps ~]#/etc/inin.d/exim stop หรือ [root@vps ~]#systemctl stop exim.service 3. run : cd /var/spool/exim [root@vps ~]#cd /var/spool/exim 4. run : find input -type f -exec rm -rf {} \; [root@vps ~]#find input -type f -exec rm -rf {} \; 5. run : find msglog -type f -exec rm -rf {} \; [root@vps ~]#find msglog -type f -exec rm -rf {} \; 6. service exim restart : /etc/init.d/exim restart [root@vps ~]#/etc/inin.d/exim restart หรือ [root@vps ~]#systemctl restart exim.service ทุกขั้นตอนในการดำเนินการ Service exim จะต้องถูก Stop ตลอดเวลา
ปัญหา เมื่อทำการ modify account ผ่าน WHM แล้วเครื่อง Server reset ทันที สาเหตุ เกิดจาก Kernel ที่ใช้งานมีปัญหา วิธีการตรวจสอบ 1. ตรวจสอบในส่วนของ /var/log/messages จะพบ Error Sep 20 14:21:40 netway40 kcare: Unknown Kernel (CloudLinux 3.10.0-793.21.1.lve1.5.20.el7.x86_64)Sep 20 14:21:40 netway40 kcare: Unknown Kernel (CloudLinux 3.10.0-793.21.1.lve1.5.20.el7.x86_64)Sep 20 14:21:40 netway40 systemd: PID file /run/apache2/httpd.pid not readable (yet?) after start.Sep 20 14:21:40 netway40 systemd: Started Apache web server managed by cPanel EasyApache.Sep 20 14:21:41 netway40 cagefs-liblve: Act like CageFS is disabled (unable to acquire lock for user punparkc uid 1064)Sep 20 14:21:41 netway40 cagefs-liblve: Act like CageFS is disabled (unable to acquire lock for user punparkc uid 1064)Sep 20 14:21:41 netway40 cagefs-liblve: Act like CageFS is disabled (unable to acquire lock for user punparkc uid 1064)Sep 20 14:21:41 netway40 cagefs-liblve: Act like CageFS is disabled (unable to acquire lock for user punparkc uid 1064)Sep 20 14:21:41 netway40 cagefs-liblve: Act like CageFS is disabled (unable to acquire lock for user punparkc uid 1064)Sep 20 14:21:42 netway40 cagefs-liblve: Act like CageFS is disabled (unable to acquire lock for user punparkc uid 1064)Sep 20 14:21:42 netway40 pure-ftpd: (?@61.91.33.142) [INFO] New connection from 61.91.33.142Sep 20 14:21:42 netway40 pure-ftpd: (?@61.91.33.142) [INFO] udon@thevaluation.com is now logged inSep 20 14:21:42 netway40 cagefs-liblve: Act like CageFS is disabled (unable to acquire lock for user punparkc uid 1064)Sep 20 14:21:45 netway40 cagefs-liblve: Act like CageFS is disabled (unable to acquire lock for user punparkc uid 1064)Sep 20 14:21:45 netway40 cagefs-liblve: Act like CageFS is disabled (unable to acquire lock for user punparkc uid 1064)Sep 20 14:21:45 netway40 cagefs-liblve: Act like CageFS is disabled (unable to acquire lock for user punparkc uid 1064) 2. ตรวจสอบ kernel ที่ใช้งานอยู่ปัจจุบัน [root@netway40 ~]# uname -r3.10.0-793.21.1.lve1.5.20.el7.x86_64 [root@netway40 ~]# kcare-uname -r3.10.0-793.21.1.lve1.5.20.el7.x86_64 [root@netway40 ~]# kcarectl --checkUnknown kernel (CloudLinux 3.10.0-793.21.1.lve1.5.20.el7.x86_64), no patches available แนวทางการแก้ไข เลือกใช้ kernel ที่ถูกต้อง จากตัวอย่างจะเป็น version : 3.10.0-714.10.2.lve1.5.17.1.el7.x86_64 ข้อมูลเปรียบเทียบ สามารตรวจสอบ version kernel เพื่อใช้ในการเปรียบเทียบได้จาก https://patches.kernelcare.com/
วิธีการใช้คำสั่ง sar เพื่อค้นหาข้อมูล Server ย้อนหลัง 1. การใช้คำสั่ง sar เพื่อตรวจสอบข้อมูล load average ของ server ตามวันที่เรากำหนด โดยจะ Report ข้อมูลตั่งแต่เวลา 00.00น. - 23.59น. ของวันที่ต้องการ ตัวอย่างการใช้คำสั่งค้นหาในวันที่ 23 sar -q -f /var/log/sa/sa23 2. การใช้คำสั่ง sar เพื่อตรวจสอบข้อมูล load average ของ server ในวันปัจจุบันโดยจะทำการ Report ข้อมูลตั้งแต่เวลา 00.00น. ถึงเวลาปัจจุบัน sar -q 3. การใช้คำสั่ง sar เพื่อตรวจสอบข้อมูล CPU load average ของ server ในวันปัจจุบันโดยจะทำการ Report ข้อมูลตั้งแต่เวลา 00.00น. ถึงเวลาปัจจุบัน sar -p 4. การใช้คำสั่ง sar เพื่อตรวจสอบข้อมูล RAM Usage ของ server ในวันปัจจุบันโดยจะทำการ Report ข้อมูลตั้งแต่เวลา 00.00น. ถึงเวลาปัจจุบัน sar -r 5. การใช้คำสั่ง sar เพื่อตรวจสอบข้อมูล Swap Usage ของ server ในวันปัจจุบันโดยจะทำการ Report ข้อมูลตั้งแต่เวลา 00.00น. ถึงเวลาปัจจุบัน sar -S 6. การใช้คำสั่ง sar เพื่อตรวจสอบข้อมูล I/O Usage ของ server ในวันปัจจุบันโดยจะทำการ Report ข้อมูลตั้งแต่เวลา 00.00น. ถึงเวลาปัจจุบัน sar -d
ปัญหา เว็บไซต์ ติด virus, malware, exploit, hacked ทางแก้ปัญหา root@netway19 [~]# cd /root root@netway19 [~]# git clone https://github.com/Hestat/lw-yara.git แล้วทำการ scan ด้วยคำสั่ง root@netway19 [~]# clamscan -ir -d /root/lw-yara/lw-rules_index.yar /home/$user/public_html/ ในส่วนนี้มันจะ list file ขึ้นมาว่าไฟล์ไหนที่เป็นปัญหา ก็ให้เข้าไปแก้ไขไฟล์ที่เป็นปัญหาตาม list นี้ครับ สาเหตุปัญหา เว็บไซต์ ถูก hacked แล้วอัพโหลด script ที่ไม่พึงประสงค์ ขึ้นมา อ้างอิง : https://laskowski-tech.com/2018/04/26/eitest-cleanup-part-2-using-clamav-and-custom-yara-rules/