Contents
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 |
################### Logwatch 7.5.5 (01/22/21) #################### Processing Initiated: Sun Oct 30 14:25:58 2022 Date Range Processed: yesterday ( 2022-Oct-29 ) Period is day. Detail Level of Output: 10 Type of Output/Format: stdout / text Logfiles for Host: Alma ################################################################## --------------------- Kernel Audit Begin ------------------------ Number of audit daemon starts: 2 Number of audit initializations: 2 **Unmatched Entries** auditd[766]: audit dispatcher initialized with q_depth=1200 and 1 active plugins: 1 Time(s) auditd[743]: audit dispatcher initialized with q_depth=1200 and 1 active plugins: 1 Time(s) ---------------------- Kernel Audit End ------------------------- <omission> --------------------- Disk Space Begin ------------------------ Filesystem Size Used Avail Use% Mounted on /dev/mapper/almalinux-root 17G 7.3G 9.8G 43% / /dev/nvme0n1p1 1014M 266M 749M 27% /boot overlay 17G 7.3G 9.8G 43% /var/snap/microk8s/common/run/containerd/io.containerd.runtime.v2.task/k8s.io/7084e6606742acf1039d8c6c88cf0317ad397b2c4a194b422e575fdebd9c5a3e/rootfs overlay 17G 7.3G 9.8G 43% /var/snap/microk8s/common/run/containerd/io.containerd.runtime.v2.task/k8s.io/0b8414e9f8d32cec59dcd2da2254d766b763c3b5ac4aa8c3ae81e2ebd6d068f5/rootfs overlay 17G 7.3G 9.8G 43% /var/snap/microk8s/common/run/containerd/io.containerd.runtime.v2.task/k8s.io/ffc331816c9f839c49a9806ba0d3c77278d5f96c5f0c7b96d4b89649956bedce/rootfs overlay 17G 7.3G 9.8G 43% /var/snap/microk8s/common/run/containerd/io.containerd.runtime.v2.task/k8s.io/780d240d57345e001121ba341dbc68d0636d32f1ca399f93a4c80c52320a267b/rootfs ---------------------- 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
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
When the DNS service is VALUEDOMAIN
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 !! |
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.
Auto Update Settings
With crontab -e, add the following to update periodically
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" |
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 11 |
Filesystem Size Used Avail Use% Mounted on devtmpfs 856M 0 856M 0% /dev tmpfs 875M 0 875M 0% /dev/shm tmpfs 350M 17M 333M 5% /run /dev/mapper/almalinux-root 17G 6.4G 11G 38% / /dev/loop1 56M 56M 0 100% /var/lib/snapd/snap/core18/2566 /dev/loop0 64M 64M 0 100% /var/lib/snapd/snap/core20/1623 /dev/loop2 45M 45M 0 100% /var/lib/snapd/snap/certbot/2414 /dev/nvme0n1p1 1014M 266M 749M 27% /boot /dev/loop4 48M 48M 0 100% /var/lib/snapd/snap/snapd/17336 tmpfs 175M 4.0K 175M 1% /run/user/1000 |
1 |
# dd if=/dev/zero of=dummyfile bs=1M count=9000 |
1 |
# df -h |
1 |
# /var/www/system/disk_capacity_check.sh |
⑤Delete "dummyfile"
1 |
# rm dummyfile |
⑥Periodic Execution Setting
1 2 |
# crontab -e 30 2 * * * /var/www/system/disk_capacity_check.sh |