<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">We have had a couple of requests for a log message warning that an NTA has just expired. The use case is, there is a help desk that needs to know when validation might be failing because of an NTA that was just removed.<div class=""><br class=""></div><div class="">Anyway, in response, Evan wrote a Python script that takes the output of <code class="">rndc nta -d</code> and lists the NTA's that are expiring in the next 24 hours. If you ran rndc nta -d and this script this daily, you would have a daily report. </div><div class=""><br class=""></div><div class=""><span style="caret-color: rgb(64, 64, 64);" class="">It gives you the full list of ntas, an indicator of whether they're already expired or yet to expire, and the time of expiration. </span></div><div class=""><span style="caret-color: rgb(64, 64, 64);" class="">The python script filters out any that are already expired or whose expiration is more than a day in the future.</span></div><div class=""><span style="caret-color: rgb(64, 64, 64);" class=""><br class=""></span></div><div class=""><div class="content"><pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code class=""><span id="LC1" class="line" lang="plaintext">#!/bin/python</span>
<span id="LC2" class="line" lang="plaintext">import sys, time, re</span>
<span id="LC3" class="line" lang="plaintext"></span>
<span id="LC4" class="line" lang="plaintext">print ('Negative trust anchors expiring in the next 24 hours:')</span>
<span id="LC5" class="line" lang="plaintext">found = False</span>
<span id="LC6" class="line" lang="plaintext"></span>
<span id="LC7" class="line" lang="plaintext">for line in sys.stdin.readlines():</span>
<span id="LC8" class="line" lang="plaintext"> r = re.compile('^([^ ]*): (expir[^ ]*) (.*)')</span>
<span id="LC9" class="line" lang="plaintext"> m = r.match(line)</span>
<span id="LC10" class="line" lang="plaintext"> try:</span>
<span id="LC11" class="line" lang="plaintext"> (name, status, date) = m.groups()</span>
<span id="LC12" class="line" lang="plaintext"> except:</span>
<span id="LC13" class="line" lang="plaintext"> continue</span>
<span id="LC14" class="line" lang="plaintext"></span>
<span id="LC15" class="line" lang="plaintext"> now = time.time()</span>
<span id="LC16" class="line" lang="plaintext"> then = time.mktime(time.strptime(date, '%d-%b-%Y %H:%M:%S.%f'))</span>
<span id="LC17" class="line" lang="plaintext"> if status == 'expiry' and then <= now + 86400:</span>
<span id="LC18" class="line" lang="plaintext"> print (' %s at %s' % (name, date))</span>
<span id="LC19" class="line" lang="plaintext"> found = True</span>
<span id="LC20" class="line" lang="plaintext"></span>
<span id="LC21" class="line" lang="plaintext">if not found:</span>
<span id="LC22" class="line" lang="plaintext"> print (' None')</span></code></pre></div><div class="footer" style="margin-top: 10px;"></div></div><div class=""><span style="caret-color: rgb(64, 64, 64);" class=""><br class=""></span></div><div class=""><span style="caret-color: rgb(64, 64, 64);" class="">I thought this might be useful to someone else out there.</span></div><div class=""><span style="caret-color: rgb(64, 64, 64);" class=""><br class=""></span></div><div class=""><div class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Vicky</div><div class=""><br class=""></div></div><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"><br class="Apple-interchange-newline">
</div>
<br class=""></div></div></body></html>