SNMPを利用して1日の通信量を取得する

最近のクラウド、VPSでは管理画面で外部との通信量はクラウドやVPSの管理画面で確認できますが、物理サーバーでYAMAHAのルーターにつながっているサーバーのインターネット回線の通信量を計 ...
CUI環境でネット速度を測定する方法【speedtest-cli】

CentOSのCUI環境で高負荷の状態ではないのにコンソール操作の反応が遅いので回線速度が遅くなっているかも思って、回線速度を調べようと思ったのですが、GUIのブ ...
「新しいBing」でプロセスを監視するシェルスクリプトを作成

前回はChatGPTでプロセス監視の記事(ChatGPTでプロセスを監視するシェルスクリプトを作成)を書きましたが、マイクロソフトの「新しいBing」も使用できるようになったので、こちらでもプロセス監視のシェルスクリプトを作って貰いま ...
cronでS3のファイルをダウンロードするシェルスクリプトを実行するとダウンロードできない

AWS CLIで、s3からファイルをダウンロードするシェルスクリプトがあって、シェルスクリプトを実行すると問題なく実行できてCron経由だとエラーになる状況でした
s3からダウンロードするスクリプトは下記のようになっています ...
ChatGPTでプロセスを監視するシェルスクリプトを作成

最近、話題になっている「ChatGPT」を利用して簡単なシェルスクリプトを作成してみました。
「ChatGPT」は、OpenAIが開発した対話型AIチャットボットです。対話型で質問をすればAIが回答してくれます。
...
シェルスクリプトで引数でループする処理する方法(for文)

シェルスクリプトで全ての引数だけfor文でループ処理するには、下記のようなコードになります
#!/bin/bashfor i in "${@}"; do echo $idonefor文の構文は以下のようになります
f .../bin/bash^M: bad interpreter: No such file or directory の時の対処法

いつもは、LinuxにSSHログインしてvim コマンドでシェルスクリプトを作るのですが、Windowsでテキストエディタでシェルスクリプトで作ると改行コードが「\r\n」で保存されて、シェルスクリプトを実行すると下記のようなエラーに ...
nohupで実行した出力結果を、nohup.out以外のファイルに保存する

nohupを実行すると、コマンド実行時の標準出力・標準エラーは「nohup.out」のファイルに追加されます。
ファイルが肥大したり、以前の ...
Firewalld環境でfail2banを利用する

CentOS 7系の環境で「fail2ban」を利用して不正なアタックを締め出すようにします。F/Wは「Firewalld」を利用しています。Firewalldの設定は既に構築済みとして説明していきます。過去の記事「Firewalld ...
Firewalldの設定方法 ポートの開放

CentOS 7からは、OSの標準のF/Wは「iptable」ではなく「Firewalld」に変更なっています。今まではクラウドの管理画面でF/Wの設定できたので運用していなかったですが、「Firewalld」の設定が必要なったので、 ...
SSHログインでログイン失敗を確認する方法

CentOSでは、SSHログイン・コンソール操作に関するログは「/var/log/secure」に保存されています
Debian, Ubuntuでは、SSHログイン・コンソール操作に関するログは「/var/log/auth ...
ディレクトリ内のファイルをzipで圧縮する

ディレクトリ内のファイルをzipファイルに圧縮するには「zip」コマンドを圧縮できます
書式は「zip -r 」になります。「-r」でサブディレクトリを含めて圧縮できます
zip -r example_com.zi ...javaのバージョンを確認する方法

LinuxでJavaのバージョンを確認するには「java -version」のコマンドで確認できます。但し、Javaがインストールされている場合です
$ java -versionopenjdk version "11.0.17 ...Linuxで使用しているポートを確認する[Netstat]

Linuxで使用しているポートを確認する方法は、lsof、ss、netstat、nmap等ありますが、本記事では「netstat」を利用した方法を紹介します
「netstat -atun」とコマンドを打つと以下のようにLi ...
MySQLのデータベースの名前を変更する

データベースの名前を変更したい場合は、MySQLではリネームのコマンドがありません。
新しいDBを作成してdumpしたデータをインポートするか、RENAME TABLEコマンドを利用してリネームするしかないようです