1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ELBのIPと台数をひたすらdigしておく

Last updated at Posted at 2019-08-02

ELBのスケーリングを観察するのが目的
ELBのDNS名解決は、インターネットに繋がっていれば可能です
ELBのIPと台数をひたすらdigしておくために、
作った適当なEC2 (インターネットに繋がる) のcrontabに登録して下記スクリプトを実行したのよ

crontab (1分おきに実行)

*/1 * * * * sh /home/ec2-user/elbdig.sh <ロードバランサのDNS名>

elbdig.sh

#!/bin/bash -

# 引数1となりうる値
# ロードバランサ名

elbname=$1

        datetime=$(date "+%Y-%m%d-%H:%M-%S")

        ipaddrlist=$(dig ${elbname} |grep -v -E "^(;|$)" |awk '{print $5}' |sort -n -t'.' -k1,1 -k2,2 -k3,3 -k4,4 |awk -v 'RS=nothing!!!!' '{print $1,",",$2,",",$3,",",$4,",",$5,",",$6,",",$7,",",$8}')

        number=$(dig ${elbname} |grep -v -E "^(;|$)" | wc -l)

        echo -e "${datetime}\t${number}\t${ipaddrlist}" |tee -a ${elbname}.txt

# 20190803 追記 : cronに登録しておくため while文は不要でした 削除しました
# また、ELBは8台まで拡張するため、$1,",",$2,",",$3,",",$4,",",$5,",",$6,",",$7,",",$8 と修正しました
1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?