DHCPサーバのIPアドレス数を監視したい。 具体的には、リースしているIPアドレス数と、空いているIPアドレス数のそれぞれである。 基になるデータはdhcpd.leasesにあるのだが、そのままでは使えない。 manなど読めば分かるのだが、ここにはIPアドレスの貸与、更新、破棄が末尾にだらだらと追記されていくので、同じクライアントが複数回出てきたりする。 だからリースされたもの、空いているものを数えようとすると意外に手間取るのである。 同じ悩みを持つ方はいるようで、少し検索すると、こういったIPアドレス数を数えるスクリプトはいくつか見つかる。 調べてみた結果を記す。 なお先に結論を言っておくと、どこかの誰かが作ってくれたawkスクリプトを使用することにした。 いくつかのスクリプト いずれも判で押したようにperlスクリプトである。 繰り返すがここにあるものは使っていない。 DHCPsta