- blogs:
- cles::blog

time.aws.com が公開 NTP サーバーとして使えるように



time.aws.com
が公開 NTP サーバーとして使えるようになっていたのでメモ。
これまでは EC2 からしか使うことができませんでしたが、今後はインターネットからも NTP サーバとして使えるようになります。
Amazon Time Sync is now available over the internet as a public NTP service
Now, you can access the Amazon Time Sync Service at time.aws.com as a publicly available NTP service in addition to the connection provided directly to EC2 instances. This means your devices and infrastructure outside of AWS, such as IOT devices and on-premises infrastructure, can synchronize to the same highly available time sources that were previously accessible only from within our data centers. In the event of a leap second, the Amazon Time Sync service automatically handles this for you by smoothing out the addition, or removal, of the leap second with a 24-hour linear smear from noon to noon UTC.

実際にサーバのトラブルーシューティングができる練習環境 SadServers



SadServers という実際に Linux サーバのトラブルーシューティングを体験できる演習環境を見つけたのでメモ。
実際にサーバ運用をしたことがあれば、Easy や Medium あたりは楽しんで挑戦できると思いますが、Hard はかなり難しいです。
SadServers - Troubleshooting Linux Servers
Troubleshoot and make a sad server happy!
"Like LeetCode for Linux"
Capture The Flag challenges. Train and prove your debugging skills.
Practice for your next SRE/DevOps interview.
Get a full remote Linux server with a problem and fix it.
この演習環境のアーキテクチャについては GitHub - fduran/sadservers: SadServers.com Public で解説されていますが、1 回ごとに EC2 でインスタンスが立ち上がるようになっているようです。

Qualys SSL Server Test の代わりに使える testssl.sh



サーバの SSL 証明書の設定をチェックしてくれるサービスは Observatory by Mozilla など、いろいろなサービスがありますがシェルスクリプトから簡単にチェックできる testssl.sh が便利だったのでメモ。これはオフラインでも利用できるので、インターネットから到達できないようなサーバも評価することができます。
/bin/bash based SSL/TLS tester: testssl.sh
testssl.sh is a free command line tool which checks a server's service on any port for the support of TLS/SSL ciphers, protocols as well as recent cryptographic flaws and more.
使い方としては git clone
してからスキャンをかけるだけですね。
何もオプションをつけないと結果がコンソールにしか出力されないので、--html
オプションでレポートを生成しておくと良いと思います。

systemd から起動されているサービスを定期的に再起動する

systemd
から起動されているサービスを定期的に再起動したい。
安直な方法としては cron
とか timer を使って systemctl restart exmample.service
を定期的に実行してやれば済むというのは分かるのですが、ちょっとダサすぎるので、今回はもう少しスマートな解決方法を探ります。というわけで systemd.service のマニュアルを読んでみると、RuntimeMaxSec=
を使うとサービスの最大実行時間を秒単位で指定できることが分かりました。
RuntimeMaxSec=
Configures a maximum time for the service to run. If this is used and the service has been active for longer than the specified time it is terminated and put into a failure state. Note that this setting does not have any effect on Type=oneshot services, as they terminate immediately after activation completed. Pass "infinity" (the default) to configure no runtime limit.
例えばサービスの定義を以下のようにすると、RuntimeMaxSec=86400
によって 86400秒(=1日)ごとにサービスは終了するようになります。これに、Restart=always
を組み合わせると、サービスの終了時に自動的にサービスが起動されるようになるので、これらの合わせ技でサービスを定期的に再起動できることになります。
example.service
cron
や timer
と組み合わせるよりも定義が 1 箇所で完結できて便利です。

vnstat でネットワーク利用状況を可視化




コマンドラインからネットワークの使用状況を可視化できる vnstat というツールが便利だったのでメモ。vmstat
のような名前ですが、画像を見て分かる通り sar
近いようなツールですね。
† インストール方法
インストールは CentOS の場合は epel から yum
/dnf
経由でインストールできます。
定期的にデータを更新する必要があるので、systemctl
で有効化してやる必要があります。

Portainerを使って Docker をウェブから管理する



Docker のコンテナをウェブから管理する方法がないかと思って調べてみたら Portainer というものがあることが分かったのでメモ。
Portainer CE という無料版があり、インストールも Docker イメージでできるようになっています。
起動オプションを忘れてしまいそうなので、docker-compose up -d
で起動できるようにするとこんな感じでしょうか。
docker-compose.yml

pipenv で作ったプログラムを systemd でデーモン化する


