1. Logwatch
①Install
1 |
# dnf install logwatch |
②Edit configuration file
1 2 |
# cat /usr/share/logwatch/default.conf/logwatch.conf >> /etc/logwatch/conf/logwatch.conf # vi /etc/logwatch/conf/logwatch.conf |
1 2 3 4 5 6 7 |
●Per line 51 Set "MailTo = root" as a comment and set the email address you want to receive notifications to the line below it. #MailTo = root MailTo = [Mail address] ●Per line 84 : Set the level of detail for log notifications #Detail = Low Detail = High |
③Output Logwatch reports
1 |
# logwatch --output stdout |
It will appear as follows
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
################### Logwatch 7.5.5 (01/22/21) #################### Processing Initiated: Sun May 28 13:33:13 2023 Date Range Processed: yesterday ( 2023-May-27 ) Period is day. Detail Level of Output: 10 Type of Output/Format: stdout / text Logfiles for Host: Lepard ################################################################## --------------------- Amavisd-new Begin ------------------------ ****** Summary ************************************************************************************* 1 Total messages scanned ------------------ 100.00% 605 Total bytes scanned 605 ======== ================================================== 1 Passed ---------------------------------- 100.00% 1 Clean passed 100.00% ======== ================================================== 1 Ham ------------------------------------- 100.00% 1 Clean passed 100.00% ======== ================================================== 1 SpamAssassin bypassed Amavis Startup Antivirus scanners Primary ClamAV-clamdscan /usr/bin/clamdscan Secondary ClamAV-clamscan /usr/bin/clamscan Code, modules and external programs Not found .lz4 tried: lz4c -d .rar tried: unrar, rar Decoders None .lz4 tried: unknown SpamAssassin plugins **Unmatched Entries** 4 starting. /usr/sbin/amavisd at mail.korodes.com amavis-2.13.0 (20230106), Unicode aware, LANG="en_US.UTF-8" ---------------------- Amavisd-new End ------------------------- <omission > --------------------- Disk Space Begin ------------------------ Filesystem Size Used Avail Use% Mounted on /dev/mapper/rl-root 17G 5.3G 12G 31% / /dev/nvme0n1p1 1014M 251M 764M 25% /boot ---------------------- Disk Space End ------------------------- --------------------- lm_sensors output Begin ------------------------ No sensors found! Make sure you loaded all the kernel drivers you need. Try sensors-detect to find out which these are. ---------------------- lm_sensors output End ------------------------- ###################### Logwatch End ######################### |
④Test to see if the report arrives at the address you set. Check if you receive a log report email like the one above.
1 |
# /etc/cron.daily/0logwatch |
2. DiCE
Whenever the global IP changes, which happens when the network is disconnected or the router is disconnected and rebooted, the dynamic DNS must be accessed to inform the user that the global IP has changed. DiCE does this automatically!
①Download and install Dice
1 2 3 4 |
# cd /usr/local/bin # wget http://www.hi-ho.ne.jp/yoshihiro_e/dice/diced01914.tar.gz # tar -xzvf diced01914.tar.gz # cd /usr/local/bin/DiCE |
②DiCE Settings
DiCE output characters are EUC and therefore garbled; install nkf to convert to UTF-8
1 |
# dnf install nkf |
Installed the following to run 32-bit software Dice on 64-bit OS
1 |
# dnf install glibc.i686 |
③Launch DiCE
1 2 |
# cd /usr/local/bin/DiCE # ./diced | nkf -uw |
④Add Event
When the DNS service is VALUEDOMAIN
※Only Japanese version is available
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# ./diced | nkf -uw : add DynamicDNSサービス名を入力してください "?"で対応しているサービスを一覧表示します (P)戻る >VALUEDOMAIN ドメイン名を入力してください "?"でドメイン一覧を表示します (P)戻る ><ドメイン名> ホスト名を入力してください (P)戻る ><ホスト名> ログインユーザ名を入力してください (P)戻る ><ユーザー名> ←VALUEDOMAINに登録したユーザー名 ログインパスワードを入力してください (P)戻る ><passwd> ←VALUEDOMAINにログインするパスワード 登録するIPアドレスを入力してください 空白にすると現在のIPアドレスを自動検出します (P)戻る >空白 このイベントに題名を付けてください (P)戻る >xxxxxxxxx(適当に付ける) 実行する頻度を指定してください (番号入力) (0)1回のみ (1)1日1回 (2)1週間に1回 (3)1ヵ月に1回 (4)その他の周期 (5)IPアドレス変化時 (6)起動時 (P)戻る >5 (任意に決める) IPアドレスがあまり変化しない環境の場合、更新せずに一定期間を過ぎると アカウントを削除されてしまうことがあります IPアドレスの変化が無い時に実行する間隔を指定してください (0)7日毎 (1)14日毎 (2)21日毎 (3)28日毎 (4)35日毎 (5)56日毎 (6)84日毎 (P)戻る >0(任意に決める) このイベントを有効にしますか? (Y/N) (イベントの有効/無効は"EN/DIS"コマンドで切替えられます) >y イベントを保存しますか? (Y/N) >y イベントの確認 list (No.) (イベント名) (スケジュール) (次回予定) 0 * xxxxxxxxx IPアドレス変化時 (7日毎) 01/27 06:27ー 手動実行 :ex 0 + 1/20 6:33 にddns_valuedomainが実行されました IPアドレスを更新しました :exit |
⑤Automatic execution of Dice
Start the DiCE daemon
1 2 3 4 5 6 7 8 |
# /usr/local/bin/DiCE/diced -d -l -=-=- DiCE DynamicDNS Client -=-=-= Version 0.19 for Japanese Copyright(c) 2001 sarad DiCE Daemon Started !! |
Check if it is activated
1 2 3 4 |
# ps aux | grep diced root 150637 0.4 0.0 5776 124 ? Ss 14:40 0:00 /usr/local/bin/DiCE/diced -d -l root 150708 94.7 0.1 5776 1796 ? Rs 14:40 0:09 /usr/local/bin/DiCE/diced -d -l root 150882 0.0 0.1 6412 2008 pts/0 S+ 14:40 0:00 grep --color=auto diced |
Set to start automatically
1 2 |
# vi /etc/rc.local /usr/local/bin/DiCE/diced -d -l (add) |
Update domain information acquired through ValueDomain
There is no English version of DiCE.
Since the above DiCE is only available in Japanese and is old and has not been updated, I have prepared a shell script to update it.
I'm not sure if it will work, but I'll try it on a trial basis.
1 2 3 4 5 6 7 8 9 10 11 12 |
# vi /var/www/system/valuedomain_updqte.sh #/bin/bash#VARIABLES DOMAINNAME="[Domain name]" PASSWORD="[Password]" HOSTNAME="*" MYIP="" #External IP Acquisition MYIP=`wget -q -O - "https://dyn.value-domain.com/cgi-bin/dyn.fcg?ip"` sleep 5 #update process wget -q -O - "https://dyn.value-domain.com/cgi-bin/dyn.fcg?d=$DOMAINNAME&p=$PASSWORD&h=$HOSTNAME&i=$MYIP" |
Auto Update Settings
With crontab -e, add the following to update periodically
1 2 |
# crontab -e */30 * * * * /var/www/system/valuedomain_updqte.sh |
3.Introduce disk usage check script
3.1 Script Creation
1 2 |
# cd /var/www/system # vi disk_capacity_check.sh |
Contents of disk_capacity_check.sh
1 2 3 4 5 6 7 8 9 10 |
#!/bin/bash #Designation of e-mail address to be notified MAIL="<your mailaddress>" DVAL=`/bin/df / | /usr/bin/tail -1 | /bin/sed 's/^.* \([0-9]*\)%.*$/\1/'` if [ $DVAL -gt 80 ]; then echo "Disk usage alert: $DVAL %" | mail -s "Disk Space Alert in `hostname`" $MAIL fi |
1 |
# chmod 700 disk_capacity_check.sh |
3.2 Execution Confirmation
①Check current usage rates
1 |
# df -h |
It appears as follows
1 2 3 4 5 6 7 8 9 10 |
Filesystem Size Used Avail Use% Mounted on devtmpfs 856M 0 856M 0% /dev tmpfs 875M 0 875M 0% /dev/shm tmpfs 350M 9.6M 341M 3% /run /dev/mapper/rl-root 17G 5.0G 13G 30% / /dev/loop0 64M 64M 0 100% /var/lib/snapd/snap/core20/1695 /dev/loop2 48M 48M 0 100% /var/lib/snapd/snap/snapd/17336 /dev/loop1 45M 45M 0 100% /var/lib/snapd/snap/certbot/2511 /dev/nvme0n1p1 1014M 270M 745M 27% /boot tmpfs 175M 4.0K 175M 1% /run/user/1000 |
②Create a dummy file to achieve at least 80% utilization
1 |
# dd if=/dev/zero of=dummyfile bs=1M count=9000 |
③check again
1 |
# df -h |
④Run check scripts
1 |
# /var/www/system/disk_capacity_check.sh |
You will receive an email to the email address you have set up, stating something like "Disk usage alert: 83 %".
⑤Delete "dummyfile"
1 |
# rm dummyfile |
⑥Periodic Execution Setting
1 2 |
# crontab -e 30 2 * * * /var/www/system/disk_capacity_check.sh |