feat(health): recent XMPP conversation log panel + stale error fix
User requirement: health tab should show recent XMPP conversations. - bot hooks log_xmpp on inbound (on_msg) and outbound (_deliver_loop) so real chats land in xmpp_messages.jsonl (was: only cron/scanner) - index.html health tab: new '最近对话' panel (last 10 msgs, dir arrow, preview, status, time); refreshHealth updates it incrementally - last_error now shows age and resolved state: once a successful outbound happens after an error, it's shown gray as '已恢复' instead of alarming red forever; unresolved errors still red - health() status no longer degraded by errors that were later resolved by successful outbound
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import urllib.request, json
|
||||
d = json.loads(urllib.request.urlopen('http://127.0.0.1:8899/api/xmpp/health', timeout=120).read())
|
||||
ba = d.get('bot_activity', {})
|
||||
print('status:', d.get('status'))
|
||||
print('last_error:', (ba.get('last_error') or '')[:80])
|
||||
print('last_error_age_sec:', ba.get('last_error_age_sec'))
|
||||
print('last_error_resolved:', ba.get('last_error_resolved'))
|
||||
print('last_outbound_age_sec:', ba.get('last_outbound_age_sec'))
|
||||
print('---')
|
||||
m = json.loads(urllib.request.urlopen('http://127.0.0.1:8899/api/xmpp/messages', timeout=30).read())
|
||||
msgs = m.get('messages', [])
|
||||
print('messages count:', len(msgs))
|
||||
for x in msgs[:5]:
|
||||
print(' ', x.get('timestamp'), x.get('direction'), (x.get('body_preview') or '')[:50])
|
||||
Reference in New Issue
Block a user