แสดงกระทู้

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - golfreeze

Pages: 1 2 3 [4] 5 6 ... 146
46
all application on unix knowledges by golfreeze / postgres psql command import query
« on: สิงหาคม 20, 2022, 02:56:45 AM »
ถ้าเรามีการเตรียม สคิปในไฟล์ check_query_alter_update.sql เพื่อทำรายการใน db=testdb เราสามารถรันผ่าน command psql ได้ดังนี้

postgres=> \c  testdb
testdb=> \i 19aug2022_operation/Script/check_query_alter_update.sql
ALTER TABLE

เท่านี้ครับผม

47
===for centos , debian 11
cd /usr/local/directadmin/scripts/custom
wget https://raw.githubusercontent.com/poralix/directadmin-utils/master/php/php-extension.sh -O php-extension.sh
chmod 750 php-extension.sh
./php-extension.sh install redis

==for freebsd
cd /usr/local/directadmin/scripts/custom
wget https://raw.githubusercontent.com/poralix/directadmin-utils/master/php/php-extension.sh -O php-extension.sh
chmod 750 php-extension.sh

mkdir -p /usr/local/src
และแก้ไข #!/bin/bash -> #!/usr/local/bin/bash ใน php-extension.sh แล้วรัน
./php-extension.sh install redis

48
byobu command
ctrl+a+c = new window
ctrl+a+o = swap window
ctrl+a+% = split vertical view

49
csf lfd stop alert email for nrpe on debian os directadmin
กรณีมีอีเมลส่งมาแจ้ง เยอะ alert สามารถแก้ไขเพื่อไม่ให้ส่ง email จาก service csf ที่เป้นหัวข้อ lfd ได้โดย

If debian enable “csf” need allow on csf.conf “TCP_in” and “TCP_out” and
Disable lfd for resource usage

Subject: lfd on packetlove.com: Excessive resource usage: nagios (494190 (Parent PID:494190))
From:  <root@packetlove.com>
Message-Id: <E1ne3x7-002N0R-7t@packetlove.com>
Date: Tue, 12 Apr 2022 07:00:13 +0700

Time:         Tue Apr 12 07:00:13 2022 +0700
Account:      nagios
Resource:     Process Time
Exceeded:     75567 > 1800 (seconds)
Executable:   /usr/local/nagios/bin/nrpe
Command Line: /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -f
PID:          494190 (Parent PID:494190)
Killed:       No

--1649721613-eximdsn-849789542--

==แก้ไขเพื่อไม่ให้ส่ง email ได้โดย
vi /etc/csf/csf.pignore
user:nagios
exe:/usr/local/nagios/bin/nrpe
cmd:/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -f
==reload csf rule 1 รอบ
csf -r

50
ในกรณี disk เป็น volume group เราสามารถสั่ง check disk ระบุ partition ได้เลยครับ
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 6% -c 3% -p /

51
ในเครื่อง client ที่ติดตั้ง nrpe client ให้ allow port 5666 ด้วยนะครับเพื่อให้ฝั่ง server check_nrpe เข้ามาได้ครับ
ufw allow 5666/tcp
: )

52
===== upgrade directadmin for centos,debian on tangmo 31mar2022
CHANNEL=current
OS_SLUG=linux_amd64
COMMIT=$(dig +short -t txt "$CHANNEL-version.directadmin.com" | sed 's|.*commit=\([0-9a-f]*\).*|\1|')     
FILE="directadmin_${COMMIT}_${OS_SLUG}.tar.gz"
curl --location --progress-bar --connect-timeout 10 "https://download.directadmin.com/${FILE}" --output "/root/${FILE}"
tar xzf "/root/${FILE}" -C /usr/local/directadmin
/usr/local/directadmin/directadmin p || true
/usr/local/directadmin/scripts/update.sh
echo 'action=directadmin&value=restart' >> /usr/local/directadmin/data/task.queue
สุดท้าย restart da 1 รอบ
systemctl restart directadmin

แล้วลองเทสเข้า login da อีกที  8)


