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,10 +96,13 @@ def index():
unreported = []
for node in puppetdb.nodes():
node_last_seen = node.report_timestamp.replace(tzinfo=None)
if node_last_seen < (datetime.utcnow()-timedelta(hours=app.config['UNRESPONSIVE_HOURS'])):
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"
try:
node_last_seen = node.report_timestamp.replace(tzinfo=None)
if node_last_seen < (datetime.utcnow()-timedelta(hours=app.config['UNRESPONSIVE_HOURS'])):
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"
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)