Skip navigation

Simple tool:  I found I needed a way to keep tabs on when a DNS changed happened.  Knowing that the current site is hosted on a CloudFlare setup, I found that using curl to read the header, it gave me the server type.  Well, all I needed to know when that server type changed and I can go ahead with the rest of my setup.  This simple bash script works well for it’s basic purpose.

  1. while [ 1 ]; do
  2.         curl -Is  > test-curl.log
  3.         date >> test-curl-results.log
  4.         head -2 test-curl.log | tail -1 >> test-curl-results.log
  5.         notify-send “$(grep Server: test-curl.log | cut -c9-)”
  6.      sleep 1m
  7. done

When I see the change, I simply just stop the script from running.  If the change happens while I’m sleeping, I can see when it officially changes over.  If you have use for it, then enjoy it!

*currently set to 1m for testing.  Change to suit.

Advertisements

One Comment

  1. Since you use Bash, it can be just while :; do.

    If you insist on using C-looking style, [[ 1 ]] may run better and faster–though probably can’t tell and I do not test–since [[ is a keyword and [ is a built-in command.

    And line with head and , should be able to be simplified with sed:

            sed -n 2p test-curl.log >> test-curl-results.log
    

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: