Zabbix 6.4 で障害時のメール通知する

Zabbixで障害が発生した時に設定したメールアドレスにメールで通知するように設定します。設定は簡単でWEBの管理画面で設定すれば障害発生時にアラートメールが飛ぶようになります
1.ZabbixのWEBの管理画面にログイン ...
SCPコマンドでタイムスタンプ・パーミッションを保持してコピー

いつもサーバー間のデータコピーは、scpコマンドを利用しています。「-r」のオプションをつかって、ディレクトリ以下のファイルやディレクトリを再帰的に取得してコピーしてました。
ファイルのタイムスタンプやパーミッションを保持 ...
curlコマンドで特定のポートを疎通確認をする

curlコマンドで80番・443番ポート以外のURLにアクセスするには、下記のようなコマンドで確認できます
curl -v :9090番ポートにアクセスしたい場合は、以下のようなコマンドとなります
【成功時】
grepで2桁の数字を含む行を抽出する

grepコマンドで2桁の数字を含む行を抽出する場合は、下記のコマンドで数字を2桁の行を抽出できます
grep -E "{2}"下記のような数字を含むテキストファイルで、2桁 ...
gz形式のファイルを解凍しないで中身を確認する

ローテーションしているログファイルで、古いログはgz形式で以下のように圧縮している場合があると思います。
$ sudo ls/var/log/mariadb/mariadb.log mariadb.log-20230922.gz ...digコマンドで逆引きする方法

digコマンドは、DNSサーバーにIPアドレスやドメイン名からDNSレコードを取得するコマンドです。
逆引きは、このdigコマンドでIPアドレスからドメイン名を取得する事です
使い方は、「dig -x IPアドレス ...
lsコマンドで、容量が大きいサイズ順にソートする方法

容量関係でついでですが、lsコマンドで容量が大きい順にソートするのは「-S」オプションを使用します
この「-S」コマンドは、ファイルやディレクトリを容量の大きい順にリ ...
CentOS系でファイル名の文字を置換してファイル名を変換

CentOS系で、「test_01.txt」等のファイルが有り「test01.txt」の用に「_」を省略したいときがあります。「mv」コマンドでもで ...
Linux の起動時間を調べる

CentOS、Ubuntuのサーバーが起動した時間を調べる方法はいくつかあります
uptimeコマンドを使用するuptimeコマンドを使用するとサーバーが起動してからの時間を確認できます。下記では、「up 1 day, 3 ...
findコマンドを結果のファイル数をカウントする

findの結果をファイル数をカウントする方法ですが、findコマンドの後にパイプ(|)の後に、wcコマンドを組み合わせればカウントできます
$ find . -name "*.log" -type f | wc -l5ファイルのバックアップを作る時に日付を付与するワンライナー

ファイルバックアップする時に下記のようなコマンドで、ファイル名に日付をつけてバックアップすることがあります。
$ cp/home/admin/test.txt/home/admin/test_20230907.txtこれ普 ...
sedコマンドで「/」 と 「&」を含む場合のエクケープ処理

シェルスクリプト内でテキストファイル内の一部の文字を置換する処理があって、半角空白と「&」を含んでいて、置換がうまく処理されずに変数名が残ってしまいました
$ cat in.txtCORPORATION 御中$ sh s ...永続オブジェクトキャッシュを使用してください 【WordPress】

Wordpressのヘルスチェックで下記のように「永続オブジェクトキャッシュを使用してください」と表示されます。以前は「Memcached Redux」を使ってい ...
「APCu」の有効になっているか確認する

PHPのAPCu(Alternative PHP Cache user caching)は、PHPプログラムのパフォーマンスを向上させるための仕組みの一つで、PHPコードの結果やデータをキャッシュする機能を提供します。これにより、同じ ...
ディレクトリ内にある、空白のファイル名を変換する

任意のディレクトリにある、空白を含むファイル名をアンスコ(_)やハイフン(-)に変換する方法ですが、ネットでは以下のワンライナーの方法がありました
find . -name "* *" | rename 's//_/g'C ...