Add nodes with missing timestamp to unreported nodes

Skip nodes with NoneType timestamps

add nodes with missing timestamp to unreported nodes
This commit is contained in:
Lars Sjöström
2013-10-29 09:34:43 +01:00
committed by Lars Sjöström
parent ee2775512d
commit 61548c819c

View File

@@ -96,11 +96,14 @@ def index():
unreported = [] unreported = []
for node in puppetdb.nodes(): for node in puppetdb.nodes():
try:
node_last_seen = node.report_timestamp.replace(tzinfo=None) node_last_seen = node.report_timestamp.replace(tzinfo=None)
if node_last_seen < (datetime.utcnow()-timedelta(hours=app.config['UNRESPONSIVE_HOURS'])): if node_last_seen < (datetime.utcnow()-timedelta(hours=app.config['UNRESPONSIVE_HOURS'])):
delta = (datetime.utcnow()-node_last_seen) delta = (datetime.utcnow()-node_last_seen)
node.noresponse = str(delta.days) + "d " + str(int(delta.seconds/3600)) +"h " + str(int((delta.seconds%3600)/60))+ "m" node.noresponse = str(delta.days) + "d " + str(int(delta.seconds/3600)) +"h " + str(int((delta.seconds%3600)/60))+ "m"
unreported.append(node) unreported.append(node)
except AttributeError:
unreported.append(node)
return render_template('index.html', metrics=metrics, latest_event_count=latest_event_count, latest_events=latest_events, unreported=unreported) return render_template('index.html', metrics=metrics, latest_event_count=latest_event_count, latest_events=latest_events, unreported=unreported)