###for FreeBSD plan for dhamma.packetlove.com 17mar2022
#downloads given directadmin build into /root dir
FILE="directadmin_a3e4091814582ab3c0fecea62ff5c1f956e023da_freebsd_amd64.tar.gz"
curl --location --progress-bar --connect-timeout 10 "https://download.directadmin.com/directadmin_a759259a6deeeb3977de8dc4387d275a9de8eaad_freebsd_amd64.tar.gz" --output "/root/directadmin_a759259a6deeeb3977de8dc4387d275a9de8eaad_freebsd_amd64.tar.gz"   
#extracts downloaded package to /usr/local/directadmin
tar xzf "/root/directadmin_a759259a6deeeb3977de8dc4387d275a9de8eaad_freebsd_amd64.tar.gz" -C /usr/local/directadmin
#runs post-upgrade permission fix step                                                                       
/usr/local/directadmin/directadmin permissions || true
# runs other post upgrade fixes 
/usr/local/directadmin/scripts/update.sh
# restarts directadmin
แล้วลองเทสเข้า login da อีกที
service directadmin restart         

53
ถ้าเจอ error โดยที่ check_nrpe บน freebsd 11.x , 12.x
/usr/local/nagios/libexec/check_nrpe -H 103.86.y.x -c check_home
CHECK_NRPE: (ssl_err != 5) Error - Could not complete SSL handshake with 103.86.y.x : 1


==install nrpe3
#pkg install net-mgmt/nrpe3
Proceed with this action? [y/N]: y
[1/2] Fetching nrpe3-3.2.1.txz: 100%   46 KiB   9.5kB/s    00:05   
[2/2] Fetching nagios-plugins-2.3.3_2,1.txz: 100%  400 KiB 204.7kB/s    00:02   
Checking integrity... done (0 conflicting)
[1/2] Installing nagios-plugins-2.3.3_2,1...
[1/2] Extracting nagios-plugins-2.3.3_2,1: 100%
[2/2] Installing nrpe3-3.2.1...
===> Creating groups.
Using existing group 'nagios'.
===> Creating users
Using existing user 'nagios'.
===> Creating homedir(s)
[2/2] Extracting nrpe3-3.2.1: 100%
=====
Message from nrpe3-3.2.1:

--
Enable NRPE in /etc/rc.conf with the following line:

   nrpe3_enable="YES"

 A sample configuration is available in /usr/local/etc/nrpe.cfg.sample.
 Copy to nrpe.cfg where required and edit to suit your needs.

54
ในกรณีที่ทำการ อัฟเดท directadmin license key แล้วแต่ก็ยังเข้าไม่ได้ ต้องทำการอัฟเดท da ดูนะครับ
เบื้องต้นแนะนำให้ทำ snapshot ไว้ก่อนนะครับ
ตามด้วย backup configure บน
/usr/local/directadmin/conf
/usr/local/directadmin/custombuild
/usr/local/directadmin/script

หลังจากทำเสร็จให้ทำการ รัน command
/usr/local/directadmin/scripts/getDA.sh current

แล้วทำการ restart directadmin 1 รอบ
systemctl restart directadmin

เท่านี้ก็จะเข้าใช้งานได้ละครับ  8)

55
ในการนำ certificate ไปใส่ใน exim.cert จะต้องนำ certificate.crt , ca-bundle , trust-root.ca , ca cert ต่างๆใส่ให้ครบ
โดยสามารถเรียงลำดับได้ดังนี้
-----BEGIN CERTIFICATE-----
content ของ certificate.crt
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
 ca-bundle , ca cert
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
rust-root.ca
-----END CERTIFICATE-----

แล้วทำการ restart service exim , dovecot จะสามารถใช้งานได้ครับผม

56
เราสามารถ monitoring spamrate การส่งเมลเข้าไปหา gmail ได้โดยทำการแอด domain เข้าระบบ postmaster
https://postmaster.google.com/managedomains?pli=1
แล้วทำการยืนยัน txt record ใส่บน zonefile ของโดเมนเรา แล้วจะสามารถเชคได้ครับผม  8)

57
วันนี้มีโจทย์ให้ทำ บน DirectAdmin ให้ uninstall pureftp และทำการ enable proftpd พร้อมกับ sFTP feature ขึ้นมา

==เริ่มด้วย stop pureftp first เพราะ default ลงมาเป็น pureftp
cd /usr/local/directadmin/custombuild
./build set pureftpd_uploadscan no