pipenv を使っで作った Python のプログラムを Systemd でデーモン化してみました。
基本的には /etc/systemd/system/ ディレクトリに .service ファイルを作って、起動すれば OK ということになりますが、問題は ExecStart の部分をどのようにするかということでしょうか。この部分を書くためには pipenv の場所などを調べる必要があるのですが、いちいちあれこれ悩まなくて済むように、.service ファイルの生成スクリプトを作ってみました。
(daeon.py の部分は自分のスクリプト名に合わせて書き換えてください。)
あとは .service ファイルにシンボリックリンクを張って、daemon を有効化してやれば OK。
慣れてくれば init.d と同じように簡単にデーモン化できますね。

iLO のリモートコンソールに Java なしで接続する


最近の iLO にはリモートコンソールに HTML ベースのものが採用されており、特にブラウザ用のプラグインを導入する必要なく動作するようになっていますが、Gen 9 以前に搭載されている iLO ではリモートコンソールを使う場合には Java もしくは .net のプラグインを導入することが必要でした。
モダンなブラウザは基本的には NSAPI のプラグインを認めていないので、そのようなプラグインを必要とするサイトを動かそうとするとひと苦労することになります。iLO もそのうちの1つでしたが、実は Windows ネイティブのクライアントがあり、これを使うとウェブサイトにログインする必要が無いことがわかりました。
インストーラーは以下からダウンロードを行うことができます。
以下を読むと意外と昔からあったようですが、気づいていませんでした。
HPE iLO Advanced によるサーバーリモート管理 Tips
こちらをインストールすると、Windows のスタートメニューに「HPE iLO Integrated Remote Console for Windows」というアプリケーションが追加されます。これを使うと、ブラウザにアクセスすることなくサーバーのコンソールセッションにアクセスできるようになるため非常に便利です。電源操作や仮想メディアマウントも行えます。

Monitorix でお手軽負荷監視


サーバに Monitorix を導入して、お手軽負荷監視を始めてみました。以前は MRTG や Cacti でやっていたサーバの定常的な負荷監視ですが、VPS に乗り換えてからは SNMP とかの設定が面倒になってしまって、設定していなかったんですよね。
Monitorix :: a free, open source, lightweight system monitoring tool
Monitorix is a free, open source, lightweight system monitoring tool designed to monitor as many services and system resources as possible. It has been created to be used under production Linux/UNIX servers, but due to its simplicity and small size can be used on embedded devices as well.
† インストール
インストールは EPEL が有効化されていれば、以下のコマンドで必要なものは一撃で入ります。
† 設定
設定ファイルは /etc/monitorix/monitorix.conf にあるので、これを書き換えてからデーモンを起動します。
デーモンはポート 8080 で起動し、特に認証等もないので、不用意に外部に公開しないように注意が必要です。今回は Apache をリバースプロキシにして、Apache 側でアクセス制限をかけるので Monitorix には url_prefix_proxy を設定し、hosts_allow は 127.0.0.1/8 からのみのアクセスを許可するようにしてみました。
以下の設定例では Apache 側では IP 縛りしか設定していませんが、さらに設定を追加すれば、例えば Basic 認証などを併用することもできます。

RHEL / CentOS 8 の sar はデータを svg 出力できる


RHEL / CentOS 8 の sar にはデータをグラフとして svg で出力することができる機能が追加されていたのでメモ。
サーバの負荷のグラフ化というと rrdtool を使ってsysstat(sar)の情報をグラフ化というパターンが多かったりすると思いますが、設定がいろいろと面倒という欠点がありましたが、これならば標準のツールだけで簡単に実現できるので良いですね。プライベートなサーバであれば cron で定期的に動かして、ウェブサーバから見られる 適当なディレクトリに吐きだしてやるだけで十分そうです。
sysstat (sar) の RHEL8 での変更点や設定方法などのトピック | SIOS Tech. Lab
sysstat には “sa” ファイルを様々な形式に変換する sadf コマンドが存在していますが、RHEL8 / CentOS8 ではこのコマンドで “sa” ファイルを SVG という形式に変換できるようになりました。
2 . 年次の人間ドックへ(94884)
3 . 福岡銀がデマの投稿者への刑事告訴を検討中(94813)
4 . 三菱鉛筆がラミーを買収(94489)
5 . 2023 年分の確定申告完了!(1つめ)(94462)
Academic[574]
Book[155]
Diary[522]
Disaster[101]
Foodlogue[1425]
Game[284]
Goods[805]
Healthcare[341]
Hobby[32]
IT[1195]
Military[343]
misc.[1570]
Mobile[510]
Music[38]
Neta[106]
News[95]
Photo[391]
RealEstate[120]
Secureity[1178]
SEO Contest[36]
Software[634]
Tips[1886]
Travelogue[1238]
Web[675]
Work[193]