ทำการ build proftpd
# cd /usr/local/directadmin/custombuild
# ./build update
# ./build set ftpd proftpd
# mkdir -p custom/proftpd/conf (make a directory for custom ProFTPd config that adds mod_sftp)
# wget -O custom/proftpd/configure.proftpd http://files.directadmin.com/services/all/sftp/configure.proftpd.sftp
# wget -O custom/proftpd/conf/proftpd.conf http://files.directadmin.com/services/all/sftp/proftpd.conf
# chmod 755 custom/proftpd/configure.proftpd
# wget -O /etc/proftpd.sftp.conf http://files.directadmin.com/services/all/sftp/proftpd.sftp.conf
# mkdir /etc/proftpd.ssl
# cp /etc/ssh/ssh_host_rsa_key* /etc/proftpd.ssl
# chmod 400 /etc/proftpd.ssl/ssh_host_rsa_key
# cp /etc/proftpd.sftp.conf /etc/proftpd.sftp.conf_original

===Edit /etc/proftpd.sftp.conf ตรงส่วน SFTPHostKey ให้ไปชี้ /etc/proftpd.ssl/ssh_host_rsa_key แทน !!!! ไม่งั้นจะทำงาน sftp ไม่ได้ ===
<IfModule mod_sftp.c>
<VirtualHost 0.0.0.0>
# The SFTP configuration
# Port 23
Port 22 # Change to standard port now possible after moving SSH to 44
AuthUserFile /etc/proftpd.passwd
TransferLog /var/log/proftpd/xferlog.legacy
ExtendedLog /var/log/proftpd/75.126.244.2.bytes WRITE,READ userlog
SFTPEngine on
SFTPLog /var/log/proftpd/sftp.log
# SFTPHostKey /etc/ssh/ssh_host_rsa_key
SFTPHostKey /etc/proftpd.ssl/ssh_host_rsa_key # Change to use key pair copied to /etc/proftpd.ssl and given necessary rights (0400) for mod_sftp.c work.
SFTPAuthorizedUserKeys file:~/.sftp/authorized_keys

หลังจากนั้นทำการ rebuild อีกรอบ
# cd /usr/local/directadmin/custombuild
# ./build proftpd
service proftpd restart

แล้วเทสกับ Filezilla ก็จะใช้งาน sFTP ได้ครับผม  :)

===recompile proftpd
https://forum.directadmin.com/threads/how-to-set-up-your-proftpd-ftp-server-to-support-the-secure-protocols-while-disabling-insecure-ftp.65025/
https://forum.directadmin.com/threads/proftpd-issue-with-sftp.63352/
https://docs.directadmin.com/other-hosting-services/ftp/general.html

58
upgrade mac-os แล้วทำการ copy text content on terminal ไม่ได้

คือหลังจากอัฟเกรด mac os จาก mojave-> montery แล้วทำการ copy text บน terminal ไม่ได้แก้ไขโดย ไปที่
Terminal -> View -> ติ๊กถูก Allow Mouse Reporting ออก 

 8)

59
ถ้าเจอปัญหาเรื่อง nagios check_ping: CRITICAL - Could not interpret output from ping command #46
sh-4.4# su - nagios
$ /bin/ping -n -U -w 30 -c 5 127.0.0.1
ping: socket: Address family not supported by protocol
$ /bin/ping -4 -n -U -w 30 -c 5 127.0.0.1
ping: socket: Operation not permitted


สามารถทำการแก้ไขได้โดย
sh-4.4# chmod +s /bin/ping
sh-4.4# su - nagios
$ /bin/ping -4 -n -U -w 30 -c 5 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.097 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.053 ms

==special thank : https://github.com/bodsch/docker-icinga2/issues/46

60
On CentOS8.x End of life , then if you running "yum update" will found error

Failed to download metadata for repo ‘appstream’: Cannot prepare internal mirrorlist

So how to fixed

==change mirrorlist ==
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*

== install centos-release-stream
sudo dnf install centos-release-stream -y
sudo dnf swap centos-{linux,stream}-repos -y
sudo dnf distro-sync -y

yum update
==finished ==
 ;)

Special Thank:
https://flutterq.com/failed-to-download-metadata-for-repo-appstream-cannot-prepare-internal-mirrorlist-no-urls-in-mirrorlist/

Pages: 1 2 3 [4] 5 6 ... 146