diff --git a/runtime/history/SUPPORT-261004-SKLADCHIK-COMPLAINTS-TITLE-TOKEN-RCA-99564R1.json b/runtime/history/SUPPORT-261004-SKLADCHIK-COMPLAINTS-TITLE-TOKEN-RCA-99564R1.json new file mode 100644 index 00000000..d6c938f9 --- /dev/null +++ b/runtime/history/SUPPORT-261004-SKLADCHIK-COMPLAINTS-TITLE-TOKEN-RCA-99564R1.json @@ -0,0 +1,38 @@ +{ + "schema_version": 1, + "channel": "homelab-runtime", + "command_id": "SUPPORT-261004-SKLADCHIK-COMPLAINTS-TITLE-TOKEN-RCA-99564R1", + "status": "OK", + "rc": 0, + "host": "pve01", + "mode": "read-only", + "component": "skladchik-complaints-title-token-rca", + "started_at_utc": "2026-10-04T20:16:41Z", + "finished_at_utc": "2026-10-04T20:16:46Z", + "reference_register_checked": true, + "reference_sha256": "5a3d8e5154c41cb582a4e0aca68090be1f0138918bf82131a948df326f9d8d66", + "error_register_checked": true, + "error_register_sha256": "3b09a553ec0f527ed3afeed4753f52a74ee3036045bbfb3c685e9f8af4ba7ba0", + "command_sha256": "bbe4077da8ab20fa07a5b8458821ecbe544b502ccbb871742ef07ac2d14d220e", + "duplicate_failed_command_blocked": false, + "block_reason": null, + "execution_started": true, + "change_declared": false, + "result_contract_valid": true, + "result_contract_status": null, + "result_contract_error": null, + "command_rc": 0, + "changes_made": false, + "rollback_started": false, + "rollback_restored": null, + "mutation_outcome": "NO_MUTATION", + "sanitized": true, + "secrets_included": false, + "private_addresses_included": false, + "raw_evidence_retained_locally": true, + "raw_evidence_sha256": "f375d4e36d4d0a70ebad8412a2dd1f0e4faa25f8c6f2d4d648a215164c8f2d2c", + "sanitized_output_sha256": "f375d4e36d4d0a70ebad8412a2dd1f0e4faa25f8c6f2d4d648a215164c8f2d2c", + "output_truncated_in_json": false, + "full_sanitized_output_url": "https://git.gram1.ru/.well-known/homelab-runtime/latest.txt", + "output": "SKLADCHIK_COMPLAINTS_TITLE_TOKEN_RCA=V1\nMODE=read-only\nNO_MAIL_SEND=true\nNO_SERVICE_RESTART=true\nNO_TIMER_MUTATION=true\nNO_NETWORK_MUTATION=true\nNO_SOURCE_MUTATION=true\nHOST_PVE01=true\nVM170_STATUS=running\nHEALTH_SCAN=V1\nHEALTH_PRESENT=true\nHEALTH_SHA256=918f3d1db31c64fe5f7548c3da6183ca6bf8be80384fa0673c55f68826dcc717\nHEALTH_BYTES=16080\nHEALTH_FUNCTION_COUNT=22\nHEALTH_FUNC=utc_now:24:25\nHEALTH_FUNC=ts:28:29\nHEALTH_FUNC=log:32:35\nHEALTH_FUNC=run_cmd:38:43\nHEALTH_FUNC=parse_kv_file:46:54\nHEALTH_FUNC=iso_age_seconds:57:64\nHEALTH_FUNC=load_state:67:71\nHEALTH_FUNC=save_state:74:78\nHEALTH_FUNC=load_monitor_module:81:87\nHEALTH_FUNC=send_mail:90:93\nHEALTH_FUNC=systemd_value:96:98\nHEALTH_FUNC=route_ok:101:103\nHEALTH_FUNC=problem_to_ru:106:129\nHEALTH_FUNC=yes_no_ru:132:133\nHEALTH_FUNC=status_ru:136:145\nHEALTH_FUNC=build_status:148:206\nHEALTH_FUNC=status_to_body:209:253\nHEALTH_FUNC=write_alert_health:256:280\nHEALTH_FUNC=do_heartbeat:283:294\nHEALTH_FUNC=do_check:297:332\nHEALTH_FUNC=do_status:335:344\nHEALTH_FUNC=main:347:356\nHEALTH_RELEVANT_COUNT=9\nHEALTH_DUMP_BEGIN=parse_kv_file\nFunctionDef(\n name='parse_kv_file',\n args=arguments(\n args=[\n arg(\n arg='path',\n annotation=Name(id='Path', ctx=Load()))]),\n body=[\n Assign(\n targets=[\n Name(id='data', ctx=Store())],\n value=Dict()),\n If(\n test=UnaryOp(\n op=Not(),\n operand=Call(\n func=Attribute(\n value=Name(id='path', ctx=Load()),\n attr='exists',\n ctx=Load()))),\n body=[\n Return(\n value=Name(id='data', ctx=Load()))]),\n For(\n target=Name(id='raw', ctx=Store()),\n iter=Call(\n func=Attribute(\n value=Call(\n func=Attribute(\n value=Name(id='path', ctx=Load()),\n attr='read_text',\n ctx=Load()),\n keywords=[\n keyword(\n arg='encoding',\n value=Constant(value='utf-8')),\n keyword(\n arg='errors',\n value=Constant(value='replace'))]),\n attr='splitlines',\n ctx=Load())),\n body=[\n If(\n test=Compare(\n left=Constant(value='='),\n ops=[\n In()],\n comparators=[\n Name(id='raw', ctx=Load())]),\n body=[\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='k', ctx=Store()),\n Name(id='v', ctx=Store())],\n ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='raw', ctx=Load()),\n attr='split',\n ctx=Load()),\n args=[\n Constant(value='='),\n Constant(value=1)])),\n Assign(\n targets=[\n Subscript(\n value=Name(id='data', ctx=Load()),\n slice=Call(\n func=Attribute(\n value=Name(id='k', ctx=Load()),\n attr='strip',\n ctx=Load())),\n ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='v', ctx=Load()),\n attr='strip',\n ctx=Load())))])]),\n Return(\n value=Name(id='data', ctx=Load()))])\nHEALTH_DUMP_SHA256=577b27aca6d27fc787beed7fda2903d72e67f386753fadfc23325e1279ff8082\nHEALTH_DUMP_TRUNCATED=false\nHEALTH_DUMP_END=parse_kv_file\nHEALTH_DUMP_BEGIN=send_mail\nFunctionDef(\n name='send_mail',\n args=arguments(\n args=[\n arg(\n arg='subject',\n annotation=Name(id='str', ctx=Load())),\n arg(\n arg='body',\n annotation=Name(id='str', ctx=Load()))]),\n body=[\n Assign(\n targets=[\n Name(id='mod', ctx=Store())],\n value=Call(\n func=Name(id='load_monitor_module', ctx=Load()))),\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='cfg', ctx=Store()),\n Name(id='secrets', ctx=Store())],\n ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='mod', ctx=Load()),\n attr='load_config',\n ctx=Load()))),\n Return(\n value=Call(\n func=Name(id='bool', ctx=Load()),\n args=[\n Call(\n func=Attribute(\n value=Name(id='mod', ctx=Load()),\n attr='send_mail',\n ctx=Load()),\n args=[\n Name(id='cfg', ctx=Load()),\n Name(id='secrets', ctx=Load()),\n Name(id='subject', ctx=Load()),\n Name(id='body', ctx=Load())])]))],\n returns=Name(id='bool', ctx=Load()))\nHEALTH_DUMP_SHA256=949d900c876b9ee94a5fa7eca5792121fe1e77eee64b76fe447c8c8ba94b48c6\nHEALTH_DUMP_TRUNCATED=false\nHEALTH_DUMP_END=send_mail\nHEALTH_DUMP_BEGIN=route_ok\nFunctionDef(\n name='route_ok',\n args=arguments(),\n body=[\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='rc', ctx=Store()),\n Name(id='out', ctx=Store())],\n ctx=Store())],\n value=Call(\n func=Name(id='run_cmd', ctx=Load()),\n args=[\n List(\n elts=[\n Constant(value='ip'),\n Constant(value='route'),\n Constant(value='get'),\n Constant(value='')],\n ctx=Load())],\n keywords=[\n keyword(\n arg='timeout',\n value=Constant(value=10))])),\n Return(\n value=Tuple(\n elts=[\n BoolOp(\n op=And(),\n values=[\n Compare(\n left=Name(id='rc', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value=0)]),\n Compare(\n left=Constant(value=' dev wt0 '),\n ops=[\n In()],\n comparators=[\n JoinedStr(\n values=[\n Constant(value=' '),\n FormattedValue(\n value=Name(id='out', ctx=Load()),\n conversion=-1),\n Constant(value=' ')])])]),\n Name(id='out', ctx=Load())],\n ctx=Load()))])\nHEALTH_DUMP_SHA256=b3c72e69fe87a4333c66b82a8e898bc417dc642ecd71381f1bb45f6b26f7e255\nHEALTH_DUMP_TRUNCATED=false\nHEALTH_DUMP_END=route_ok\nHEALTH_DUMP_BEGIN=status_ru\nFunctionDef(\n name='status_ru',\n args=arguments(\n args=[\n arg(\n arg='value',\n annotation=Name(id='str', ctx=Load()))]),\n body=[\n If(\n test=Compare(\n left=Name(id='value', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='OK')]),\n body=[\n Return(\n value=Constant(value='OK'))]),\n If(\n test=Compare(\n left=Name(id='value', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='ALERT')]),\n body=[\n Return(\n value=Constant(value='ТРЕВОГА'))]),\n If(\n test=Compare(\n left=Name(id='value', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='AUTH_REQUIRED')]),\n body=[\n Return(\n value=Constant(value='нужна повторная авторизация'))]),\n If(\n test=Compare(\n left=Name(id='value', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='ERROR')]),\n body=[\n Return(\n value=Constant(value='ошибка'))]),\n Return(\n value=BoolOp(\n op=Or(),\n values=[\n Name(id='value', ctx=Load()),\n Constant(value='неизвестно')]))],\n returns=Name(id='str', ctx=Load()))\nHEALTH_DUMP_SHA256=177f282793ef16e747defa8dbd1fb35e704b9d54ffa892799e430ac9e0ecf22a\nHEALTH_DUMP_TRUNCATED=false\nHEALTH_DUMP_END=status_ru\nHEALTH_DUMP_BEGIN=build_status\nFunctionDef(\n name='build_status',\n args=arguments(),\n body=[\n Assign(\n targets=[\n Name(id='problems', ctx=Store())],\n value=List(ctx=Load())),\n Assign(\n targets=[\n Name(id='health', ctx=Store())],\n value=Call(\n func=Name(id='parse_kv_file', ctx=Load()),\n args=[\n Name(id='HEALTH_PATH', ctx=Load())])),\n Assign(\n targets=[\n Name(id='timer_active', ctx=Store())],\n value=Call(\n func=Name(id='systemd_value', ctx=Load()),\n args=[\n Constant(value='skladchik-reports-monitor.timer'),\n Constant(value='ActiveState')])),\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='timer_enabled_rc', ctx=Store()),\n Name(id='timer_enabled', ctx=Store())],\n ctx=Store())],\n value=Call(\n func=Name(id='run_cmd', ctx=Load()),\n args=[\n List(\n elts=[\n Constant(value='systemctl'),\n Constant(value='is-enabled'),\n Constant(value='skladchik-reports-monitor.timer')],\n ctx=Load())],\n keywords=[\n keyword(\n arg='timeout',\n value=Constant(value=10))])),\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='watchdog_enabled_rc', ctx=Store()),\n Name(id='watchdog_enabled', ctx=Store())],\n ctx=Store())],\n value=Call(\n func=Name(id='run_cmd', ctx=Load()),\n args=[\n List(\n elts=[\n Constant(value='systemctl'),\n Constant(value='is-enabled'),\n Constant(value='skladchik-reports-monitor-watchdog.timer')],\n ctx=Load())],\n keywords=[\n keyword(\n arg='timeout',\n value=Constant(value=10))])),\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='heartbeat_enabled_rc', ctx=Store()),\n Name(id='heartbeat_enabled', ctx=Store())],\n ctx=Store())],\n value=Call(\n func=Name(id='run_cmd', ctx=Load()),\n args=[\n List(\n elts=[\n Constant(value='systemctl'),\n Constant(value='is-enabled'),\n Constant(value='skladchik-reports-monitor-heartbeat.timer')],\n ctx=Load())],\n keywords=[\n keyword(\n arg='timeout',\n value=Constant(value=10))])),\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='r_ok', ctx=Store()),\n Name(id='route_text', ctx=Store())],\n ctx=Store())],\n value=Call(\n func=Name(id='route_ok', ctx=Load()))),\n If(\n test=Compare(\n left=Name(id='timer_active', ctx=Load()),\n ops=[\n NotEq()],\n comparators=[\n Constant(value='active')]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='problems', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='monitor_timer_not_active:'),\n FormattedValue(\n value=Name(id='timer_active', ctx=Load()),\n conversion=-1)])]))]),\n If(\n test=BoolOp(\n op=Or(),\n values=[\n Compare(\n left=Name(id='timer_enabled_rc', ctx=Load()),\n ops=[\n NotEq()],\n comparators=[\n Constant(value=0)]),\n Compare(\n left=Name(id='timer_enabled', ctx=Load()),\n ops=[\n NotEq()],\n comparators=[\n Constant(value='enabled')])]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='problems', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='monitor_timer_not_enabled:'),\n FormattedValue(\n value=Name(id='timer_enabled', ctx=Load()),\n conversion=-1)])]))]),\n If(\n test=UnaryOp(\n op=Not(),\n operand=Call(\n func=Attribute(\n value=Name(id='HEALTH_PATH', ctx=Load()),\n attr='exists',\n ctx=Load()))),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='problems', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n Constant(value='monitor_health_missing')]))]),\n If(\n test=Compare(\n left=Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='STATUS')]),\n ops=[\n NotEq()],\n comparators=[\n Constant(value='OK')]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='problems', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='monitor_status_not_ok:'),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='STATUS'),\n Constant(value='missing')]),\n conversion=-1)])]))]),\n Assign(\n targets=[\n Name(id='age', ctx=Store())],\n value=Call(\n func=Name(id='iso_age_seconds', ctx=Load()),\n args=[\n Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='TS'),\n Constant(value='')])])),\n If(\n test=Compare(\n left=Name(id='age', ctx=Load()),\n ops=[\n Is()],\n comparators=[\n Constant(value=None)]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='problems', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n Constant(value='monitor_health_ts_invalid')]))],\n orelse=[\n If(\n test=Compare(\n left=Name(id='age', ctx=Load()),\n ops=[\n Gt()],\n comparators=[\n Name(id='MAX_HEALTH_AGE_SECONDS', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='problems', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='monitor_health_stale:'),\n FormattedValue(\n value=Name(id='age', ctx=Load()),\n conversion=-1),\n Constant(value='s')])]))])]),\n Try(\n body=[\n Assign(\n targets=[\n Name(id='reports', ctx=Store())],\n value=Call(\n func=Name(id='int', ctx=Load()),\n args=[\n Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='reports'),\n Constant(value='-1')])]))],\n handlers=[\n ExceptHandler(\n type=Name(id='ValueError', ctx=Load()),\n body=[\n Assign(\n targets=[\n Name(id='reports', ctx=Store())],\n value=UnaryOp(\n op=USub(),\n operand=Constant(value=1)))])]),\n If(\n test=Compare(\n left=Name(id='reports', ctx=Load()),\n ops=[\n LtE()],\n comparators=[\n Constant(value=0)]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='problems', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='monitor_reports_bad:'),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='reports'),\n Constant(value='missing')]),\n conversion=-1)])]))]),\n If(\n test=Compare(\n left=Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='')]),\n ops=[\n NotIn()],\n comparators=[\n Tuple(\n elts=[\n Constant(value='yes'),\n Constant(value='empty')],\n ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='problems', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value=''),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value=''),\n Constant(value='missing')]),\n conversion=-1)])]))]),\n Assign(\n targets=[\n Name(id='expiry_status', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value=''),\n Constant(value='')])),\n Assign(\n targets=[\n Name(id='expires_raw', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value=''),\n Constant(value='')])),\n Try(\n body=[\n Assign(\n targets=[\n Name(id='expires_in', ctx=Store())],\n value=Call(\n func=Name(id='int', ctx=Load()),\n args=[\n Name(id='expires_raw', ctx=Load())]))],\n handlers=[\n ExceptHandler(\n type=Name(id='Exception', ctx=Load()),\n body=[\n Assign(\n targets=[\n Name(id='expires_in', ctx=Store())],\n value=Constant(value=None))])]),\n If(\n test=Compare(\n left=Name(id='expiry_status', ctx=Load()),\n ops=[\n In()],\n comparators=[\n Tuple(\n elts=[\n Constant(value=''),\n Constant(value=''),\n Constant(value=''),\n Constant(value='ERROR')],\n ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='problems', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n Constant(value='')]))],\n orelse=[\n If(\n test=BoolOp(\n op=Or(),\n values=[\n Compare(\n left=Name(id='expiry_status', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='EXPIRED')]),\n BoolOp(\n op=And(),\n values=[\n Compare(\n left=Name(id='expires_in', ctx=Load()),\n ops=[\n IsNot()],\n comparators=[\n Constant(value=None)]),\n Compare(\n left=Name(id='expires_in', ctx=Load()),\n ops=[\n LtE()],\n comparators=[\n Constant(value=0)])])]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='problems', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n Constant(value='')]))],\n orelse=[\n If(\n test=BoolOp(\n op=Or(),\n values=[\n Compare(\n left=Name(id='expiry_status', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='WARN')]),\n BoolOp(\n op=And(),\n values=[\n Compare(\n left=Name(id='expires_in', ctx=Load()),\n ops=[\n IsNot()],\n comparators=[\n Constant(value=None)]),\n Compare(\n left=Name(id='expires_in', ctx=Load()),\n ops=[\n Lt()],\n comparators=[\n Name(id='COOKIE\nHEALTH_DUMP_SHA256=d30ee0c7a70105bffab10e001bddfad80466fe5a99394d96b4449e991cbfbeaf\nHEALTH_DUMP_TRUNCATED=true\nHEALTH_DUMP_END=build_status\nHEALTH_DUMP_BEGIN=status_to_body\nFunctionDef(\n name='status_to_body',\n args=arguments(\n args=[\n arg(arg='status'),\n arg(\n arg='mode',\n annotation=Name(id='str', ctx=Load()))]),\n body=[\n Assign(\n targets=[\n Name(id='health', ctx=Store())],\n value=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='health'),\n ctx=Load())),\n Assign(\n targets=[\n Name(id='lines', ctx=Store())],\n value=List(ctx=Load())),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='Мониторинг жалоб Складчика: '),\n FormattedValue(\n value=Name(id='mode', ctx=Load()),\n conversion=-1)])])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='Время UTC: '),\n FormattedValue(\n value=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='ts'),\n ctx=Load()),\n conversion=-1)])])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='Общий статус: '),\n FormattedValue(\n value=IfExp(\n test=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='ok'),\n ctx=Load()),\n body=Constant(value='OK'),\n orelse=Constant(value='ТРЕВОГА')),\n conversion=-1)])])),\n If(\n test=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='problems'),\n ctx=Load()),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n Constant(value='Проблемы:')])),\n For(\n target=Name(id='problem', ctx=Store()),\n iter=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='problems'),\n ctx=Load()),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='- '),\n FormattedValue(\n value=Call(\n func=Name(id='problem_to_ru', ctx=Load()),\n args=[\n Name(id='problem', ctx=Load())]),\n conversion=-1)])]))])]),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n Constant(value='')])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n Constant(value='Состояние основного монитора:')])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='- Статус: '),\n FormattedValue(\n value=Call(\n func=Name(id='status_ru', ctx=Load()),\n args=[\n Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='STATUS'),\n Constant(value='missing')])]),\n conversion=-1)])])),\n If(\n test=Compare(\n left=Constant(value='TS'),\n ops=[\n In()],\n comparators=[\n Name(id='health', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='- Последний успешный опрос UTC: '),\n FormattedValue(\n value=Subscript(\n value=Name(id='health', ctx=Load()),\n slice=Constant(value='TS'),\n ctx=Load()),\n conversion=-1)])]))]),\n If(\n test=Compare(\n left=Constant(value='url'),\n ops=[\n In()],\n comparators=[\n Name(id='health', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='- URL: '),\n FormattedValue(\n value=Subscript(\n value=Name(id='health', ctx=Load()),\n slice=Constant(value='url'),\n ctx=Load()),\n conversion=-1)])]))]),\n If(\n test=Compare(\n left=Constant(value='reports'),\n ops=[\n In()],\n comparators=[\n Name(id='health', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='- Всего жалоб на странице: '),\n FormattedValue(\n value=Subscript(\n value=Name(id='health', ctx=Load()),\n slice=Constant(value='reports'),\n ctx=Load()),\n conversion=-1)])]))]),\n If(\n test=Compare(\n left=Constant(value='open'),\n ops=[\n In()],\n comparators=[\n Name(id='health', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='- Открытые / в работе: '),\n FormattedValue(\n value=Subscript(\n value=Name(id='health', ctx=Load()),\n slice=Constant(value='open'),\n ctx=Load()),\n conversion=-1)])]))]),\n If(\n test=Compare(\n left=Constant(value='resolved'),\n ops=[\n In()],\n comparators=[\n Name(id='health', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='- Закрытые / отработанные: '),\n FormattedValue(\n value=Subscript(\n value=Name(id='health', ctx=Load()),\n slice=Constant(value='resolved'),\n ctx=Load()),\n conversion=-1)])]))]),\n If(\n test=Compare(\n left=Constant(value='session_keepalive'),\n ops=[\n In()],\n comparators=[\n Name(id='health', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n Constant(value='')]))]),\n If(\n test=Compare(\n left=Constant(value=''),\n ops=[\n In()],\n comparators=[\n Name(id='health', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value=''),\n FormattedValue(\n value=Subscript(\n value=Name(id='health', ctx=Load()),\n slice=Constant(value=''),\n ctx=Load()),\n conversion=-1),\n Constant(value=', байт: '),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value=''),\n Constant(value='?')]),\n conversion=-1)])]))]),\n If(\n test=Compare(\n left=Constant(value=''),\n ops=[\n In()],\n comparators=[\n Name(id='health', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value=''),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='')]),\n conversion=-1)])])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value=''),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value=''),\n Constant(value='?')]),\n conversion=-1)])])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value=''),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value=''),\n Constant(value='?')]),\n conversion=-1)])]))]),\n If(\n test=Compare(\n left=Constant(value='new_events'),\n ops=[\n In()],\n comparators=[\n Name(id='health', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='- Новые события за последний опрос: '),\n FormattedValue(\n value=Subscript(\n value=Name(id='health', ctx=Load()),\n slice=Constant(value='new_events'),\n ctx=Load()),\n conversion=-1)])]))]),\n If(\n test=Compare(\n left=Constant(value='resolved_events'),\n ops=[\n In()],\n comparators=[\n Name(id='health', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='- Закрытые события за последний опрос: '),\n FormattedValue(\n value=Subscript(\n value=Name(id='health', ctx=Load()),\n slice=Constant(value='resolved_events'),\n ctx=Load()),\n conversion=-1)])]))]),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='- Возраст состояния, секунд: '),\n FormattedValue(\n value=Subscript(\n value=Name(id='status', ctx=Loa\nHEALTH_DUMP_SHA256=680c4e2fd2c19d569bb38130327a7044c6cd29de4d4a7490ecf3c860ee5f7865\nHEALTH_DUMP_TRUNCATED=true\nHEALTH_DUMP_END=status_to_body\nHEALTH_DUMP_BEGIN=do_check\nFunctionDef(\n name='do_check',\n args=arguments(),\n body=[\n Assign(\n targets=[\n Name(id='status', ctx=Store())],\n value=Call(\n func=Name(id='build_status', ctx=Load()))),\n Assign(\n targets=[\n Name(id='state', ctx=Store())],\n value=Call(\n func=Name(id='load_state', ctx=Load()))),\n Assign(\n targets=[\n Name(id='now', ctx=Store())],\n value=Call(\n func=Name(id='int', ctx=Load()),\n args=[\n Call(\n func=Attribute(\n value=Name(id='time', ctx=Load()),\n attr='time',\n ctx=Load()))])),\n Assign(\n targets=[\n Name(id='problem_key', ctx=Store())],\n value=IfExp(\n test=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='problems'),\n ctx=Load()),\n body=Call(\n func=Attribute(\n value=Call(\n func=Attribute(\n value=Name(id='hashlib', ctx=Load()),\n attr='sha256',\n ctx=Load()),\n args=[\n Call(\n func=Attribute(\n value=Call(\n func=Attribute(\n value=Constant(value='|'),\n attr='join',\n ctx=Load()),\n args=[\n Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='problems'),\n ctx=Load())]),\n attr='encode',\n ctx=Load()),\n args=[\n Constant(value='utf-8')])]),\n attr='hexdigest',\n ctx=Load())),\n orelse=Constant(value=''))),\n Assign(\n targets=[\n Name(id='mail_sent', ctx=Store())],\n value=Constant(value=False)),\n If(\n test=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='ok'),\n ctx=Load()),\n body=[\n If(\n test=Call(\n func=Attribute(\n value=Name(id='state', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='active_alert')]),\n body=[\n Assign(\n targets=[\n Name(id='subject', ctx=Store())],\n value=Constant(value='Мониторинг жалоб восстановлен: OK')),\n Assign(\n targets=[\n Name(id='body', ctx=Store())],\n value=Call(\n func=Name(id='status_to_body', ctx=Load()),\n args=[\n Name(id='status', ctx=Load()),\n Constant(value='восстановление')])),\n Assign(\n targets=[\n Name(id='mail_sent', ctx=Store())],\n value=Call(\n func=Name(id='send_mail', ctx=Load()),\n args=[\n Name(id='subject', ctx=Load()),\n Name(id='body', ctx=Load())])),\n Assign(\n targets=[\n Name(id='state', ctx=Store())],\n value=Dict(\n keys=[\n Constant(value='active_alert'),\n Constant(value='last_recovery_ts')],\n values=[\n Constant(value=False),\n Name(id='now', ctx=Load())])),\n Expr(\n value=Call(\n func=Name(id='log', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='RECOVERY mail_sent='),\n FormattedValue(\n value=Name(id='mail_sent', ctx=Load()),\n conversion=-1)])]))],\n orelse=[\n Expr(\n value=Call(\n func=Name(id='log', ctx=Load()),\n args=[\n Constant(value='CHECK ok=true mail_sent=false')]))])],\n orelse=[\n Assign(\n targets=[\n Name(id='last_alert_ts', ctx=Store())],\n value=Call(\n func=Name(id='int', ctx=Load()),\n args=[\n BoolOp(\n op=Or(),\n values=[\n Call(\n func=Attribute(\n value=Name(id='state', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='last_alert_ts'),\n Constant(value=0)]),\n Constant(value=0)])])),\n Assign(\n targets=[\n Name(id='last_key', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='state', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='last_problem_key'),\n Constant(value='')])),\n Assign(\n targets=[\n Name(id='should_send', ctx=Store())],\n value=BoolOp(\n op=Or(),\n values=[\n UnaryOp(\n op=Not(),\n operand=Call(\n func=Attribute(\n value=Name(id='state', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='active_alert')])),\n Compare(\n left=Name(id='last_key', ctx=Load()),\n ops=[\n NotEq()],\n comparators=[\n Name(id='problem_key', ctx=Load())]),\n Compare(\n left=BinOp(\n left=Name(id='now', ctx=Load()),\n op=Sub(),\n right=Name(id='last_alert_ts', ctx=Load())),\n ops=[\n GtE()],\n comparators=[\n Name(id='ALERT_REPEAT_SECONDS', ctx=Load())])])),\n If(\n test=Name(id='should_send', ctx=Load()),\n body=[\n Assign(\n targets=[\n Name(id='subject', ctx=Store())],\n value=BinOp(\n left=Constant(value='ТРЕВОГА мониторинга жалоб: '),\n op=Add(),\n right=Call(\n func=Attribute(\n value=Constant(value=', '),\n attr='join',\n ctx=Load()),\n args=[\n GeneratorExp(\n elt=Call(\n func=Name(id='problem_to_ru', ctx=Load()),\n args=[\n Name(id='p', ctx=Load())]),\n generators=[\n comprehension(\n target=Name(id='p', ctx=Store()),\n iter=Subscript(\n value=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='problems'),\n ctx=Load()),\n slice=Slice(\n upper=Constant(value=2)),\n ctx=Load()),\n is_async=0)])]))),\n Assign(\n targets=[\n Name(id='body', ctx=Store())],\n value=Call(\n func=Name(id='status_to_body', ctx=Load()),\n args=[\n Name(id='status', ctx=Load()),\n Constant(value='тревога')])),\n Assign(\n targets=[\n Name(id='mail_sent', ctx=Store())],\n value=Call(\n func=Name(id='send_mail', ctx=Load()),\n args=[\n Name(id='subject', ctx=Load()),\n Name(id='body', ctx=Load())])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='state', ctx=Load()),\n attr='update',\n ctx=Load()),\n args=[\n Dict(\n keys=[\n Constant(value='active_alert'),\n Constant(value='last_alert_ts'),\n Constant(value='last_problem_key'),\n Constant(value='last_problems')],\n values=[\n Constant(value=True),\n Name(id='now', ctx=Load()),\n Name(id='problem_key', ctx=Load()),\n Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='problems'),\n ctx=Load())])])),\n Expr(\n value=Call(\n func=Name(id='log', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='ALERT mail_sent='),\n FormattedValue(\n value=Name(id='mail_sent', ctx=Load()),\n conversion=-1),\n Constant(value=' problems='),\n FormattedValue(\n value=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='problems'),\n ctx=Load()),\n conversion=-1)])]))],\n orelse=[\n Expr(\n value=Call(\n func=Name(id='log', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='CHECK ok=false suppressed=true problems='),\n FormattedValue(\n value=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='problems'),\n ctx=Load()),\n conversion=-1)])]))])]),\n Expr(\n value=Call(\n func=Name(id='save_state', ctx=Load()),\n args=[\n Name(id='state', ctx=Load())])),\n Expr(\n value=Call(\n func=Name(id='write_alert_health', ctx=Load()),\n args=[\n Name(id='status', ctx=Load()),\n Name(id='mail_sent', ctx=Load())])),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n BinOp(\n left=Constant(value='WATCHDOG_STATUS='),\n op=Add(),\n right=IfExp(\n test=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='ok'),\n ctx=Load()),\n body=Constant(value='OK'),\n orelse=Constant(value='ALERT')))])),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n BinOp(\n left=Constant(value='WATCHDOG_MAIL_SENT='),\n op=Add(),\n right=IfExp(\n test=Name(id='mail_sent', ctx=Load()),\n body=Constant(value='yes'),\n orelse=Constant(value='no')))])),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='PROBLEMS='),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Constant(value=';'),\n attr='join',\n ctx=Load()),\n args=[\n Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='problems'),\n ctx=Load())]),\n conversion=-1)])])),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='OPEN='),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='health'),\n ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='open'),\n Constant(value='missing')]),\n conversion=-1)])])),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='RESOLVED='),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='health'),\n ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='resolved'),\n Constant(value='missing')]),\n conversion=-1)])])),\n Return(\n value=Constant(value=0))])\nHEALTH_DUMP_SHA256=da7bbe1956bd719cb634bbf6d2d3ace50781963d52bba841ec8197af0888f282\nHEALTH_DUMP_TRUNCATED=false\nHEALTH_DUMP_END=do_check\nHEALTH_DUMP_BEGIN=do_status\nFunctionDef(\n name='do_status',\n args=arguments(),\n body=[\n Assign(\n targets=[\n Name(id='status', ctx=Store())],\n value=Call(\n func=Name(id='build_status', ctx=Load()))),\n Expr(\n value=Call(\n func=Name(id='write_alert_health', ctx=Load()),\n args=[\n Name(id='status', ctx=Load()),\n Constant(value=None)])),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n BinOp(\n left=Constant(value='WATCHDOG_STATUS='),\n op=Add(),\n right=IfExp(\n test=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='ok'),\n ctx=Load()),\n body=Constant(value='OK'),\n orelse=Constant(value='ALERT')))])),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='PROBLEMS='),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Constant(value=';'),\n attr='join',\n ctx=Load()),\n args=[\n Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='problems'),\n ctx=Load())]),\n conversion=-1)])])),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='OPEN='),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='health'),\n ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='open'),\n Constant(value='missing')]),\n conversion=-1)])])),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='RESOLVED='),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='health'),\n ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='resolved'),\n Constant(value='missing')]),\n conversion=-1)])])),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='HEALTH_AGE_SECONDS='),\n FormattedValue(\n value=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='health_age_seconds'),\n ctx=Load()),\n conversion=-1)])])),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='NETBIRD_ROUTE_OK='),\n FormattedValue(\n value=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='route_ok'),\n ctx=Load()),\n conversion=-1)])])),\n Return(\n value=IfExp(\n test=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='ok'),\n ctx=Load()),\n body=Constant(value=0),\n orelse=Constant(value=1)))])\nHEALTH_DUMP_SHA256=cbf3c7c1c58dd802afb48ef237a648104b27d72a6b727156bde564cb253cc0a2\nHEALTH_DUMP_TRUNCATED=false\nHEALTH_DUMP_END=do_status\nHEALTH_DUMP_BEGIN=main\nFunctionDef(\n name='main',\n args=arguments(),\n body=[\n Assign(\n targets=[\n Name(id='mode', ctx=Store())],\n value=IfExp(\n test=Compare(\n left=Call(\n func=Name(id='len', ctx=Load()),\n args=[\n Attribute(\n value=Name(id='sys', ctx=Load()),\n attr='argv',\n ctx=Load())]),\n ops=[\n Gt()],\n comparators=[\n Constant(value=1)]),\n body=Subscript(\n value=Attribute(\n value=Name(id='sys', ctx=Load()),\n attr='argv',\n ctx=Load()),\n slice=Constant(value=1),\n ctx=Load()),\n orelse=Constant(value='check'))),\n If(\n test=Compare(\n left=Name(id='mode', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='heartbeat')]),\n body=[\n Return(\n value=Call(\n func=Name(id='do_heartbeat', ctx=Load())))]),\n If(\n test=Compare(\n left=Name(id='mode', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='check')]),\n body=[\n Return(\n value=Call(\n func=Name(id='do_check', ctx=Load())))]),\n If(\n test=Compare(\n left=Name(id='mode', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='status')]),\n body=[\n Return(\n value=Call(\n func=Name(id='do_status', ctx=Load())))]),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n Constant(value='usage: health_alert.py [check|heartbeat|status]')],\n keywords=[\n keyword(\n arg='file',\n value=Attribute(\n value=Name(id='sys', ctx=Load()),\n attr='stderr',\n ctx=Load()))])),\n Return(\n value=Constant(value=64))])\nHEALTH_DUMP_SHA256=9a6149262fde18c30b641e25ec67b04a04957d0b2588ec05b1775c875c6722d2\nHEALTH_DUMP_TRUNCATED=false\nHEALTH_DUMP_END=main\nHEALTH_SCAN_OK=true\nQGA_CANARY_QM_RC=0\nQGA_CANARY_STDERR_PRESENT=false\nQGA_CANARY_JSON=true\nQGA_CANARY_GUEST_EXITCODE=0\nQGA_SHORT_OK=true\nMONITOR_SCAN_QM_RC=0\nMONITOR_SCAN_STDERR_PRESENT=false\nMONITOR_SCAN_JSON=true\nMONITOR_SCAN_GUEST_EXITCODE=0\nMONITOR_SCAN=V1\nMONITOR_PRESENT=true\nMONITOR_SHA256=f62288797f80ce561f1e3ea721b87090eb1cd751fd5bf07152a3608b3a8aaed2\nMONITOR_BYTES=17878\nMONITOR_FUNCTION_COUNT=26\nMONITOR_FUNC=utc_now:48:49\nMONITOR_FUNC=log:52:55\nMONITOR_FUNC=write_health:58:64\nMONITOR_FUNC=read_env:67:81\nMONITOR_FUNC=load_config:84:101\nMONITOR_FUNC=connect_db:104:136\nMONITOR_FUNC=meta_get:139:141\nMONITOR_FUNC=meta_set:144:146\nMONITOR_FUNC=event_sent:149:150\nMONITOR_FUNC=mark_event:153:158\nMONITOR_FUNC=fetch_reports_page:161:179\nMONITOR_FUNC=login_required:182:192\nMONITOR_FUNC=strip_tags:195:198\nMONITOR_FUNC=full_url:201:202\nMONITOR_FUNC=section_positions:205:222\nMONITOR_FUNC=parse_int:225:227\nMONITOR_FUNC=parse_reports:230:281\nMONITOR_FUNC=smtp_ready:284:285\nMONITOR_FUNC=send_mail:288:312\nMONITOR_FUNC=report_body:315:324\nMONITOR_FUNC=process_reports:327:370\nMONITOR_FUNC=maybe_send_auth_required:373:391\nMONITOR_FUNC=acquire_lock:394:401\nMONITOR_FUNC=run_once:404:451\nMONITOR_FUNC=show_status:454:459\nMONITOR_FUNC=main:462:468\nMONITOR_RELEVANT_COUNT=10\nMONITOR_DUMP_BEGIN=fetch_reports_page\nFunctionDef(\n name='fetch_reports_page',\n args=arguments(\n args=[\n arg(\n arg='cfg',\n annotation=Attribute(\n value=Name(id='configparser', ctx=Load()),\n attr='ConfigParser',\n ctx=Load())),\n arg(\n arg='secrets',\n annotation=Subscript(\n value=Name(id='dict', ctx=Load()),\n slice=Tuple(\n elts=[\n Name(id='str', ctx=Load()),\n Name(id='str', ctx=Load())],\n ctx=Load()),\n ctx=Load()))]),\n body=[\n Assign(\n targets=[\n Name(id='url', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Subscript(\n value=Name(id='cfg', ctx=Load()),\n slice=Constant(value='forum'),\n ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='reports_url'),\n Constant(value='')])),\n Assign(\n targets=[\n Name(id='request', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Attribute(\n value=Name(id='urllib', ctx=Load()),\n attr='request',\n ctx=Load()),\n attr='Request',\n ctx=Load()),\n args=[\n Name(id='url', ctx=Load())])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='request', ctx=Load()),\n attr='add_header',\n ctx=Load()),\n args=[\n Constant(value='User-Agent'),\n Call(\n func=Attribute(\n value=Subscript(\n value=Name(id='cfg', ctx=Load()),\n slice=Constant(value='forum'),\n ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='user_agent'),\n Constant(value='Mozilla/5.0')])])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='request', ctx=Load()),\n attr='add_header',\n ctx=Load()),\n args=[\n Constant(value='Accept'),\n Constant(value='text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='request', ctx=Load()),\n attr='add_header',\n ctx=Load()),\n args=[\n Constant(value='Accept-Language'),\n Constant(value='ru-RU,ru;q=0.9,en;q=0.5')])),\n Assign(\n targets=[\n Name(id='cookie', ctx=Store())],\n value=BoolOp(\n op=Or(),\n values=[\n Call(\n func=Attribute(\n value=Name(id='secrets', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='')]),\n Call(\n func=Attribute(\n value=Name(id='secrets', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='')]),\n Constant(value='')])),\n If(\n test=Name(id='cookie', ctx=Load()),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='request', ctx=Load()),\n attr='add_header',\n ctx=Load()),\n args=[\n Constant(value=''),\n Name(id='cookie', ctx=Load())]))]),\n Assign(\n targets=[\n Name(id='timeout', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Subscript(\n value=Name(id='cfg', ctx=Load()),\n slice=Constant(value='forum'),\n ctx=Load()),\n attr='getint',\n ctx=Load()),\n args=[\n Constant(value='timeout_seconds')],\n keywords=[\n keyword(\n arg='fallback',\n value=Constant(value=25))])),\n With(\n items=[\n withitem(\n context_expr=Call(\n func=Attribute(\n value=Attribute(\n value=Name(id='urllib', ctx=Load()),\n attr='request',\n ctx=Load()),\n attr='urlopen',\n ctx=Load()),\n args=[\n Name(id='request', ctx=Load())],\n keywords=[\n keyword(\n arg='timeout',\n value=Name(id='timeout', ctx=Load()))]),\n optional_vars=Name(id='response', ctx=Store()))],\n body=[\n Assign(\n targets=[\n Name(id='final_url', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='response', ctx=Load()),\n attr='geturl',\n ctx=Load()))),\n Assign(\n targets=[\n Name(id='body', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='response', ctx=Load()),\n attr='read',\n ctx=Load()))),\n Assign(\n targets=[\n Name(id='charset', ctx=Store())],\n value=Constant(value='utf-8')),\n Assign(\n targets=[\n Name(id='content_type', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Attribute(\n value=Name(id='response', ctx=Load()),\n attr='headers',\n ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='Content-Type'),\n Constant(value='')])),\n Assign(\n targets=[\n Name(id='match', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='re', ctx=Load()),\n attr='search',\n ctx=Load()),\n args=[\n Constant(value='charset=([A-Za-z0-9._-]+)'),\n Name(id='content_type', ctx=Load())],\n keywords=[\n keyword(\n arg='flags',\n value=Attribute(\n value=Name(id='re', ctx=Load()),\n attr='I',\n ctx=Load()))])),\n If(\n test=Name(id='match', ctx=Load()),\n body=[\n Assign(\n targets=[\n Name(id='charset', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='match', ctx=Load()),\n attr='group',\n ctx=Load()),\n args=[\n Constant(value=1)]))]),\n Return(\n value=Tuple(\n elts=[\n Name(id='final_url', ctx=Load()),\n Call(\n func=Attribute(\n value=Name(id='body', ctx=Load()),\n attr='decode',\n ctx=Load()),\n args=[\n Name(id='charset', ctx=Load())],\n keywords=[\n keyword(\n arg='errors',\n value=Constant(value='replace'))])],\n ctx=Load()))])],\n returns=Subscript(\n value=Name(id='tuple', ctx=Load()),\n slice=Tuple(\n elts=[\n Name(id='str', ctx=Load()),\n Name(id='str', ctx=Load())],\n ctx=Load()),\n ctx=Load()))\nMONITOR_DUMP_SHA256=5b5c22665fa95eba6f84bbab6664b6750ec6ce801008b74213b7318201cded18\nMONITOR_DUMP_TRUNCATED=false\nMONITOR_DUMP_END=fetch_reports_page\nMONITOR_DUMP_BEGIN=parse_int\nFunctionDef(\n name='parse_int',\n args=arguments(\n args=[\n arg(\n arg='pattern',\n annotation=Name(id='str', ctx=Load())),\n arg(\n arg='text',\n annotation=Name(id='str', ctx=Load()))]),\n body=[\n Assign(\n targets=[\n Name(id='match', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='re', ctx=Load()),\n attr='search',\n ctx=Load()),\n args=[\n Name(id='pattern', ctx=Load()),\n Name(id='text', ctx=Load())],\n keywords=[\n keyword(\n arg='flags',\n value=Attribute(\n value=Name(id='re', ctx=Load()),\n attr='I',\n ctx=Load()))])),\n Return(\n value=IfExp(\n test=Name(id='match', ctx=Load()),\n body=Call(\n func=Name(id='int', ctx=Load()),\n args=[\n Call(\n func=Attribute(\n value=Name(id='match', ctx=Load()),\n attr='group',\n ctx=Load()),\n args=[\n Constant(value=1)])]),\n orelse=Constant(value=None)))],\n returns=BinOp(\n left=Name(id='int', ctx=Load()),\n op=BitOr(),\n right=Constant(value=None)))\nMONITOR_DUMP_SHA256=cb2011a9afb6eed1914e736d66227b0214cb4adb04afb833df8799db0dbf500e\nMONITOR_DUMP_TRUNCATED=false\nMONITOR_DUMP_END=parse_int\nMONITOR_DUMP_BEGIN=parse_reports\nFunctionDef(\n name='parse_reports',\n args=arguments(\n args=[\n arg(\n arg='text',\n annotation=Name(id='str', ctx=Load())),\n arg(\n arg='cfg',\n annotation=Attribute(\n value=Name(id='configparser', ctx=Load()),\n attr='ConfigParser',\n ctx=Load()))]),\n body=[\n Assign(\n targets=[\n Name(id='base_url', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Subscript(\n value=Name(id='cfg', ctx=Load()),\n slice=Constant(value='forum'),\n ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='base_url'),\n Constant(value='')])),\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='open_pos', ctx=Store()),\n Name(id='closed_pos', ctx=Store())],\n ctx=Store())],\n value=Call(\n func=Name(id='section_positions', ctx=Load()),\n args=[\n Name(id='text', ctx=Load())])),\n AnnAssign(\n target=Name(id='results', ctx=Store()),\n annotation=Subscript(\n value=Name(id='dict', ctx=Load()),\n slice=Tuple(\n elts=[\n Name(id='str', ctx=Load()),\n Subscript(\n value=Name(id='dict', ctx=Load()),\n slice=Tuple(\n elts=[\n Name(id='str', ctx=Load()),\n Name(id='Any', ctx=Load())],\n ctx=Load()),\n ctx=Load())],\n ctx=Load()),\n ctx=Load()),\n value=Dict(),\n simple=1),\n Assign(\n targets=[\n Name(id='pattern', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='re', ctx=Load()),\n attr='compile',\n ctx=Load()),\n args=[\n Constant(value='(?is)]*href=[\\\\\"\\']((?:reports/|[^\\\\\"\\']*/reports/)(\\\\d+)/?[^\\\\\"\\']*)[\\\\\"\\'][^>]*>(.*?)')])),\n For(\n target=Name(id='match', ctx=Store()),\n iter=Call(\n func=Attribute(\n value=Name(id='pattern', ctx=Load()),\n attr='finditer',\n ctx=Load()),\n args=[\n Name(id='text', ctx=Load())]),\n body=[\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='href', ctx=Store()),\n Name(id='report_id', ctx=Store()),\n Name(id='title_html', ctx=Store())],\n ctx=Store())],\n value=Tuple(\n elts=[\n Call(\n func=Attribute(\n value=Name(id='match', ctx=Load()),\n attr='group',\n ctx=Load()),\n args=[\n Constant(value=1)]),\n Call(\n func=Attribute(\n value=Name(id='match', ctx=Load()),\n attr='group',\n ctx=Load()),\n args=[\n Constant(value=2)]),\n Call(\n func=Attribute(\n value=Name(id='match', ctx=Load()),\n attr='group',\n ctx=Load()),\n args=[\n Constant(value=3)])],\n ctx=Load())),\n Assign(\n targets=[\n Name(id='title', ctx=Store())],\n value=Call(\n func=Name(id='strip_tags', ctx=Load()),\n args=[\n Name(id='title_html', ctx=Load())])),\n If(\n test=BoolOp(\n op=Or(),\n values=[\n UnaryOp(\n op=Not(),\n operand=Name(id='title', ctx=Load())),\n Compare(\n left=Call(\n func=Attribute(\n value=Name(id='title', ctx=Load()),\n attr='lower',\n ctx=Load())),\n ops=[\n In()],\n comparators=[\n Set(\n elts=[\n Constant(value='жалобы'),\n Constant(value='reports'),\n Constant(value='обработанные жалобы')])])]),\n body=[\n Continue()]),\n Assign(\n targets=[\n Name(id='position', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='match', ctx=Load()),\n attr='start',\n ctx=Load()))),\n Assign(\n targets=[\n Name(id='item_window_start', ctx=Store())],\n value=Call(\n func=Name(id='max', ctx=Load()),\n args=[\n Constant(value=0),\n BinOp(\n left=Name(id='position', ctx=Load()),\n op=Sub(),\n right=Constant(value=6000))])),\n Assign(\n targets=[\n Name(id='item_tag', ctx=Store())],\n value=Constant(value='')),\n For(\n target=Name(id='item_match', ctx=Store()),\n iter=Call(\n func=Attribute(\n value=Name(id='re', ctx=Load()),\n attr='finditer',\n ctx=Load()),\n args=[\n Constant(value='(?is)<(?:li|div|tr)\\\\b[^>]*class=[\"\\'][^\"\\']*\\\\bdiscussionListItem\\\\b[^\"\\']*[\"\\'][^>]*>'),\n Subscript(\n value=Name(id='text', ctx=Load()),\n slice=Slice(\n lower=Name(id='item_window_start', ctx=Load()),\n upper=Name(id='position', ctx=Load())),\n ctx=Load())]),\n body=[\n Assign(\n targets=[\n Name(id='item_tag', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Call(\n func=Attribute(\n value=Name(id='item_match', ctx=Load()),\n attr='group',\n ctx=Load()),\n args=[\n Constant(value=0)]),\n attr='lower',\n ctx=Load())))]),\n If(\n test=Compare(\n left=Constant(value='report-resolved'),\n ops=[\n In()],\n comparators=[\n Name(id='item_tag', ctx=Load())]),\n body=[\n Assign(\n targets=[\n Name(id='status', ctx=Store())],\n value=Constant(value='resolved'))],\n orelse=[\n If(\n test=BoolOp(\n op=Or(),\n values=[\n Compare(\n left=Constant(value='report-assigned'),\n ops=[\n In()],\n comparators=[\n Name(id='item_tag', ctx=Load())]),\n Compare(\n left=Constant(value='report-open'),\n ops=[\n In()],\n comparators=[\n Name(id='item_tag', ctx=Load())])]),\n body=[\n Assign(\n targets=[\n Name(id='status', ctx=Store())],\n value=Constant(value='open'))],\n orelse=[\n If(\n test=BoolOp(\n op=And(),\n values=[\n Compare(\n left=Name(id='closed_pos', ctx=Load()),\n ops=[\n GtE()],\n comparators=[\n Constant(value=0)]),\n Compare(\n left=Name(id='position', ctx=Load()),\n ops=[\n Gt()],\n comparators=[\n Name(id='closed_pos', ctx=Load())])]),\n body=[\n Assign(\n targets=[\n Name(id='status', ctx=Store())],\n value=Constant(value='resolved'))],\n orelse=[\n If(\n test=BoolOp(\n op=And(),\n values=[\n Compare(\n left=Name(id='open_pos', ctx=Load()),\n ops=[\n GtE()],\n comparators=[\n Constant(value=0)]),\n Compare(\n left=Name(id='position', ctx=Load()),\n ops=[\n Gt()],\n comparators=[\n Name(id='open_pos', ctx=Load())]),\n BoolOp(\n op=Or(),\n values=[\n Compare(\n left=Name(id='closed_pos', ctx=Load()),\n ops=[\n Lt()],\n comparators=[\n Constant(value=0)]),\n Compare(\n left=Name(id='position', ctx=Load()),\n ops=[\n Lt()],\n comparators=[\n Name(id='closed_pos', ctx=Load())])])]),\n body=[\n Assign(\n targets=[\n Name(id='status', ctx=Store())],\n value=Constant(value='open'))],\n orelse=[\n Assign(\n targets=[\n Name(id='status', ctx=Store())],\n value=Constant(value='open'))])])])]),\n Assign(\n targets=[\n Name(id='row_start', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='text', ctx=Load()),\n attr='rfind',\n ctx=Load()),\n args=[\n Constant(value=''),\n ctx=Load())),\n Assign(\n targets=[\n Name(id='port', ctx=Store())],\n value=Call(\n func=Name(id='int', ctx=Load()),\n args=[\n Call(\n func=Attribute(\n value=Name(id='secrets', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value=''),\n Constant(value='587')])])),\n Assign(\n targets=[\n Name(id='user', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='secrets', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value=''),\n Constant(value='')])),\n Assign(\n targets=[\n Name(id='password', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='secrets', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value=''),\n Constant(value='')])),\n Assign(\n targets=[\n Name(id='tls', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Call(\n func=Attribute(\n value=Name(id='secrets', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value=''),\n Constant(value='starttls')]),\n attr='lower',\n ctx=Load()))),\n Assign(\n targets=[\n Name(id='msg', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Attribute(\n value=Name(id='email', ctx=Load()),\n attr='message',\n ctx=Load()),\n attr='EmailMessage',\n ctx=Load()))),\n Assign(\n targets=[\n Subscript(\n value=Name(id='msg', ctx=Load()),\n slice=Constant(value='From'),\n ctx=Store())],\n value=Subscript(\n value=Name(id='secrets', ctx=Load()),\n slice=Constant(value=''),\n ctx=Load())),\n Assign(\n targets=[\n Subscript(\n value=Name(id='msg', ctx=Load()),\n slice=Constant(value='To'),\n ctx=Store())],\n value=Subscript(\n value=Name(id='secrets', ctx=Load()),\n slice=Constant(value=''),\n ctx=Load())),\n Assign(\n targets=[\n Subscript(\n value=Name(id='msg', ctx=Load()),\n slice=Constant(value='Subject'),\n ctx=Store())],\n value=BinOp(\n left=BinOp(\n left=Call(\n func=Attribute(\n value=Subscript(\n value=Name(id='cfg', ctx=Load()),\n slice=Constant(value='email'),\n ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='subject_prefix'),\n Constant(value='[Skladchik]')]),\n op=Add(),\n right=Constant(value=' ')),\n op=Add(),\n right=Name(id='subject', ctx=Load()))),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='msg', ctx=Load()),\n attr='set_content',\n ctx=Load()),\n args=[\n Name(id='body', ctx=Load())])),\n If(\n test=Compare(\n left=Name(id='tls', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='ssl')]),\n body=[\n Assign(\n targets=[\n Name(id='smtp', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='smtplib', ctx=Load()),\n attr='SMTP_SSL',\n ctx=Load()),\n args=[\n Name(id='host', ctx=Load()),\n Name(id='port', ctx=Load())],\n keywords=[\n keyword(\n arg='timeout',\n value=Constant(value=30))]))],\n orelse=[\n Assign(\n targets=[\n Name(id='smtp', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='smtplib', ctx=Load()),\n attr='SMTP',\n ctx=Load()),\n args=[\n Name(id='host', ctx=Load()),\n Name(id='port', ctx=Load())],\n keywords=[\n keyword(\n arg='timeout',\n value=Constant(value=30))]))]),\n With(\n items=[\n withitem(\n context_expr=Name(id='smtp', ctx=Load()),\n optional_vars=Name(id='server', ctx=Store()))],\n body=[\n If(\n test=Compare(\n left=Name(id='tls', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='starttls')]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='server', ctx=Load()),\n attr='starttls',\n ctx=Load()),\n keywords=[\n keyword(\n arg='context',\n value=Call(\n func=Attribute(\n value=Name(id='ssl', ctx=Load()),\n attr='create_default_context',\n ctx=Load())))]))]),\n If(\n test=Name(id='user', ctx=Load()),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='server', ctx=Load()),\n attr='login',\n ctx=Load()),\n args=[\n Name(id='user', ctx=Load()),\n Name(id='password', ctx=Load())]))]),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='server', ctx=Load()),\n attr='send_message',\n ctx=Load()),\n args=[\n Name(id='msg', ctx=Load())]))]),\n Return(\n value=Constant(value=True))],\n returns=Name(id='bool', ctx=Load()))\nMONITOR_DUMP_SHA256=af72f54e66459d653cc65a65494c97a1eeabaa80cee95f1777319a7df1efc133\nMONITOR_DUMP_TRUNCATED=false\nMONITOR_DUMP_END=send_mail\nMONITOR_DUMP_BEGIN=report_body\nFunctionDef(\n name='report_body',\n args=arguments(\n args=[\n arg(\n arg='prefix',\n annotation=Name(id='str', ctx=Load())),\n arg(\n arg='report',\n annotation=Subscript(\n value=Name(id='dict', ctx=Load()),\n slice=Tuple(\n elts=[\n Name(id='str', ctx=Load()),\n Name(id='Any', ctx=Load())],\n ctx=Load()),\n ctx=Load()))]),\n body=[\n Return(\n value=JoinedStr(\n values=[\n FormattedValue(\n value=Name(id='prefix', ctx=Load()),\n conversion=-1),\n Constant(value=''),\n FormattedValue(\n value=Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='title'),\n ctx=Load()),\n conversion=-1),\n Constant(value=''),\n FormattedValue(\n value=Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='status'),\n ctx=Load()),\n conversion=-1),\n Constant(value=''),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Name(id='report', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='report_count')]),\n conversion=-1),\n Constant(value=''),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Name(id='report', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='comment_count')]),\n conversion=-1),\n Constant(value=''),\n FormattedValue(\n value=Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='url'),\n ctx=Load()),\n conversion=-1),\n Constant(value=''),\n FormattedValue(\n value=Call(\n func=Name(id='utc_now', ctx=Load())),\n conversion=-1),\n Constant(value='')]))],\n returns=Name(id='str', ctx=Load()))\nMONITOR_DUMP_SHA256=668abfab86ee05df948412e7aca1247e115d8d5c6d7c52ddda0746f288f2978a\nMONITOR_DUMP_TRUNCATED=false\nMONITOR_DUMP_END=report_body\nMONITOR_DUMP_BEGIN=process_reports\nFunctionDef(\n name='process_reports',\n args=arguments(\n args=[\n arg(\n arg='con',\n annotation=Attribute(\n value=Name(id='sqlite3', ctx=Load()),\n attr='Connection',\n ctx=Load())),\n arg(\n arg='cfg',\n annotation=Attribute(\n value=Name(id='configparser', ctx=Load()),\n attr='ConfigParser',\n ctx=Load())),\n arg(\n arg='secrets',\n annotation=Subscript(\n value=Name(id='dict', ctx=Load()),\n slice=Tuple(\n elts=[\n Name(id='str', ctx=Load()),\n Name(id='str', ctx=Load())],\n ctx=Load()),\n ctx=Load())),\n arg(\n arg='reports',\n annotation=Subscript(\n value=Name(id='list', ctx=Load()),\n slice=Subscript(\n value=Name(id='dict', ctx=Load()),\n slice=Tuple(\n elts=[\n Name(id='str', ctx=Load()),\n Name(id='Any', ctx=Load())],\n ctx=Load()),\n ctx=Load()),\n ctx=Load()))]),\n body=[\n Assign(\n targets=[\n Name(id='baseline', ctx=Store())],\n value=Call(\n func=Name(id='meta_get', ctx=Load()),\n args=[\n Name(id='con', ctx=Load()),\n Constant(value='baseline_created_at')])),\n Assign(\n targets=[\n Name(id='baseline_mode', ctx=Store())],\n value=Compare(\n left=Call(\n func=Attribute(\n value=Call(\n func=Attribute(\n value=Subscript(\n value=Name(id='cfg', ctx=Load()),\n slice=Constant(value='monitor'),\n ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='baseline_no_email'),\n Constant(value='yes')]),\n attr='lower',\n ctx=Load())),\n ops=[\n In()],\n comparators=[\n Set(\n elts=[\n Constant(value='yes'),\n Constant(value='true'),\n Constant(value='1'),\n Constant(value='on')])])),\n Assign(\n targets=[\n Name(id='new_events', ctx=Store())],\n value=Constant(value=0)),\n Assign(\n targets=[\n Name(id='resolved_events', ctx=Store())],\n value=Constant(value=0)),\n For(\n target=Name(id='report', ctx=Store()),\n iter=Name(id='reports', ctx=Load()),\n body=[\n Assign(\n targets=[\n Name(id='row', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Call(\n func=Attribute(\n value=Name(id='con', ctx=Load()),\n attr='execute',\n ctx=Load()),\n args=[\n Constant(value='SELECT status FROM reports WHERE report_id=?'),\n Tuple(\n elts=[\n Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='report_id'),\n ctx=Load())],\n ctx=Load())]),\n attr='fetchone',\n ctx=Load()))),\n If(\n test=Compare(\n left=Name(id='row', ctx=Load()),\n ops=[\n Is()],\n comparators=[\n Constant(value=None)]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='con', ctx=Load()),\n attr='execute',\n ctx=Load()),\n args=[\n Constant(value=''),\n Tuple(\n elts=[\n Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='report_id'),\n ctx=Load()),\n Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='url'),\n ctx=Load()),\n Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='title'),\n ctx=Load()),\n Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='status'),\n ctx=Load()),\n Call(\n func=Attribute(\n value=Name(id='report', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='report_count')]),\n Call(\n func=Attribute(\n value=Name(id='report', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='comment_count')]),\n Call(\n func=Attribute(\n value=Name(id='report', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='row_text'),\n Constant(value='')]),\n Call(\n func=Name(id='utc_now', ctx=Load())),\n Call(\n func=Name(id='utc_now', ctx=Load())),\n IfExp(\n test=Compare(\n left=Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='status'),\n ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='resolved')]),\n body=Call(\n func=Name(id='utc_now', ctx=Load())),\n orelse=Constant(value=None))],\n ctx=Load())])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='con', ctx=Load()),\n attr='commit',\n ctx=Load()))),\n If(\n test=BoolOp(\n op=Or(),\n values=[\n Name(id='baseline', ctx=Load()),\n UnaryOp(\n op=Not(),\n operand=Name(id='baseline_mode', ctx=Load()))]),\n body=[\n If(\n test=Compare(\n left=Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='status'),\n ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='open')]),\n body=[\n Assign(\n targets=[\n Name(id='key', ctx=Store())],\n value=BinOp(\n left=Constant(value='new:'),\n op=Add(),\n right=Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='report_id'),\n ctx=Load()))),\n If(\n test=UnaryOp(\n op=Not(),\n operand=Call(\n func=Name(id='event_sent', ctx=Load()),\n args=[\n Name(id='con', ctx=Load()),\n Name(id='key', ctx=Load())])),\n body=[\n If(\n test=Call(\n func=Name(id='send_mail', ctx=Load()),\n args=[\n Name(id='cfg', ctx=Load()),\n Name(id='secrets', ctx=Load()),\n Constant(value='Новая жалоба'),\n Call(\n func=Name(id='report_body', ctx=Load()),\n args=[\n Constant(value='Появилась новая жалоба.'),\n Name(id='report', ctx=Load())])]),\n body=[\n Expr(\n value=Call(\n func=Name(id='mark_event', ctx=Load()),\n args=[\n Name(id='con', ctx=Load()),\n Name(id='key', ctx=Load()),\n Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='report_id'),\n ctx=Load()),\n Constant(value='new')])),\n AugAssign(\n target=Name(id='new_events', ctx=Store()),\n op=Add(),\n value=Constant(value=1))])])])])],\n orelse=[\n Assign(\n targets=[\n Name(id='old_status', ctx=Store())],\n value=Subscript(\n value=Name(id='row', ctx=Load()),\n slice=Constant(value=0),\n ctx=Load())),\n If(\n test=BoolOp(\n op=And(),\n values=[\n Compare(\n left=Name(id='old_status', ctx=Load()),\n ops=[\n NotEq()],\n comparators=[\n Constant(value='resolved')]),\n Compare(\n left=Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='status'),\n ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='resolved')])]),\n body=[\n Assign(\n targets=[\n Name(id='key', ctx=Store())],\n value=BinOp(\n left=Constant(value='resolved:'),\n op=Add(),\n right=Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='report_id'),\n ctx=Load()))),\n If(\n test=UnaryOp(\n op=Not(),\n operand=Call(\n func=Name(id='event_sent', ctx=Load()),\n args=[\n Name(id='con', ctx=Load()),\n Name(id='key', ctx=Load())])),\n body=[\n If(\n test=Call(\n func=Name(id='send_mail', ctx=Load()),\n args=[\n Name(id='cfg', ctx=Load()),\n Name(id='secrets', ctx=Load()),\n Constant(value='Жалоба отработана'),\n Call(\n func=Name(id='report_body', ctx=Load()),\n args=[\n Constant(value='Жалоба перешла в обработанные.'),\n Name(id='report', ctx=Load())])]),\n body=[\n Expr(\n value=Call(\n func=Name(id='mark_event', ctx=Load()),\n args=[\n Name(id='con', ctx=Load()),\n Name(id='key', ctx=Load()),\n Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='report_id'),\n ctx=Load()),\n Constant(value='resolved')])),\n AugAssign(\n target=Name(id='resolved_events', ctx=Store()),\n op=Add(),\n value=Constant(value=1))])])]),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='con', ctx=Load()),\n attr='execute',\n ctx=Load()),\n args=[\n Constant(value=''),\n Tuple(\n elts=[\n Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='url'),\n ctx=Load()),\n Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='title'),\n ctx=Load()),\n Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='status'),\n ctx=Load()),\n Call(\n func=Attribute(\n value=Name(id='report', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='report_count')]),\n Call(\n func=Attribute(\n value=Name(id='report', ctx=Load()),\n attr='get',\n ctx=Load()),\n \nMONITOR_DUMP_SHA256=898a51f0ad422cfbd6a9dc3c30e38db7fa53aa91216f5ef5bf390e2728d2da25\nMONITOR_DUMP_TRUNCATED=true\nMONITOR_DUMP_END=process_reports\nMONITOR_DUMP_BEGIN=maybe_send_auth_required\nFunctionDef(\n name='maybe_send_auth_required',\n args=arguments(\n args=[\n arg(\n arg='con',\n annotation=Attribute(\n value=Name(id='sqlite3', ctx=Load()),\n attr='Connection',\n ctx=Load())),\n arg(\n arg='cfg',\n annotation=Attribute(\n value=Name(id='configparser', ctx=Load()),\n attr='ConfigParser',\n ctx=Load())),\n arg(\n arg='secrets',\n annotation=Subscript(\n value=Name(id='dict', ctx=Load()),\n slice=Tuple(\n elts=[\n Name(id='str', ctx=Load()),\n Name(id='str', ctx=Load())],\n ctx=Load()),\n ctx=Load())),\n arg(\n arg='final_url',\n annotation=Name(id='str', ctx=Load()))]),\n body=[\n Assign(\n targets=[\n Name(id='now_ts', ctx=Store())],\n value=Call(\n func=Name(id='int', ctx=Load()),\n args=[\n Call(\n func=Attribute(\n value=Name(id='time', ctx=Load()),\n attr='time',\n ctx=Load()))])),\n Assign(\n targets=[\n Name(id='interval', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Subscript(\n value=Name(id='cfg', ctx=Load()),\n slice=Constant(value='email'),\n ctx=Load()),\n attr='getint',\n ctx=Load()),\n args=[\n Constant(value='auth_notice_min_interval_seconds')],\n keywords=[\n keyword(\n arg='fallback',\n value=Constant(value=86400))])),\n Assign(\n targets=[\n Name(id='last_raw', ctx=Store())],\n value=BoolOp(\n op=Or(),\n values=[\n Call(\n func=Name(id='meta_get', ctx=Load()),\n args=[\n Name(id='con', ctx=Load()),\n Constant(value='last_auth_notice_ts')]),\n Constant(value='0')])),\n Try(\n body=[\n Assign(\n targets=[\n Name(id='last', ctx=Store())],\n value=Call(\n func=Name(id='int', ctx=Load()),\n args=[\n Name(id='last_raw', ctx=Load())]))],\n handlers=[\n ExceptHandler(\n type=Name(id='ValueError', ctx=Load()),\n body=[\n Assign(\n targets=[\n Name(id='last', ctx=Store())],\n value=Constant(value=0))])]),\n If(\n test=Compare(\n left=BinOp(\n left=Name(id='now_ts', ctx=Load()),\n op=Sub(),\n right=Name(id='last', ctx=Load())),\n ops=[\n GtE()],\n comparators=[\n Name(id='interval', ctx=Load())]),\n body=[\n If(\n test=Call(\n func=Name(id='send_mail', ctx=Load()),\n args=[\n Name(id='cfg', ctx=Load()),\n Name(id='secrets', ctx=Load()),\n Constant(value='Нужна повторная авторизация'),\n JoinedStr(\n values=[\n Constant(value=''),\n FormattedValue(\n value=Name(id='final_url', ctx=Load()),\n conversion=-1),\n Constant(value=''),\n FormattedValue(\n value=Call(\n func=Name(id='utc_now', ctx=Load())),\n conversion=-1),\n Constant(value='')])]),\n body=[\n Expr(\n value=Call(\n func=Name(id='meta_set', ctx=Load()),\n args=[\n Name(id='con', ctx=Load()),\n Constant(value='last_auth_notice_ts'),\n Call(\n func=Name(id='str', ctx=Load()),\n args=[\n Name(id='now_ts', ctx=Load())])]))])])],\n returns=Constant(value=None))\nMONITOR_DUMP_SHA256=396252a7a870238ab735e22192d95a704509acc56af3bca2289e5e307c4e5f10\nMONITOR_DUMP_TRUNCATED=false\nMONITOR_DUMP_END=maybe_send_auth_required\nMONITOR_DUMP_BEGIN=run_once\nFunctionDef(\n name='run_once',\n args=arguments(),\n body=[\n Assign(\n targets=[\n Name(id='lock', ctx=Store())],\n value=Call(\n func=Name(id='acquire_lock', ctx=Load()))),\n If(\n test=Compare(\n left=Name(id='lock', ctx=Load()),\n ops=[\n Is()],\n comparators=[\n Constant(value=None)]),\n body=[\n Expr(\n value=Call(\n func=Name(id='log', ctx=Load()),\n args=[\n Constant(value='LOCK_BUSY previous run still active')])),\n Expr(\n value=Call(\n func=Name(id='write_health', ctx=Load()),\n args=[\n Constant(value='LOCK_BUSY')])),\n Return(\n value=Constant(value=0))]),\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='cfg', ctx=Store()),\n Name(id='secrets', ctx=Store())],\n ctx=Store())],\n value=Call(\n func=Name(id='load_config', ctx=Load()))),\n Assign(\n targets=[\n Name(id='con', ctx=Store())],\n value=Call(\n func=Name(id='connect_db', ctx=Load()))),\n Try(\n body=[\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='final_url', ctx=Store()),\n Name(id='text', ctx=Store())],\n ctx=Store())],\n value=Call(\n func=Name(id='fetch_reports_page', ctx=Load()),\n args=[\n Name(id='cfg', ctx=Load()),\n Name(id='secrets', ctx=Load())])),\n If(\n test=Call(\n func=Name(id='login_required', ctx=Load()),\n args=[\n Name(id='final_url', ctx=Load()),\n Name(id='text', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Name(id='maybe_send_auth_required', ctx=Load()),\n args=[\n Name(id='con', ctx=Load()),\n Name(id='cfg', ctx=Load()),\n Name(id='secrets', ctx=Load()),\n Name(id='final_url', ctx=Load())])),\n Expr(\n value=Call(\n func=Name(id='write_health', ctx=Load()),\n args=[\n Constant(value='AUTH_REQUIRED')],\n keywords=[\n keyword(\n arg='url',\n value=Name(id='final_url', ctx=Load()))])),\n Return(\n value=Constant(value=2))]),\n Assign(\n targets=[\n Name(id='reports', ctx=Store())],\n value=Call(\n func=Name(id='parse_reports', ctx=Load()),\n args=[\n Name(id='text', ctx=Load()),\n Name(id='cfg', ctx=Load())])),\n If(\n test=UnaryOp(\n op=Not(),\n operand=Name(id='reports', ctx=Load())),\n body=[\n Expr(\n value=Call(\n func=Name(id='write_health', ctx=Load()),\n args=[\n Constant(value='ERROR')],\n keywords=[\n keyword(\n arg='reason',\n value=Constant(value='no_reports_parsed')),\n keyword(\n arg='url',\n value=Name(id='final_url', ctx=Load()))])),\n Expr(\n value=Call(\n func=Name(id='log', ctx=Load()),\n args=[\n Constant(value='ERROR no reports parsed')])),\n Return(\n value=Constant(value=1))]),\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='new_events', ctx=Store()),\n Name(id='resolved_events', ctx=Store())],\n ctx=Store())],\n value=Call(\n func=Name(id='process_reports', ctx=Load()),\n args=[\n Name(id='con', ctx=Load()),\n Name(id='cfg', ctx=Load()),\n Name(id='secrets', ctx=Load()),\n Name(id='reports', ctx=Load())])),\n Assign(\n targets=[\n Name(id='open_count', ctx=Store())],\n value=Call(\n func=Name(id='sum', ctx=Load()),\n args=[\n GeneratorExp(\n elt=Constant(value=1),\n generators=[\n comprehension(\n target=Name(id='r', ctx=Store()),\n iter=Name(id='reports', ctx=Load()),\n ifs=[\n Compare(\n left=Subscript(\n value=Name(id='r', ctx=Load()),\n slice=Constant(value='status'),\n ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='open')])],\n is_async=0)])])),\n Assign(\n targets=[\n Name(id='resolved_count', ctx=Store())],\n value=Call(\n func=Name(id='sum', ctx=Load()),\n args=[\n GeneratorExp(\n elt=Constant(value=1),\n generators=[\n comprehension(\n target=Name(id='r', ctx=Store()),\n iter=Name(id='reports', ctx=Load()),\n ifs=[\n Compare(\n left=Subscript(\n value=Name(id='r', ctx=Load()),\n slice=Constant(value='status'),\n ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='resolved')])],\n is_async=0)])])),\n Expr(\n value=Call(\n func=Name(id='write_health', ctx=Load()),\n args=[\n Constant(value='OK')],\n keywords=[\n keyword(\n arg='url',\n value=Name(id='final_url', ctx=Load())),\n keyword(\n arg='reports',\n value=Call(\n func=Name(id='len', ctx=Load()),\n args=[\n Name(id='reports', ctx=Load())])),\n keyword(\n arg='open',\n value=Name(id='open_count', ctx=Load())),\n keyword(\n arg='resolved',\n value=Name(id='resolved_count', ctx=Load())),\n keyword(\n arg='new_events',\n value=Name(id='new_events', ctx=Load())),\n keyword(\n arg='resolved_events',\n value=Name(id='resolved_events', ctx=Load())),\n keyword(\n arg='smtp_configured',\n value=IfExp(\n test=Call(\n func=Name(id='smtp_ready', ctx=Load()),\n args=[\n Name(id='secrets', ctx=Load())]),\n body=Constant(value='yes'),\n orelse=Constant(value='no')))])),\n Expr(\n value=Call(\n func=Name(id='log', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='OK reports='),\n FormattedValue(\n value=Call(\n func=Name(id='len', ctx=Load()),\n args=[\n Name(id='reports', ctx=Load())]),\n conversion=-1),\n Constant(value=' open='),\n FormattedValue(\n value=Name(id='open_count', ctx=Load()),\n conversion=-1),\n Constant(value=' resolved='),\n FormattedValue(\n value=Name(id='resolved_count', ctx=Load()),\n conversion=-1),\n Constant(value=' new='),\n FormattedValue(\n value=Name(id='new_events', ctx=Load()),\n conversion=-1),\n Constant(value=' done='),\n FormattedValue(\n value=Name(id='resolved_events', ctx=Load()),\n conversion=-1)])])),\n Return(\n value=Constant(value=0))],\n handlers=[\n ExceptHandler(\n type=Attribute(\n value=Attribute(\n value=Name(id='urllib', ctx=Load()),\n attr='error',\n ctx=Load()),\n attr='HTTPError',\n ctx=Load()),\n name='e',\n body=[\n Expr(\n value=Call(\n func=Name(id='write_health', ctx=Load()),\n args=[\n Constant(value='ERROR')],\n keywords=[\n keyword(\n arg='error',\n value=JoinedStr(\n values=[\n Constant(value='HTTPError '),\n FormattedValue(\n value=Attribute(\n value=Name(id='e', ctx=Load()),\n attr='code',\n ctx=Load()),\n conversion=-1)]))])),\n Expr(\n value=Call(\n func=Name(id='log', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='ERROR HTTPError '),\n FormattedValue(\n value=Attribute(\n value=Name(id='e', ctx=Load()),\n attr='code',\n ctx=Load()),\n conversion=-1)])])),\n Return(\n value=Constant(value=1))]),\n ExceptHandler(\n type=Name(id='Exception', ctx=Load()),\n name='e',\n body=[\n Expr(\n value=Call(\n func=Name(id='write_health', ctx=Load()),\n args=[\n Constant(value='ERROR')],\n keywords=[\n keyword(\n arg='error',\n value=Call(\n func=Name(id='repr', ctx=Load()),\n args=[\n Name(id='e', ctx=Load())]))])),\n Expr(\n value=Call(\n func=Name(id='log', ctx=Load()),\n args=[\n BinOp(\n left=BinOp(\n left=BinOp(\n left=Constant(value='ERROR '),\n op=Add(),\n right=Call(\n func=Name(id='repr', ctx=Load()),\n args=[\n Name(id='e', ctx=Load())])),\n op=Add(),\n right=Constant(value=' ')),\n op=Add(),\n right=Call(\n func=Attribute(\n value=Name(id='traceback', ctx=Load()),\n attr='format_exc',\n ctx=Load())))])),\n Return(\n value=Constant(value=1))])],\n finalbody=[\n Try(\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='fcntl', ctx=Load()),\n attr='flock',\n ctx=Load()),\n args=[\n Call(\n func=Attribute(\n value=Name(id='lock', ctx=Load()),\n attr='fileno',\n ctx=Load())),\n Attribute(\n value=Name(id='fcntl', ctx=Load()),\n attr='LOCK_UN',\n ctx=Load())])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lock', ctx=Load()),\n attr='close',\n ctx=Load())))],\n handlers=[\n ExceptHandler(\n type=Name(id='Exception', ctx=Load()),\n body=[\n Pass()])])])],\n returns=Name(id='int', ctx=Load()))\nMONITOR_DUMP_SHA256=eceb52bc948ca75d79fddb992ecc9e3c61ae10413339a5d6d14b5c20b00407db\nMONITOR_DUMP_TRUNCATED=false\nMONITOR_DUMP_END=run_once\nMONITOR_DUMP_BEGIN=show_status\nFunctionDef(\n name='show_status',\n args=arguments(),\n body=[\n If(\n test=Call(\n func=Attribute(\n value=Name(id='HEALTH_PATH', ctx=Load()),\n attr='exists',\n ctx=Load())),\n body=[\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n Call(\n func=Attribute(\n value=Name(id='HEALTH_PATH', ctx=Load()),\n attr='read_text',\n ctx=Load()),\n keywords=[\n keyword(\n arg='encoding',\n value=Constant(value='utf-8'))])],\n keywords=[\n keyword(\n arg='end',\n value=Constant(value=''))]))],\n orelse=[\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n Constant(value='STATUS=UNKNOWN')]))]),\n Return(\n value=Constant(value=0))],\n returns=Name(id='int', ctx=Load()))\nMONITOR_DUMP_SHA256=ee45eb0e5db867e890df5fce7f7afa8ad77ba828845e20e5e7d1dcfdab13e551\nMONITOR_DUMP_TRUNCATED=false\nMONITOR_DUMP_END=show_status\nMONITOR_DUMP_BEGIN=main\nFunctionDef(\n name='main',\n args=arguments(),\n body=[\n Assign(\n targets=[\n Name(id='parser', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='argparse', ctx=Load()),\n attr='ArgumentParser',\n ctx=Load()))),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='parser', ctx=Load()),\n attr='add_argument',\n ctx=Load()),\n args=[\n Constant(value='cmd')],\n keywords=[\n keyword(\n arg='choices',\n value=List(\n elts=[\n Constant(value='run'),\n Constant(value='status')],\n ctx=Load())),\n keyword(\n arg='nargs',\n value=Constant(value='?')),\n keyword(\n arg='default',\n value=Constant(value='run'))])),\n Assign(\n targets=[\n Name(id='args', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='parser', ctx=Load()),\n attr='parse_args',\n ctx=Load()))),\n If(\n test=Compare(\n left=Attribute(\n value=Name(id='args', ctx=Load()),\n attr='cmd',\n ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='status')]),\n body=[\n Return(\n value=Call(\n func=Name(id='show_status', ctx=Load())))]),\n Return(\n value=Call(\n func=Name(id='run_once', ctx=Load())))],\n returns=Name(id='int', ctx=Load()))\nMONITOR_DUMP_SHA256=02ad6bee6cd63312a57b18daedc366b2edfc1b747c3ac27f5bd9cfd71210fb2e\nMONITOR_DUMP_TRUNCATED=false\nMONITOR_DUMP_END=main\nMONITOR_SCAN_OK=true\nUNIT_PROBE_QM_RC=0\nUNIT_PROBE_STDERR_PRESENT=false\nUNIT_PROBE_JSON=true\nUNIT_PROBE_GUEST_EXITCODE=0\nactive\nenabled\nsuccess\n0\nMAIL_DRY_RUN_ONLY=true\nMAIL_SENT=false\nDECISION=PASS_TITLE_AND_ALERT_SOURCE_RCA\nNEXT_GATE=DESIGN_ATOMIC_FALSE_ALERT_AND_TITLE_REPAIR_FROM_99564\nTASK_RESULT=SKLADCHIK_COMPLAINTS_TITLE_TOKEN_RCA\nCHANGES_MADE=false\nROLLBACK_STARTED=false\nROLLBACK_RESTORED=null\nMUTATION_OUTCOME=NO_MUTATION\n" +} diff --git a/runtime/history/SUPPORT-261004-SKLADCHIK-COMPLAINTS-TITLE-TOKEN-RCA-99564R1.txt b/runtime/history/SUPPORT-261004-SKLADCHIK-COMPLAINTS-TITLE-TOKEN-RCA-99564R1.txt new file mode 100644 index 00000000..4d702feb --- /dev/null +++ b/runtime/history/SUPPORT-261004-SKLADCHIK-COMPLAINTS-TITLE-TOKEN-RCA-99564R1.txt @@ -0,0 +1,3900 @@ +CHAT_OUTPUT_BEGIN +COMMAND_ID=SUPPORT-261004-SKLADCHIK-COMPLAINTS-TITLE-TOKEN-RCA-99564R1 +STATUS=OK +RC=0 +HOST=pve01 +MODE=read-only +COMPONENT=skladchik-complaints-title-token-rca +REFERENCE_REGISTER_CHECK=OK +REFERENCE_SHA256=5a3d8e5154c41cb582a4e0aca68090be1f0138918bf82131a948df326f9d8d66 +ERROR_REGISTER_CHECK=OK +ERROR_REGISTER_SHA256=3b09a553ec0f527ed3afeed4753f52a74ee3036045bbfb3c685e9f8af4ba7ba0 +COMMAND_SHA256=bbe4077da8ab20fa07a5b8458821ecbe544b502ccbb871742ef07ac2d14d220e +DUPLICATE_FAILED_COMMAND_BLOCKED=false +EXECUTION_STARTED=true +CHANGE_DECLARED=false +RESULT_CONTRACT_VALID=true +RESULT_CONTRACT_STATUS=NOT_APPLICABLE +RESULT_CONTRACT_ERROR=NONE +COMMAND_RC=0 +CHANGES_MADE=false +ROLLBACK_STARTED=false +ROLLBACK_RESTORED=null +MUTATION_OUTCOME=NO_MUTATION +SANITIZED=yes +SECRETS_INCLUDED=no +PRIVATE_ADDRESSES_INCLUDED=no +RAW_EVIDENCE_SHA256=f375d4e36d4d0a70ebad8412a2dd1f0e4faa25f8c6f2d4d648a215164c8f2d2c +SANITIZED_OUTPUT_SHA256=f375d4e36d4d0a70ebad8412a2dd1f0e4faa25f8c6f2d4d648a215164c8f2d2c +OUTPUT_BEGIN +SKLADCHIK_COMPLAINTS_TITLE_TOKEN_RCA=V1 +MODE=read-only +NO_MAIL_SEND=true +NO_SERVICE_RESTART=true +NO_TIMER_MUTATION=true +NO_NETWORK_MUTATION=true +NO_SOURCE_MUTATION=true +HOST_PVE01=true +VM170_STATUS=running +HEALTH_SCAN=V1 +HEALTH_PRESENT=true +HEALTH_SHA256=918f3d1db31c64fe5f7548c3da6183ca6bf8be80384fa0673c55f68826dcc717 +HEALTH_BYTES=16080 +HEALTH_FUNCTION_COUNT=22 +HEALTH_FUNC=utc_now:24:25 +HEALTH_FUNC=ts:28:29 +HEALTH_FUNC=log:32:35 +HEALTH_FUNC=run_cmd:38:43 +HEALTH_FUNC=parse_kv_file:46:54 +HEALTH_FUNC=iso_age_seconds:57:64 +HEALTH_FUNC=load_state:67:71 +HEALTH_FUNC=save_state:74:78 +HEALTH_FUNC=load_monitor_module:81:87 +HEALTH_FUNC=send_mail:90:93 +HEALTH_FUNC=systemd_value:96:98 +HEALTH_FUNC=route_ok:101:103 +HEALTH_FUNC=problem_to_ru:106:129 +HEALTH_FUNC=yes_no_ru:132:133 +HEALTH_FUNC=status_ru:136:145 +HEALTH_FUNC=build_status:148:206 +HEALTH_FUNC=status_to_body:209:253 +HEALTH_FUNC=write_alert_health:256:280 +HEALTH_FUNC=do_heartbeat:283:294 +HEALTH_FUNC=do_check:297:332 +HEALTH_FUNC=do_status:335:344 +HEALTH_FUNC=main:347:356 +HEALTH_RELEVANT_COUNT=9 +HEALTH_DUMP_BEGIN=parse_kv_file +FunctionDef( + name='parse_kv_file', + args=arguments( + args=[ + arg( + arg='path', + annotation=Name(id='Path', ctx=Load()))]), + body=[ + Assign( + targets=[ + Name(id='data', ctx=Store())], + value=Dict()), + If( + test=UnaryOp( + op=Not(), + operand=Call( + func=Attribute( + value=Name(id='path', ctx=Load()), + attr='exists', + ctx=Load()))), + body=[ + Return( + value=Name(id='data', ctx=Load()))]), + For( + target=Name(id='raw', ctx=Store()), + iter=Call( + func=Attribute( + value=Call( + func=Attribute( + value=Name(id='path', ctx=Load()), + attr='read_text', + ctx=Load()), + keywords=[ + keyword( + arg='encoding', + value=Constant(value='utf-8')), + keyword( + arg='errors', + value=Constant(value='replace'))]), + attr='splitlines', + ctx=Load())), + body=[ + If( + test=Compare( + left=Constant(value='='), + ops=[ + In()], + comparators=[ + Name(id='raw', ctx=Load())]), + body=[ + Assign( + targets=[ + Tuple( + elts=[ + Name(id='k', ctx=Store()), + Name(id='v', ctx=Store())], + ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='raw', ctx=Load()), + attr='split', + ctx=Load()), + args=[ + Constant(value='='), + Constant(value=1)])), + Assign( + targets=[ + Subscript( + value=Name(id='data', ctx=Load()), + slice=Call( + func=Attribute( + value=Name(id='k', ctx=Load()), + attr='strip', + ctx=Load())), + ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='v', ctx=Load()), + attr='strip', + ctx=Load())))])]), + Return( + value=Name(id='data', ctx=Load()))]) +HEALTH_DUMP_SHA256=577b27aca6d27fc787beed7fda2903d72e67f386753fadfc23325e1279ff8082 +HEALTH_DUMP_TRUNCATED=false +HEALTH_DUMP_END=parse_kv_file +HEALTH_DUMP_BEGIN=send_mail +FunctionDef( + name='send_mail', + args=arguments( + args=[ + arg( + arg='subject', + annotation=Name(id='str', ctx=Load())), + arg( + arg='body', + annotation=Name(id='str', ctx=Load()))]), + body=[ + Assign( + targets=[ + Name(id='mod', ctx=Store())], + value=Call( + func=Name(id='load_monitor_module', ctx=Load()))), + Assign( + targets=[ + Tuple( + elts=[ + Name(id='cfg', ctx=Store()), + Name(id='secrets', ctx=Store())], + ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='mod', ctx=Load()), + attr='load_config', + ctx=Load()))), + Return( + value=Call( + func=Name(id='bool', ctx=Load()), + args=[ + Call( + func=Attribute( + value=Name(id='mod', ctx=Load()), + attr='send_mail', + ctx=Load()), + args=[ + Name(id='cfg', ctx=Load()), + Name(id='secrets', ctx=Load()), + Name(id='subject', ctx=Load()), + Name(id='body', ctx=Load())])]))], + returns=Name(id='bool', ctx=Load())) +HEALTH_DUMP_SHA256=949d900c876b9ee94a5fa7eca5792121fe1e77eee64b76fe447c8c8ba94b48c6 +HEALTH_DUMP_TRUNCATED=false +HEALTH_DUMP_END=send_mail +HEALTH_DUMP_BEGIN=route_ok +FunctionDef( + name='route_ok', + args=arguments(), + body=[ + Assign( + targets=[ + Tuple( + elts=[ + Name(id='rc', ctx=Store()), + Name(id='out', ctx=Store())], + ctx=Store())], + value=Call( + func=Name(id='run_cmd', ctx=Load()), + args=[ + List( + elts=[ + Constant(value='ip'), + Constant(value='route'), + Constant(value='get'), + Constant(value='')], + ctx=Load())], + keywords=[ + keyword( + arg='timeout', + value=Constant(value=10))])), + Return( + value=Tuple( + elts=[ + BoolOp( + op=And(), + values=[ + Compare( + left=Name(id='rc', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value=0)]), + Compare( + left=Constant(value=' dev wt0 '), + ops=[ + In()], + comparators=[ + JoinedStr( + values=[ + Constant(value=' '), + FormattedValue( + value=Name(id='out', ctx=Load()), + conversion=-1), + Constant(value=' ')])])]), + Name(id='out', ctx=Load())], + ctx=Load()))]) +HEALTH_DUMP_SHA256=b3c72e69fe87a4333c66b82a8e898bc417dc642ecd71381f1bb45f6b26f7e255 +HEALTH_DUMP_TRUNCATED=false +HEALTH_DUMP_END=route_ok +HEALTH_DUMP_BEGIN=status_ru +FunctionDef( + name='status_ru', + args=arguments( + args=[ + arg( + arg='value', + annotation=Name(id='str', ctx=Load()))]), + body=[ + If( + test=Compare( + left=Name(id='value', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='OK')]), + body=[ + Return( + value=Constant(value='OK'))]), + If( + test=Compare( + left=Name(id='value', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='ALERT')]), + body=[ + Return( + value=Constant(value='ТРЕВОГА'))]), + If( + test=Compare( + left=Name(id='value', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='AUTH_REQUIRED')]), + body=[ + Return( + value=Constant(value='нужна повторная авторизация'))]), + If( + test=Compare( + left=Name(id='value', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='ERROR')]), + body=[ + Return( + value=Constant(value='ошибка'))]), + Return( + value=BoolOp( + op=Or(), + values=[ + Name(id='value', ctx=Load()), + Constant(value='неизвестно')]))], + returns=Name(id='str', ctx=Load())) +HEALTH_DUMP_SHA256=177f282793ef16e747defa8dbd1fb35e704b9d54ffa892799e430ac9e0ecf22a +HEALTH_DUMP_TRUNCATED=false +HEALTH_DUMP_END=status_ru +HEALTH_DUMP_BEGIN=build_status +FunctionDef( + name='build_status', + args=arguments(), + body=[ + Assign( + targets=[ + Name(id='problems', ctx=Store())], + value=List(ctx=Load())), + Assign( + targets=[ + Name(id='health', ctx=Store())], + value=Call( + func=Name(id='parse_kv_file', ctx=Load()), + args=[ + Name(id='HEALTH_PATH', ctx=Load())])), + Assign( + targets=[ + Name(id='timer_active', ctx=Store())], + value=Call( + func=Name(id='systemd_value', ctx=Load()), + args=[ + Constant(value='skladchik-reports-monitor.timer'), + Constant(value='ActiveState')])), + Assign( + targets=[ + Tuple( + elts=[ + Name(id='timer_enabled_rc', ctx=Store()), + Name(id='timer_enabled', ctx=Store())], + ctx=Store())], + value=Call( + func=Name(id='run_cmd', ctx=Load()), + args=[ + List( + elts=[ + Constant(value='systemctl'), + Constant(value='is-enabled'), + Constant(value='skladchik-reports-monitor.timer')], + ctx=Load())], + keywords=[ + keyword( + arg='timeout', + value=Constant(value=10))])), + Assign( + targets=[ + Tuple( + elts=[ + Name(id='watchdog_enabled_rc', ctx=Store()), + Name(id='watchdog_enabled', ctx=Store())], + ctx=Store())], + value=Call( + func=Name(id='run_cmd', ctx=Load()), + args=[ + List( + elts=[ + Constant(value='systemctl'), + Constant(value='is-enabled'), + Constant(value='skladchik-reports-monitor-watchdog.timer')], + ctx=Load())], + keywords=[ + keyword( + arg='timeout', + value=Constant(value=10))])), + Assign( + targets=[ + Tuple( + elts=[ + Name(id='heartbeat_enabled_rc', ctx=Store()), + Name(id='heartbeat_enabled', ctx=Store())], + ctx=Store())], + value=Call( + func=Name(id='run_cmd', ctx=Load()), + args=[ + List( + elts=[ + Constant(value='systemctl'), + Constant(value='is-enabled'), + Constant(value='skladchik-reports-monitor-heartbeat.timer')], + ctx=Load())], + keywords=[ + keyword( + arg='timeout', + value=Constant(value=10))])), + Assign( + targets=[ + Tuple( + elts=[ + Name(id='r_ok', ctx=Store()), + Name(id='route_text', ctx=Store())], + ctx=Store())], + value=Call( + func=Name(id='route_ok', ctx=Load()))), + If( + test=Compare( + left=Name(id='timer_active', ctx=Load()), + ops=[ + NotEq()], + comparators=[ + Constant(value='active')]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='problems', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='monitor_timer_not_active:'), + FormattedValue( + value=Name(id='timer_active', ctx=Load()), + conversion=-1)])]))]), + If( + test=BoolOp( + op=Or(), + values=[ + Compare( + left=Name(id='timer_enabled_rc', ctx=Load()), + ops=[ + NotEq()], + comparators=[ + Constant(value=0)]), + Compare( + left=Name(id='timer_enabled', ctx=Load()), + ops=[ + NotEq()], + comparators=[ + Constant(value='enabled')])]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='problems', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='monitor_timer_not_enabled:'), + FormattedValue( + value=Name(id='timer_enabled', ctx=Load()), + conversion=-1)])]))]), + If( + test=UnaryOp( + op=Not(), + operand=Call( + func=Attribute( + value=Name(id='HEALTH_PATH', ctx=Load()), + attr='exists', + ctx=Load()))), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='problems', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + Constant(value='monitor_health_missing')]))]), + If( + test=Compare( + left=Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='STATUS')]), + ops=[ + NotEq()], + comparators=[ + Constant(value='OK')]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='problems', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='monitor_status_not_ok:'), + FormattedValue( + value=Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='STATUS'), + Constant(value='missing')]), + conversion=-1)])]))]), + Assign( + targets=[ + Name(id='age', ctx=Store())], + value=Call( + func=Name(id='iso_age_seconds', ctx=Load()), + args=[ + Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='TS'), + Constant(value='')])])), + If( + test=Compare( + left=Name(id='age', ctx=Load()), + ops=[ + Is()], + comparators=[ + Constant(value=None)]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='problems', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + Constant(value='monitor_health_ts_invalid')]))], + orelse=[ + If( + test=Compare( + left=Name(id='age', ctx=Load()), + ops=[ + Gt()], + comparators=[ + Name(id='MAX_HEALTH_AGE_SECONDS', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='problems', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='monitor_health_stale:'), + FormattedValue( + value=Name(id='age', ctx=Load()), + conversion=-1), + Constant(value='s')])]))])]), + Try( + body=[ + Assign( + targets=[ + Name(id='reports', ctx=Store())], + value=Call( + func=Name(id='int', ctx=Load()), + args=[ + Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='reports'), + Constant(value='-1')])]))], + handlers=[ + ExceptHandler( + type=Name(id='ValueError', ctx=Load()), + body=[ + Assign( + targets=[ + Name(id='reports', ctx=Store())], + value=UnaryOp( + op=USub(), + operand=Constant(value=1)))])]), + If( + test=Compare( + left=Name(id='reports', ctx=Load()), + ops=[ + LtE()], + comparators=[ + Constant(value=0)]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='problems', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='monitor_reports_bad:'), + FormattedValue( + value=Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='reports'), + Constant(value='missing')]), + conversion=-1)])]))]), + If( + test=Compare( + left=Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='')]), + ops=[ + NotIn()], + comparators=[ + Tuple( + elts=[ + Constant(value='yes'), + Constant(value='empty')], + ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='problems', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value=''), + FormattedValue( + value=Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value=''), + Constant(value='missing')]), + conversion=-1)])]))]), + Assign( + targets=[ + Name(id='expiry_status', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value=''), + Constant(value='')])), + Assign( + targets=[ + Name(id='expires_raw', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value=''), + Constant(value='')])), + Try( + body=[ + Assign( + targets=[ + Name(id='expires_in', ctx=Store())], + value=Call( + func=Name(id='int', ctx=Load()), + args=[ + Name(id='expires_raw', ctx=Load())]))], + handlers=[ + ExceptHandler( + type=Name(id='Exception', ctx=Load()), + body=[ + Assign( + targets=[ + Name(id='expires_in', ctx=Store())], + value=Constant(value=None))])]), + If( + test=Compare( + left=Name(id='expiry_status', ctx=Load()), + ops=[ + In()], + comparators=[ + Tuple( + elts=[ + Constant(value=''), + Constant(value=''), + Constant(value=''), + Constant(value='ERROR')], + ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='problems', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + Constant(value='')]))], + orelse=[ + If( + test=BoolOp( + op=Or(), + values=[ + Compare( + left=Name(id='expiry_status', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='EXPIRED')]), + BoolOp( + op=And(), + values=[ + Compare( + left=Name(id='expires_in', ctx=Load()), + ops=[ + IsNot()], + comparators=[ + Constant(value=None)]), + Compare( + left=Name(id='expires_in', ctx=Load()), + ops=[ + LtE()], + comparators=[ + Constant(value=0)])])]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='problems', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + Constant(value='')]))], + orelse=[ + If( + test=BoolOp( + op=Or(), + values=[ + Compare( + left=Name(id='expiry_status', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='WARN')]), + BoolOp( + op=And(), + values=[ + Compare( + left=Name(id='expires_in', ctx=Load()), + ops=[ + IsNot()], + comparators=[ + Constant(value=None)]), + Compare( + left=Name(id='expires_in', ctx=Load()), + ops=[ + Lt()], + comparators=[ + Name(id='COOKIE +HEALTH_DUMP_SHA256=d30ee0c7a70105bffab10e001bddfad80466fe5a99394d96b4449e991cbfbeaf +HEALTH_DUMP_TRUNCATED=true +HEALTH_DUMP_END=build_status +HEALTH_DUMP_BEGIN=status_to_body +FunctionDef( + name='status_to_body', + args=arguments( + args=[ + arg(arg='status'), + arg( + arg='mode', + annotation=Name(id='str', ctx=Load()))]), + body=[ + Assign( + targets=[ + Name(id='health', ctx=Store())], + value=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='health'), + ctx=Load())), + Assign( + targets=[ + Name(id='lines', ctx=Store())], + value=List(ctx=Load())), + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='Мониторинг жалоб Складчика: '), + FormattedValue( + value=Name(id='mode', ctx=Load()), + conversion=-1)])])), + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='Время UTC: '), + FormattedValue( + value=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='ts'), + ctx=Load()), + conversion=-1)])])), + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='Общий статус: '), + FormattedValue( + value=IfExp( + test=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='ok'), + ctx=Load()), + body=Constant(value='OK'), + orelse=Constant(value='ТРЕВОГА')), + conversion=-1)])])), + If( + test=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='problems'), + ctx=Load()), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + Constant(value='Проблемы:')])), + For( + target=Name(id='problem', ctx=Store()), + iter=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='problems'), + ctx=Load()), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='- '), + FormattedValue( + value=Call( + func=Name(id='problem_to_ru', ctx=Load()), + args=[ + Name(id='problem', ctx=Load())]), + conversion=-1)])]))])]), + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + Constant(value='')])), + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + Constant(value='Состояние основного монитора:')])), + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='- Статус: '), + FormattedValue( + value=Call( + func=Name(id='status_ru', ctx=Load()), + args=[ + Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='STATUS'), + Constant(value='missing')])]), + conversion=-1)])])), + If( + test=Compare( + left=Constant(value='TS'), + ops=[ + In()], + comparators=[ + Name(id='health', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='- Последний успешный опрос UTC: '), + FormattedValue( + value=Subscript( + value=Name(id='health', ctx=Load()), + slice=Constant(value='TS'), + ctx=Load()), + conversion=-1)])]))]), + If( + test=Compare( + left=Constant(value='url'), + ops=[ + In()], + comparators=[ + Name(id='health', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='- URL: '), + FormattedValue( + value=Subscript( + value=Name(id='health', ctx=Load()), + slice=Constant(value='url'), + ctx=Load()), + conversion=-1)])]))]), + If( + test=Compare( + left=Constant(value='reports'), + ops=[ + In()], + comparators=[ + Name(id='health', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='- Всего жалоб на странице: '), + FormattedValue( + value=Subscript( + value=Name(id='health', ctx=Load()), + slice=Constant(value='reports'), + ctx=Load()), + conversion=-1)])]))]), + If( + test=Compare( + left=Constant(value='open'), + ops=[ + In()], + comparators=[ + Name(id='health', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='- Открытые / в работе: '), + FormattedValue( + value=Subscript( + value=Name(id='health', ctx=Load()), + slice=Constant(value='open'), + ctx=Load()), + conversion=-1)])]))]), + If( + test=Compare( + left=Constant(value='resolved'), + ops=[ + In()], + comparators=[ + Name(id='health', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='- Закрытые / отработанные: '), + FormattedValue( + value=Subscript( + value=Name(id='health', ctx=Load()), + slice=Constant(value='resolved'), + ctx=Load()), + conversion=-1)])]))]), + If( + test=Compare( + left=Constant(value='session_keepalive'), + ops=[ + In()], + comparators=[ + Name(id='health', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + Constant(value='')]))]), + If( + test=Compare( + left=Constant(value=''), + ops=[ + In()], + comparators=[ + Name(id='health', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value=''), + FormattedValue( + value=Subscript( + value=Name(id='health', ctx=Load()), + slice=Constant(value=''), + ctx=Load()), + conversion=-1), + Constant(value=', байт: '), + FormattedValue( + value=Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value=''), + Constant(value='?')]), + conversion=-1)])]))]), + If( + test=Compare( + left=Constant(value=''), + ops=[ + In()], + comparators=[ + Name(id='health', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value=''), + FormattedValue( + value=Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='')]), + conversion=-1)])])), + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value=''), + FormattedValue( + value=Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value=''), + Constant(value='?')]), + conversion=-1)])])), + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value=''), + FormattedValue( + value=Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value=''), + Constant(value='?')]), + conversion=-1)])]))]), + If( + test=Compare( + left=Constant(value='new_events'), + ops=[ + In()], + comparators=[ + Name(id='health', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='- Новые события за последний опрос: '), + FormattedValue( + value=Subscript( + value=Name(id='health', ctx=Load()), + slice=Constant(value='new_events'), + ctx=Load()), + conversion=-1)])]))]), + If( + test=Compare( + left=Constant(value='resolved_events'), + ops=[ + In()], + comparators=[ + Name(id='health', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='- Закрытые события за последний опрос: '), + FormattedValue( + value=Subscript( + value=Name(id='health', ctx=Load()), + slice=Constant(value='resolved_events'), + ctx=Load()), + conversion=-1)])]))]), + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='- Возраст состояния, секунд: '), + FormattedValue( + value=Subscript( + value=Name(id='status', ctx=Loa +HEALTH_DUMP_SHA256=680c4e2fd2c19d569bb38130327a7044c6cd29de4d4a7490ecf3c860ee5f7865 +HEALTH_DUMP_TRUNCATED=true +HEALTH_DUMP_END=status_to_body +HEALTH_DUMP_BEGIN=do_check +FunctionDef( + name='do_check', + args=arguments(), + body=[ + Assign( + targets=[ + Name(id='status', ctx=Store())], + value=Call( + func=Name(id='build_status', ctx=Load()))), + Assign( + targets=[ + Name(id='state', ctx=Store())], + value=Call( + func=Name(id='load_state', ctx=Load()))), + Assign( + targets=[ + Name(id='now', ctx=Store())], + value=Call( + func=Name(id='int', ctx=Load()), + args=[ + Call( + func=Attribute( + value=Name(id='time', ctx=Load()), + attr='time', + ctx=Load()))])), + Assign( + targets=[ + Name(id='problem_key', ctx=Store())], + value=IfExp( + test=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='problems'), + ctx=Load()), + body=Call( + func=Attribute( + value=Call( + func=Attribute( + value=Name(id='hashlib', ctx=Load()), + attr='sha256', + ctx=Load()), + args=[ + Call( + func=Attribute( + value=Call( + func=Attribute( + value=Constant(value='|'), + attr='join', + ctx=Load()), + args=[ + Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='problems'), + ctx=Load())]), + attr='encode', + ctx=Load()), + args=[ + Constant(value='utf-8')])]), + attr='hexdigest', + ctx=Load())), + orelse=Constant(value=''))), + Assign( + targets=[ + Name(id='mail_sent', ctx=Store())], + value=Constant(value=False)), + If( + test=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='ok'), + ctx=Load()), + body=[ + If( + test=Call( + func=Attribute( + value=Name(id='state', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='active_alert')]), + body=[ + Assign( + targets=[ + Name(id='subject', ctx=Store())], + value=Constant(value='Мониторинг жалоб восстановлен: OK')), + Assign( + targets=[ + Name(id='body', ctx=Store())], + value=Call( + func=Name(id='status_to_body', ctx=Load()), + args=[ + Name(id='status', ctx=Load()), + Constant(value='восстановление')])), + Assign( + targets=[ + Name(id='mail_sent', ctx=Store())], + value=Call( + func=Name(id='send_mail', ctx=Load()), + args=[ + Name(id='subject', ctx=Load()), + Name(id='body', ctx=Load())])), + Assign( + targets=[ + Name(id='state', ctx=Store())], + value=Dict( + keys=[ + Constant(value='active_alert'), + Constant(value='last_recovery_ts')], + values=[ + Constant(value=False), + Name(id='now', ctx=Load())])), + Expr( + value=Call( + func=Name(id='log', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='RECOVERY mail_sent='), + FormattedValue( + value=Name(id='mail_sent', ctx=Load()), + conversion=-1)])]))], + orelse=[ + Expr( + value=Call( + func=Name(id='log', ctx=Load()), + args=[ + Constant(value='CHECK ok=true mail_sent=false')]))])], + orelse=[ + Assign( + targets=[ + Name(id='last_alert_ts', ctx=Store())], + value=Call( + func=Name(id='int', ctx=Load()), + args=[ + BoolOp( + op=Or(), + values=[ + Call( + func=Attribute( + value=Name(id='state', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='last_alert_ts'), + Constant(value=0)]), + Constant(value=0)])])), + Assign( + targets=[ + Name(id='last_key', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='state', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='last_problem_key'), + Constant(value='')])), + Assign( + targets=[ + Name(id='should_send', ctx=Store())], + value=BoolOp( + op=Or(), + values=[ + UnaryOp( + op=Not(), + operand=Call( + func=Attribute( + value=Name(id='state', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='active_alert')])), + Compare( + left=Name(id='last_key', ctx=Load()), + ops=[ + NotEq()], + comparators=[ + Name(id='problem_key', ctx=Load())]), + Compare( + left=BinOp( + left=Name(id='now', ctx=Load()), + op=Sub(), + right=Name(id='last_alert_ts', ctx=Load())), + ops=[ + GtE()], + comparators=[ + Name(id='ALERT_REPEAT_SECONDS', ctx=Load())])])), + If( + test=Name(id='should_send', ctx=Load()), + body=[ + Assign( + targets=[ + Name(id='subject', ctx=Store())], + value=BinOp( + left=Constant(value='ТРЕВОГА мониторинга жалоб: '), + op=Add(), + right=Call( + func=Attribute( + value=Constant(value=', '), + attr='join', + ctx=Load()), + args=[ + GeneratorExp( + elt=Call( + func=Name(id='problem_to_ru', ctx=Load()), + args=[ + Name(id='p', ctx=Load())]), + generators=[ + comprehension( + target=Name(id='p', ctx=Store()), + iter=Subscript( + value=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='problems'), + ctx=Load()), + slice=Slice( + upper=Constant(value=2)), + ctx=Load()), + is_async=0)])]))), + Assign( + targets=[ + Name(id='body', ctx=Store())], + value=Call( + func=Name(id='status_to_body', ctx=Load()), + args=[ + Name(id='status', ctx=Load()), + Constant(value='тревога')])), + Assign( + targets=[ + Name(id='mail_sent', ctx=Store())], + value=Call( + func=Name(id='send_mail', ctx=Load()), + args=[ + Name(id='subject', ctx=Load()), + Name(id='body', ctx=Load())])), + Expr( + value=Call( + func=Attribute( + value=Name(id='state', ctx=Load()), + attr='update', + ctx=Load()), + args=[ + Dict( + keys=[ + Constant(value='active_alert'), + Constant(value='last_alert_ts'), + Constant(value='last_problem_key'), + Constant(value='last_problems')], + values=[ + Constant(value=True), + Name(id='now', ctx=Load()), + Name(id='problem_key', ctx=Load()), + Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='problems'), + ctx=Load())])])), + Expr( + value=Call( + func=Name(id='log', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='ALERT mail_sent='), + FormattedValue( + value=Name(id='mail_sent', ctx=Load()), + conversion=-1), + Constant(value=' problems='), + FormattedValue( + value=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='problems'), + ctx=Load()), + conversion=-1)])]))], + orelse=[ + Expr( + value=Call( + func=Name(id='log', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='CHECK ok=false suppressed=true problems='), + FormattedValue( + value=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='problems'), + ctx=Load()), + conversion=-1)])]))])]), + Expr( + value=Call( + func=Name(id='save_state', ctx=Load()), + args=[ + Name(id='state', ctx=Load())])), + Expr( + value=Call( + func=Name(id='write_alert_health', ctx=Load()), + args=[ + Name(id='status', ctx=Load()), + Name(id='mail_sent', ctx=Load())])), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + BinOp( + left=Constant(value='WATCHDOG_STATUS='), + op=Add(), + right=IfExp( + test=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='ok'), + ctx=Load()), + body=Constant(value='OK'), + orelse=Constant(value='ALERT')))])), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + BinOp( + left=Constant(value='WATCHDOG_MAIL_SENT='), + op=Add(), + right=IfExp( + test=Name(id='mail_sent', ctx=Load()), + body=Constant(value='yes'), + orelse=Constant(value='no')))])), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='PROBLEMS='), + FormattedValue( + value=Call( + func=Attribute( + value=Constant(value=';'), + attr='join', + ctx=Load()), + args=[ + Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='problems'), + ctx=Load())]), + conversion=-1)])])), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='OPEN='), + FormattedValue( + value=Call( + func=Attribute( + value=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='health'), + ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='open'), + Constant(value='missing')]), + conversion=-1)])])), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='RESOLVED='), + FormattedValue( + value=Call( + func=Attribute( + value=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='health'), + ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='resolved'), + Constant(value='missing')]), + conversion=-1)])])), + Return( + value=Constant(value=0))]) +HEALTH_DUMP_SHA256=da7bbe1956bd719cb634bbf6d2d3ace50781963d52bba841ec8197af0888f282 +HEALTH_DUMP_TRUNCATED=false +HEALTH_DUMP_END=do_check +HEALTH_DUMP_BEGIN=do_status +FunctionDef( + name='do_status', + args=arguments(), + body=[ + Assign( + targets=[ + Name(id='status', ctx=Store())], + value=Call( + func=Name(id='build_status', ctx=Load()))), + Expr( + value=Call( + func=Name(id='write_alert_health', ctx=Load()), + args=[ + Name(id='status', ctx=Load()), + Constant(value=None)])), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + BinOp( + left=Constant(value='WATCHDOG_STATUS='), + op=Add(), + right=IfExp( + test=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='ok'), + ctx=Load()), + body=Constant(value='OK'), + orelse=Constant(value='ALERT')))])), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='PROBLEMS='), + FormattedValue( + value=Call( + func=Attribute( + value=Constant(value=';'), + attr='join', + ctx=Load()), + args=[ + Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='problems'), + ctx=Load())]), + conversion=-1)])])), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='OPEN='), + FormattedValue( + value=Call( + func=Attribute( + value=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='health'), + ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='open'), + Constant(value='missing')]), + conversion=-1)])])), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='RESOLVED='), + FormattedValue( + value=Call( + func=Attribute( + value=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='health'), + ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='resolved'), + Constant(value='missing')]), + conversion=-1)])])), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='HEALTH_AGE_SECONDS='), + FormattedValue( + value=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='health_age_seconds'), + ctx=Load()), + conversion=-1)])])), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='NETBIRD_ROUTE_OK='), + FormattedValue( + value=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='route_ok'), + ctx=Load()), + conversion=-1)])])), + Return( + value=IfExp( + test=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='ok'), + ctx=Load()), + body=Constant(value=0), + orelse=Constant(value=1)))]) +HEALTH_DUMP_SHA256=cbf3c7c1c58dd802afb48ef237a648104b27d72a6b727156bde564cb253cc0a2 +HEALTH_DUMP_TRUNCATED=false +HEALTH_DUMP_END=do_status +HEALTH_DUMP_BEGIN=main +FunctionDef( + name='main', + args=arguments(), + body=[ + Assign( + targets=[ + Name(id='mode', ctx=Store())], + value=IfExp( + test=Compare( + left=Call( + func=Name(id='len', ctx=Load()), + args=[ + Attribute( + value=Name(id='sys', ctx=Load()), + attr='argv', + ctx=Load())]), + ops=[ + Gt()], + comparators=[ + Constant(value=1)]), + body=Subscript( + value=Attribute( + value=Name(id='sys', ctx=Load()), + attr='argv', + ctx=Load()), + slice=Constant(value=1), + ctx=Load()), + orelse=Constant(value='check'))), + If( + test=Compare( + left=Name(id='mode', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='heartbeat')]), + body=[ + Return( + value=Call( + func=Name(id='do_heartbeat', ctx=Load())))]), + If( + test=Compare( + left=Name(id='mode', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='check')]), + body=[ + Return( + value=Call( + func=Name(id='do_check', ctx=Load())))]), + If( + test=Compare( + left=Name(id='mode', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='status')]), + body=[ + Return( + value=Call( + func=Name(id='do_status', ctx=Load())))]), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + Constant(value='usage: health_alert.py [check|heartbeat|status]')], + keywords=[ + keyword( + arg='file', + value=Attribute( + value=Name(id='sys', ctx=Load()), + attr='stderr', + ctx=Load()))])), + Return( + value=Constant(value=64))]) +HEALTH_DUMP_SHA256=9a6149262fde18c30b641e25ec67b04a04957d0b2588ec05b1775c875c6722d2 +HEALTH_DUMP_TRUNCATED=false +HEALTH_DUMP_END=main +HEALTH_SCAN_OK=true +QGA_CANARY_QM_RC=0 +QGA_CANARY_STDERR_PRESENT=false +QGA_CANARY_JSON=true +QGA_CANARY_GUEST_EXITCODE=0 +QGA_SHORT_OK=true +MONITOR_SCAN_QM_RC=0 +MONITOR_SCAN_STDERR_PRESENT=false +MONITOR_SCAN_JSON=true +MONITOR_SCAN_GUEST_EXITCODE=0 +MONITOR_SCAN=V1 +MONITOR_PRESENT=true +MONITOR_SHA256=f62288797f80ce561f1e3ea721b87090eb1cd751fd5bf07152a3608b3a8aaed2 +MONITOR_BYTES=17878 +MONITOR_FUNCTION_COUNT=26 +MONITOR_FUNC=utc_now:48:49 +MONITOR_FUNC=log:52:55 +MONITOR_FUNC=write_health:58:64 +MONITOR_FUNC=read_env:67:81 +MONITOR_FUNC=load_config:84:101 +MONITOR_FUNC=connect_db:104:136 +MONITOR_FUNC=meta_get:139:141 +MONITOR_FUNC=meta_set:144:146 +MONITOR_FUNC=event_sent:149:150 +MONITOR_FUNC=mark_event:153:158 +MONITOR_FUNC=fetch_reports_page:161:179 +MONITOR_FUNC=login_required:182:192 +MONITOR_FUNC=strip_tags:195:198 +MONITOR_FUNC=full_url:201:202 +MONITOR_FUNC=section_positions:205:222 +MONITOR_FUNC=parse_int:225:227 +MONITOR_FUNC=parse_reports:230:281 +MONITOR_FUNC=smtp_ready:284:285 +MONITOR_FUNC=send_mail:288:312 +MONITOR_FUNC=report_body:315:324 +MONITOR_FUNC=process_reports:327:370 +MONITOR_FUNC=maybe_send_auth_required:373:391 +MONITOR_FUNC=acquire_lock:394:401 +MONITOR_FUNC=run_once:404:451 +MONITOR_FUNC=show_status:454:459 +MONITOR_FUNC=main:462:468 +MONITOR_RELEVANT_COUNT=10 +MONITOR_DUMP_BEGIN=fetch_reports_page +FunctionDef( + name='fetch_reports_page', + args=arguments( + args=[ + arg( + arg='cfg', + annotation=Attribute( + value=Name(id='configparser', ctx=Load()), + attr='ConfigParser', + ctx=Load())), + arg( + arg='secrets', + annotation=Subscript( + value=Name(id='dict', ctx=Load()), + slice=Tuple( + elts=[ + Name(id='str', ctx=Load()), + Name(id='str', ctx=Load())], + ctx=Load()), + ctx=Load()))]), + body=[ + Assign( + targets=[ + Name(id='url', ctx=Store())], + value=Call( + func=Attribute( + value=Subscript( + value=Name(id='cfg', ctx=Load()), + slice=Constant(value='forum'), + ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='reports_url'), + Constant(value='')])), + Assign( + targets=[ + Name(id='request', ctx=Store())], + value=Call( + func=Attribute( + value=Attribute( + value=Name(id='urllib', ctx=Load()), + attr='request', + ctx=Load()), + attr='Request', + ctx=Load()), + args=[ + Name(id='url', ctx=Load())])), + Expr( + value=Call( + func=Attribute( + value=Name(id='request', ctx=Load()), + attr='add_header', + ctx=Load()), + args=[ + Constant(value='User-Agent'), + Call( + func=Attribute( + value=Subscript( + value=Name(id='cfg', ctx=Load()), + slice=Constant(value='forum'), + ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='user_agent'), + Constant(value='Mozilla/5.0')])])), + Expr( + value=Call( + func=Attribute( + value=Name(id='request', ctx=Load()), + attr='add_header', + ctx=Load()), + args=[ + Constant(value='Accept'), + Constant(value='text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')])), + Expr( + value=Call( + func=Attribute( + value=Name(id='request', ctx=Load()), + attr='add_header', + ctx=Load()), + args=[ + Constant(value='Accept-Language'), + Constant(value='ru-RU,ru;q=0.9,en;q=0.5')])), + Assign( + targets=[ + Name(id='cookie', ctx=Store())], + value=BoolOp( + op=Or(), + values=[ + Call( + func=Attribute( + value=Name(id='secrets', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='')]), + Call( + func=Attribute( + value=Name(id='secrets', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='')]), + Constant(value='')])), + If( + test=Name(id='cookie', ctx=Load()), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='request', ctx=Load()), + attr='add_header', + ctx=Load()), + args=[ + Constant(value=''), + Name(id='cookie', ctx=Load())]))]), + Assign( + targets=[ + Name(id='timeout', ctx=Store())], + value=Call( + func=Attribute( + value=Subscript( + value=Name(id='cfg', ctx=Load()), + slice=Constant(value='forum'), + ctx=Load()), + attr='getint', + ctx=Load()), + args=[ + Constant(value='timeout_seconds')], + keywords=[ + keyword( + arg='fallback', + value=Constant(value=25))])), + With( + items=[ + withitem( + context_expr=Call( + func=Attribute( + value=Attribute( + value=Name(id='urllib', ctx=Load()), + attr='request', + ctx=Load()), + attr='urlopen', + ctx=Load()), + args=[ + Name(id='request', ctx=Load())], + keywords=[ + keyword( + arg='timeout', + value=Name(id='timeout', ctx=Load()))]), + optional_vars=Name(id='response', ctx=Store()))], + body=[ + Assign( + targets=[ + Name(id='final_url', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='response', ctx=Load()), + attr='geturl', + ctx=Load()))), + Assign( + targets=[ + Name(id='body', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='response', ctx=Load()), + attr='read', + ctx=Load()))), + Assign( + targets=[ + Name(id='charset', ctx=Store())], + value=Constant(value='utf-8')), + Assign( + targets=[ + Name(id='content_type', ctx=Store())], + value=Call( + func=Attribute( + value=Attribute( + value=Name(id='response', ctx=Load()), + attr='headers', + ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='Content-Type'), + Constant(value='')])), + Assign( + targets=[ + Name(id='match', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='re', ctx=Load()), + attr='search', + ctx=Load()), + args=[ + Constant(value='charset=([A-Za-z0-9._-]+)'), + Name(id='content_type', ctx=Load())], + keywords=[ + keyword( + arg='flags', + value=Attribute( + value=Name(id='re', ctx=Load()), + attr='I', + ctx=Load()))])), + If( + test=Name(id='match', ctx=Load()), + body=[ + Assign( + targets=[ + Name(id='charset', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='match', ctx=Load()), + attr='group', + ctx=Load()), + args=[ + Constant(value=1)]))]), + Return( + value=Tuple( + elts=[ + Name(id='final_url', ctx=Load()), + Call( + func=Attribute( + value=Name(id='body', ctx=Load()), + attr='decode', + ctx=Load()), + args=[ + Name(id='charset', ctx=Load())], + keywords=[ + keyword( + arg='errors', + value=Constant(value='replace'))])], + ctx=Load()))])], + returns=Subscript( + value=Name(id='tuple', ctx=Load()), + slice=Tuple( + elts=[ + Name(id='str', ctx=Load()), + Name(id='str', ctx=Load())], + ctx=Load()), + ctx=Load())) +MONITOR_DUMP_SHA256=5b5c22665fa95eba6f84bbab6664b6750ec6ce801008b74213b7318201cded18 +MONITOR_DUMP_TRUNCATED=false +MONITOR_DUMP_END=fetch_reports_page +MONITOR_DUMP_BEGIN=parse_int +FunctionDef( + name='parse_int', + args=arguments( + args=[ + arg( + arg='pattern', + annotation=Name(id='str', ctx=Load())), + arg( + arg='text', + annotation=Name(id='str', ctx=Load()))]), + body=[ + Assign( + targets=[ + Name(id='match', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='re', ctx=Load()), + attr='search', + ctx=Load()), + args=[ + Name(id='pattern', ctx=Load()), + Name(id='text', ctx=Load())], + keywords=[ + keyword( + arg='flags', + value=Attribute( + value=Name(id='re', ctx=Load()), + attr='I', + ctx=Load()))])), + Return( + value=IfExp( + test=Name(id='match', ctx=Load()), + body=Call( + func=Name(id='int', ctx=Load()), + args=[ + Call( + func=Attribute( + value=Name(id='match', ctx=Load()), + attr='group', + ctx=Load()), + args=[ + Constant(value=1)])]), + orelse=Constant(value=None)))], + returns=BinOp( + left=Name(id='int', ctx=Load()), + op=BitOr(), + right=Constant(value=None))) +MONITOR_DUMP_SHA256=cb2011a9afb6eed1914e736d66227b0214cb4adb04afb833df8799db0dbf500e +MONITOR_DUMP_TRUNCATED=false +MONITOR_DUMP_END=parse_int +MONITOR_DUMP_BEGIN=parse_reports +FunctionDef( + name='parse_reports', + args=arguments( + args=[ + arg( + arg='text', + annotation=Name(id='str', ctx=Load())), + arg( + arg='cfg', + annotation=Attribute( + value=Name(id='configparser', ctx=Load()), + attr='ConfigParser', + ctx=Load()))]), + body=[ + Assign( + targets=[ + Name(id='base_url', ctx=Store())], + value=Call( + func=Attribute( + value=Subscript( + value=Name(id='cfg', ctx=Load()), + slice=Constant(value='forum'), + ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='base_url'), + Constant(value='')])), + Assign( + targets=[ + Tuple( + elts=[ + Name(id='open_pos', ctx=Store()), + Name(id='closed_pos', ctx=Store())], + ctx=Store())], + value=Call( + func=Name(id='section_positions', ctx=Load()), + args=[ + Name(id='text', ctx=Load())])), + AnnAssign( + target=Name(id='results', ctx=Store()), + annotation=Subscript( + value=Name(id='dict', ctx=Load()), + slice=Tuple( + elts=[ + Name(id='str', ctx=Load()), + Subscript( + value=Name(id='dict', ctx=Load()), + slice=Tuple( + elts=[ + Name(id='str', ctx=Load()), + Name(id='Any', ctx=Load())], + ctx=Load()), + ctx=Load())], + ctx=Load()), + ctx=Load()), + value=Dict(), + simple=1), + Assign( + targets=[ + Name(id='pattern', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='re', ctx=Load()), + attr='compile', + ctx=Load()), + args=[ + Constant(value='(?is)]*href=[\\"\']((?:reports/|[^\\"\']*/reports/)(\\d+)/?[^\\"\']*)[\\"\'][^>]*>(.*?)')])), + For( + target=Name(id='match', ctx=Store()), + iter=Call( + func=Attribute( + value=Name(id='pattern', ctx=Load()), + attr='finditer', + ctx=Load()), + args=[ + Name(id='text', ctx=Load())]), + body=[ + Assign( + targets=[ + Tuple( + elts=[ + Name(id='href', ctx=Store()), + Name(id='report_id', ctx=Store()), + Name(id='title_html', ctx=Store())], + ctx=Store())], + value=Tuple( + elts=[ + Call( + func=Attribute( + value=Name(id='match', ctx=Load()), + attr='group', + ctx=Load()), + args=[ + Constant(value=1)]), + Call( + func=Attribute( + value=Name(id='match', ctx=Load()), + attr='group', + ctx=Load()), + args=[ + Constant(value=2)]), + Call( + func=Attribute( + value=Name(id='match', ctx=Load()), + attr='group', + ctx=Load()), + args=[ + Constant(value=3)])], + ctx=Load())), + Assign( + targets=[ + Name(id='title', ctx=Store())], + value=Call( + func=Name(id='strip_tags', ctx=Load()), + args=[ + Name(id='title_html', ctx=Load())])), + If( + test=BoolOp( + op=Or(), + values=[ + UnaryOp( + op=Not(), + operand=Name(id='title', ctx=Load())), + Compare( + left=Call( + func=Attribute( + value=Name(id='title', ctx=Load()), + attr='lower', + ctx=Load())), + ops=[ + In()], + comparators=[ + Set( + elts=[ + Constant(value='жалобы'), + Constant(value='reports'), + Constant(value='обработанные жалобы')])])]), + body=[ + Continue()]), + Assign( + targets=[ + Name(id='position', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='match', ctx=Load()), + attr='start', + ctx=Load()))), + Assign( + targets=[ + Name(id='item_window_start', ctx=Store())], + value=Call( + func=Name(id='max', ctx=Load()), + args=[ + Constant(value=0), + BinOp( + left=Name(id='position', ctx=Load()), + op=Sub(), + right=Constant(value=6000))])), + Assign( + targets=[ + Name(id='item_tag', ctx=Store())], + value=Constant(value='')), + For( + target=Name(id='item_match', ctx=Store()), + iter=Call( + func=Attribute( + value=Name(id='re', ctx=Load()), + attr='finditer', + ctx=Load()), + args=[ + Constant(value='(?is)<(?:li|div|tr)\\b[^>]*class=["\'][^"\']*\\bdiscussionListItem\\b[^"\']*["\'][^>]*>'), + Subscript( + value=Name(id='text', ctx=Load()), + slice=Slice( + lower=Name(id='item_window_start', ctx=Load()), + upper=Name(id='position', ctx=Load())), + ctx=Load())]), + body=[ + Assign( + targets=[ + Name(id='item_tag', ctx=Store())], + value=Call( + func=Attribute( + value=Call( + func=Attribute( + value=Name(id='item_match', ctx=Load()), + attr='group', + ctx=Load()), + args=[ + Constant(value=0)]), + attr='lower', + ctx=Load())))]), + If( + test=Compare( + left=Constant(value='report-resolved'), + ops=[ + In()], + comparators=[ + Name(id='item_tag', ctx=Load())]), + body=[ + Assign( + targets=[ + Name(id='status', ctx=Store())], + value=Constant(value='resolved'))], + orelse=[ + If( + test=BoolOp( + op=Or(), + values=[ + Compare( + left=Constant(value='report-assigned'), + ops=[ + In()], + comparators=[ + Name(id='item_tag', ctx=Load())]), + Compare( + left=Constant(value='report-open'), + ops=[ + In()], + comparators=[ + Name(id='item_tag', ctx=Load())])]), + body=[ + Assign( + targets=[ + Name(id='status', ctx=Store())], + value=Constant(value='open'))], + orelse=[ + If( + test=BoolOp( + op=And(), + values=[ + Compare( + left=Name(id='closed_pos', ctx=Load()), + ops=[ + GtE()], + comparators=[ + Constant(value=0)]), + Compare( + left=Name(id='position', ctx=Load()), + ops=[ + Gt()], + comparators=[ + Name(id='closed_pos', ctx=Load())])]), + body=[ + Assign( + targets=[ + Name(id='status', ctx=Store())], + value=Constant(value='resolved'))], + orelse=[ + If( + test=BoolOp( + op=And(), + values=[ + Compare( + left=Name(id='open_pos', ctx=Load()), + ops=[ + GtE()], + comparators=[ + Constant(value=0)]), + Compare( + left=Name(id='position', ctx=Load()), + ops=[ + Gt()], + comparators=[ + Name(id='open_pos', ctx=Load())]), + BoolOp( + op=Or(), + values=[ + Compare( + left=Name(id='closed_pos', ctx=Load()), + ops=[ + Lt()], + comparators=[ + Constant(value=0)]), + Compare( + left=Name(id='position', ctx=Load()), + ops=[ + Lt()], + comparators=[ + Name(id='closed_pos', ctx=Load())])])]), + body=[ + Assign( + targets=[ + Name(id='status', ctx=Store())], + value=Constant(value='open'))], + orelse=[ + Assign( + targets=[ + Name(id='status', ctx=Store())], + value=Constant(value='open'))])])])]), + Assign( + targets=[ + Name(id='row_start', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='text', ctx=Load()), + attr='rfind', + ctx=Load()), + args=[ + Constant(value=''), + ctx=Load())), + Assign( + targets=[ + Name(id='port', ctx=Store())], + value=Call( + func=Name(id='int', ctx=Load()), + args=[ + Call( + func=Attribute( + value=Name(id='secrets', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value=''), + Constant(value='587')])])), + Assign( + targets=[ + Name(id='user', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='secrets', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value=''), + Constant(value='')])), + Assign( + targets=[ + Name(id='password', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='secrets', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value=''), + Constant(value='')])), + Assign( + targets=[ + Name(id='tls', ctx=Store())], + value=Call( + func=Attribute( + value=Call( + func=Attribute( + value=Name(id='secrets', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value=''), + Constant(value='starttls')]), + attr='lower', + ctx=Load()))), + Assign( + targets=[ + Name(id='msg', ctx=Store())], + value=Call( + func=Attribute( + value=Attribute( + value=Name(id='email', ctx=Load()), + attr='message', + ctx=Load()), + attr='EmailMessage', + ctx=Load()))), + Assign( + targets=[ + Subscript( + value=Name(id='msg', ctx=Load()), + slice=Constant(value='From'), + ctx=Store())], + value=Subscript( + value=Name(id='secrets', ctx=Load()), + slice=Constant(value=''), + ctx=Load())), + Assign( + targets=[ + Subscript( + value=Name(id='msg', ctx=Load()), + slice=Constant(value='To'), + ctx=Store())], + value=Subscript( + value=Name(id='secrets', ctx=Load()), + slice=Constant(value=''), + ctx=Load())), + Assign( + targets=[ + Subscript( + value=Name(id='msg', ctx=Load()), + slice=Constant(value='Subject'), + ctx=Store())], + value=BinOp( + left=BinOp( + left=Call( + func=Attribute( + value=Subscript( + value=Name(id='cfg', ctx=Load()), + slice=Constant(value='email'), + ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='subject_prefix'), + Constant(value='[Skladchik]')]), + op=Add(), + right=Constant(value=' ')), + op=Add(), + right=Name(id='subject', ctx=Load()))), + Expr( + value=Call( + func=Attribute( + value=Name(id='msg', ctx=Load()), + attr='set_content', + ctx=Load()), + args=[ + Name(id='body', ctx=Load())])), + If( + test=Compare( + left=Name(id='tls', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='ssl')]), + body=[ + Assign( + targets=[ + Name(id='smtp', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='smtplib', ctx=Load()), + attr='SMTP_SSL', + ctx=Load()), + args=[ + Name(id='host', ctx=Load()), + Name(id='port', ctx=Load())], + keywords=[ + keyword( + arg='timeout', + value=Constant(value=30))]))], + orelse=[ + Assign( + targets=[ + Name(id='smtp', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='smtplib', ctx=Load()), + attr='SMTP', + ctx=Load()), + args=[ + Name(id='host', ctx=Load()), + Name(id='port', ctx=Load())], + keywords=[ + keyword( + arg='timeout', + value=Constant(value=30))]))]), + With( + items=[ + withitem( + context_expr=Name(id='smtp', ctx=Load()), + optional_vars=Name(id='server', ctx=Store()))], + body=[ + If( + test=Compare( + left=Name(id='tls', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='starttls')]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='server', ctx=Load()), + attr='starttls', + ctx=Load()), + keywords=[ + keyword( + arg='context', + value=Call( + func=Attribute( + value=Name(id='ssl', ctx=Load()), + attr='create_default_context', + ctx=Load())))]))]), + If( + test=Name(id='user', ctx=Load()), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='server', ctx=Load()), + attr='login', + ctx=Load()), + args=[ + Name(id='user', ctx=Load()), + Name(id='password', ctx=Load())]))]), + Expr( + value=Call( + func=Attribute( + value=Name(id='server', ctx=Load()), + attr='send_message', + ctx=Load()), + args=[ + Name(id='msg', ctx=Load())]))]), + Return( + value=Constant(value=True))], + returns=Name(id='bool', ctx=Load())) +MONITOR_DUMP_SHA256=af72f54e66459d653cc65a65494c97a1eeabaa80cee95f1777319a7df1efc133 +MONITOR_DUMP_TRUNCATED=false +MONITOR_DUMP_END=send_mail +MONITOR_DUMP_BEGIN=report_body +FunctionDef( + name='report_body', + args=arguments( + args=[ + arg( + arg='prefix', + annotation=Name(id='str', ctx=Load())), + arg( + arg='report', + annotation=Subscript( + value=Name(id='dict', ctx=Load()), + slice=Tuple( + elts=[ + Name(id='str', ctx=Load()), + Name(id='Any', ctx=Load())], + ctx=Load()), + ctx=Load()))]), + body=[ + Return( + value=JoinedStr( + values=[ + FormattedValue( + value=Name(id='prefix', ctx=Load()), + conversion=-1), + Constant(value=''), + FormattedValue( + value=Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='title'), + ctx=Load()), + conversion=-1), + Constant(value=''), + FormattedValue( + value=Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='status'), + ctx=Load()), + conversion=-1), + Constant(value=''), + FormattedValue( + value=Call( + func=Attribute( + value=Name(id='report', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='report_count')]), + conversion=-1), + Constant(value=''), + FormattedValue( + value=Call( + func=Attribute( + value=Name(id='report', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='comment_count')]), + conversion=-1), + Constant(value=''), + FormattedValue( + value=Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='url'), + ctx=Load()), + conversion=-1), + Constant(value=''), + FormattedValue( + value=Call( + func=Name(id='utc_now', ctx=Load())), + conversion=-1), + Constant(value='')]))], + returns=Name(id='str', ctx=Load())) +MONITOR_DUMP_SHA256=668abfab86ee05df948412e7aca1247e115d8d5c6d7c52ddda0746f288f2978a +MONITOR_DUMP_TRUNCATED=false +MONITOR_DUMP_END=report_body +MONITOR_DUMP_BEGIN=process_reports +FunctionDef( + name='process_reports', + args=arguments( + args=[ + arg( + arg='con', + annotation=Attribute( + value=Name(id='sqlite3', ctx=Load()), + attr='Connection', + ctx=Load())), + arg( + arg='cfg', + annotation=Attribute( + value=Name(id='configparser', ctx=Load()), + attr='ConfigParser', + ctx=Load())), + arg( + arg='secrets', + annotation=Subscript( + value=Name(id='dict', ctx=Load()), + slice=Tuple( + elts=[ + Name(id='str', ctx=Load()), + Name(id='str', ctx=Load())], + ctx=Load()), + ctx=Load())), + arg( + arg='reports', + annotation=Subscript( + value=Name(id='list', ctx=Load()), + slice=Subscript( + value=Name(id='dict', ctx=Load()), + slice=Tuple( + elts=[ + Name(id='str', ctx=Load()), + Name(id='Any', ctx=Load())], + ctx=Load()), + ctx=Load()), + ctx=Load()))]), + body=[ + Assign( + targets=[ + Name(id='baseline', ctx=Store())], + value=Call( + func=Name(id='meta_get', ctx=Load()), + args=[ + Name(id='con', ctx=Load()), + Constant(value='baseline_created_at')])), + Assign( + targets=[ + Name(id='baseline_mode', ctx=Store())], + value=Compare( + left=Call( + func=Attribute( + value=Call( + func=Attribute( + value=Subscript( + value=Name(id='cfg', ctx=Load()), + slice=Constant(value='monitor'), + ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='baseline_no_email'), + Constant(value='yes')]), + attr='lower', + ctx=Load())), + ops=[ + In()], + comparators=[ + Set( + elts=[ + Constant(value='yes'), + Constant(value='true'), + Constant(value='1'), + Constant(value='on')])])), + Assign( + targets=[ + Name(id='new_events', ctx=Store())], + value=Constant(value=0)), + Assign( + targets=[ + Name(id='resolved_events', ctx=Store())], + value=Constant(value=0)), + For( + target=Name(id='report', ctx=Store()), + iter=Name(id='reports', ctx=Load()), + body=[ + Assign( + targets=[ + Name(id='row', ctx=Store())], + value=Call( + func=Attribute( + value=Call( + func=Attribute( + value=Name(id='con', ctx=Load()), + attr='execute', + ctx=Load()), + args=[ + Constant(value='SELECT status FROM reports WHERE report_id=?'), + Tuple( + elts=[ + Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='report_id'), + ctx=Load())], + ctx=Load())]), + attr='fetchone', + ctx=Load()))), + If( + test=Compare( + left=Name(id='row', ctx=Load()), + ops=[ + Is()], + comparators=[ + Constant(value=None)]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='con', ctx=Load()), + attr='execute', + ctx=Load()), + args=[ + Constant(value=''), + Tuple( + elts=[ + Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='report_id'), + ctx=Load()), + Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='url'), + ctx=Load()), + Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='title'), + ctx=Load()), + Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='status'), + ctx=Load()), + Call( + func=Attribute( + value=Name(id='report', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='report_count')]), + Call( + func=Attribute( + value=Name(id='report', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='comment_count')]), + Call( + func=Attribute( + value=Name(id='report', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='row_text'), + Constant(value='')]), + Call( + func=Name(id='utc_now', ctx=Load())), + Call( + func=Name(id='utc_now', ctx=Load())), + IfExp( + test=Compare( + left=Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='status'), + ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='resolved')]), + body=Call( + func=Name(id='utc_now', ctx=Load())), + orelse=Constant(value=None))], + ctx=Load())])), + Expr( + value=Call( + func=Attribute( + value=Name(id='con', ctx=Load()), + attr='commit', + ctx=Load()))), + If( + test=BoolOp( + op=Or(), + values=[ + Name(id='baseline', ctx=Load()), + UnaryOp( + op=Not(), + operand=Name(id='baseline_mode', ctx=Load()))]), + body=[ + If( + test=Compare( + left=Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='status'), + ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='open')]), + body=[ + Assign( + targets=[ + Name(id='key', ctx=Store())], + value=BinOp( + left=Constant(value='new:'), + op=Add(), + right=Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='report_id'), + ctx=Load()))), + If( + test=UnaryOp( + op=Not(), + operand=Call( + func=Name(id='event_sent', ctx=Load()), + args=[ + Name(id='con', ctx=Load()), + Name(id='key', ctx=Load())])), + body=[ + If( + test=Call( + func=Name(id='send_mail', ctx=Load()), + args=[ + Name(id='cfg', ctx=Load()), + Name(id='secrets', ctx=Load()), + Constant(value='Новая жалоба'), + Call( + func=Name(id='report_body', ctx=Load()), + args=[ + Constant(value='Появилась новая жалоба.'), + Name(id='report', ctx=Load())])]), + body=[ + Expr( + value=Call( + func=Name(id='mark_event', ctx=Load()), + args=[ + Name(id='con', ctx=Load()), + Name(id='key', ctx=Load()), + Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='report_id'), + ctx=Load()), + Constant(value='new')])), + AugAssign( + target=Name(id='new_events', ctx=Store()), + op=Add(), + value=Constant(value=1))])])])])], + orelse=[ + Assign( + targets=[ + Name(id='old_status', ctx=Store())], + value=Subscript( + value=Name(id='row', ctx=Load()), + slice=Constant(value=0), + ctx=Load())), + If( + test=BoolOp( + op=And(), + values=[ + Compare( + left=Name(id='old_status', ctx=Load()), + ops=[ + NotEq()], + comparators=[ + Constant(value='resolved')]), + Compare( + left=Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='status'), + ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='resolved')])]), + body=[ + Assign( + targets=[ + Name(id='key', ctx=Store())], + value=BinOp( + left=Constant(value='resolved:'), + op=Add(), + right=Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='report_id'), + ctx=Load()))), + If( + test=UnaryOp( + op=Not(), + operand=Call( + func=Name(id='event_sent', ctx=Load()), + args=[ + Name(id='con', ctx=Load()), + Name(id='key', ctx=Load())])), + body=[ + If( + test=Call( + func=Name(id='send_mail', ctx=Load()), + args=[ + Name(id='cfg', ctx=Load()), + Name(id='secrets', ctx=Load()), + Constant(value='Жалоба отработана'), + Call( + func=Name(id='report_body', ctx=Load()), + args=[ + Constant(value='Жалоба перешла в обработанные.'), + Name(id='report', ctx=Load())])]), + body=[ + Expr( + value=Call( + func=Name(id='mark_event', ctx=Load()), + args=[ + Name(id='con', ctx=Load()), + Name(id='key', ctx=Load()), + Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='report_id'), + ctx=Load()), + Constant(value='resolved')])), + AugAssign( + target=Name(id='resolved_events', ctx=Store()), + op=Add(), + value=Constant(value=1))])])]), + Expr( + value=Call( + func=Attribute( + value=Name(id='con', ctx=Load()), + attr='execute', + ctx=Load()), + args=[ + Constant(value=''), + Tuple( + elts=[ + Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='url'), + ctx=Load()), + Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='title'), + ctx=Load()), + Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='status'), + ctx=Load()), + Call( + func=Attribute( + value=Name(id='report', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='report_count')]), + Call( + func=Attribute( + value=Name(id='report', ctx=Load()), + attr='get', + ctx=Load()), + +MONITOR_DUMP_SHA256=898a51f0ad422cfbd6a9dc3c30e38db7fa53aa91216f5ef5bf390e2728d2da25 +MONITOR_DUMP_TRUNCATED=true +MONITOR_DUMP_END=process_reports +MONITOR_DUMP_BEGIN=maybe_send_auth_required +FunctionDef( + name='maybe_send_auth_required', + args=arguments( + args=[ + arg( + arg='con', + annotation=Attribute( + value=Name(id='sqlite3', ctx=Load()), + attr='Connection', + ctx=Load())), + arg( + arg='cfg', + annotation=Attribute( + value=Name(id='configparser', ctx=Load()), + attr='ConfigParser', + ctx=Load())), + arg( + arg='secrets', + annotation=Subscript( + value=Name(id='dict', ctx=Load()), + slice=Tuple( + elts=[ + Name(id='str', ctx=Load()), + Name(id='str', ctx=Load())], + ctx=Load()), + ctx=Load())), + arg( + arg='final_url', + annotation=Name(id='str', ctx=Load()))]), + body=[ + Assign( + targets=[ + Name(id='now_ts', ctx=Store())], + value=Call( + func=Name(id='int', ctx=Load()), + args=[ + Call( + func=Attribute( + value=Name(id='time', ctx=Load()), + attr='time', + ctx=Load()))])), + Assign( + targets=[ + Name(id='interval', ctx=Store())], + value=Call( + func=Attribute( + value=Subscript( + value=Name(id='cfg', ctx=Load()), + slice=Constant(value='email'), + ctx=Load()), + attr='getint', + ctx=Load()), + args=[ + Constant(value='auth_notice_min_interval_seconds')], + keywords=[ + keyword( + arg='fallback', + value=Constant(value=86400))])), + Assign( + targets=[ + Name(id='last_raw', ctx=Store())], + value=BoolOp( + op=Or(), + values=[ + Call( + func=Name(id='meta_get', ctx=Load()), + args=[ + Name(id='con', ctx=Load()), + Constant(value='last_auth_notice_ts')]), + Constant(value='0')])), + Try( + body=[ + Assign( + targets=[ + Name(id='last', ctx=Store())], + value=Call( + func=Name(id='int', ctx=Load()), + args=[ + Name(id='last_raw', ctx=Load())]))], + handlers=[ + ExceptHandler( + type=Name(id='ValueError', ctx=Load()), + body=[ + Assign( + targets=[ + Name(id='last', ctx=Store())], + value=Constant(value=0))])]), + If( + test=Compare( + left=BinOp( + left=Name(id='now_ts', ctx=Load()), + op=Sub(), + right=Name(id='last', ctx=Load())), + ops=[ + GtE()], + comparators=[ + Name(id='interval', ctx=Load())]), + body=[ + If( + test=Call( + func=Name(id='send_mail', ctx=Load()), + args=[ + Name(id='cfg', ctx=Load()), + Name(id='secrets', ctx=Load()), + Constant(value='Нужна повторная авторизация'), + JoinedStr( + values=[ + Constant(value=''), + FormattedValue( + value=Name(id='final_url', ctx=Load()), + conversion=-1), + Constant(value=''), + FormattedValue( + value=Call( + func=Name(id='utc_now', ctx=Load())), + conversion=-1), + Constant(value='')])]), + body=[ + Expr( + value=Call( + func=Name(id='meta_set', ctx=Load()), + args=[ + Name(id='con', ctx=Load()), + Constant(value='last_auth_notice_ts'), + Call( + func=Name(id='str', ctx=Load()), + args=[ + Name(id='now_ts', ctx=Load())])]))])])], + returns=Constant(value=None)) +MONITOR_DUMP_SHA256=396252a7a870238ab735e22192d95a704509acc56af3bca2289e5e307c4e5f10 +MONITOR_DUMP_TRUNCATED=false +MONITOR_DUMP_END=maybe_send_auth_required +MONITOR_DUMP_BEGIN=run_once +FunctionDef( + name='run_once', + args=arguments(), + body=[ + Assign( + targets=[ + Name(id='lock', ctx=Store())], + value=Call( + func=Name(id='acquire_lock', ctx=Load()))), + If( + test=Compare( + left=Name(id='lock', ctx=Load()), + ops=[ + Is()], + comparators=[ + Constant(value=None)]), + body=[ + Expr( + value=Call( + func=Name(id='log', ctx=Load()), + args=[ + Constant(value='LOCK_BUSY previous run still active')])), + Expr( + value=Call( + func=Name(id='write_health', ctx=Load()), + args=[ + Constant(value='LOCK_BUSY')])), + Return( + value=Constant(value=0))]), + Assign( + targets=[ + Tuple( + elts=[ + Name(id='cfg', ctx=Store()), + Name(id='secrets', ctx=Store())], + ctx=Store())], + value=Call( + func=Name(id='load_config', ctx=Load()))), + Assign( + targets=[ + Name(id='con', ctx=Store())], + value=Call( + func=Name(id='connect_db', ctx=Load()))), + Try( + body=[ + Assign( + targets=[ + Tuple( + elts=[ + Name(id='final_url', ctx=Store()), + Name(id='text', ctx=Store())], + ctx=Store())], + value=Call( + func=Name(id='fetch_reports_page', ctx=Load()), + args=[ + Name(id='cfg', ctx=Load()), + Name(id='secrets', ctx=Load())])), + If( + test=Call( + func=Name(id='login_required', ctx=Load()), + args=[ + Name(id='final_url', ctx=Load()), + Name(id='text', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Name(id='maybe_send_auth_required', ctx=Load()), + args=[ + Name(id='con', ctx=Load()), + Name(id='cfg', ctx=Load()), + Name(id='secrets', ctx=Load()), + Name(id='final_url', ctx=Load())])), + Expr( + value=Call( + func=Name(id='write_health', ctx=Load()), + args=[ + Constant(value='AUTH_REQUIRED')], + keywords=[ + keyword( + arg='url', + value=Name(id='final_url', ctx=Load()))])), + Return( + value=Constant(value=2))]), + Assign( + targets=[ + Name(id='reports', ctx=Store())], + value=Call( + func=Name(id='parse_reports', ctx=Load()), + args=[ + Name(id='text', ctx=Load()), + Name(id='cfg', ctx=Load())])), + If( + test=UnaryOp( + op=Not(), + operand=Name(id='reports', ctx=Load())), + body=[ + Expr( + value=Call( + func=Name(id='write_health', ctx=Load()), + args=[ + Constant(value='ERROR')], + keywords=[ + keyword( + arg='reason', + value=Constant(value='no_reports_parsed')), + keyword( + arg='url', + value=Name(id='final_url', ctx=Load()))])), + Expr( + value=Call( + func=Name(id='log', ctx=Load()), + args=[ + Constant(value='ERROR no reports parsed')])), + Return( + value=Constant(value=1))]), + Assign( + targets=[ + Tuple( + elts=[ + Name(id='new_events', ctx=Store()), + Name(id='resolved_events', ctx=Store())], + ctx=Store())], + value=Call( + func=Name(id='process_reports', ctx=Load()), + args=[ + Name(id='con', ctx=Load()), + Name(id='cfg', ctx=Load()), + Name(id='secrets', ctx=Load()), + Name(id='reports', ctx=Load())])), + Assign( + targets=[ + Name(id='open_count', ctx=Store())], + value=Call( + func=Name(id='sum', ctx=Load()), + args=[ + GeneratorExp( + elt=Constant(value=1), + generators=[ + comprehension( + target=Name(id='r', ctx=Store()), + iter=Name(id='reports', ctx=Load()), + ifs=[ + Compare( + left=Subscript( + value=Name(id='r', ctx=Load()), + slice=Constant(value='status'), + ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='open')])], + is_async=0)])])), + Assign( + targets=[ + Name(id='resolved_count', ctx=Store())], + value=Call( + func=Name(id='sum', ctx=Load()), + args=[ + GeneratorExp( + elt=Constant(value=1), + generators=[ + comprehension( + target=Name(id='r', ctx=Store()), + iter=Name(id='reports', ctx=Load()), + ifs=[ + Compare( + left=Subscript( + value=Name(id='r', ctx=Load()), + slice=Constant(value='status'), + ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='resolved')])], + is_async=0)])])), + Expr( + value=Call( + func=Name(id='write_health', ctx=Load()), + args=[ + Constant(value='OK')], + keywords=[ + keyword( + arg='url', + value=Name(id='final_url', ctx=Load())), + keyword( + arg='reports', + value=Call( + func=Name(id='len', ctx=Load()), + args=[ + Name(id='reports', ctx=Load())])), + keyword( + arg='open', + value=Name(id='open_count', ctx=Load())), + keyword( + arg='resolved', + value=Name(id='resolved_count', ctx=Load())), + keyword( + arg='new_events', + value=Name(id='new_events', ctx=Load())), + keyword( + arg='resolved_events', + value=Name(id='resolved_events', ctx=Load())), + keyword( + arg='smtp_configured', + value=IfExp( + test=Call( + func=Name(id='smtp_ready', ctx=Load()), + args=[ + Name(id='secrets', ctx=Load())]), + body=Constant(value='yes'), + orelse=Constant(value='no')))])), + Expr( + value=Call( + func=Name(id='log', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='OK reports='), + FormattedValue( + value=Call( + func=Name(id='len', ctx=Load()), + args=[ + Name(id='reports', ctx=Load())]), + conversion=-1), + Constant(value=' open='), + FormattedValue( + value=Name(id='open_count', ctx=Load()), + conversion=-1), + Constant(value=' resolved='), + FormattedValue( + value=Name(id='resolved_count', ctx=Load()), + conversion=-1), + Constant(value=' new='), + FormattedValue( + value=Name(id='new_events', ctx=Load()), + conversion=-1), + Constant(value=' done='), + FormattedValue( + value=Name(id='resolved_events', ctx=Load()), + conversion=-1)])])), + Return( + value=Constant(value=0))], + handlers=[ + ExceptHandler( + type=Attribute( + value=Attribute( + value=Name(id='urllib', ctx=Load()), + attr='error', + ctx=Load()), + attr='HTTPError', + ctx=Load()), + name='e', + body=[ + Expr( + value=Call( + func=Name(id='write_health', ctx=Load()), + args=[ + Constant(value='ERROR')], + keywords=[ + keyword( + arg='error', + value=JoinedStr( + values=[ + Constant(value='HTTPError '), + FormattedValue( + value=Attribute( + value=Name(id='e', ctx=Load()), + attr='code', + ctx=Load()), + conversion=-1)]))])), + Expr( + value=Call( + func=Name(id='log', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='ERROR HTTPError '), + FormattedValue( + value=Attribute( + value=Name(id='e', ctx=Load()), + attr='code', + ctx=Load()), + conversion=-1)])])), + Return( + value=Constant(value=1))]), + ExceptHandler( + type=Name(id='Exception', ctx=Load()), + name='e', + body=[ + Expr( + value=Call( + func=Name(id='write_health', ctx=Load()), + args=[ + Constant(value='ERROR')], + keywords=[ + keyword( + arg='error', + value=Call( + func=Name(id='repr', ctx=Load()), + args=[ + Name(id='e', ctx=Load())]))])), + Expr( + value=Call( + func=Name(id='log', ctx=Load()), + args=[ + BinOp( + left=BinOp( + left=BinOp( + left=Constant(value='ERROR '), + op=Add(), + right=Call( + func=Name(id='repr', ctx=Load()), + args=[ + Name(id='e', ctx=Load())])), + op=Add(), + right=Constant(value=' ')), + op=Add(), + right=Call( + func=Attribute( + value=Name(id='traceback', ctx=Load()), + attr='format_exc', + ctx=Load())))])), + Return( + value=Constant(value=1))])], + finalbody=[ + Try( + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='fcntl', ctx=Load()), + attr='flock', + ctx=Load()), + args=[ + Call( + func=Attribute( + value=Name(id='lock', ctx=Load()), + attr='fileno', + ctx=Load())), + Attribute( + value=Name(id='fcntl', ctx=Load()), + attr='LOCK_UN', + ctx=Load())])), + Expr( + value=Call( + func=Attribute( + value=Name(id='lock', ctx=Load()), + attr='close', + ctx=Load())))], + handlers=[ + ExceptHandler( + type=Name(id='Exception', ctx=Load()), + body=[ + Pass()])])])], + returns=Name(id='int', ctx=Load())) +MONITOR_DUMP_SHA256=eceb52bc948ca75d79fddb992ecc9e3c61ae10413339a5d6d14b5c20b00407db +MONITOR_DUMP_TRUNCATED=false +MONITOR_DUMP_END=run_once +MONITOR_DUMP_BEGIN=show_status +FunctionDef( + name='show_status', + args=arguments(), + body=[ + If( + test=Call( + func=Attribute( + value=Name(id='HEALTH_PATH', ctx=Load()), + attr='exists', + ctx=Load())), + body=[ + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + Call( + func=Attribute( + value=Name(id='HEALTH_PATH', ctx=Load()), + attr='read_text', + ctx=Load()), + keywords=[ + keyword( + arg='encoding', + value=Constant(value='utf-8'))])], + keywords=[ + keyword( + arg='end', + value=Constant(value=''))]))], + orelse=[ + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + Constant(value='STATUS=UNKNOWN')]))]), + Return( + value=Constant(value=0))], + returns=Name(id='int', ctx=Load())) +MONITOR_DUMP_SHA256=ee45eb0e5db867e890df5fce7f7afa8ad77ba828845e20e5e7d1dcfdab13e551 +MONITOR_DUMP_TRUNCATED=false +MONITOR_DUMP_END=show_status +MONITOR_DUMP_BEGIN=main +FunctionDef( + name='main', + args=arguments(), + body=[ + Assign( + targets=[ + Name(id='parser', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='argparse', ctx=Load()), + attr='ArgumentParser', + ctx=Load()))), + Expr( + value=Call( + func=Attribute( + value=Name(id='parser', ctx=Load()), + attr='add_argument', + ctx=Load()), + args=[ + Constant(value='cmd')], + keywords=[ + keyword( + arg='choices', + value=List( + elts=[ + Constant(value='run'), + Constant(value='status')], + ctx=Load())), + keyword( + arg='nargs', + value=Constant(value='?')), + keyword( + arg='default', + value=Constant(value='run'))])), + Assign( + targets=[ + Name(id='args', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='parser', ctx=Load()), + attr='parse_args', + ctx=Load()))), + If( + test=Compare( + left=Attribute( + value=Name(id='args', ctx=Load()), + attr='cmd', + ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='status')]), + body=[ + Return( + value=Call( + func=Name(id='show_status', ctx=Load())))]), + Return( + value=Call( + func=Name(id='run_once', ctx=Load())))], + returns=Name(id='int', ctx=Load())) +MONITOR_DUMP_SHA256=02ad6bee6cd63312a57b18daedc366b2edfc1b747c3ac27f5bd9cfd71210fb2e +MONITOR_DUMP_TRUNCATED=false +MONITOR_DUMP_END=main +MONITOR_SCAN_OK=true +UNIT_PROBE_QM_RC=0 +UNIT_PROBE_STDERR_PRESENT=false +UNIT_PROBE_JSON=true +UNIT_PROBE_GUEST_EXITCODE=0 +active +enabled +success +0 +MAIL_DRY_RUN_ONLY=true +MAIL_SENT=false +DECISION=PASS_TITLE_AND_ALERT_SOURCE_RCA +NEXT_GATE=DESIGN_ATOMIC_FALSE_ALERT_AND_TITLE_REPAIR_FROM_99564 +TASK_RESULT=SKLADCHIK_COMPLAINTS_TITLE_TOKEN_RCA +CHANGES_MADE=false +ROLLBACK_STARTED=false +ROLLBACK_RESTORED=null +MUTATION_OUTCOME=NO_MUTATION + +OUTPUT_END +CHAT_OUTPUT_END diff --git a/runtime/latest.json b/runtime/latest.json index dc6f6a2f..d6c938f9 100644 --- a/runtime/latest.json +++ b/runtime/latest.json @@ -1,19 +1,19 @@ { "schema_version": 1, "channel": "homelab-runtime", - "command_id": "SUPPORT-261004-SKLADCHIK-COMPLAINTS-TITLE-SOURCE-RCA-99563R1", + "command_id": "SUPPORT-261004-SKLADCHIK-COMPLAINTS-TITLE-TOKEN-RCA-99564R1", "status": "OK", "rc": 0, "host": "pve01", "mode": "read-only", - "component": "skladchik-complaints-title-source-rca", - "started_at_utc": "2026-10-04T20:11:37Z", - "finished_at_utc": "2026-10-04T20:11:42Z", + "component": "skladchik-complaints-title-token-rca", + "started_at_utc": "2026-10-04T20:16:41Z", + "finished_at_utc": "2026-10-04T20:16:46Z", "reference_register_checked": true, "reference_sha256": "5a3d8e5154c41cb582a4e0aca68090be1f0138918bf82131a948df326f9d8d66", "error_register_checked": true, "error_register_sha256": "3b09a553ec0f527ed3afeed4753f52a74ee3036045bbfb3c685e9f8af4ba7ba0", - "command_sha256": "c28f66f660512e5078b815cc6a12e6fdac5e9ebeea8aba7a6d31c5277543509a", + "command_sha256": "bbe4077da8ab20fa07a5b8458821ecbe544b502ccbb871742ef07ac2d14d220e", "duplicate_failed_command_blocked": false, "block_reason": null, "execution_started": true, @@ -30,9 +30,9 @@ "secrets_included": false, "private_addresses_included": false, "raw_evidence_retained_locally": true, - "raw_evidence_sha256": "fdeb4b237c7563f75b29c383fd5a81258cd6eccff766eed11efb65bd15795027", - "sanitized_output_sha256": "fdeb4b237c7563f75b29c383fd5a81258cd6eccff766eed11efb65bd15795027", + "raw_evidence_sha256": "f375d4e36d4d0a70ebad8412a2dd1f0e4faa25f8c6f2d4d648a215164c8f2d2c", + "sanitized_output_sha256": "f375d4e36d4d0a70ebad8412a2dd1f0e4faa25f8c6f2d4d648a215164c8f2d2c", "output_truncated_in_json": false, "full_sanitized_output_url": "https://git.gram1.ru/.well-known/homelab-runtime/latest.txt", - "output": "SKLADCHIK_COMPLAINTS_TITLE_SOURCE_RCA=V1\nMODE=read-only\nNO_MAIL_SEND=true\nNO_SERVICE_RESTART=true\nNO_TIMER_MUTATION=true\nNO_NETWORK_MUTATION=true\nNO_SOURCE_MUTATION=true\nHOST_PVE01=true\nVM170_STATUS=running\nHEALTH_PRESENT=true\nHEALTH_SHA256=918f3d1db31c64fe5f7548c3da6183ca6bf8be80384fa0673c55f68826dcc717\nHEALTH_WT0_LITERAL_COUNT=5\nQGA_CANARY_QM_RC=0\nQGA_CANARY_STDERR_PRESENT=false\nQGA_CANARY_JSON=true\nQGA_CANARY_GUEST_EXITCODE=0\nQGA_SHORT_OK=true\nPATH_PROBE_QM_RC=0\nPATH_PROBE_STDERR_PRESENT=false\nPATH_PROBE_JSON=true\nPATH_PROBE_GUEST_EXITCODE=0\nMONITOR_PATH_PRESENT=true\nMONITOR_MODE=700 MONITOR_UID=0 MONITOR_GID=0 MONITOR_SIZE=17878\nf62288797f80ce561f1e3ea721b87090eb1cd751fd5bf07152a3608b3a8aaed2\nAST_PROBE_QM_RC=0\nAST_PROBE_STDERR_PRESENT=false\nAST_PROBE_JSON=true\nAST_PROBE_GUEST_EXITCODE=1\nUNIT_PROBE_QM_RC=0\nUNIT_PROBE_STDERR_PRESENT=false\nUNIT_PROBE_JSON=true\nUNIT_PROBE_GUEST_EXITCODE=0\nactive\nenabled\nsuccess\n0\nMAIL_DRY_RUN_ONLY=true\nMAIL_SENT=false\nAST_CONFIRM_EXITCODE=1\nDECISION=HOLD_TITLE_SOURCE_RCA_INCOMPLETE\nNEXT_GATE=TITLE_SOURCE_PROBE_RECONCILE\nTASK_RESULT=SKLADCHIK_COMPLAINTS_TITLE_SOURCE_RCA\nCHANGES_MADE=false\nROLLBACK_STARTED=false\nROLLBACK_RESTORED=null\nMUTATION_OUTCOME=NO_MUTATION\n" + "output": "SKLADCHIK_COMPLAINTS_TITLE_TOKEN_RCA=V1\nMODE=read-only\nNO_MAIL_SEND=true\nNO_SERVICE_RESTART=true\nNO_TIMER_MUTATION=true\nNO_NETWORK_MUTATION=true\nNO_SOURCE_MUTATION=true\nHOST_PVE01=true\nVM170_STATUS=running\nHEALTH_SCAN=V1\nHEALTH_PRESENT=true\nHEALTH_SHA256=918f3d1db31c64fe5f7548c3da6183ca6bf8be80384fa0673c55f68826dcc717\nHEALTH_BYTES=16080\nHEALTH_FUNCTION_COUNT=22\nHEALTH_FUNC=utc_now:24:25\nHEALTH_FUNC=ts:28:29\nHEALTH_FUNC=log:32:35\nHEALTH_FUNC=run_cmd:38:43\nHEALTH_FUNC=parse_kv_file:46:54\nHEALTH_FUNC=iso_age_seconds:57:64\nHEALTH_FUNC=load_state:67:71\nHEALTH_FUNC=save_state:74:78\nHEALTH_FUNC=load_monitor_module:81:87\nHEALTH_FUNC=send_mail:90:93\nHEALTH_FUNC=systemd_value:96:98\nHEALTH_FUNC=route_ok:101:103\nHEALTH_FUNC=problem_to_ru:106:129\nHEALTH_FUNC=yes_no_ru:132:133\nHEALTH_FUNC=status_ru:136:145\nHEALTH_FUNC=build_status:148:206\nHEALTH_FUNC=status_to_body:209:253\nHEALTH_FUNC=write_alert_health:256:280\nHEALTH_FUNC=do_heartbeat:283:294\nHEALTH_FUNC=do_check:297:332\nHEALTH_FUNC=do_status:335:344\nHEALTH_FUNC=main:347:356\nHEALTH_RELEVANT_COUNT=9\nHEALTH_DUMP_BEGIN=parse_kv_file\nFunctionDef(\n name='parse_kv_file',\n args=arguments(\n args=[\n arg(\n arg='path',\n annotation=Name(id='Path', ctx=Load()))]),\n body=[\n Assign(\n targets=[\n Name(id='data', ctx=Store())],\n value=Dict()),\n If(\n test=UnaryOp(\n op=Not(),\n operand=Call(\n func=Attribute(\n value=Name(id='path', ctx=Load()),\n attr='exists',\n ctx=Load()))),\n body=[\n Return(\n value=Name(id='data', ctx=Load()))]),\n For(\n target=Name(id='raw', ctx=Store()),\n iter=Call(\n func=Attribute(\n value=Call(\n func=Attribute(\n value=Name(id='path', ctx=Load()),\n attr='read_text',\n ctx=Load()),\n keywords=[\n keyword(\n arg='encoding',\n value=Constant(value='utf-8')),\n keyword(\n arg='errors',\n value=Constant(value='replace'))]),\n attr='splitlines',\n ctx=Load())),\n body=[\n If(\n test=Compare(\n left=Constant(value='='),\n ops=[\n In()],\n comparators=[\n Name(id='raw', ctx=Load())]),\n body=[\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='k', ctx=Store()),\n Name(id='v', ctx=Store())],\n ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='raw', ctx=Load()),\n attr='split',\n ctx=Load()),\n args=[\n Constant(value='='),\n Constant(value=1)])),\n Assign(\n targets=[\n Subscript(\n value=Name(id='data', ctx=Load()),\n slice=Call(\n func=Attribute(\n value=Name(id='k', ctx=Load()),\n attr='strip',\n ctx=Load())),\n ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='v', ctx=Load()),\n attr='strip',\n ctx=Load())))])]),\n Return(\n value=Name(id='data', ctx=Load()))])\nHEALTH_DUMP_SHA256=577b27aca6d27fc787beed7fda2903d72e67f386753fadfc23325e1279ff8082\nHEALTH_DUMP_TRUNCATED=false\nHEALTH_DUMP_END=parse_kv_file\nHEALTH_DUMP_BEGIN=send_mail\nFunctionDef(\n name='send_mail',\n args=arguments(\n args=[\n arg(\n arg='subject',\n annotation=Name(id='str', ctx=Load())),\n arg(\n arg='body',\n annotation=Name(id='str', ctx=Load()))]),\n body=[\n Assign(\n targets=[\n Name(id='mod', ctx=Store())],\n value=Call(\n func=Name(id='load_monitor_module', ctx=Load()))),\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='cfg', ctx=Store()),\n Name(id='secrets', ctx=Store())],\n ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='mod', ctx=Load()),\n attr='load_config',\n ctx=Load()))),\n Return(\n value=Call(\n func=Name(id='bool', ctx=Load()),\n args=[\n Call(\n func=Attribute(\n value=Name(id='mod', ctx=Load()),\n attr='send_mail',\n ctx=Load()),\n args=[\n Name(id='cfg', ctx=Load()),\n Name(id='secrets', ctx=Load()),\n Name(id='subject', ctx=Load()),\n Name(id='body', ctx=Load())])]))],\n returns=Name(id='bool', ctx=Load()))\nHEALTH_DUMP_SHA256=949d900c876b9ee94a5fa7eca5792121fe1e77eee64b76fe447c8c8ba94b48c6\nHEALTH_DUMP_TRUNCATED=false\nHEALTH_DUMP_END=send_mail\nHEALTH_DUMP_BEGIN=route_ok\nFunctionDef(\n name='route_ok',\n args=arguments(),\n body=[\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='rc', ctx=Store()),\n Name(id='out', ctx=Store())],\n ctx=Store())],\n value=Call(\n func=Name(id='run_cmd', ctx=Load()),\n args=[\n List(\n elts=[\n Constant(value='ip'),\n Constant(value='route'),\n Constant(value='get'),\n Constant(value='')],\n ctx=Load())],\n keywords=[\n keyword(\n arg='timeout',\n value=Constant(value=10))])),\n Return(\n value=Tuple(\n elts=[\n BoolOp(\n op=And(),\n values=[\n Compare(\n left=Name(id='rc', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value=0)]),\n Compare(\n left=Constant(value=' dev wt0 '),\n ops=[\n In()],\n comparators=[\n JoinedStr(\n values=[\n Constant(value=' '),\n FormattedValue(\n value=Name(id='out', ctx=Load()),\n conversion=-1),\n Constant(value=' ')])])]),\n Name(id='out', ctx=Load())],\n ctx=Load()))])\nHEALTH_DUMP_SHA256=b3c72e69fe87a4333c66b82a8e898bc417dc642ecd71381f1bb45f6b26f7e255\nHEALTH_DUMP_TRUNCATED=false\nHEALTH_DUMP_END=route_ok\nHEALTH_DUMP_BEGIN=status_ru\nFunctionDef(\n name='status_ru',\n args=arguments(\n args=[\n arg(\n arg='value',\n annotation=Name(id='str', ctx=Load()))]),\n body=[\n If(\n test=Compare(\n left=Name(id='value', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='OK')]),\n body=[\n Return(\n value=Constant(value='OK'))]),\n If(\n test=Compare(\n left=Name(id='value', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='ALERT')]),\n body=[\n Return(\n value=Constant(value='ТРЕВОГА'))]),\n If(\n test=Compare(\n left=Name(id='value', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='AUTH_REQUIRED')]),\n body=[\n Return(\n value=Constant(value='нужна повторная авторизация'))]),\n If(\n test=Compare(\n left=Name(id='value', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='ERROR')]),\n body=[\n Return(\n value=Constant(value='ошибка'))]),\n Return(\n value=BoolOp(\n op=Or(),\n values=[\n Name(id='value', ctx=Load()),\n Constant(value='неизвестно')]))],\n returns=Name(id='str', ctx=Load()))\nHEALTH_DUMP_SHA256=177f282793ef16e747defa8dbd1fb35e704b9d54ffa892799e430ac9e0ecf22a\nHEALTH_DUMP_TRUNCATED=false\nHEALTH_DUMP_END=status_ru\nHEALTH_DUMP_BEGIN=build_status\nFunctionDef(\n name='build_status',\n args=arguments(),\n body=[\n Assign(\n targets=[\n Name(id='problems', ctx=Store())],\n value=List(ctx=Load())),\n Assign(\n targets=[\n Name(id='health', ctx=Store())],\n value=Call(\n func=Name(id='parse_kv_file', ctx=Load()),\n args=[\n Name(id='HEALTH_PATH', ctx=Load())])),\n Assign(\n targets=[\n Name(id='timer_active', ctx=Store())],\n value=Call(\n func=Name(id='systemd_value', ctx=Load()),\n args=[\n Constant(value='skladchik-reports-monitor.timer'),\n Constant(value='ActiveState')])),\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='timer_enabled_rc', ctx=Store()),\n Name(id='timer_enabled', ctx=Store())],\n ctx=Store())],\n value=Call(\n func=Name(id='run_cmd', ctx=Load()),\n args=[\n List(\n elts=[\n Constant(value='systemctl'),\n Constant(value='is-enabled'),\n Constant(value='skladchik-reports-monitor.timer')],\n ctx=Load())],\n keywords=[\n keyword(\n arg='timeout',\n value=Constant(value=10))])),\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='watchdog_enabled_rc', ctx=Store()),\n Name(id='watchdog_enabled', ctx=Store())],\n ctx=Store())],\n value=Call(\n func=Name(id='run_cmd', ctx=Load()),\n args=[\n List(\n elts=[\n Constant(value='systemctl'),\n Constant(value='is-enabled'),\n Constant(value='skladchik-reports-monitor-watchdog.timer')],\n ctx=Load())],\n keywords=[\n keyword(\n arg='timeout',\n value=Constant(value=10))])),\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='heartbeat_enabled_rc', ctx=Store()),\n Name(id='heartbeat_enabled', ctx=Store())],\n ctx=Store())],\n value=Call(\n func=Name(id='run_cmd', ctx=Load()),\n args=[\n List(\n elts=[\n Constant(value='systemctl'),\n Constant(value='is-enabled'),\n Constant(value='skladchik-reports-monitor-heartbeat.timer')],\n ctx=Load())],\n keywords=[\n keyword(\n arg='timeout',\n value=Constant(value=10))])),\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='r_ok', ctx=Store()),\n Name(id='route_text', ctx=Store())],\n ctx=Store())],\n value=Call(\n func=Name(id='route_ok', ctx=Load()))),\n If(\n test=Compare(\n left=Name(id='timer_active', ctx=Load()),\n ops=[\n NotEq()],\n comparators=[\n Constant(value='active')]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='problems', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='monitor_timer_not_active:'),\n FormattedValue(\n value=Name(id='timer_active', ctx=Load()),\n conversion=-1)])]))]),\n If(\n test=BoolOp(\n op=Or(),\n values=[\n Compare(\n left=Name(id='timer_enabled_rc', ctx=Load()),\n ops=[\n NotEq()],\n comparators=[\n Constant(value=0)]),\n Compare(\n left=Name(id='timer_enabled', ctx=Load()),\n ops=[\n NotEq()],\n comparators=[\n Constant(value='enabled')])]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='problems', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='monitor_timer_not_enabled:'),\n FormattedValue(\n value=Name(id='timer_enabled', ctx=Load()),\n conversion=-1)])]))]),\n If(\n test=UnaryOp(\n op=Not(),\n operand=Call(\n func=Attribute(\n value=Name(id='HEALTH_PATH', ctx=Load()),\n attr='exists',\n ctx=Load()))),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='problems', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n Constant(value='monitor_health_missing')]))]),\n If(\n test=Compare(\n left=Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='STATUS')]),\n ops=[\n NotEq()],\n comparators=[\n Constant(value='OK')]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='problems', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='monitor_status_not_ok:'),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='STATUS'),\n Constant(value='missing')]),\n conversion=-1)])]))]),\n Assign(\n targets=[\n Name(id='age', ctx=Store())],\n value=Call(\n func=Name(id='iso_age_seconds', ctx=Load()),\n args=[\n Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='TS'),\n Constant(value='')])])),\n If(\n test=Compare(\n left=Name(id='age', ctx=Load()),\n ops=[\n Is()],\n comparators=[\n Constant(value=None)]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='problems', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n Constant(value='monitor_health_ts_invalid')]))],\n orelse=[\n If(\n test=Compare(\n left=Name(id='age', ctx=Load()),\n ops=[\n Gt()],\n comparators=[\n Name(id='MAX_HEALTH_AGE_SECONDS', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='problems', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='monitor_health_stale:'),\n FormattedValue(\n value=Name(id='age', ctx=Load()),\n conversion=-1),\n Constant(value='s')])]))])]),\n Try(\n body=[\n Assign(\n targets=[\n Name(id='reports', ctx=Store())],\n value=Call(\n func=Name(id='int', ctx=Load()),\n args=[\n Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='reports'),\n Constant(value='-1')])]))],\n handlers=[\n ExceptHandler(\n type=Name(id='ValueError', ctx=Load()),\n body=[\n Assign(\n targets=[\n Name(id='reports', ctx=Store())],\n value=UnaryOp(\n op=USub(),\n operand=Constant(value=1)))])]),\n If(\n test=Compare(\n left=Name(id='reports', ctx=Load()),\n ops=[\n LtE()],\n comparators=[\n Constant(value=0)]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='problems', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='monitor_reports_bad:'),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='reports'),\n Constant(value='missing')]),\n conversion=-1)])]))]),\n If(\n test=Compare(\n left=Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='')]),\n ops=[\n NotIn()],\n comparators=[\n Tuple(\n elts=[\n Constant(value='yes'),\n Constant(value='empty')],\n ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='problems', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value=''),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value=''),\n Constant(value='missing')]),\n conversion=-1)])]))]),\n Assign(\n targets=[\n Name(id='expiry_status', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value=''),\n Constant(value='')])),\n Assign(\n targets=[\n Name(id='expires_raw', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value=''),\n Constant(value='')])),\n Try(\n body=[\n Assign(\n targets=[\n Name(id='expires_in', ctx=Store())],\n value=Call(\n func=Name(id='int', ctx=Load()),\n args=[\n Name(id='expires_raw', ctx=Load())]))],\n handlers=[\n ExceptHandler(\n type=Name(id='Exception', ctx=Load()),\n body=[\n Assign(\n targets=[\n Name(id='expires_in', ctx=Store())],\n value=Constant(value=None))])]),\n If(\n test=Compare(\n left=Name(id='expiry_status', ctx=Load()),\n ops=[\n In()],\n comparators=[\n Tuple(\n elts=[\n Constant(value=''),\n Constant(value=''),\n Constant(value=''),\n Constant(value='ERROR')],\n ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='problems', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n Constant(value='')]))],\n orelse=[\n If(\n test=BoolOp(\n op=Or(),\n values=[\n Compare(\n left=Name(id='expiry_status', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='EXPIRED')]),\n BoolOp(\n op=And(),\n values=[\n Compare(\n left=Name(id='expires_in', ctx=Load()),\n ops=[\n IsNot()],\n comparators=[\n Constant(value=None)]),\n Compare(\n left=Name(id='expires_in', ctx=Load()),\n ops=[\n LtE()],\n comparators=[\n Constant(value=0)])])]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='problems', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n Constant(value='')]))],\n orelse=[\n If(\n test=BoolOp(\n op=Or(),\n values=[\n Compare(\n left=Name(id='expiry_status', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='WARN')]),\n BoolOp(\n op=And(),\n values=[\n Compare(\n left=Name(id='expires_in', ctx=Load()),\n ops=[\n IsNot()],\n comparators=[\n Constant(value=None)]),\n Compare(\n left=Name(id='expires_in', ctx=Load()),\n ops=[\n Lt()],\n comparators=[\n Name(id='COOKIE\nHEALTH_DUMP_SHA256=d30ee0c7a70105bffab10e001bddfad80466fe5a99394d96b4449e991cbfbeaf\nHEALTH_DUMP_TRUNCATED=true\nHEALTH_DUMP_END=build_status\nHEALTH_DUMP_BEGIN=status_to_body\nFunctionDef(\n name='status_to_body',\n args=arguments(\n args=[\n arg(arg='status'),\n arg(\n arg='mode',\n annotation=Name(id='str', ctx=Load()))]),\n body=[\n Assign(\n targets=[\n Name(id='health', ctx=Store())],\n value=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='health'),\n ctx=Load())),\n Assign(\n targets=[\n Name(id='lines', ctx=Store())],\n value=List(ctx=Load())),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='Мониторинг жалоб Складчика: '),\n FormattedValue(\n value=Name(id='mode', ctx=Load()),\n conversion=-1)])])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='Время UTC: '),\n FormattedValue(\n value=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='ts'),\n ctx=Load()),\n conversion=-1)])])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='Общий статус: '),\n FormattedValue(\n value=IfExp(\n test=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='ok'),\n ctx=Load()),\n body=Constant(value='OK'),\n orelse=Constant(value='ТРЕВОГА')),\n conversion=-1)])])),\n If(\n test=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='problems'),\n ctx=Load()),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n Constant(value='Проблемы:')])),\n For(\n target=Name(id='problem', ctx=Store()),\n iter=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='problems'),\n ctx=Load()),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='- '),\n FormattedValue(\n value=Call(\n func=Name(id='problem_to_ru', ctx=Load()),\n args=[\n Name(id='problem', ctx=Load())]),\n conversion=-1)])]))])]),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n Constant(value='')])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n Constant(value='Состояние основного монитора:')])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='- Статус: '),\n FormattedValue(\n value=Call(\n func=Name(id='status_ru', ctx=Load()),\n args=[\n Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='STATUS'),\n Constant(value='missing')])]),\n conversion=-1)])])),\n If(\n test=Compare(\n left=Constant(value='TS'),\n ops=[\n In()],\n comparators=[\n Name(id='health', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='- Последний успешный опрос UTC: '),\n FormattedValue(\n value=Subscript(\n value=Name(id='health', ctx=Load()),\n slice=Constant(value='TS'),\n ctx=Load()),\n conversion=-1)])]))]),\n If(\n test=Compare(\n left=Constant(value='url'),\n ops=[\n In()],\n comparators=[\n Name(id='health', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='- URL: '),\n FormattedValue(\n value=Subscript(\n value=Name(id='health', ctx=Load()),\n slice=Constant(value='url'),\n ctx=Load()),\n conversion=-1)])]))]),\n If(\n test=Compare(\n left=Constant(value='reports'),\n ops=[\n In()],\n comparators=[\n Name(id='health', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='- Всего жалоб на странице: '),\n FormattedValue(\n value=Subscript(\n value=Name(id='health', ctx=Load()),\n slice=Constant(value='reports'),\n ctx=Load()),\n conversion=-1)])]))]),\n If(\n test=Compare(\n left=Constant(value='open'),\n ops=[\n In()],\n comparators=[\n Name(id='health', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='- Открытые / в работе: '),\n FormattedValue(\n value=Subscript(\n value=Name(id='health', ctx=Load()),\n slice=Constant(value='open'),\n ctx=Load()),\n conversion=-1)])]))]),\n If(\n test=Compare(\n left=Constant(value='resolved'),\n ops=[\n In()],\n comparators=[\n Name(id='health', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='- Закрытые / отработанные: '),\n FormattedValue(\n value=Subscript(\n value=Name(id='health', ctx=Load()),\n slice=Constant(value='resolved'),\n ctx=Load()),\n conversion=-1)])]))]),\n If(\n test=Compare(\n left=Constant(value='session_keepalive'),\n ops=[\n In()],\n comparators=[\n Name(id='health', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n Constant(value='')]))]),\n If(\n test=Compare(\n left=Constant(value=''),\n ops=[\n In()],\n comparators=[\n Name(id='health', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value=''),\n FormattedValue(\n value=Subscript(\n value=Name(id='health', ctx=Load()),\n slice=Constant(value=''),\n ctx=Load()),\n conversion=-1),\n Constant(value=', байт: '),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value=''),\n Constant(value='?')]),\n conversion=-1)])]))]),\n If(\n test=Compare(\n left=Constant(value=''),\n ops=[\n In()],\n comparators=[\n Name(id='health', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value=''),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='')]),\n conversion=-1)])])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value=''),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value=''),\n Constant(value='?')]),\n conversion=-1)])])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value=''),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Name(id='health', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value=''),\n Constant(value='?')]),\n conversion=-1)])]))]),\n If(\n test=Compare(\n left=Constant(value='new_events'),\n ops=[\n In()],\n comparators=[\n Name(id='health', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='- Новые события за последний опрос: '),\n FormattedValue(\n value=Subscript(\n value=Name(id='health', ctx=Load()),\n slice=Constant(value='new_events'),\n ctx=Load()),\n conversion=-1)])]))]),\n If(\n test=Compare(\n left=Constant(value='resolved_events'),\n ops=[\n In()],\n comparators=[\n Name(id='health', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='- Закрытые события за последний опрос: '),\n FormattedValue(\n value=Subscript(\n value=Name(id='health', ctx=Load()),\n slice=Constant(value='resolved_events'),\n ctx=Load()),\n conversion=-1)])]))]),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lines', ctx=Load()),\n attr='append',\n ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='- Возраст состояния, секунд: '),\n FormattedValue(\n value=Subscript(\n value=Name(id='status', ctx=Loa\nHEALTH_DUMP_SHA256=680c4e2fd2c19d569bb38130327a7044c6cd29de4d4a7490ecf3c860ee5f7865\nHEALTH_DUMP_TRUNCATED=true\nHEALTH_DUMP_END=status_to_body\nHEALTH_DUMP_BEGIN=do_check\nFunctionDef(\n name='do_check',\n args=arguments(),\n body=[\n Assign(\n targets=[\n Name(id='status', ctx=Store())],\n value=Call(\n func=Name(id='build_status', ctx=Load()))),\n Assign(\n targets=[\n Name(id='state', ctx=Store())],\n value=Call(\n func=Name(id='load_state', ctx=Load()))),\n Assign(\n targets=[\n Name(id='now', ctx=Store())],\n value=Call(\n func=Name(id='int', ctx=Load()),\n args=[\n Call(\n func=Attribute(\n value=Name(id='time', ctx=Load()),\n attr='time',\n ctx=Load()))])),\n Assign(\n targets=[\n Name(id='problem_key', ctx=Store())],\n value=IfExp(\n test=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='problems'),\n ctx=Load()),\n body=Call(\n func=Attribute(\n value=Call(\n func=Attribute(\n value=Name(id='hashlib', ctx=Load()),\n attr='sha256',\n ctx=Load()),\n args=[\n Call(\n func=Attribute(\n value=Call(\n func=Attribute(\n value=Constant(value='|'),\n attr='join',\n ctx=Load()),\n args=[\n Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='problems'),\n ctx=Load())]),\n attr='encode',\n ctx=Load()),\n args=[\n Constant(value='utf-8')])]),\n attr='hexdigest',\n ctx=Load())),\n orelse=Constant(value=''))),\n Assign(\n targets=[\n Name(id='mail_sent', ctx=Store())],\n value=Constant(value=False)),\n If(\n test=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='ok'),\n ctx=Load()),\n body=[\n If(\n test=Call(\n func=Attribute(\n value=Name(id='state', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='active_alert')]),\n body=[\n Assign(\n targets=[\n Name(id='subject', ctx=Store())],\n value=Constant(value='Мониторинг жалоб восстановлен: OK')),\n Assign(\n targets=[\n Name(id='body', ctx=Store())],\n value=Call(\n func=Name(id='status_to_body', ctx=Load()),\n args=[\n Name(id='status', ctx=Load()),\n Constant(value='восстановление')])),\n Assign(\n targets=[\n Name(id='mail_sent', ctx=Store())],\n value=Call(\n func=Name(id='send_mail', ctx=Load()),\n args=[\n Name(id='subject', ctx=Load()),\n Name(id='body', ctx=Load())])),\n Assign(\n targets=[\n Name(id='state', ctx=Store())],\n value=Dict(\n keys=[\n Constant(value='active_alert'),\n Constant(value='last_recovery_ts')],\n values=[\n Constant(value=False),\n Name(id='now', ctx=Load())])),\n Expr(\n value=Call(\n func=Name(id='log', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='RECOVERY mail_sent='),\n FormattedValue(\n value=Name(id='mail_sent', ctx=Load()),\n conversion=-1)])]))],\n orelse=[\n Expr(\n value=Call(\n func=Name(id='log', ctx=Load()),\n args=[\n Constant(value='CHECK ok=true mail_sent=false')]))])],\n orelse=[\n Assign(\n targets=[\n Name(id='last_alert_ts', ctx=Store())],\n value=Call(\n func=Name(id='int', ctx=Load()),\n args=[\n BoolOp(\n op=Or(),\n values=[\n Call(\n func=Attribute(\n value=Name(id='state', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='last_alert_ts'),\n Constant(value=0)]),\n Constant(value=0)])])),\n Assign(\n targets=[\n Name(id='last_key', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='state', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='last_problem_key'),\n Constant(value='')])),\n Assign(\n targets=[\n Name(id='should_send', ctx=Store())],\n value=BoolOp(\n op=Or(),\n values=[\n UnaryOp(\n op=Not(),\n operand=Call(\n func=Attribute(\n value=Name(id='state', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='active_alert')])),\n Compare(\n left=Name(id='last_key', ctx=Load()),\n ops=[\n NotEq()],\n comparators=[\n Name(id='problem_key', ctx=Load())]),\n Compare(\n left=BinOp(\n left=Name(id='now', ctx=Load()),\n op=Sub(),\n right=Name(id='last_alert_ts', ctx=Load())),\n ops=[\n GtE()],\n comparators=[\n Name(id='ALERT_REPEAT_SECONDS', ctx=Load())])])),\n If(\n test=Name(id='should_send', ctx=Load()),\n body=[\n Assign(\n targets=[\n Name(id='subject', ctx=Store())],\n value=BinOp(\n left=Constant(value='ТРЕВОГА мониторинга жалоб: '),\n op=Add(),\n right=Call(\n func=Attribute(\n value=Constant(value=', '),\n attr='join',\n ctx=Load()),\n args=[\n GeneratorExp(\n elt=Call(\n func=Name(id='problem_to_ru', ctx=Load()),\n args=[\n Name(id='p', ctx=Load())]),\n generators=[\n comprehension(\n target=Name(id='p', ctx=Store()),\n iter=Subscript(\n value=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='problems'),\n ctx=Load()),\n slice=Slice(\n upper=Constant(value=2)),\n ctx=Load()),\n is_async=0)])]))),\n Assign(\n targets=[\n Name(id='body', ctx=Store())],\n value=Call(\n func=Name(id='status_to_body', ctx=Load()),\n args=[\n Name(id='status', ctx=Load()),\n Constant(value='тревога')])),\n Assign(\n targets=[\n Name(id='mail_sent', ctx=Store())],\n value=Call(\n func=Name(id='send_mail', ctx=Load()),\n args=[\n Name(id='subject', ctx=Load()),\n Name(id='body', ctx=Load())])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='state', ctx=Load()),\n attr='update',\n ctx=Load()),\n args=[\n Dict(\n keys=[\n Constant(value='active_alert'),\n Constant(value='last_alert_ts'),\n Constant(value='last_problem_key'),\n Constant(value='last_problems')],\n values=[\n Constant(value=True),\n Name(id='now', ctx=Load()),\n Name(id='problem_key', ctx=Load()),\n Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='problems'),\n ctx=Load())])])),\n Expr(\n value=Call(\n func=Name(id='log', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='ALERT mail_sent='),\n FormattedValue(\n value=Name(id='mail_sent', ctx=Load()),\n conversion=-1),\n Constant(value=' problems='),\n FormattedValue(\n value=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='problems'),\n ctx=Load()),\n conversion=-1)])]))],\n orelse=[\n Expr(\n value=Call(\n func=Name(id='log', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='CHECK ok=false suppressed=true problems='),\n FormattedValue(\n value=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='problems'),\n ctx=Load()),\n conversion=-1)])]))])]),\n Expr(\n value=Call(\n func=Name(id='save_state', ctx=Load()),\n args=[\n Name(id='state', ctx=Load())])),\n Expr(\n value=Call(\n func=Name(id='write_alert_health', ctx=Load()),\n args=[\n Name(id='status', ctx=Load()),\n Name(id='mail_sent', ctx=Load())])),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n BinOp(\n left=Constant(value='WATCHDOG_STATUS='),\n op=Add(),\n right=IfExp(\n test=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='ok'),\n ctx=Load()),\n body=Constant(value='OK'),\n orelse=Constant(value='ALERT')))])),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n BinOp(\n left=Constant(value='WATCHDOG_MAIL_SENT='),\n op=Add(),\n right=IfExp(\n test=Name(id='mail_sent', ctx=Load()),\n body=Constant(value='yes'),\n orelse=Constant(value='no')))])),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='PROBLEMS='),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Constant(value=';'),\n attr='join',\n ctx=Load()),\n args=[\n Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='problems'),\n ctx=Load())]),\n conversion=-1)])])),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='OPEN='),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='health'),\n ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='open'),\n Constant(value='missing')]),\n conversion=-1)])])),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='RESOLVED='),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='health'),\n ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='resolved'),\n Constant(value='missing')]),\n conversion=-1)])])),\n Return(\n value=Constant(value=0))])\nHEALTH_DUMP_SHA256=da7bbe1956bd719cb634bbf6d2d3ace50781963d52bba841ec8197af0888f282\nHEALTH_DUMP_TRUNCATED=false\nHEALTH_DUMP_END=do_check\nHEALTH_DUMP_BEGIN=do_status\nFunctionDef(\n name='do_status',\n args=arguments(),\n body=[\n Assign(\n targets=[\n Name(id='status', ctx=Store())],\n value=Call(\n func=Name(id='build_status', ctx=Load()))),\n Expr(\n value=Call(\n func=Name(id='write_alert_health', ctx=Load()),\n args=[\n Name(id='status', ctx=Load()),\n Constant(value=None)])),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n BinOp(\n left=Constant(value='WATCHDOG_STATUS='),\n op=Add(),\n right=IfExp(\n test=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='ok'),\n ctx=Load()),\n body=Constant(value='OK'),\n orelse=Constant(value='ALERT')))])),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='PROBLEMS='),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Constant(value=';'),\n attr='join',\n ctx=Load()),\n args=[\n Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='problems'),\n ctx=Load())]),\n conversion=-1)])])),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='OPEN='),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='health'),\n ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='open'),\n Constant(value='missing')]),\n conversion=-1)])])),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='RESOLVED='),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='health'),\n ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='resolved'),\n Constant(value='missing')]),\n conversion=-1)])])),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='HEALTH_AGE_SECONDS='),\n FormattedValue(\n value=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='health_age_seconds'),\n ctx=Load()),\n conversion=-1)])])),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='NETBIRD_ROUTE_OK='),\n FormattedValue(\n value=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='route_ok'),\n ctx=Load()),\n conversion=-1)])])),\n Return(\n value=IfExp(\n test=Subscript(\n value=Name(id='status', ctx=Load()),\n slice=Constant(value='ok'),\n ctx=Load()),\n body=Constant(value=0),\n orelse=Constant(value=1)))])\nHEALTH_DUMP_SHA256=cbf3c7c1c58dd802afb48ef237a648104b27d72a6b727156bde564cb253cc0a2\nHEALTH_DUMP_TRUNCATED=false\nHEALTH_DUMP_END=do_status\nHEALTH_DUMP_BEGIN=main\nFunctionDef(\n name='main',\n args=arguments(),\n body=[\n Assign(\n targets=[\n Name(id='mode', ctx=Store())],\n value=IfExp(\n test=Compare(\n left=Call(\n func=Name(id='len', ctx=Load()),\n args=[\n Attribute(\n value=Name(id='sys', ctx=Load()),\n attr='argv',\n ctx=Load())]),\n ops=[\n Gt()],\n comparators=[\n Constant(value=1)]),\n body=Subscript(\n value=Attribute(\n value=Name(id='sys', ctx=Load()),\n attr='argv',\n ctx=Load()),\n slice=Constant(value=1),\n ctx=Load()),\n orelse=Constant(value='check'))),\n If(\n test=Compare(\n left=Name(id='mode', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='heartbeat')]),\n body=[\n Return(\n value=Call(\n func=Name(id='do_heartbeat', ctx=Load())))]),\n If(\n test=Compare(\n left=Name(id='mode', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='check')]),\n body=[\n Return(\n value=Call(\n func=Name(id='do_check', ctx=Load())))]),\n If(\n test=Compare(\n left=Name(id='mode', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='status')]),\n body=[\n Return(\n value=Call(\n func=Name(id='do_status', ctx=Load())))]),\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n Constant(value='usage: health_alert.py [check|heartbeat|status]')],\n keywords=[\n keyword(\n arg='file',\n value=Attribute(\n value=Name(id='sys', ctx=Load()),\n attr='stderr',\n ctx=Load()))])),\n Return(\n value=Constant(value=64))])\nHEALTH_DUMP_SHA256=9a6149262fde18c30b641e25ec67b04a04957d0b2588ec05b1775c875c6722d2\nHEALTH_DUMP_TRUNCATED=false\nHEALTH_DUMP_END=main\nHEALTH_SCAN_OK=true\nQGA_CANARY_QM_RC=0\nQGA_CANARY_STDERR_PRESENT=false\nQGA_CANARY_JSON=true\nQGA_CANARY_GUEST_EXITCODE=0\nQGA_SHORT_OK=true\nMONITOR_SCAN_QM_RC=0\nMONITOR_SCAN_STDERR_PRESENT=false\nMONITOR_SCAN_JSON=true\nMONITOR_SCAN_GUEST_EXITCODE=0\nMONITOR_SCAN=V1\nMONITOR_PRESENT=true\nMONITOR_SHA256=f62288797f80ce561f1e3ea721b87090eb1cd751fd5bf07152a3608b3a8aaed2\nMONITOR_BYTES=17878\nMONITOR_FUNCTION_COUNT=26\nMONITOR_FUNC=utc_now:48:49\nMONITOR_FUNC=log:52:55\nMONITOR_FUNC=write_health:58:64\nMONITOR_FUNC=read_env:67:81\nMONITOR_FUNC=load_config:84:101\nMONITOR_FUNC=connect_db:104:136\nMONITOR_FUNC=meta_get:139:141\nMONITOR_FUNC=meta_set:144:146\nMONITOR_FUNC=event_sent:149:150\nMONITOR_FUNC=mark_event:153:158\nMONITOR_FUNC=fetch_reports_page:161:179\nMONITOR_FUNC=login_required:182:192\nMONITOR_FUNC=strip_tags:195:198\nMONITOR_FUNC=full_url:201:202\nMONITOR_FUNC=section_positions:205:222\nMONITOR_FUNC=parse_int:225:227\nMONITOR_FUNC=parse_reports:230:281\nMONITOR_FUNC=smtp_ready:284:285\nMONITOR_FUNC=send_mail:288:312\nMONITOR_FUNC=report_body:315:324\nMONITOR_FUNC=process_reports:327:370\nMONITOR_FUNC=maybe_send_auth_required:373:391\nMONITOR_FUNC=acquire_lock:394:401\nMONITOR_FUNC=run_once:404:451\nMONITOR_FUNC=show_status:454:459\nMONITOR_FUNC=main:462:468\nMONITOR_RELEVANT_COUNT=10\nMONITOR_DUMP_BEGIN=fetch_reports_page\nFunctionDef(\n name='fetch_reports_page',\n args=arguments(\n args=[\n arg(\n arg='cfg',\n annotation=Attribute(\n value=Name(id='configparser', ctx=Load()),\n attr='ConfigParser',\n ctx=Load())),\n arg(\n arg='secrets',\n annotation=Subscript(\n value=Name(id='dict', ctx=Load()),\n slice=Tuple(\n elts=[\n Name(id='str', ctx=Load()),\n Name(id='str', ctx=Load())],\n ctx=Load()),\n ctx=Load()))]),\n body=[\n Assign(\n targets=[\n Name(id='url', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Subscript(\n value=Name(id='cfg', ctx=Load()),\n slice=Constant(value='forum'),\n ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='reports_url'),\n Constant(value='')])),\n Assign(\n targets=[\n Name(id='request', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Attribute(\n value=Name(id='urllib', ctx=Load()),\n attr='request',\n ctx=Load()),\n attr='Request',\n ctx=Load()),\n args=[\n Name(id='url', ctx=Load())])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='request', ctx=Load()),\n attr='add_header',\n ctx=Load()),\n args=[\n Constant(value='User-Agent'),\n Call(\n func=Attribute(\n value=Subscript(\n value=Name(id='cfg', ctx=Load()),\n slice=Constant(value='forum'),\n ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='user_agent'),\n Constant(value='Mozilla/5.0')])])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='request', ctx=Load()),\n attr='add_header',\n ctx=Load()),\n args=[\n Constant(value='Accept'),\n Constant(value='text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='request', ctx=Load()),\n attr='add_header',\n ctx=Load()),\n args=[\n Constant(value='Accept-Language'),\n Constant(value='ru-RU,ru;q=0.9,en;q=0.5')])),\n Assign(\n targets=[\n Name(id='cookie', ctx=Store())],\n value=BoolOp(\n op=Or(),\n values=[\n Call(\n func=Attribute(\n value=Name(id='secrets', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='')]),\n Call(\n func=Attribute(\n value=Name(id='secrets', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='')]),\n Constant(value='')])),\n If(\n test=Name(id='cookie', ctx=Load()),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='request', ctx=Load()),\n attr='add_header',\n ctx=Load()),\n args=[\n Constant(value=''),\n Name(id='cookie', ctx=Load())]))]),\n Assign(\n targets=[\n Name(id='timeout', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Subscript(\n value=Name(id='cfg', ctx=Load()),\n slice=Constant(value='forum'),\n ctx=Load()),\n attr='getint',\n ctx=Load()),\n args=[\n Constant(value='timeout_seconds')],\n keywords=[\n keyword(\n arg='fallback',\n value=Constant(value=25))])),\n With(\n items=[\n withitem(\n context_expr=Call(\n func=Attribute(\n value=Attribute(\n value=Name(id='urllib', ctx=Load()),\n attr='request',\n ctx=Load()),\n attr='urlopen',\n ctx=Load()),\n args=[\n Name(id='request', ctx=Load())],\n keywords=[\n keyword(\n arg='timeout',\n value=Name(id='timeout', ctx=Load()))]),\n optional_vars=Name(id='response', ctx=Store()))],\n body=[\n Assign(\n targets=[\n Name(id='final_url', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='response', ctx=Load()),\n attr='geturl',\n ctx=Load()))),\n Assign(\n targets=[\n Name(id='body', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='response', ctx=Load()),\n attr='read',\n ctx=Load()))),\n Assign(\n targets=[\n Name(id='charset', ctx=Store())],\n value=Constant(value='utf-8')),\n Assign(\n targets=[\n Name(id='content_type', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Attribute(\n value=Name(id='response', ctx=Load()),\n attr='headers',\n ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='Content-Type'),\n Constant(value='')])),\n Assign(\n targets=[\n Name(id='match', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='re', ctx=Load()),\n attr='search',\n ctx=Load()),\n args=[\n Constant(value='charset=([A-Za-z0-9._-]+)'),\n Name(id='content_type', ctx=Load())],\n keywords=[\n keyword(\n arg='flags',\n value=Attribute(\n value=Name(id='re', ctx=Load()),\n attr='I',\n ctx=Load()))])),\n If(\n test=Name(id='match', ctx=Load()),\n body=[\n Assign(\n targets=[\n Name(id='charset', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='match', ctx=Load()),\n attr='group',\n ctx=Load()),\n args=[\n Constant(value=1)]))]),\n Return(\n value=Tuple(\n elts=[\n Name(id='final_url', ctx=Load()),\n Call(\n func=Attribute(\n value=Name(id='body', ctx=Load()),\n attr='decode',\n ctx=Load()),\n args=[\n Name(id='charset', ctx=Load())],\n keywords=[\n keyword(\n arg='errors',\n value=Constant(value='replace'))])],\n ctx=Load()))])],\n returns=Subscript(\n value=Name(id='tuple', ctx=Load()),\n slice=Tuple(\n elts=[\n Name(id='str', ctx=Load()),\n Name(id='str', ctx=Load())],\n ctx=Load()),\n ctx=Load()))\nMONITOR_DUMP_SHA256=5b5c22665fa95eba6f84bbab6664b6750ec6ce801008b74213b7318201cded18\nMONITOR_DUMP_TRUNCATED=false\nMONITOR_DUMP_END=fetch_reports_page\nMONITOR_DUMP_BEGIN=parse_int\nFunctionDef(\n name='parse_int',\n args=arguments(\n args=[\n arg(\n arg='pattern',\n annotation=Name(id='str', ctx=Load())),\n arg(\n arg='text',\n annotation=Name(id='str', ctx=Load()))]),\n body=[\n Assign(\n targets=[\n Name(id='match', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='re', ctx=Load()),\n attr='search',\n ctx=Load()),\n args=[\n Name(id='pattern', ctx=Load()),\n Name(id='text', ctx=Load())],\n keywords=[\n keyword(\n arg='flags',\n value=Attribute(\n value=Name(id='re', ctx=Load()),\n attr='I',\n ctx=Load()))])),\n Return(\n value=IfExp(\n test=Name(id='match', ctx=Load()),\n body=Call(\n func=Name(id='int', ctx=Load()),\n args=[\n Call(\n func=Attribute(\n value=Name(id='match', ctx=Load()),\n attr='group',\n ctx=Load()),\n args=[\n Constant(value=1)])]),\n orelse=Constant(value=None)))],\n returns=BinOp(\n left=Name(id='int', ctx=Load()),\n op=BitOr(),\n right=Constant(value=None)))\nMONITOR_DUMP_SHA256=cb2011a9afb6eed1914e736d66227b0214cb4adb04afb833df8799db0dbf500e\nMONITOR_DUMP_TRUNCATED=false\nMONITOR_DUMP_END=parse_int\nMONITOR_DUMP_BEGIN=parse_reports\nFunctionDef(\n name='parse_reports',\n args=arguments(\n args=[\n arg(\n arg='text',\n annotation=Name(id='str', ctx=Load())),\n arg(\n arg='cfg',\n annotation=Attribute(\n value=Name(id='configparser', ctx=Load()),\n attr='ConfigParser',\n ctx=Load()))]),\n body=[\n Assign(\n targets=[\n Name(id='base_url', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Subscript(\n value=Name(id='cfg', ctx=Load()),\n slice=Constant(value='forum'),\n ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='base_url'),\n Constant(value='')])),\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='open_pos', ctx=Store()),\n Name(id='closed_pos', ctx=Store())],\n ctx=Store())],\n value=Call(\n func=Name(id='section_positions', ctx=Load()),\n args=[\n Name(id='text', ctx=Load())])),\n AnnAssign(\n target=Name(id='results', ctx=Store()),\n annotation=Subscript(\n value=Name(id='dict', ctx=Load()),\n slice=Tuple(\n elts=[\n Name(id='str', ctx=Load()),\n Subscript(\n value=Name(id='dict', ctx=Load()),\n slice=Tuple(\n elts=[\n Name(id='str', ctx=Load()),\n Name(id='Any', ctx=Load())],\n ctx=Load()),\n ctx=Load())],\n ctx=Load()),\n ctx=Load()),\n value=Dict(),\n simple=1),\n Assign(\n targets=[\n Name(id='pattern', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='re', ctx=Load()),\n attr='compile',\n ctx=Load()),\n args=[\n Constant(value='(?is)]*href=[\\\\\"\\']((?:reports/|[^\\\\\"\\']*/reports/)(\\\\d+)/?[^\\\\\"\\']*)[\\\\\"\\'][^>]*>(.*?)')])),\n For(\n target=Name(id='match', ctx=Store()),\n iter=Call(\n func=Attribute(\n value=Name(id='pattern', ctx=Load()),\n attr='finditer',\n ctx=Load()),\n args=[\n Name(id='text', ctx=Load())]),\n body=[\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='href', ctx=Store()),\n Name(id='report_id', ctx=Store()),\n Name(id='title_html', ctx=Store())],\n ctx=Store())],\n value=Tuple(\n elts=[\n Call(\n func=Attribute(\n value=Name(id='match', ctx=Load()),\n attr='group',\n ctx=Load()),\n args=[\n Constant(value=1)]),\n Call(\n func=Attribute(\n value=Name(id='match', ctx=Load()),\n attr='group',\n ctx=Load()),\n args=[\n Constant(value=2)]),\n Call(\n func=Attribute(\n value=Name(id='match', ctx=Load()),\n attr='group',\n ctx=Load()),\n args=[\n Constant(value=3)])],\n ctx=Load())),\n Assign(\n targets=[\n Name(id='title', ctx=Store())],\n value=Call(\n func=Name(id='strip_tags', ctx=Load()),\n args=[\n Name(id='title_html', ctx=Load())])),\n If(\n test=BoolOp(\n op=Or(),\n values=[\n UnaryOp(\n op=Not(),\n operand=Name(id='title', ctx=Load())),\n Compare(\n left=Call(\n func=Attribute(\n value=Name(id='title', ctx=Load()),\n attr='lower',\n ctx=Load())),\n ops=[\n In()],\n comparators=[\n Set(\n elts=[\n Constant(value='жалобы'),\n Constant(value='reports'),\n Constant(value='обработанные жалобы')])])]),\n body=[\n Continue()]),\n Assign(\n targets=[\n Name(id='position', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='match', ctx=Load()),\n attr='start',\n ctx=Load()))),\n Assign(\n targets=[\n Name(id='item_window_start', ctx=Store())],\n value=Call(\n func=Name(id='max', ctx=Load()),\n args=[\n Constant(value=0),\n BinOp(\n left=Name(id='position', ctx=Load()),\n op=Sub(),\n right=Constant(value=6000))])),\n Assign(\n targets=[\n Name(id='item_tag', ctx=Store())],\n value=Constant(value='')),\n For(\n target=Name(id='item_match', ctx=Store()),\n iter=Call(\n func=Attribute(\n value=Name(id='re', ctx=Load()),\n attr='finditer',\n ctx=Load()),\n args=[\n Constant(value='(?is)<(?:li|div|tr)\\\\b[^>]*class=[\"\\'][^\"\\']*\\\\bdiscussionListItem\\\\b[^\"\\']*[\"\\'][^>]*>'),\n Subscript(\n value=Name(id='text', ctx=Load()),\n slice=Slice(\n lower=Name(id='item_window_start', ctx=Load()),\n upper=Name(id='position', ctx=Load())),\n ctx=Load())]),\n body=[\n Assign(\n targets=[\n Name(id='item_tag', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Call(\n func=Attribute(\n value=Name(id='item_match', ctx=Load()),\n attr='group',\n ctx=Load()),\n args=[\n Constant(value=0)]),\n attr='lower',\n ctx=Load())))]),\n If(\n test=Compare(\n left=Constant(value='report-resolved'),\n ops=[\n In()],\n comparators=[\n Name(id='item_tag', ctx=Load())]),\n body=[\n Assign(\n targets=[\n Name(id='status', ctx=Store())],\n value=Constant(value='resolved'))],\n orelse=[\n If(\n test=BoolOp(\n op=Or(),\n values=[\n Compare(\n left=Constant(value='report-assigned'),\n ops=[\n In()],\n comparators=[\n Name(id='item_tag', ctx=Load())]),\n Compare(\n left=Constant(value='report-open'),\n ops=[\n In()],\n comparators=[\n Name(id='item_tag', ctx=Load())])]),\n body=[\n Assign(\n targets=[\n Name(id='status', ctx=Store())],\n value=Constant(value='open'))],\n orelse=[\n If(\n test=BoolOp(\n op=And(),\n values=[\n Compare(\n left=Name(id='closed_pos', ctx=Load()),\n ops=[\n GtE()],\n comparators=[\n Constant(value=0)]),\n Compare(\n left=Name(id='position', ctx=Load()),\n ops=[\n Gt()],\n comparators=[\n Name(id='closed_pos', ctx=Load())])]),\n body=[\n Assign(\n targets=[\n Name(id='status', ctx=Store())],\n value=Constant(value='resolved'))],\n orelse=[\n If(\n test=BoolOp(\n op=And(),\n values=[\n Compare(\n left=Name(id='open_pos', ctx=Load()),\n ops=[\n GtE()],\n comparators=[\n Constant(value=0)]),\n Compare(\n left=Name(id='position', ctx=Load()),\n ops=[\n Gt()],\n comparators=[\n Name(id='open_pos', ctx=Load())]),\n BoolOp(\n op=Or(),\n values=[\n Compare(\n left=Name(id='closed_pos', ctx=Load()),\n ops=[\n Lt()],\n comparators=[\n Constant(value=0)]),\n Compare(\n left=Name(id='position', ctx=Load()),\n ops=[\n Lt()],\n comparators=[\n Name(id='closed_pos', ctx=Load())])])]),\n body=[\n Assign(\n targets=[\n Name(id='status', ctx=Store())],\n value=Constant(value='open'))],\n orelse=[\n Assign(\n targets=[\n Name(id='status', ctx=Store())],\n value=Constant(value='open'))])])])]),\n Assign(\n targets=[\n Name(id='row_start', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='text', ctx=Load()),\n attr='rfind',\n ctx=Load()),\n args=[\n Constant(value=''),\n ctx=Load())),\n Assign(\n targets=[\n Name(id='port', ctx=Store())],\n value=Call(\n func=Name(id='int', ctx=Load()),\n args=[\n Call(\n func=Attribute(\n value=Name(id='secrets', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value=''),\n Constant(value='587')])])),\n Assign(\n targets=[\n Name(id='user', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='secrets', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value=''),\n Constant(value='')])),\n Assign(\n targets=[\n Name(id='password', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='secrets', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value=''),\n Constant(value='')])),\n Assign(\n targets=[\n Name(id='tls', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Call(\n func=Attribute(\n value=Name(id='secrets', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value=''),\n Constant(value='starttls')]),\n attr='lower',\n ctx=Load()))),\n Assign(\n targets=[\n Name(id='msg', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Attribute(\n value=Name(id='email', ctx=Load()),\n attr='message',\n ctx=Load()),\n attr='EmailMessage',\n ctx=Load()))),\n Assign(\n targets=[\n Subscript(\n value=Name(id='msg', ctx=Load()),\n slice=Constant(value='From'),\n ctx=Store())],\n value=Subscript(\n value=Name(id='secrets', ctx=Load()),\n slice=Constant(value=''),\n ctx=Load())),\n Assign(\n targets=[\n Subscript(\n value=Name(id='msg', ctx=Load()),\n slice=Constant(value='To'),\n ctx=Store())],\n value=Subscript(\n value=Name(id='secrets', ctx=Load()),\n slice=Constant(value=''),\n ctx=Load())),\n Assign(\n targets=[\n Subscript(\n value=Name(id='msg', ctx=Load()),\n slice=Constant(value='Subject'),\n ctx=Store())],\n value=BinOp(\n left=BinOp(\n left=Call(\n func=Attribute(\n value=Subscript(\n value=Name(id='cfg', ctx=Load()),\n slice=Constant(value='email'),\n ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='subject_prefix'),\n Constant(value='[Skladchik]')]),\n op=Add(),\n right=Constant(value=' ')),\n op=Add(),\n right=Name(id='subject', ctx=Load()))),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='msg', ctx=Load()),\n attr='set_content',\n ctx=Load()),\n args=[\n Name(id='body', ctx=Load())])),\n If(\n test=Compare(\n left=Name(id='tls', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='ssl')]),\n body=[\n Assign(\n targets=[\n Name(id='smtp', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='smtplib', ctx=Load()),\n attr='SMTP_SSL',\n ctx=Load()),\n args=[\n Name(id='host', ctx=Load()),\n Name(id='port', ctx=Load())],\n keywords=[\n keyword(\n arg='timeout',\n value=Constant(value=30))]))],\n orelse=[\n Assign(\n targets=[\n Name(id='smtp', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='smtplib', ctx=Load()),\n attr='SMTP',\n ctx=Load()),\n args=[\n Name(id='host', ctx=Load()),\n Name(id='port', ctx=Load())],\n keywords=[\n keyword(\n arg='timeout',\n value=Constant(value=30))]))]),\n With(\n items=[\n withitem(\n context_expr=Name(id='smtp', ctx=Load()),\n optional_vars=Name(id='server', ctx=Store()))],\n body=[\n If(\n test=Compare(\n left=Name(id='tls', ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='starttls')]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='server', ctx=Load()),\n attr='starttls',\n ctx=Load()),\n keywords=[\n keyword(\n arg='context',\n value=Call(\n func=Attribute(\n value=Name(id='ssl', ctx=Load()),\n attr='create_default_context',\n ctx=Load())))]))]),\n If(\n test=Name(id='user', ctx=Load()),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='server', ctx=Load()),\n attr='login',\n ctx=Load()),\n args=[\n Name(id='user', ctx=Load()),\n Name(id='password', ctx=Load())]))]),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='server', ctx=Load()),\n attr='send_message',\n ctx=Load()),\n args=[\n Name(id='msg', ctx=Load())]))]),\n Return(\n value=Constant(value=True))],\n returns=Name(id='bool', ctx=Load()))\nMONITOR_DUMP_SHA256=af72f54e66459d653cc65a65494c97a1eeabaa80cee95f1777319a7df1efc133\nMONITOR_DUMP_TRUNCATED=false\nMONITOR_DUMP_END=send_mail\nMONITOR_DUMP_BEGIN=report_body\nFunctionDef(\n name='report_body',\n args=arguments(\n args=[\n arg(\n arg='prefix',\n annotation=Name(id='str', ctx=Load())),\n arg(\n arg='report',\n annotation=Subscript(\n value=Name(id='dict', ctx=Load()),\n slice=Tuple(\n elts=[\n Name(id='str', ctx=Load()),\n Name(id='Any', ctx=Load())],\n ctx=Load()),\n ctx=Load()))]),\n body=[\n Return(\n value=JoinedStr(\n values=[\n FormattedValue(\n value=Name(id='prefix', ctx=Load()),\n conversion=-1),\n Constant(value=''),\n FormattedValue(\n value=Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='title'),\n ctx=Load()),\n conversion=-1),\n Constant(value=''),\n FormattedValue(\n value=Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='status'),\n ctx=Load()),\n conversion=-1),\n Constant(value=''),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Name(id='report', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='report_count')]),\n conversion=-1),\n Constant(value=''),\n FormattedValue(\n value=Call(\n func=Attribute(\n value=Name(id='report', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='comment_count')]),\n conversion=-1),\n Constant(value=''),\n FormattedValue(\n value=Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='url'),\n ctx=Load()),\n conversion=-1),\n Constant(value=''),\n FormattedValue(\n value=Call(\n func=Name(id='utc_now', ctx=Load())),\n conversion=-1),\n Constant(value='')]))],\n returns=Name(id='str', ctx=Load()))\nMONITOR_DUMP_SHA256=668abfab86ee05df948412e7aca1247e115d8d5c6d7c52ddda0746f288f2978a\nMONITOR_DUMP_TRUNCATED=false\nMONITOR_DUMP_END=report_body\nMONITOR_DUMP_BEGIN=process_reports\nFunctionDef(\n name='process_reports',\n args=arguments(\n args=[\n arg(\n arg='con',\n annotation=Attribute(\n value=Name(id='sqlite3', ctx=Load()),\n attr='Connection',\n ctx=Load())),\n arg(\n arg='cfg',\n annotation=Attribute(\n value=Name(id='configparser', ctx=Load()),\n attr='ConfigParser',\n ctx=Load())),\n arg(\n arg='secrets',\n annotation=Subscript(\n value=Name(id='dict', ctx=Load()),\n slice=Tuple(\n elts=[\n Name(id='str', ctx=Load()),\n Name(id='str', ctx=Load())],\n ctx=Load()),\n ctx=Load())),\n arg(\n arg='reports',\n annotation=Subscript(\n value=Name(id='list', ctx=Load()),\n slice=Subscript(\n value=Name(id='dict', ctx=Load()),\n slice=Tuple(\n elts=[\n Name(id='str', ctx=Load()),\n Name(id='Any', ctx=Load())],\n ctx=Load()),\n ctx=Load()),\n ctx=Load()))]),\n body=[\n Assign(\n targets=[\n Name(id='baseline', ctx=Store())],\n value=Call(\n func=Name(id='meta_get', ctx=Load()),\n args=[\n Name(id='con', ctx=Load()),\n Constant(value='baseline_created_at')])),\n Assign(\n targets=[\n Name(id='baseline_mode', ctx=Store())],\n value=Compare(\n left=Call(\n func=Attribute(\n value=Call(\n func=Attribute(\n value=Subscript(\n value=Name(id='cfg', ctx=Load()),\n slice=Constant(value='monitor'),\n ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='baseline_no_email'),\n Constant(value='yes')]),\n attr='lower',\n ctx=Load())),\n ops=[\n In()],\n comparators=[\n Set(\n elts=[\n Constant(value='yes'),\n Constant(value='true'),\n Constant(value='1'),\n Constant(value='on')])])),\n Assign(\n targets=[\n Name(id='new_events', ctx=Store())],\n value=Constant(value=0)),\n Assign(\n targets=[\n Name(id='resolved_events', ctx=Store())],\n value=Constant(value=0)),\n For(\n target=Name(id='report', ctx=Store()),\n iter=Name(id='reports', ctx=Load()),\n body=[\n Assign(\n targets=[\n Name(id='row', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Call(\n func=Attribute(\n value=Name(id='con', ctx=Load()),\n attr='execute',\n ctx=Load()),\n args=[\n Constant(value='SELECT status FROM reports WHERE report_id=?'),\n Tuple(\n elts=[\n Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='report_id'),\n ctx=Load())],\n ctx=Load())]),\n attr='fetchone',\n ctx=Load()))),\n If(\n test=Compare(\n left=Name(id='row', ctx=Load()),\n ops=[\n Is()],\n comparators=[\n Constant(value=None)]),\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='con', ctx=Load()),\n attr='execute',\n ctx=Load()),\n args=[\n Constant(value=''),\n Tuple(\n elts=[\n Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='report_id'),\n ctx=Load()),\n Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='url'),\n ctx=Load()),\n Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='title'),\n ctx=Load()),\n Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='status'),\n ctx=Load()),\n Call(\n func=Attribute(\n value=Name(id='report', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='report_count')]),\n Call(\n func=Attribute(\n value=Name(id='report', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='comment_count')]),\n Call(\n func=Attribute(\n value=Name(id='report', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='row_text'),\n Constant(value='')]),\n Call(\n func=Name(id='utc_now', ctx=Load())),\n Call(\n func=Name(id='utc_now', ctx=Load())),\n IfExp(\n test=Compare(\n left=Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='status'),\n ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='resolved')]),\n body=Call(\n func=Name(id='utc_now', ctx=Load())),\n orelse=Constant(value=None))],\n ctx=Load())])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='con', ctx=Load()),\n attr='commit',\n ctx=Load()))),\n If(\n test=BoolOp(\n op=Or(),\n values=[\n Name(id='baseline', ctx=Load()),\n UnaryOp(\n op=Not(),\n operand=Name(id='baseline_mode', ctx=Load()))]),\n body=[\n If(\n test=Compare(\n left=Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='status'),\n ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='open')]),\n body=[\n Assign(\n targets=[\n Name(id='key', ctx=Store())],\n value=BinOp(\n left=Constant(value='new:'),\n op=Add(),\n right=Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='report_id'),\n ctx=Load()))),\n If(\n test=UnaryOp(\n op=Not(),\n operand=Call(\n func=Name(id='event_sent', ctx=Load()),\n args=[\n Name(id='con', ctx=Load()),\n Name(id='key', ctx=Load())])),\n body=[\n If(\n test=Call(\n func=Name(id='send_mail', ctx=Load()),\n args=[\n Name(id='cfg', ctx=Load()),\n Name(id='secrets', ctx=Load()),\n Constant(value='Новая жалоба'),\n Call(\n func=Name(id='report_body', ctx=Load()),\n args=[\n Constant(value='Появилась новая жалоба.'),\n Name(id='report', ctx=Load())])]),\n body=[\n Expr(\n value=Call(\n func=Name(id='mark_event', ctx=Load()),\n args=[\n Name(id='con', ctx=Load()),\n Name(id='key', ctx=Load()),\n Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='report_id'),\n ctx=Load()),\n Constant(value='new')])),\n AugAssign(\n target=Name(id='new_events', ctx=Store()),\n op=Add(),\n value=Constant(value=1))])])])])],\n orelse=[\n Assign(\n targets=[\n Name(id='old_status', ctx=Store())],\n value=Subscript(\n value=Name(id='row', ctx=Load()),\n slice=Constant(value=0),\n ctx=Load())),\n If(\n test=BoolOp(\n op=And(),\n values=[\n Compare(\n left=Name(id='old_status', ctx=Load()),\n ops=[\n NotEq()],\n comparators=[\n Constant(value='resolved')]),\n Compare(\n left=Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='status'),\n ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='resolved')])]),\n body=[\n Assign(\n targets=[\n Name(id='key', ctx=Store())],\n value=BinOp(\n left=Constant(value='resolved:'),\n op=Add(),\n right=Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='report_id'),\n ctx=Load()))),\n If(\n test=UnaryOp(\n op=Not(),\n operand=Call(\n func=Name(id='event_sent', ctx=Load()),\n args=[\n Name(id='con', ctx=Load()),\n Name(id='key', ctx=Load())])),\n body=[\n If(\n test=Call(\n func=Name(id='send_mail', ctx=Load()),\n args=[\n Name(id='cfg', ctx=Load()),\n Name(id='secrets', ctx=Load()),\n Constant(value='Жалоба отработана'),\n Call(\n func=Name(id='report_body', ctx=Load()),\n args=[\n Constant(value='Жалоба перешла в обработанные.'),\n Name(id='report', ctx=Load())])]),\n body=[\n Expr(\n value=Call(\n func=Name(id='mark_event', ctx=Load()),\n args=[\n Name(id='con', ctx=Load()),\n Name(id='key', ctx=Load()),\n Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='report_id'),\n ctx=Load()),\n Constant(value='resolved')])),\n AugAssign(\n target=Name(id='resolved_events', ctx=Store()),\n op=Add(),\n value=Constant(value=1))])])]),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='con', ctx=Load()),\n attr='execute',\n ctx=Load()),\n args=[\n Constant(value=''),\n Tuple(\n elts=[\n Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='url'),\n ctx=Load()),\n Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='title'),\n ctx=Load()),\n Subscript(\n value=Name(id='report', ctx=Load()),\n slice=Constant(value='status'),\n ctx=Load()),\n Call(\n func=Attribute(\n value=Name(id='report', ctx=Load()),\n attr='get',\n ctx=Load()),\n args=[\n Constant(value='report_count')]),\n Call(\n func=Attribute(\n value=Name(id='report', ctx=Load()),\n attr='get',\n ctx=Load()),\n \nMONITOR_DUMP_SHA256=898a51f0ad422cfbd6a9dc3c30e38db7fa53aa91216f5ef5bf390e2728d2da25\nMONITOR_DUMP_TRUNCATED=true\nMONITOR_DUMP_END=process_reports\nMONITOR_DUMP_BEGIN=maybe_send_auth_required\nFunctionDef(\n name='maybe_send_auth_required',\n args=arguments(\n args=[\n arg(\n arg='con',\n annotation=Attribute(\n value=Name(id='sqlite3', ctx=Load()),\n attr='Connection',\n ctx=Load())),\n arg(\n arg='cfg',\n annotation=Attribute(\n value=Name(id='configparser', ctx=Load()),\n attr='ConfigParser',\n ctx=Load())),\n arg(\n arg='secrets',\n annotation=Subscript(\n value=Name(id='dict', ctx=Load()),\n slice=Tuple(\n elts=[\n Name(id='str', ctx=Load()),\n Name(id='str', ctx=Load())],\n ctx=Load()),\n ctx=Load())),\n arg(\n arg='final_url',\n annotation=Name(id='str', ctx=Load()))]),\n body=[\n Assign(\n targets=[\n Name(id='now_ts', ctx=Store())],\n value=Call(\n func=Name(id='int', ctx=Load()),\n args=[\n Call(\n func=Attribute(\n value=Name(id='time', ctx=Load()),\n attr='time',\n ctx=Load()))])),\n Assign(\n targets=[\n Name(id='interval', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Subscript(\n value=Name(id='cfg', ctx=Load()),\n slice=Constant(value='email'),\n ctx=Load()),\n attr='getint',\n ctx=Load()),\n args=[\n Constant(value='auth_notice_min_interval_seconds')],\n keywords=[\n keyword(\n arg='fallback',\n value=Constant(value=86400))])),\n Assign(\n targets=[\n Name(id='last_raw', ctx=Store())],\n value=BoolOp(\n op=Or(),\n values=[\n Call(\n func=Name(id='meta_get', ctx=Load()),\n args=[\n Name(id='con', ctx=Load()),\n Constant(value='last_auth_notice_ts')]),\n Constant(value='0')])),\n Try(\n body=[\n Assign(\n targets=[\n Name(id='last', ctx=Store())],\n value=Call(\n func=Name(id='int', ctx=Load()),\n args=[\n Name(id='last_raw', ctx=Load())]))],\n handlers=[\n ExceptHandler(\n type=Name(id='ValueError', ctx=Load()),\n body=[\n Assign(\n targets=[\n Name(id='last', ctx=Store())],\n value=Constant(value=0))])]),\n If(\n test=Compare(\n left=BinOp(\n left=Name(id='now_ts', ctx=Load()),\n op=Sub(),\n right=Name(id='last', ctx=Load())),\n ops=[\n GtE()],\n comparators=[\n Name(id='interval', ctx=Load())]),\n body=[\n If(\n test=Call(\n func=Name(id='send_mail', ctx=Load()),\n args=[\n Name(id='cfg', ctx=Load()),\n Name(id='secrets', ctx=Load()),\n Constant(value='Нужна повторная авторизация'),\n JoinedStr(\n values=[\n Constant(value=''),\n FormattedValue(\n value=Name(id='final_url', ctx=Load()),\n conversion=-1),\n Constant(value=''),\n FormattedValue(\n value=Call(\n func=Name(id='utc_now', ctx=Load())),\n conversion=-1),\n Constant(value='')])]),\n body=[\n Expr(\n value=Call(\n func=Name(id='meta_set', ctx=Load()),\n args=[\n Name(id='con', ctx=Load()),\n Constant(value='last_auth_notice_ts'),\n Call(\n func=Name(id='str', ctx=Load()),\n args=[\n Name(id='now_ts', ctx=Load())])]))])])],\n returns=Constant(value=None))\nMONITOR_DUMP_SHA256=396252a7a870238ab735e22192d95a704509acc56af3bca2289e5e307c4e5f10\nMONITOR_DUMP_TRUNCATED=false\nMONITOR_DUMP_END=maybe_send_auth_required\nMONITOR_DUMP_BEGIN=run_once\nFunctionDef(\n name='run_once',\n args=arguments(),\n body=[\n Assign(\n targets=[\n Name(id='lock', ctx=Store())],\n value=Call(\n func=Name(id='acquire_lock', ctx=Load()))),\n If(\n test=Compare(\n left=Name(id='lock', ctx=Load()),\n ops=[\n Is()],\n comparators=[\n Constant(value=None)]),\n body=[\n Expr(\n value=Call(\n func=Name(id='log', ctx=Load()),\n args=[\n Constant(value='LOCK_BUSY previous run still active')])),\n Expr(\n value=Call(\n func=Name(id='write_health', ctx=Load()),\n args=[\n Constant(value='LOCK_BUSY')])),\n Return(\n value=Constant(value=0))]),\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='cfg', ctx=Store()),\n Name(id='secrets', ctx=Store())],\n ctx=Store())],\n value=Call(\n func=Name(id='load_config', ctx=Load()))),\n Assign(\n targets=[\n Name(id='con', ctx=Store())],\n value=Call(\n func=Name(id='connect_db', ctx=Load()))),\n Try(\n body=[\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='final_url', ctx=Store()),\n Name(id='text', ctx=Store())],\n ctx=Store())],\n value=Call(\n func=Name(id='fetch_reports_page', ctx=Load()),\n args=[\n Name(id='cfg', ctx=Load()),\n Name(id='secrets', ctx=Load())])),\n If(\n test=Call(\n func=Name(id='login_required', ctx=Load()),\n args=[\n Name(id='final_url', ctx=Load()),\n Name(id='text', ctx=Load())]),\n body=[\n Expr(\n value=Call(\n func=Name(id='maybe_send_auth_required', ctx=Load()),\n args=[\n Name(id='con', ctx=Load()),\n Name(id='cfg', ctx=Load()),\n Name(id='secrets', ctx=Load()),\n Name(id='final_url', ctx=Load())])),\n Expr(\n value=Call(\n func=Name(id='write_health', ctx=Load()),\n args=[\n Constant(value='AUTH_REQUIRED')],\n keywords=[\n keyword(\n arg='url',\n value=Name(id='final_url', ctx=Load()))])),\n Return(\n value=Constant(value=2))]),\n Assign(\n targets=[\n Name(id='reports', ctx=Store())],\n value=Call(\n func=Name(id='parse_reports', ctx=Load()),\n args=[\n Name(id='text', ctx=Load()),\n Name(id='cfg', ctx=Load())])),\n If(\n test=UnaryOp(\n op=Not(),\n operand=Name(id='reports', ctx=Load())),\n body=[\n Expr(\n value=Call(\n func=Name(id='write_health', ctx=Load()),\n args=[\n Constant(value='ERROR')],\n keywords=[\n keyword(\n arg='reason',\n value=Constant(value='no_reports_parsed')),\n keyword(\n arg='url',\n value=Name(id='final_url', ctx=Load()))])),\n Expr(\n value=Call(\n func=Name(id='log', ctx=Load()),\n args=[\n Constant(value='ERROR no reports parsed')])),\n Return(\n value=Constant(value=1))]),\n Assign(\n targets=[\n Tuple(\n elts=[\n Name(id='new_events', ctx=Store()),\n Name(id='resolved_events', ctx=Store())],\n ctx=Store())],\n value=Call(\n func=Name(id='process_reports', ctx=Load()),\n args=[\n Name(id='con', ctx=Load()),\n Name(id='cfg', ctx=Load()),\n Name(id='secrets', ctx=Load()),\n Name(id='reports', ctx=Load())])),\n Assign(\n targets=[\n Name(id='open_count', ctx=Store())],\n value=Call(\n func=Name(id='sum', ctx=Load()),\n args=[\n GeneratorExp(\n elt=Constant(value=1),\n generators=[\n comprehension(\n target=Name(id='r', ctx=Store()),\n iter=Name(id='reports', ctx=Load()),\n ifs=[\n Compare(\n left=Subscript(\n value=Name(id='r', ctx=Load()),\n slice=Constant(value='status'),\n ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='open')])],\n is_async=0)])])),\n Assign(\n targets=[\n Name(id='resolved_count', ctx=Store())],\n value=Call(\n func=Name(id='sum', ctx=Load()),\n args=[\n GeneratorExp(\n elt=Constant(value=1),\n generators=[\n comprehension(\n target=Name(id='r', ctx=Store()),\n iter=Name(id='reports', ctx=Load()),\n ifs=[\n Compare(\n left=Subscript(\n value=Name(id='r', ctx=Load()),\n slice=Constant(value='status'),\n ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='resolved')])],\n is_async=0)])])),\n Expr(\n value=Call(\n func=Name(id='write_health', ctx=Load()),\n args=[\n Constant(value='OK')],\n keywords=[\n keyword(\n arg='url',\n value=Name(id='final_url', ctx=Load())),\n keyword(\n arg='reports',\n value=Call(\n func=Name(id='len', ctx=Load()),\n args=[\n Name(id='reports', ctx=Load())])),\n keyword(\n arg='open',\n value=Name(id='open_count', ctx=Load())),\n keyword(\n arg='resolved',\n value=Name(id='resolved_count', ctx=Load())),\n keyword(\n arg='new_events',\n value=Name(id='new_events', ctx=Load())),\n keyword(\n arg='resolved_events',\n value=Name(id='resolved_events', ctx=Load())),\n keyword(\n arg='smtp_configured',\n value=IfExp(\n test=Call(\n func=Name(id='smtp_ready', ctx=Load()),\n args=[\n Name(id='secrets', ctx=Load())]),\n body=Constant(value='yes'),\n orelse=Constant(value='no')))])),\n Expr(\n value=Call(\n func=Name(id='log', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='OK reports='),\n FormattedValue(\n value=Call(\n func=Name(id='len', ctx=Load()),\n args=[\n Name(id='reports', ctx=Load())]),\n conversion=-1),\n Constant(value=' open='),\n FormattedValue(\n value=Name(id='open_count', ctx=Load()),\n conversion=-1),\n Constant(value=' resolved='),\n FormattedValue(\n value=Name(id='resolved_count', ctx=Load()),\n conversion=-1),\n Constant(value=' new='),\n FormattedValue(\n value=Name(id='new_events', ctx=Load()),\n conversion=-1),\n Constant(value=' done='),\n FormattedValue(\n value=Name(id='resolved_events', ctx=Load()),\n conversion=-1)])])),\n Return(\n value=Constant(value=0))],\n handlers=[\n ExceptHandler(\n type=Attribute(\n value=Attribute(\n value=Name(id='urllib', ctx=Load()),\n attr='error',\n ctx=Load()),\n attr='HTTPError',\n ctx=Load()),\n name='e',\n body=[\n Expr(\n value=Call(\n func=Name(id='write_health', ctx=Load()),\n args=[\n Constant(value='ERROR')],\n keywords=[\n keyword(\n arg='error',\n value=JoinedStr(\n values=[\n Constant(value='HTTPError '),\n FormattedValue(\n value=Attribute(\n value=Name(id='e', ctx=Load()),\n attr='code',\n ctx=Load()),\n conversion=-1)]))])),\n Expr(\n value=Call(\n func=Name(id='log', ctx=Load()),\n args=[\n JoinedStr(\n values=[\n Constant(value='ERROR HTTPError '),\n FormattedValue(\n value=Attribute(\n value=Name(id='e', ctx=Load()),\n attr='code',\n ctx=Load()),\n conversion=-1)])])),\n Return(\n value=Constant(value=1))]),\n ExceptHandler(\n type=Name(id='Exception', ctx=Load()),\n name='e',\n body=[\n Expr(\n value=Call(\n func=Name(id='write_health', ctx=Load()),\n args=[\n Constant(value='ERROR')],\n keywords=[\n keyword(\n arg='error',\n value=Call(\n func=Name(id='repr', ctx=Load()),\n args=[\n Name(id='e', ctx=Load())]))])),\n Expr(\n value=Call(\n func=Name(id='log', ctx=Load()),\n args=[\n BinOp(\n left=BinOp(\n left=BinOp(\n left=Constant(value='ERROR '),\n op=Add(),\n right=Call(\n func=Name(id='repr', ctx=Load()),\n args=[\n Name(id='e', ctx=Load())])),\n op=Add(),\n right=Constant(value=' ')),\n op=Add(),\n right=Call(\n func=Attribute(\n value=Name(id='traceback', ctx=Load()),\n attr='format_exc',\n ctx=Load())))])),\n Return(\n value=Constant(value=1))])],\n finalbody=[\n Try(\n body=[\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='fcntl', ctx=Load()),\n attr='flock',\n ctx=Load()),\n args=[\n Call(\n func=Attribute(\n value=Name(id='lock', ctx=Load()),\n attr='fileno',\n ctx=Load())),\n Attribute(\n value=Name(id='fcntl', ctx=Load()),\n attr='LOCK_UN',\n ctx=Load())])),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='lock', ctx=Load()),\n attr='close',\n ctx=Load())))],\n handlers=[\n ExceptHandler(\n type=Name(id='Exception', ctx=Load()),\n body=[\n Pass()])])])],\n returns=Name(id='int', ctx=Load()))\nMONITOR_DUMP_SHA256=eceb52bc948ca75d79fddb992ecc9e3c61ae10413339a5d6d14b5c20b00407db\nMONITOR_DUMP_TRUNCATED=false\nMONITOR_DUMP_END=run_once\nMONITOR_DUMP_BEGIN=show_status\nFunctionDef(\n name='show_status',\n args=arguments(),\n body=[\n If(\n test=Call(\n func=Attribute(\n value=Name(id='HEALTH_PATH', ctx=Load()),\n attr='exists',\n ctx=Load())),\n body=[\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n Call(\n func=Attribute(\n value=Name(id='HEALTH_PATH', ctx=Load()),\n attr='read_text',\n ctx=Load()),\n keywords=[\n keyword(\n arg='encoding',\n value=Constant(value='utf-8'))])],\n keywords=[\n keyword(\n arg='end',\n value=Constant(value=''))]))],\n orelse=[\n Expr(\n value=Call(\n func=Name(id='print', ctx=Load()),\n args=[\n Constant(value='STATUS=UNKNOWN')]))]),\n Return(\n value=Constant(value=0))],\n returns=Name(id='int', ctx=Load()))\nMONITOR_DUMP_SHA256=ee45eb0e5db867e890df5fce7f7afa8ad77ba828845e20e5e7d1dcfdab13e551\nMONITOR_DUMP_TRUNCATED=false\nMONITOR_DUMP_END=show_status\nMONITOR_DUMP_BEGIN=main\nFunctionDef(\n name='main',\n args=arguments(),\n body=[\n Assign(\n targets=[\n Name(id='parser', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='argparse', ctx=Load()),\n attr='ArgumentParser',\n ctx=Load()))),\n Expr(\n value=Call(\n func=Attribute(\n value=Name(id='parser', ctx=Load()),\n attr='add_argument',\n ctx=Load()),\n args=[\n Constant(value='cmd')],\n keywords=[\n keyword(\n arg='choices',\n value=List(\n elts=[\n Constant(value='run'),\n Constant(value='status')],\n ctx=Load())),\n keyword(\n arg='nargs',\n value=Constant(value='?')),\n keyword(\n arg='default',\n value=Constant(value='run'))])),\n Assign(\n targets=[\n Name(id='args', ctx=Store())],\n value=Call(\n func=Attribute(\n value=Name(id='parser', ctx=Load()),\n attr='parse_args',\n ctx=Load()))),\n If(\n test=Compare(\n left=Attribute(\n value=Name(id='args', ctx=Load()),\n attr='cmd',\n ctx=Load()),\n ops=[\n Eq()],\n comparators=[\n Constant(value='status')]),\n body=[\n Return(\n value=Call(\n func=Name(id='show_status', ctx=Load())))]),\n Return(\n value=Call(\n func=Name(id='run_once', ctx=Load())))],\n returns=Name(id='int', ctx=Load()))\nMONITOR_DUMP_SHA256=02ad6bee6cd63312a57b18daedc366b2edfc1b747c3ac27f5bd9cfd71210fb2e\nMONITOR_DUMP_TRUNCATED=false\nMONITOR_DUMP_END=main\nMONITOR_SCAN_OK=true\nUNIT_PROBE_QM_RC=0\nUNIT_PROBE_STDERR_PRESENT=false\nUNIT_PROBE_JSON=true\nUNIT_PROBE_GUEST_EXITCODE=0\nactive\nenabled\nsuccess\n0\nMAIL_DRY_RUN_ONLY=true\nMAIL_SENT=false\nDECISION=PASS_TITLE_AND_ALERT_SOURCE_RCA\nNEXT_GATE=DESIGN_ATOMIC_FALSE_ALERT_AND_TITLE_REPAIR_FROM_99564\nTASK_RESULT=SKLADCHIK_COMPLAINTS_TITLE_TOKEN_RCA\nCHANGES_MADE=false\nROLLBACK_STARTED=false\nROLLBACK_RESTORED=null\nMUTATION_OUTCOME=NO_MUTATION\n" } diff --git a/runtime/latest.txt b/runtime/latest.txt index 97f53bbd..4d702feb 100644 --- a/runtime/latest.txt +++ b/runtime/latest.txt @@ -1,15 +1,15 @@ CHAT_OUTPUT_BEGIN -COMMAND_ID=SUPPORT-261004-SKLADCHIK-COMPLAINTS-TITLE-SOURCE-RCA-99563R1 +COMMAND_ID=SUPPORT-261004-SKLADCHIK-COMPLAINTS-TITLE-TOKEN-RCA-99564R1 STATUS=OK RC=0 HOST=pve01 MODE=read-only -COMPONENT=skladchik-complaints-title-source-rca +COMPONENT=skladchik-complaints-title-token-rca REFERENCE_REGISTER_CHECK=OK REFERENCE_SHA256=5a3d8e5154c41cb582a4e0aca68090be1f0138918bf82131a948df326f9d8d66 ERROR_REGISTER_CHECK=OK ERROR_REGISTER_SHA256=3b09a553ec0f527ed3afeed4753f52a74ee3036045bbfb3c685e9f8af4ba7ba0 -COMMAND_SHA256=c28f66f660512e5078b815cc6a12e6fdac5e9ebeea8aba7a6d31c5277543509a +COMMAND_SHA256=bbe4077da8ab20fa07a5b8458821ecbe544b502ccbb871742ef07ac2d14d220e DUPLICATE_FAILED_COMMAND_BLOCKED=false EXECUTION_STARTED=true CHANGE_DECLARED=false @@ -24,10 +24,10 @@ MUTATION_OUTCOME=NO_MUTATION SANITIZED=yes SECRETS_INCLUDED=no PRIVATE_ADDRESSES_INCLUDED=no -RAW_EVIDENCE_SHA256=fdeb4b237c7563f75b29c383fd5a81258cd6eccff766eed11efb65bd15795027 -SANITIZED_OUTPUT_SHA256=fdeb4b237c7563f75b29c383fd5a81258cd6eccff766eed11efb65bd15795027 +RAW_EVIDENCE_SHA256=f375d4e36d4d0a70ebad8412a2dd1f0e4faa25f8c6f2d4d648a215164c8f2d2c +SANITIZED_OUTPUT_SHA256=f375d4e36d4d0a70ebad8412a2dd1f0e4faa25f8c6f2d4d648a215164c8f2d2c OUTPUT_BEGIN -SKLADCHIK_COMPLAINTS_TITLE_SOURCE_RCA=V1 +SKLADCHIK_COMPLAINTS_TITLE_TOKEN_RCA=V1 MODE=read-only NO_MAIL_SEND=true NO_SERVICE_RESTART=true @@ -36,25 +36,3848 @@ NO_NETWORK_MUTATION=true NO_SOURCE_MUTATION=true HOST_PVE01=true VM170_STATUS=running +HEALTH_SCAN=V1 HEALTH_PRESENT=true HEALTH_SHA256=918f3d1db31c64fe5f7548c3da6183ca6bf8be80384fa0673c55f68826dcc717 -HEALTH_WT0_LITERAL_COUNT=5 +HEALTH_BYTES=16080 +HEALTH_FUNCTION_COUNT=22 +HEALTH_FUNC=utc_now:24:25 +HEALTH_FUNC=ts:28:29 +HEALTH_FUNC=log:32:35 +HEALTH_FUNC=run_cmd:38:43 +HEALTH_FUNC=parse_kv_file:46:54 +HEALTH_FUNC=iso_age_seconds:57:64 +HEALTH_FUNC=load_state:67:71 +HEALTH_FUNC=save_state:74:78 +HEALTH_FUNC=load_monitor_module:81:87 +HEALTH_FUNC=send_mail:90:93 +HEALTH_FUNC=systemd_value:96:98 +HEALTH_FUNC=route_ok:101:103 +HEALTH_FUNC=problem_to_ru:106:129 +HEALTH_FUNC=yes_no_ru:132:133 +HEALTH_FUNC=status_ru:136:145 +HEALTH_FUNC=build_status:148:206 +HEALTH_FUNC=status_to_body:209:253 +HEALTH_FUNC=write_alert_health:256:280 +HEALTH_FUNC=do_heartbeat:283:294 +HEALTH_FUNC=do_check:297:332 +HEALTH_FUNC=do_status:335:344 +HEALTH_FUNC=main:347:356 +HEALTH_RELEVANT_COUNT=9 +HEALTH_DUMP_BEGIN=parse_kv_file +FunctionDef( + name='parse_kv_file', + args=arguments( + args=[ + arg( + arg='path', + annotation=Name(id='Path', ctx=Load()))]), + body=[ + Assign( + targets=[ + Name(id='data', ctx=Store())], + value=Dict()), + If( + test=UnaryOp( + op=Not(), + operand=Call( + func=Attribute( + value=Name(id='path', ctx=Load()), + attr='exists', + ctx=Load()))), + body=[ + Return( + value=Name(id='data', ctx=Load()))]), + For( + target=Name(id='raw', ctx=Store()), + iter=Call( + func=Attribute( + value=Call( + func=Attribute( + value=Name(id='path', ctx=Load()), + attr='read_text', + ctx=Load()), + keywords=[ + keyword( + arg='encoding', + value=Constant(value='utf-8')), + keyword( + arg='errors', + value=Constant(value='replace'))]), + attr='splitlines', + ctx=Load())), + body=[ + If( + test=Compare( + left=Constant(value='='), + ops=[ + In()], + comparators=[ + Name(id='raw', ctx=Load())]), + body=[ + Assign( + targets=[ + Tuple( + elts=[ + Name(id='k', ctx=Store()), + Name(id='v', ctx=Store())], + ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='raw', ctx=Load()), + attr='split', + ctx=Load()), + args=[ + Constant(value='='), + Constant(value=1)])), + Assign( + targets=[ + Subscript( + value=Name(id='data', ctx=Load()), + slice=Call( + func=Attribute( + value=Name(id='k', ctx=Load()), + attr='strip', + ctx=Load())), + ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='v', ctx=Load()), + attr='strip', + ctx=Load())))])]), + Return( + value=Name(id='data', ctx=Load()))]) +HEALTH_DUMP_SHA256=577b27aca6d27fc787beed7fda2903d72e67f386753fadfc23325e1279ff8082 +HEALTH_DUMP_TRUNCATED=false +HEALTH_DUMP_END=parse_kv_file +HEALTH_DUMP_BEGIN=send_mail +FunctionDef( + name='send_mail', + args=arguments( + args=[ + arg( + arg='subject', + annotation=Name(id='str', ctx=Load())), + arg( + arg='body', + annotation=Name(id='str', ctx=Load()))]), + body=[ + Assign( + targets=[ + Name(id='mod', ctx=Store())], + value=Call( + func=Name(id='load_monitor_module', ctx=Load()))), + Assign( + targets=[ + Tuple( + elts=[ + Name(id='cfg', ctx=Store()), + Name(id='secrets', ctx=Store())], + ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='mod', ctx=Load()), + attr='load_config', + ctx=Load()))), + Return( + value=Call( + func=Name(id='bool', ctx=Load()), + args=[ + Call( + func=Attribute( + value=Name(id='mod', ctx=Load()), + attr='send_mail', + ctx=Load()), + args=[ + Name(id='cfg', ctx=Load()), + Name(id='secrets', ctx=Load()), + Name(id='subject', ctx=Load()), + Name(id='body', ctx=Load())])]))], + returns=Name(id='bool', ctx=Load())) +HEALTH_DUMP_SHA256=949d900c876b9ee94a5fa7eca5792121fe1e77eee64b76fe447c8c8ba94b48c6 +HEALTH_DUMP_TRUNCATED=false +HEALTH_DUMP_END=send_mail +HEALTH_DUMP_BEGIN=route_ok +FunctionDef( + name='route_ok', + args=arguments(), + body=[ + Assign( + targets=[ + Tuple( + elts=[ + Name(id='rc', ctx=Store()), + Name(id='out', ctx=Store())], + ctx=Store())], + value=Call( + func=Name(id='run_cmd', ctx=Load()), + args=[ + List( + elts=[ + Constant(value='ip'), + Constant(value='route'), + Constant(value='get'), + Constant(value='')], + ctx=Load())], + keywords=[ + keyword( + arg='timeout', + value=Constant(value=10))])), + Return( + value=Tuple( + elts=[ + BoolOp( + op=And(), + values=[ + Compare( + left=Name(id='rc', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value=0)]), + Compare( + left=Constant(value=' dev wt0 '), + ops=[ + In()], + comparators=[ + JoinedStr( + values=[ + Constant(value=' '), + FormattedValue( + value=Name(id='out', ctx=Load()), + conversion=-1), + Constant(value=' ')])])]), + Name(id='out', ctx=Load())], + ctx=Load()))]) +HEALTH_DUMP_SHA256=b3c72e69fe87a4333c66b82a8e898bc417dc642ecd71381f1bb45f6b26f7e255 +HEALTH_DUMP_TRUNCATED=false +HEALTH_DUMP_END=route_ok +HEALTH_DUMP_BEGIN=status_ru +FunctionDef( + name='status_ru', + args=arguments( + args=[ + arg( + arg='value', + annotation=Name(id='str', ctx=Load()))]), + body=[ + If( + test=Compare( + left=Name(id='value', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='OK')]), + body=[ + Return( + value=Constant(value='OK'))]), + If( + test=Compare( + left=Name(id='value', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='ALERT')]), + body=[ + Return( + value=Constant(value='ТРЕВОГА'))]), + If( + test=Compare( + left=Name(id='value', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='AUTH_REQUIRED')]), + body=[ + Return( + value=Constant(value='нужна повторная авторизация'))]), + If( + test=Compare( + left=Name(id='value', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='ERROR')]), + body=[ + Return( + value=Constant(value='ошибка'))]), + Return( + value=BoolOp( + op=Or(), + values=[ + Name(id='value', ctx=Load()), + Constant(value='неизвестно')]))], + returns=Name(id='str', ctx=Load())) +HEALTH_DUMP_SHA256=177f282793ef16e747defa8dbd1fb35e704b9d54ffa892799e430ac9e0ecf22a +HEALTH_DUMP_TRUNCATED=false +HEALTH_DUMP_END=status_ru +HEALTH_DUMP_BEGIN=build_status +FunctionDef( + name='build_status', + args=arguments(), + body=[ + Assign( + targets=[ + Name(id='problems', ctx=Store())], + value=List(ctx=Load())), + Assign( + targets=[ + Name(id='health', ctx=Store())], + value=Call( + func=Name(id='parse_kv_file', ctx=Load()), + args=[ + Name(id='HEALTH_PATH', ctx=Load())])), + Assign( + targets=[ + Name(id='timer_active', ctx=Store())], + value=Call( + func=Name(id='systemd_value', ctx=Load()), + args=[ + Constant(value='skladchik-reports-monitor.timer'), + Constant(value='ActiveState')])), + Assign( + targets=[ + Tuple( + elts=[ + Name(id='timer_enabled_rc', ctx=Store()), + Name(id='timer_enabled', ctx=Store())], + ctx=Store())], + value=Call( + func=Name(id='run_cmd', ctx=Load()), + args=[ + List( + elts=[ + Constant(value='systemctl'), + Constant(value='is-enabled'), + Constant(value='skladchik-reports-monitor.timer')], + ctx=Load())], + keywords=[ + keyword( + arg='timeout', + value=Constant(value=10))])), + Assign( + targets=[ + Tuple( + elts=[ + Name(id='watchdog_enabled_rc', ctx=Store()), + Name(id='watchdog_enabled', ctx=Store())], + ctx=Store())], + value=Call( + func=Name(id='run_cmd', ctx=Load()), + args=[ + List( + elts=[ + Constant(value='systemctl'), + Constant(value='is-enabled'), + Constant(value='skladchik-reports-monitor-watchdog.timer')], + ctx=Load())], + keywords=[ + keyword( + arg='timeout', + value=Constant(value=10))])), + Assign( + targets=[ + Tuple( + elts=[ + Name(id='heartbeat_enabled_rc', ctx=Store()), + Name(id='heartbeat_enabled', ctx=Store())], + ctx=Store())], + value=Call( + func=Name(id='run_cmd', ctx=Load()), + args=[ + List( + elts=[ + Constant(value='systemctl'), + Constant(value='is-enabled'), + Constant(value='skladchik-reports-monitor-heartbeat.timer')], + ctx=Load())], + keywords=[ + keyword( + arg='timeout', + value=Constant(value=10))])), + Assign( + targets=[ + Tuple( + elts=[ + Name(id='r_ok', ctx=Store()), + Name(id='route_text', ctx=Store())], + ctx=Store())], + value=Call( + func=Name(id='route_ok', ctx=Load()))), + If( + test=Compare( + left=Name(id='timer_active', ctx=Load()), + ops=[ + NotEq()], + comparators=[ + Constant(value='active')]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='problems', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='monitor_timer_not_active:'), + FormattedValue( + value=Name(id='timer_active', ctx=Load()), + conversion=-1)])]))]), + If( + test=BoolOp( + op=Or(), + values=[ + Compare( + left=Name(id='timer_enabled_rc', ctx=Load()), + ops=[ + NotEq()], + comparators=[ + Constant(value=0)]), + Compare( + left=Name(id='timer_enabled', ctx=Load()), + ops=[ + NotEq()], + comparators=[ + Constant(value='enabled')])]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='problems', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='monitor_timer_not_enabled:'), + FormattedValue( + value=Name(id='timer_enabled', ctx=Load()), + conversion=-1)])]))]), + If( + test=UnaryOp( + op=Not(), + operand=Call( + func=Attribute( + value=Name(id='HEALTH_PATH', ctx=Load()), + attr='exists', + ctx=Load()))), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='problems', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + Constant(value='monitor_health_missing')]))]), + If( + test=Compare( + left=Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='STATUS')]), + ops=[ + NotEq()], + comparators=[ + Constant(value='OK')]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='problems', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='monitor_status_not_ok:'), + FormattedValue( + value=Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='STATUS'), + Constant(value='missing')]), + conversion=-1)])]))]), + Assign( + targets=[ + Name(id='age', ctx=Store())], + value=Call( + func=Name(id='iso_age_seconds', ctx=Load()), + args=[ + Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='TS'), + Constant(value='')])])), + If( + test=Compare( + left=Name(id='age', ctx=Load()), + ops=[ + Is()], + comparators=[ + Constant(value=None)]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='problems', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + Constant(value='monitor_health_ts_invalid')]))], + orelse=[ + If( + test=Compare( + left=Name(id='age', ctx=Load()), + ops=[ + Gt()], + comparators=[ + Name(id='MAX_HEALTH_AGE_SECONDS', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='problems', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='monitor_health_stale:'), + FormattedValue( + value=Name(id='age', ctx=Load()), + conversion=-1), + Constant(value='s')])]))])]), + Try( + body=[ + Assign( + targets=[ + Name(id='reports', ctx=Store())], + value=Call( + func=Name(id='int', ctx=Load()), + args=[ + Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='reports'), + Constant(value='-1')])]))], + handlers=[ + ExceptHandler( + type=Name(id='ValueError', ctx=Load()), + body=[ + Assign( + targets=[ + Name(id='reports', ctx=Store())], + value=UnaryOp( + op=USub(), + operand=Constant(value=1)))])]), + If( + test=Compare( + left=Name(id='reports', ctx=Load()), + ops=[ + LtE()], + comparators=[ + Constant(value=0)]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='problems', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='monitor_reports_bad:'), + FormattedValue( + value=Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='reports'), + Constant(value='missing')]), + conversion=-1)])]))]), + If( + test=Compare( + left=Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='')]), + ops=[ + NotIn()], + comparators=[ + Tuple( + elts=[ + Constant(value='yes'), + Constant(value='empty')], + ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='problems', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value=''), + FormattedValue( + value=Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value=''), + Constant(value='missing')]), + conversion=-1)])]))]), + Assign( + targets=[ + Name(id='expiry_status', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value=''), + Constant(value='')])), + Assign( + targets=[ + Name(id='expires_raw', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value=''), + Constant(value='')])), + Try( + body=[ + Assign( + targets=[ + Name(id='expires_in', ctx=Store())], + value=Call( + func=Name(id='int', ctx=Load()), + args=[ + Name(id='expires_raw', ctx=Load())]))], + handlers=[ + ExceptHandler( + type=Name(id='Exception', ctx=Load()), + body=[ + Assign( + targets=[ + Name(id='expires_in', ctx=Store())], + value=Constant(value=None))])]), + If( + test=Compare( + left=Name(id='expiry_status', ctx=Load()), + ops=[ + In()], + comparators=[ + Tuple( + elts=[ + Constant(value=''), + Constant(value=''), + Constant(value=''), + Constant(value='ERROR')], + ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='problems', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + Constant(value='')]))], + orelse=[ + If( + test=BoolOp( + op=Or(), + values=[ + Compare( + left=Name(id='expiry_status', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='EXPIRED')]), + BoolOp( + op=And(), + values=[ + Compare( + left=Name(id='expires_in', ctx=Load()), + ops=[ + IsNot()], + comparators=[ + Constant(value=None)]), + Compare( + left=Name(id='expires_in', ctx=Load()), + ops=[ + LtE()], + comparators=[ + Constant(value=0)])])]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='problems', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + Constant(value='')]))], + orelse=[ + If( + test=BoolOp( + op=Or(), + values=[ + Compare( + left=Name(id='expiry_status', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='WARN')]), + BoolOp( + op=And(), + values=[ + Compare( + left=Name(id='expires_in', ctx=Load()), + ops=[ + IsNot()], + comparators=[ + Constant(value=None)]), + Compare( + left=Name(id='expires_in', ctx=Load()), + ops=[ + Lt()], + comparators=[ + Name(id='COOKIE +HEALTH_DUMP_SHA256=d30ee0c7a70105bffab10e001bddfad80466fe5a99394d96b4449e991cbfbeaf +HEALTH_DUMP_TRUNCATED=true +HEALTH_DUMP_END=build_status +HEALTH_DUMP_BEGIN=status_to_body +FunctionDef( + name='status_to_body', + args=arguments( + args=[ + arg(arg='status'), + arg( + arg='mode', + annotation=Name(id='str', ctx=Load()))]), + body=[ + Assign( + targets=[ + Name(id='health', ctx=Store())], + value=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='health'), + ctx=Load())), + Assign( + targets=[ + Name(id='lines', ctx=Store())], + value=List(ctx=Load())), + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='Мониторинг жалоб Складчика: '), + FormattedValue( + value=Name(id='mode', ctx=Load()), + conversion=-1)])])), + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='Время UTC: '), + FormattedValue( + value=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='ts'), + ctx=Load()), + conversion=-1)])])), + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='Общий статус: '), + FormattedValue( + value=IfExp( + test=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='ok'), + ctx=Load()), + body=Constant(value='OK'), + orelse=Constant(value='ТРЕВОГА')), + conversion=-1)])])), + If( + test=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='problems'), + ctx=Load()), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + Constant(value='Проблемы:')])), + For( + target=Name(id='problem', ctx=Store()), + iter=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='problems'), + ctx=Load()), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='- '), + FormattedValue( + value=Call( + func=Name(id='problem_to_ru', ctx=Load()), + args=[ + Name(id='problem', ctx=Load())]), + conversion=-1)])]))])]), + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + Constant(value='')])), + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + Constant(value='Состояние основного монитора:')])), + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='- Статус: '), + FormattedValue( + value=Call( + func=Name(id='status_ru', ctx=Load()), + args=[ + Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='STATUS'), + Constant(value='missing')])]), + conversion=-1)])])), + If( + test=Compare( + left=Constant(value='TS'), + ops=[ + In()], + comparators=[ + Name(id='health', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='- Последний успешный опрос UTC: '), + FormattedValue( + value=Subscript( + value=Name(id='health', ctx=Load()), + slice=Constant(value='TS'), + ctx=Load()), + conversion=-1)])]))]), + If( + test=Compare( + left=Constant(value='url'), + ops=[ + In()], + comparators=[ + Name(id='health', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='- URL: '), + FormattedValue( + value=Subscript( + value=Name(id='health', ctx=Load()), + slice=Constant(value='url'), + ctx=Load()), + conversion=-1)])]))]), + If( + test=Compare( + left=Constant(value='reports'), + ops=[ + In()], + comparators=[ + Name(id='health', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='- Всего жалоб на странице: '), + FormattedValue( + value=Subscript( + value=Name(id='health', ctx=Load()), + slice=Constant(value='reports'), + ctx=Load()), + conversion=-1)])]))]), + If( + test=Compare( + left=Constant(value='open'), + ops=[ + In()], + comparators=[ + Name(id='health', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='- Открытые / в работе: '), + FormattedValue( + value=Subscript( + value=Name(id='health', ctx=Load()), + slice=Constant(value='open'), + ctx=Load()), + conversion=-1)])]))]), + If( + test=Compare( + left=Constant(value='resolved'), + ops=[ + In()], + comparators=[ + Name(id='health', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='- Закрытые / отработанные: '), + FormattedValue( + value=Subscript( + value=Name(id='health', ctx=Load()), + slice=Constant(value='resolved'), + ctx=Load()), + conversion=-1)])]))]), + If( + test=Compare( + left=Constant(value='session_keepalive'), + ops=[ + In()], + comparators=[ + Name(id='health', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + Constant(value='')]))]), + If( + test=Compare( + left=Constant(value=''), + ops=[ + In()], + comparators=[ + Name(id='health', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value=''), + FormattedValue( + value=Subscript( + value=Name(id='health', ctx=Load()), + slice=Constant(value=''), + ctx=Load()), + conversion=-1), + Constant(value=', байт: '), + FormattedValue( + value=Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value=''), + Constant(value='?')]), + conversion=-1)])]))]), + If( + test=Compare( + left=Constant(value=''), + ops=[ + In()], + comparators=[ + Name(id='health', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value=''), + FormattedValue( + value=Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='')]), + conversion=-1)])])), + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value=''), + FormattedValue( + value=Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value=''), + Constant(value='?')]), + conversion=-1)])])), + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value=''), + FormattedValue( + value=Call( + func=Attribute( + value=Name(id='health', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value=''), + Constant(value='?')]), + conversion=-1)])]))]), + If( + test=Compare( + left=Constant(value='new_events'), + ops=[ + In()], + comparators=[ + Name(id='health', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='- Новые события за последний опрос: '), + FormattedValue( + value=Subscript( + value=Name(id='health', ctx=Load()), + slice=Constant(value='new_events'), + ctx=Load()), + conversion=-1)])]))]), + If( + test=Compare( + left=Constant(value='resolved_events'), + ops=[ + In()], + comparators=[ + Name(id='health', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='- Закрытые события за последний опрос: '), + FormattedValue( + value=Subscript( + value=Name(id='health', ctx=Load()), + slice=Constant(value='resolved_events'), + ctx=Load()), + conversion=-1)])]))]), + Expr( + value=Call( + func=Attribute( + value=Name(id='lines', ctx=Load()), + attr='append', + ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='- Возраст состояния, секунд: '), + FormattedValue( + value=Subscript( + value=Name(id='status', ctx=Loa +HEALTH_DUMP_SHA256=680c4e2fd2c19d569bb38130327a7044c6cd29de4d4a7490ecf3c860ee5f7865 +HEALTH_DUMP_TRUNCATED=true +HEALTH_DUMP_END=status_to_body +HEALTH_DUMP_BEGIN=do_check +FunctionDef( + name='do_check', + args=arguments(), + body=[ + Assign( + targets=[ + Name(id='status', ctx=Store())], + value=Call( + func=Name(id='build_status', ctx=Load()))), + Assign( + targets=[ + Name(id='state', ctx=Store())], + value=Call( + func=Name(id='load_state', ctx=Load()))), + Assign( + targets=[ + Name(id='now', ctx=Store())], + value=Call( + func=Name(id='int', ctx=Load()), + args=[ + Call( + func=Attribute( + value=Name(id='time', ctx=Load()), + attr='time', + ctx=Load()))])), + Assign( + targets=[ + Name(id='problem_key', ctx=Store())], + value=IfExp( + test=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='problems'), + ctx=Load()), + body=Call( + func=Attribute( + value=Call( + func=Attribute( + value=Name(id='hashlib', ctx=Load()), + attr='sha256', + ctx=Load()), + args=[ + Call( + func=Attribute( + value=Call( + func=Attribute( + value=Constant(value='|'), + attr='join', + ctx=Load()), + args=[ + Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='problems'), + ctx=Load())]), + attr='encode', + ctx=Load()), + args=[ + Constant(value='utf-8')])]), + attr='hexdigest', + ctx=Load())), + orelse=Constant(value=''))), + Assign( + targets=[ + Name(id='mail_sent', ctx=Store())], + value=Constant(value=False)), + If( + test=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='ok'), + ctx=Load()), + body=[ + If( + test=Call( + func=Attribute( + value=Name(id='state', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='active_alert')]), + body=[ + Assign( + targets=[ + Name(id='subject', ctx=Store())], + value=Constant(value='Мониторинг жалоб восстановлен: OK')), + Assign( + targets=[ + Name(id='body', ctx=Store())], + value=Call( + func=Name(id='status_to_body', ctx=Load()), + args=[ + Name(id='status', ctx=Load()), + Constant(value='восстановление')])), + Assign( + targets=[ + Name(id='mail_sent', ctx=Store())], + value=Call( + func=Name(id='send_mail', ctx=Load()), + args=[ + Name(id='subject', ctx=Load()), + Name(id='body', ctx=Load())])), + Assign( + targets=[ + Name(id='state', ctx=Store())], + value=Dict( + keys=[ + Constant(value='active_alert'), + Constant(value='last_recovery_ts')], + values=[ + Constant(value=False), + Name(id='now', ctx=Load())])), + Expr( + value=Call( + func=Name(id='log', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='RECOVERY mail_sent='), + FormattedValue( + value=Name(id='mail_sent', ctx=Load()), + conversion=-1)])]))], + orelse=[ + Expr( + value=Call( + func=Name(id='log', ctx=Load()), + args=[ + Constant(value='CHECK ok=true mail_sent=false')]))])], + orelse=[ + Assign( + targets=[ + Name(id='last_alert_ts', ctx=Store())], + value=Call( + func=Name(id='int', ctx=Load()), + args=[ + BoolOp( + op=Or(), + values=[ + Call( + func=Attribute( + value=Name(id='state', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='last_alert_ts'), + Constant(value=0)]), + Constant(value=0)])])), + Assign( + targets=[ + Name(id='last_key', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='state', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='last_problem_key'), + Constant(value='')])), + Assign( + targets=[ + Name(id='should_send', ctx=Store())], + value=BoolOp( + op=Or(), + values=[ + UnaryOp( + op=Not(), + operand=Call( + func=Attribute( + value=Name(id='state', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='active_alert')])), + Compare( + left=Name(id='last_key', ctx=Load()), + ops=[ + NotEq()], + comparators=[ + Name(id='problem_key', ctx=Load())]), + Compare( + left=BinOp( + left=Name(id='now', ctx=Load()), + op=Sub(), + right=Name(id='last_alert_ts', ctx=Load())), + ops=[ + GtE()], + comparators=[ + Name(id='ALERT_REPEAT_SECONDS', ctx=Load())])])), + If( + test=Name(id='should_send', ctx=Load()), + body=[ + Assign( + targets=[ + Name(id='subject', ctx=Store())], + value=BinOp( + left=Constant(value='ТРЕВОГА мониторинга жалоб: '), + op=Add(), + right=Call( + func=Attribute( + value=Constant(value=', '), + attr='join', + ctx=Load()), + args=[ + GeneratorExp( + elt=Call( + func=Name(id='problem_to_ru', ctx=Load()), + args=[ + Name(id='p', ctx=Load())]), + generators=[ + comprehension( + target=Name(id='p', ctx=Store()), + iter=Subscript( + value=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='problems'), + ctx=Load()), + slice=Slice( + upper=Constant(value=2)), + ctx=Load()), + is_async=0)])]))), + Assign( + targets=[ + Name(id='body', ctx=Store())], + value=Call( + func=Name(id='status_to_body', ctx=Load()), + args=[ + Name(id='status', ctx=Load()), + Constant(value='тревога')])), + Assign( + targets=[ + Name(id='mail_sent', ctx=Store())], + value=Call( + func=Name(id='send_mail', ctx=Load()), + args=[ + Name(id='subject', ctx=Load()), + Name(id='body', ctx=Load())])), + Expr( + value=Call( + func=Attribute( + value=Name(id='state', ctx=Load()), + attr='update', + ctx=Load()), + args=[ + Dict( + keys=[ + Constant(value='active_alert'), + Constant(value='last_alert_ts'), + Constant(value='last_problem_key'), + Constant(value='last_problems')], + values=[ + Constant(value=True), + Name(id='now', ctx=Load()), + Name(id='problem_key', ctx=Load()), + Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='problems'), + ctx=Load())])])), + Expr( + value=Call( + func=Name(id='log', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='ALERT mail_sent='), + FormattedValue( + value=Name(id='mail_sent', ctx=Load()), + conversion=-1), + Constant(value=' problems='), + FormattedValue( + value=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='problems'), + ctx=Load()), + conversion=-1)])]))], + orelse=[ + Expr( + value=Call( + func=Name(id='log', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='CHECK ok=false suppressed=true problems='), + FormattedValue( + value=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='problems'), + ctx=Load()), + conversion=-1)])]))])]), + Expr( + value=Call( + func=Name(id='save_state', ctx=Load()), + args=[ + Name(id='state', ctx=Load())])), + Expr( + value=Call( + func=Name(id='write_alert_health', ctx=Load()), + args=[ + Name(id='status', ctx=Load()), + Name(id='mail_sent', ctx=Load())])), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + BinOp( + left=Constant(value='WATCHDOG_STATUS='), + op=Add(), + right=IfExp( + test=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='ok'), + ctx=Load()), + body=Constant(value='OK'), + orelse=Constant(value='ALERT')))])), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + BinOp( + left=Constant(value='WATCHDOG_MAIL_SENT='), + op=Add(), + right=IfExp( + test=Name(id='mail_sent', ctx=Load()), + body=Constant(value='yes'), + orelse=Constant(value='no')))])), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='PROBLEMS='), + FormattedValue( + value=Call( + func=Attribute( + value=Constant(value=';'), + attr='join', + ctx=Load()), + args=[ + Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='problems'), + ctx=Load())]), + conversion=-1)])])), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='OPEN='), + FormattedValue( + value=Call( + func=Attribute( + value=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='health'), + ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='open'), + Constant(value='missing')]), + conversion=-1)])])), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='RESOLVED='), + FormattedValue( + value=Call( + func=Attribute( + value=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='health'), + ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='resolved'), + Constant(value='missing')]), + conversion=-1)])])), + Return( + value=Constant(value=0))]) +HEALTH_DUMP_SHA256=da7bbe1956bd719cb634bbf6d2d3ace50781963d52bba841ec8197af0888f282 +HEALTH_DUMP_TRUNCATED=false +HEALTH_DUMP_END=do_check +HEALTH_DUMP_BEGIN=do_status +FunctionDef( + name='do_status', + args=arguments(), + body=[ + Assign( + targets=[ + Name(id='status', ctx=Store())], + value=Call( + func=Name(id='build_status', ctx=Load()))), + Expr( + value=Call( + func=Name(id='write_alert_health', ctx=Load()), + args=[ + Name(id='status', ctx=Load()), + Constant(value=None)])), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + BinOp( + left=Constant(value='WATCHDOG_STATUS='), + op=Add(), + right=IfExp( + test=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='ok'), + ctx=Load()), + body=Constant(value='OK'), + orelse=Constant(value='ALERT')))])), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='PROBLEMS='), + FormattedValue( + value=Call( + func=Attribute( + value=Constant(value=';'), + attr='join', + ctx=Load()), + args=[ + Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='problems'), + ctx=Load())]), + conversion=-1)])])), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='OPEN='), + FormattedValue( + value=Call( + func=Attribute( + value=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='health'), + ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='open'), + Constant(value='missing')]), + conversion=-1)])])), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='RESOLVED='), + FormattedValue( + value=Call( + func=Attribute( + value=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='health'), + ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='resolved'), + Constant(value='missing')]), + conversion=-1)])])), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='HEALTH_AGE_SECONDS='), + FormattedValue( + value=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='health_age_seconds'), + ctx=Load()), + conversion=-1)])])), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='NETBIRD_ROUTE_OK='), + FormattedValue( + value=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='route_ok'), + ctx=Load()), + conversion=-1)])])), + Return( + value=IfExp( + test=Subscript( + value=Name(id='status', ctx=Load()), + slice=Constant(value='ok'), + ctx=Load()), + body=Constant(value=0), + orelse=Constant(value=1)))]) +HEALTH_DUMP_SHA256=cbf3c7c1c58dd802afb48ef237a648104b27d72a6b727156bde564cb253cc0a2 +HEALTH_DUMP_TRUNCATED=false +HEALTH_DUMP_END=do_status +HEALTH_DUMP_BEGIN=main +FunctionDef( + name='main', + args=arguments(), + body=[ + Assign( + targets=[ + Name(id='mode', ctx=Store())], + value=IfExp( + test=Compare( + left=Call( + func=Name(id='len', ctx=Load()), + args=[ + Attribute( + value=Name(id='sys', ctx=Load()), + attr='argv', + ctx=Load())]), + ops=[ + Gt()], + comparators=[ + Constant(value=1)]), + body=Subscript( + value=Attribute( + value=Name(id='sys', ctx=Load()), + attr='argv', + ctx=Load()), + slice=Constant(value=1), + ctx=Load()), + orelse=Constant(value='check'))), + If( + test=Compare( + left=Name(id='mode', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='heartbeat')]), + body=[ + Return( + value=Call( + func=Name(id='do_heartbeat', ctx=Load())))]), + If( + test=Compare( + left=Name(id='mode', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='check')]), + body=[ + Return( + value=Call( + func=Name(id='do_check', ctx=Load())))]), + If( + test=Compare( + left=Name(id='mode', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='status')]), + body=[ + Return( + value=Call( + func=Name(id='do_status', ctx=Load())))]), + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + Constant(value='usage: health_alert.py [check|heartbeat|status]')], + keywords=[ + keyword( + arg='file', + value=Attribute( + value=Name(id='sys', ctx=Load()), + attr='stderr', + ctx=Load()))])), + Return( + value=Constant(value=64))]) +HEALTH_DUMP_SHA256=9a6149262fde18c30b641e25ec67b04a04957d0b2588ec05b1775c875c6722d2 +HEALTH_DUMP_TRUNCATED=false +HEALTH_DUMP_END=main +HEALTH_SCAN_OK=true QGA_CANARY_QM_RC=0 QGA_CANARY_STDERR_PRESENT=false QGA_CANARY_JSON=true QGA_CANARY_GUEST_EXITCODE=0 QGA_SHORT_OK=true -PATH_PROBE_QM_RC=0 -PATH_PROBE_STDERR_PRESENT=false -PATH_PROBE_JSON=true -PATH_PROBE_GUEST_EXITCODE=0 -MONITOR_PATH_PRESENT=true -MONITOR_MODE=700 MONITOR_UID=0 MONITOR_GID=0 MONITOR_SIZE=17878 -f62288797f80ce561f1e3ea721b87090eb1cd751fd5bf07152a3608b3a8aaed2 -AST_PROBE_QM_RC=0 -AST_PROBE_STDERR_PRESENT=false -AST_PROBE_JSON=true -AST_PROBE_GUEST_EXITCODE=1 +MONITOR_SCAN_QM_RC=0 +MONITOR_SCAN_STDERR_PRESENT=false +MONITOR_SCAN_JSON=true +MONITOR_SCAN_GUEST_EXITCODE=0 +MONITOR_SCAN=V1 +MONITOR_PRESENT=true +MONITOR_SHA256=f62288797f80ce561f1e3ea721b87090eb1cd751fd5bf07152a3608b3a8aaed2 +MONITOR_BYTES=17878 +MONITOR_FUNCTION_COUNT=26 +MONITOR_FUNC=utc_now:48:49 +MONITOR_FUNC=log:52:55 +MONITOR_FUNC=write_health:58:64 +MONITOR_FUNC=read_env:67:81 +MONITOR_FUNC=load_config:84:101 +MONITOR_FUNC=connect_db:104:136 +MONITOR_FUNC=meta_get:139:141 +MONITOR_FUNC=meta_set:144:146 +MONITOR_FUNC=event_sent:149:150 +MONITOR_FUNC=mark_event:153:158 +MONITOR_FUNC=fetch_reports_page:161:179 +MONITOR_FUNC=login_required:182:192 +MONITOR_FUNC=strip_tags:195:198 +MONITOR_FUNC=full_url:201:202 +MONITOR_FUNC=section_positions:205:222 +MONITOR_FUNC=parse_int:225:227 +MONITOR_FUNC=parse_reports:230:281 +MONITOR_FUNC=smtp_ready:284:285 +MONITOR_FUNC=send_mail:288:312 +MONITOR_FUNC=report_body:315:324 +MONITOR_FUNC=process_reports:327:370 +MONITOR_FUNC=maybe_send_auth_required:373:391 +MONITOR_FUNC=acquire_lock:394:401 +MONITOR_FUNC=run_once:404:451 +MONITOR_FUNC=show_status:454:459 +MONITOR_FUNC=main:462:468 +MONITOR_RELEVANT_COUNT=10 +MONITOR_DUMP_BEGIN=fetch_reports_page +FunctionDef( + name='fetch_reports_page', + args=arguments( + args=[ + arg( + arg='cfg', + annotation=Attribute( + value=Name(id='configparser', ctx=Load()), + attr='ConfigParser', + ctx=Load())), + arg( + arg='secrets', + annotation=Subscript( + value=Name(id='dict', ctx=Load()), + slice=Tuple( + elts=[ + Name(id='str', ctx=Load()), + Name(id='str', ctx=Load())], + ctx=Load()), + ctx=Load()))]), + body=[ + Assign( + targets=[ + Name(id='url', ctx=Store())], + value=Call( + func=Attribute( + value=Subscript( + value=Name(id='cfg', ctx=Load()), + slice=Constant(value='forum'), + ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='reports_url'), + Constant(value='')])), + Assign( + targets=[ + Name(id='request', ctx=Store())], + value=Call( + func=Attribute( + value=Attribute( + value=Name(id='urllib', ctx=Load()), + attr='request', + ctx=Load()), + attr='Request', + ctx=Load()), + args=[ + Name(id='url', ctx=Load())])), + Expr( + value=Call( + func=Attribute( + value=Name(id='request', ctx=Load()), + attr='add_header', + ctx=Load()), + args=[ + Constant(value='User-Agent'), + Call( + func=Attribute( + value=Subscript( + value=Name(id='cfg', ctx=Load()), + slice=Constant(value='forum'), + ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='user_agent'), + Constant(value='Mozilla/5.0')])])), + Expr( + value=Call( + func=Attribute( + value=Name(id='request', ctx=Load()), + attr='add_header', + ctx=Load()), + args=[ + Constant(value='Accept'), + Constant(value='text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')])), + Expr( + value=Call( + func=Attribute( + value=Name(id='request', ctx=Load()), + attr='add_header', + ctx=Load()), + args=[ + Constant(value='Accept-Language'), + Constant(value='ru-RU,ru;q=0.9,en;q=0.5')])), + Assign( + targets=[ + Name(id='cookie', ctx=Store())], + value=BoolOp( + op=Or(), + values=[ + Call( + func=Attribute( + value=Name(id='secrets', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='')]), + Call( + func=Attribute( + value=Name(id='secrets', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='')]), + Constant(value='')])), + If( + test=Name(id='cookie', ctx=Load()), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='request', ctx=Load()), + attr='add_header', + ctx=Load()), + args=[ + Constant(value=''), + Name(id='cookie', ctx=Load())]))]), + Assign( + targets=[ + Name(id='timeout', ctx=Store())], + value=Call( + func=Attribute( + value=Subscript( + value=Name(id='cfg', ctx=Load()), + slice=Constant(value='forum'), + ctx=Load()), + attr='getint', + ctx=Load()), + args=[ + Constant(value='timeout_seconds')], + keywords=[ + keyword( + arg='fallback', + value=Constant(value=25))])), + With( + items=[ + withitem( + context_expr=Call( + func=Attribute( + value=Attribute( + value=Name(id='urllib', ctx=Load()), + attr='request', + ctx=Load()), + attr='urlopen', + ctx=Load()), + args=[ + Name(id='request', ctx=Load())], + keywords=[ + keyword( + arg='timeout', + value=Name(id='timeout', ctx=Load()))]), + optional_vars=Name(id='response', ctx=Store()))], + body=[ + Assign( + targets=[ + Name(id='final_url', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='response', ctx=Load()), + attr='geturl', + ctx=Load()))), + Assign( + targets=[ + Name(id='body', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='response', ctx=Load()), + attr='read', + ctx=Load()))), + Assign( + targets=[ + Name(id='charset', ctx=Store())], + value=Constant(value='utf-8')), + Assign( + targets=[ + Name(id='content_type', ctx=Store())], + value=Call( + func=Attribute( + value=Attribute( + value=Name(id='response', ctx=Load()), + attr='headers', + ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='Content-Type'), + Constant(value='')])), + Assign( + targets=[ + Name(id='match', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='re', ctx=Load()), + attr='search', + ctx=Load()), + args=[ + Constant(value='charset=([A-Za-z0-9._-]+)'), + Name(id='content_type', ctx=Load())], + keywords=[ + keyword( + arg='flags', + value=Attribute( + value=Name(id='re', ctx=Load()), + attr='I', + ctx=Load()))])), + If( + test=Name(id='match', ctx=Load()), + body=[ + Assign( + targets=[ + Name(id='charset', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='match', ctx=Load()), + attr='group', + ctx=Load()), + args=[ + Constant(value=1)]))]), + Return( + value=Tuple( + elts=[ + Name(id='final_url', ctx=Load()), + Call( + func=Attribute( + value=Name(id='body', ctx=Load()), + attr='decode', + ctx=Load()), + args=[ + Name(id='charset', ctx=Load())], + keywords=[ + keyword( + arg='errors', + value=Constant(value='replace'))])], + ctx=Load()))])], + returns=Subscript( + value=Name(id='tuple', ctx=Load()), + slice=Tuple( + elts=[ + Name(id='str', ctx=Load()), + Name(id='str', ctx=Load())], + ctx=Load()), + ctx=Load())) +MONITOR_DUMP_SHA256=5b5c22665fa95eba6f84bbab6664b6750ec6ce801008b74213b7318201cded18 +MONITOR_DUMP_TRUNCATED=false +MONITOR_DUMP_END=fetch_reports_page +MONITOR_DUMP_BEGIN=parse_int +FunctionDef( + name='parse_int', + args=arguments( + args=[ + arg( + arg='pattern', + annotation=Name(id='str', ctx=Load())), + arg( + arg='text', + annotation=Name(id='str', ctx=Load()))]), + body=[ + Assign( + targets=[ + Name(id='match', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='re', ctx=Load()), + attr='search', + ctx=Load()), + args=[ + Name(id='pattern', ctx=Load()), + Name(id='text', ctx=Load())], + keywords=[ + keyword( + arg='flags', + value=Attribute( + value=Name(id='re', ctx=Load()), + attr='I', + ctx=Load()))])), + Return( + value=IfExp( + test=Name(id='match', ctx=Load()), + body=Call( + func=Name(id='int', ctx=Load()), + args=[ + Call( + func=Attribute( + value=Name(id='match', ctx=Load()), + attr='group', + ctx=Load()), + args=[ + Constant(value=1)])]), + orelse=Constant(value=None)))], + returns=BinOp( + left=Name(id='int', ctx=Load()), + op=BitOr(), + right=Constant(value=None))) +MONITOR_DUMP_SHA256=cb2011a9afb6eed1914e736d66227b0214cb4adb04afb833df8799db0dbf500e +MONITOR_DUMP_TRUNCATED=false +MONITOR_DUMP_END=parse_int +MONITOR_DUMP_BEGIN=parse_reports +FunctionDef( + name='parse_reports', + args=arguments( + args=[ + arg( + arg='text', + annotation=Name(id='str', ctx=Load())), + arg( + arg='cfg', + annotation=Attribute( + value=Name(id='configparser', ctx=Load()), + attr='ConfigParser', + ctx=Load()))]), + body=[ + Assign( + targets=[ + Name(id='base_url', ctx=Store())], + value=Call( + func=Attribute( + value=Subscript( + value=Name(id='cfg', ctx=Load()), + slice=Constant(value='forum'), + ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='base_url'), + Constant(value='')])), + Assign( + targets=[ + Tuple( + elts=[ + Name(id='open_pos', ctx=Store()), + Name(id='closed_pos', ctx=Store())], + ctx=Store())], + value=Call( + func=Name(id='section_positions', ctx=Load()), + args=[ + Name(id='text', ctx=Load())])), + AnnAssign( + target=Name(id='results', ctx=Store()), + annotation=Subscript( + value=Name(id='dict', ctx=Load()), + slice=Tuple( + elts=[ + Name(id='str', ctx=Load()), + Subscript( + value=Name(id='dict', ctx=Load()), + slice=Tuple( + elts=[ + Name(id='str', ctx=Load()), + Name(id='Any', ctx=Load())], + ctx=Load()), + ctx=Load())], + ctx=Load()), + ctx=Load()), + value=Dict(), + simple=1), + Assign( + targets=[ + Name(id='pattern', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='re', ctx=Load()), + attr='compile', + ctx=Load()), + args=[ + Constant(value='(?is)]*href=[\\"\']((?:reports/|[^\\"\']*/reports/)(\\d+)/?[^\\"\']*)[\\"\'][^>]*>(.*?)')])), + For( + target=Name(id='match', ctx=Store()), + iter=Call( + func=Attribute( + value=Name(id='pattern', ctx=Load()), + attr='finditer', + ctx=Load()), + args=[ + Name(id='text', ctx=Load())]), + body=[ + Assign( + targets=[ + Tuple( + elts=[ + Name(id='href', ctx=Store()), + Name(id='report_id', ctx=Store()), + Name(id='title_html', ctx=Store())], + ctx=Store())], + value=Tuple( + elts=[ + Call( + func=Attribute( + value=Name(id='match', ctx=Load()), + attr='group', + ctx=Load()), + args=[ + Constant(value=1)]), + Call( + func=Attribute( + value=Name(id='match', ctx=Load()), + attr='group', + ctx=Load()), + args=[ + Constant(value=2)]), + Call( + func=Attribute( + value=Name(id='match', ctx=Load()), + attr='group', + ctx=Load()), + args=[ + Constant(value=3)])], + ctx=Load())), + Assign( + targets=[ + Name(id='title', ctx=Store())], + value=Call( + func=Name(id='strip_tags', ctx=Load()), + args=[ + Name(id='title_html', ctx=Load())])), + If( + test=BoolOp( + op=Or(), + values=[ + UnaryOp( + op=Not(), + operand=Name(id='title', ctx=Load())), + Compare( + left=Call( + func=Attribute( + value=Name(id='title', ctx=Load()), + attr='lower', + ctx=Load())), + ops=[ + In()], + comparators=[ + Set( + elts=[ + Constant(value='жалобы'), + Constant(value='reports'), + Constant(value='обработанные жалобы')])])]), + body=[ + Continue()]), + Assign( + targets=[ + Name(id='position', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='match', ctx=Load()), + attr='start', + ctx=Load()))), + Assign( + targets=[ + Name(id='item_window_start', ctx=Store())], + value=Call( + func=Name(id='max', ctx=Load()), + args=[ + Constant(value=0), + BinOp( + left=Name(id='position', ctx=Load()), + op=Sub(), + right=Constant(value=6000))])), + Assign( + targets=[ + Name(id='item_tag', ctx=Store())], + value=Constant(value='')), + For( + target=Name(id='item_match', ctx=Store()), + iter=Call( + func=Attribute( + value=Name(id='re', ctx=Load()), + attr='finditer', + ctx=Load()), + args=[ + Constant(value='(?is)<(?:li|div|tr)\\b[^>]*class=["\'][^"\']*\\bdiscussionListItem\\b[^"\']*["\'][^>]*>'), + Subscript( + value=Name(id='text', ctx=Load()), + slice=Slice( + lower=Name(id='item_window_start', ctx=Load()), + upper=Name(id='position', ctx=Load())), + ctx=Load())]), + body=[ + Assign( + targets=[ + Name(id='item_tag', ctx=Store())], + value=Call( + func=Attribute( + value=Call( + func=Attribute( + value=Name(id='item_match', ctx=Load()), + attr='group', + ctx=Load()), + args=[ + Constant(value=0)]), + attr='lower', + ctx=Load())))]), + If( + test=Compare( + left=Constant(value='report-resolved'), + ops=[ + In()], + comparators=[ + Name(id='item_tag', ctx=Load())]), + body=[ + Assign( + targets=[ + Name(id='status', ctx=Store())], + value=Constant(value='resolved'))], + orelse=[ + If( + test=BoolOp( + op=Or(), + values=[ + Compare( + left=Constant(value='report-assigned'), + ops=[ + In()], + comparators=[ + Name(id='item_tag', ctx=Load())]), + Compare( + left=Constant(value='report-open'), + ops=[ + In()], + comparators=[ + Name(id='item_tag', ctx=Load())])]), + body=[ + Assign( + targets=[ + Name(id='status', ctx=Store())], + value=Constant(value='open'))], + orelse=[ + If( + test=BoolOp( + op=And(), + values=[ + Compare( + left=Name(id='closed_pos', ctx=Load()), + ops=[ + GtE()], + comparators=[ + Constant(value=0)]), + Compare( + left=Name(id='position', ctx=Load()), + ops=[ + Gt()], + comparators=[ + Name(id='closed_pos', ctx=Load())])]), + body=[ + Assign( + targets=[ + Name(id='status', ctx=Store())], + value=Constant(value='resolved'))], + orelse=[ + If( + test=BoolOp( + op=And(), + values=[ + Compare( + left=Name(id='open_pos', ctx=Load()), + ops=[ + GtE()], + comparators=[ + Constant(value=0)]), + Compare( + left=Name(id='position', ctx=Load()), + ops=[ + Gt()], + comparators=[ + Name(id='open_pos', ctx=Load())]), + BoolOp( + op=Or(), + values=[ + Compare( + left=Name(id='closed_pos', ctx=Load()), + ops=[ + Lt()], + comparators=[ + Constant(value=0)]), + Compare( + left=Name(id='position', ctx=Load()), + ops=[ + Lt()], + comparators=[ + Name(id='closed_pos', ctx=Load())])])]), + body=[ + Assign( + targets=[ + Name(id='status', ctx=Store())], + value=Constant(value='open'))], + orelse=[ + Assign( + targets=[ + Name(id='status', ctx=Store())], + value=Constant(value='open'))])])])]), + Assign( + targets=[ + Name(id='row_start', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='text', ctx=Load()), + attr='rfind', + ctx=Load()), + args=[ + Constant(value=''), + ctx=Load())), + Assign( + targets=[ + Name(id='port', ctx=Store())], + value=Call( + func=Name(id='int', ctx=Load()), + args=[ + Call( + func=Attribute( + value=Name(id='secrets', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value=''), + Constant(value='587')])])), + Assign( + targets=[ + Name(id='user', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='secrets', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value=''), + Constant(value='')])), + Assign( + targets=[ + Name(id='password', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='secrets', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value=''), + Constant(value='')])), + Assign( + targets=[ + Name(id='tls', ctx=Store())], + value=Call( + func=Attribute( + value=Call( + func=Attribute( + value=Name(id='secrets', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value=''), + Constant(value='starttls')]), + attr='lower', + ctx=Load()))), + Assign( + targets=[ + Name(id='msg', ctx=Store())], + value=Call( + func=Attribute( + value=Attribute( + value=Name(id='email', ctx=Load()), + attr='message', + ctx=Load()), + attr='EmailMessage', + ctx=Load()))), + Assign( + targets=[ + Subscript( + value=Name(id='msg', ctx=Load()), + slice=Constant(value='From'), + ctx=Store())], + value=Subscript( + value=Name(id='secrets', ctx=Load()), + slice=Constant(value=''), + ctx=Load())), + Assign( + targets=[ + Subscript( + value=Name(id='msg', ctx=Load()), + slice=Constant(value='To'), + ctx=Store())], + value=Subscript( + value=Name(id='secrets', ctx=Load()), + slice=Constant(value=''), + ctx=Load())), + Assign( + targets=[ + Subscript( + value=Name(id='msg', ctx=Load()), + slice=Constant(value='Subject'), + ctx=Store())], + value=BinOp( + left=BinOp( + left=Call( + func=Attribute( + value=Subscript( + value=Name(id='cfg', ctx=Load()), + slice=Constant(value='email'), + ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='subject_prefix'), + Constant(value='[Skladchik]')]), + op=Add(), + right=Constant(value=' ')), + op=Add(), + right=Name(id='subject', ctx=Load()))), + Expr( + value=Call( + func=Attribute( + value=Name(id='msg', ctx=Load()), + attr='set_content', + ctx=Load()), + args=[ + Name(id='body', ctx=Load())])), + If( + test=Compare( + left=Name(id='tls', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='ssl')]), + body=[ + Assign( + targets=[ + Name(id='smtp', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='smtplib', ctx=Load()), + attr='SMTP_SSL', + ctx=Load()), + args=[ + Name(id='host', ctx=Load()), + Name(id='port', ctx=Load())], + keywords=[ + keyword( + arg='timeout', + value=Constant(value=30))]))], + orelse=[ + Assign( + targets=[ + Name(id='smtp', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='smtplib', ctx=Load()), + attr='SMTP', + ctx=Load()), + args=[ + Name(id='host', ctx=Load()), + Name(id='port', ctx=Load())], + keywords=[ + keyword( + arg='timeout', + value=Constant(value=30))]))]), + With( + items=[ + withitem( + context_expr=Name(id='smtp', ctx=Load()), + optional_vars=Name(id='server', ctx=Store()))], + body=[ + If( + test=Compare( + left=Name(id='tls', ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='starttls')]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='server', ctx=Load()), + attr='starttls', + ctx=Load()), + keywords=[ + keyword( + arg='context', + value=Call( + func=Attribute( + value=Name(id='ssl', ctx=Load()), + attr='create_default_context', + ctx=Load())))]))]), + If( + test=Name(id='user', ctx=Load()), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='server', ctx=Load()), + attr='login', + ctx=Load()), + args=[ + Name(id='user', ctx=Load()), + Name(id='password', ctx=Load())]))]), + Expr( + value=Call( + func=Attribute( + value=Name(id='server', ctx=Load()), + attr='send_message', + ctx=Load()), + args=[ + Name(id='msg', ctx=Load())]))]), + Return( + value=Constant(value=True))], + returns=Name(id='bool', ctx=Load())) +MONITOR_DUMP_SHA256=af72f54e66459d653cc65a65494c97a1eeabaa80cee95f1777319a7df1efc133 +MONITOR_DUMP_TRUNCATED=false +MONITOR_DUMP_END=send_mail +MONITOR_DUMP_BEGIN=report_body +FunctionDef( + name='report_body', + args=arguments( + args=[ + arg( + arg='prefix', + annotation=Name(id='str', ctx=Load())), + arg( + arg='report', + annotation=Subscript( + value=Name(id='dict', ctx=Load()), + slice=Tuple( + elts=[ + Name(id='str', ctx=Load()), + Name(id='Any', ctx=Load())], + ctx=Load()), + ctx=Load()))]), + body=[ + Return( + value=JoinedStr( + values=[ + FormattedValue( + value=Name(id='prefix', ctx=Load()), + conversion=-1), + Constant(value=''), + FormattedValue( + value=Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='title'), + ctx=Load()), + conversion=-1), + Constant(value=''), + FormattedValue( + value=Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='status'), + ctx=Load()), + conversion=-1), + Constant(value=''), + FormattedValue( + value=Call( + func=Attribute( + value=Name(id='report', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='report_count')]), + conversion=-1), + Constant(value=''), + FormattedValue( + value=Call( + func=Attribute( + value=Name(id='report', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='comment_count')]), + conversion=-1), + Constant(value=''), + FormattedValue( + value=Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='url'), + ctx=Load()), + conversion=-1), + Constant(value=''), + FormattedValue( + value=Call( + func=Name(id='utc_now', ctx=Load())), + conversion=-1), + Constant(value='')]))], + returns=Name(id='str', ctx=Load())) +MONITOR_DUMP_SHA256=668abfab86ee05df948412e7aca1247e115d8d5c6d7c52ddda0746f288f2978a +MONITOR_DUMP_TRUNCATED=false +MONITOR_DUMP_END=report_body +MONITOR_DUMP_BEGIN=process_reports +FunctionDef( + name='process_reports', + args=arguments( + args=[ + arg( + arg='con', + annotation=Attribute( + value=Name(id='sqlite3', ctx=Load()), + attr='Connection', + ctx=Load())), + arg( + arg='cfg', + annotation=Attribute( + value=Name(id='configparser', ctx=Load()), + attr='ConfigParser', + ctx=Load())), + arg( + arg='secrets', + annotation=Subscript( + value=Name(id='dict', ctx=Load()), + slice=Tuple( + elts=[ + Name(id='str', ctx=Load()), + Name(id='str', ctx=Load())], + ctx=Load()), + ctx=Load())), + arg( + arg='reports', + annotation=Subscript( + value=Name(id='list', ctx=Load()), + slice=Subscript( + value=Name(id='dict', ctx=Load()), + slice=Tuple( + elts=[ + Name(id='str', ctx=Load()), + Name(id='Any', ctx=Load())], + ctx=Load()), + ctx=Load()), + ctx=Load()))]), + body=[ + Assign( + targets=[ + Name(id='baseline', ctx=Store())], + value=Call( + func=Name(id='meta_get', ctx=Load()), + args=[ + Name(id='con', ctx=Load()), + Constant(value='baseline_created_at')])), + Assign( + targets=[ + Name(id='baseline_mode', ctx=Store())], + value=Compare( + left=Call( + func=Attribute( + value=Call( + func=Attribute( + value=Subscript( + value=Name(id='cfg', ctx=Load()), + slice=Constant(value='monitor'), + ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='baseline_no_email'), + Constant(value='yes')]), + attr='lower', + ctx=Load())), + ops=[ + In()], + comparators=[ + Set( + elts=[ + Constant(value='yes'), + Constant(value='true'), + Constant(value='1'), + Constant(value='on')])])), + Assign( + targets=[ + Name(id='new_events', ctx=Store())], + value=Constant(value=0)), + Assign( + targets=[ + Name(id='resolved_events', ctx=Store())], + value=Constant(value=0)), + For( + target=Name(id='report', ctx=Store()), + iter=Name(id='reports', ctx=Load()), + body=[ + Assign( + targets=[ + Name(id='row', ctx=Store())], + value=Call( + func=Attribute( + value=Call( + func=Attribute( + value=Name(id='con', ctx=Load()), + attr='execute', + ctx=Load()), + args=[ + Constant(value='SELECT status FROM reports WHERE report_id=?'), + Tuple( + elts=[ + Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='report_id'), + ctx=Load())], + ctx=Load())]), + attr='fetchone', + ctx=Load()))), + If( + test=Compare( + left=Name(id='row', ctx=Load()), + ops=[ + Is()], + comparators=[ + Constant(value=None)]), + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='con', ctx=Load()), + attr='execute', + ctx=Load()), + args=[ + Constant(value=''), + Tuple( + elts=[ + Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='report_id'), + ctx=Load()), + Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='url'), + ctx=Load()), + Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='title'), + ctx=Load()), + Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='status'), + ctx=Load()), + Call( + func=Attribute( + value=Name(id='report', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='report_count')]), + Call( + func=Attribute( + value=Name(id='report', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='comment_count')]), + Call( + func=Attribute( + value=Name(id='report', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='row_text'), + Constant(value='')]), + Call( + func=Name(id='utc_now', ctx=Load())), + Call( + func=Name(id='utc_now', ctx=Load())), + IfExp( + test=Compare( + left=Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='status'), + ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='resolved')]), + body=Call( + func=Name(id='utc_now', ctx=Load())), + orelse=Constant(value=None))], + ctx=Load())])), + Expr( + value=Call( + func=Attribute( + value=Name(id='con', ctx=Load()), + attr='commit', + ctx=Load()))), + If( + test=BoolOp( + op=Or(), + values=[ + Name(id='baseline', ctx=Load()), + UnaryOp( + op=Not(), + operand=Name(id='baseline_mode', ctx=Load()))]), + body=[ + If( + test=Compare( + left=Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='status'), + ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='open')]), + body=[ + Assign( + targets=[ + Name(id='key', ctx=Store())], + value=BinOp( + left=Constant(value='new:'), + op=Add(), + right=Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='report_id'), + ctx=Load()))), + If( + test=UnaryOp( + op=Not(), + operand=Call( + func=Name(id='event_sent', ctx=Load()), + args=[ + Name(id='con', ctx=Load()), + Name(id='key', ctx=Load())])), + body=[ + If( + test=Call( + func=Name(id='send_mail', ctx=Load()), + args=[ + Name(id='cfg', ctx=Load()), + Name(id='secrets', ctx=Load()), + Constant(value='Новая жалоба'), + Call( + func=Name(id='report_body', ctx=Load()), + args=[ + Constant(value='Появилась новая жалоба.'), + Name(id='report', ctx=Load())])]), + body=[ + Expr( + value=Call( + func=Name(id='mark_event', ctx=Load()), + args=[ + Name(id='con', ctx=Load()), + Name(id='key', ctx=Load()), + Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='report_id'), + ctx=Load()), + Constant(value='new')])), + AugAssign( + target=Name(id='new_events', ctx=Store()), + op=Add(), + value=Constant(value=1))])])])])], + orelse=[ + Assign( + targets=[ + Name(id='old_status', ctx=Store())], + value=Subscript( + value=Name(id='row', ctx=Load()), + slice=Constant(value=0), + ctx=Load())), + If( + test=BoolOp( + op=And(), + values=[ + Compare( + left=Name(id='old_status', ctx=Load()), + ops=[ + NotEq()], + comparators=[ + Constant(value='resolved')]), + Compare( + left=Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='status'), + ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='resolved')])]), + body=[ + Assign( + targets=[ + Name(id='key', ctx=Store())], + value=BinOp( + left=Constant(value='resolved:'), + op=Add(), + right=Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='report_id'), + ctx=Load()))), + If( + test=UnaryOp( + op=Not(), + operand=Call( + func=Name(id='event_sent', ctx=Load()), + args=[ + Name(id='con', ctx=Load()), + Name(id='key', ctx=Load())])), + body=[ + If( + test=Call( + func=Name(id='send_mail', ctx=Load()), + args=[ + Name(id='cfg', ctx=Load()), + Name(id='secrets', ctx=Load()), + Constant(value='Жалоба отработана'), + Call( + func=Name(id='report_body', ctx=Load()), + args=[ + Constant(value='Жалоба перешла в обработанные.'), + Name(id='report', ctx=Load())])]), + body=[ + Expr( + value=Call( + func=Name(id='mark_event', ctx=Load()), + args=[ + Name(id='con', ctx=Load()), + Name(id='key', ctx=Load()), + Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='report_id'), + ctx=Load()), + Constant(value='resolved')])), + AugAssign( + target=Name(id='resolved_events', ctx=Store()), + op=Add(), + value=Constant(value=1))])])]), + Expr( + value=Call( + func=Attribute( + value=Name(id='con', ctx=Load()), + attr='execute', + ctx=Load()), + args=[ + Constant(value=''), + Tuple( + elts=[ + Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='url'), + ctx=Load()), + Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='title'), + ctx=Load()), + Subscript( + value=Name(id='report', ctx=Load()), + slice=Constant(value='status'), + ctx=Load()), + Call( + func=Attribute( + value=Name(id='report', ctx=Load()), + attr='get', + ctx=Load()), + args=[ + Constant(value='report_count')]), + Call( + func=Attribute( + value=Name(id='report', ctx=Load()), + attr='get', + ctx=Load()), + +MONITOR_DUMP_SHA256=898a51f0ad422cfbd6a9dc3c30e38db7fa53aa91216f5ef5bf390e2728d2da25 +MONITOR_DUMP_TRUNCATED=true +MONITOR_DUMP_END=process_reports +MONITOR_DUMP_BEGIN=maybe_send_auth_required +FunctionDef( + name='maybe_send_auth_required', + args=arguments( + args=[ + arg( + arg='con', + annotation=Attribute( + value=Name(id='sqlite3', ctx=Load()), + attr='Connection', + ctx=Load())), + arg( + arg='cfg', + annotation=Attribute( + value=Name(id='configparser', ctx=Load()), + attr='ConfigParser', + ctx=Load())), + arg( + arg='secrets', + annotation=Subscript( + value=Name(id='dict', ctx=Load()), + slice=Tuple( + elts=[ + Name(id='str', ctx=Load()), + Name(id='str', ctx=Load())], + ctx=Load()), + ctx=Load())), + arg( + arg='final_url', + annotation=Name(id='str', ctx=Load()))]), + body=[ + Assign( + targets=[ + Name(id='now_ts', ctx=Store())], + value=Call( + func=Name(id='int', ctx=Load()), + args=[ + Call( + func=Attribute( + value=Name(id='time', ctx=Load()), + attr='time', + ctx=Load()))])), + Assign( + targets=[ + Name(id='interval', ctx=Store())], + value=Call( + func=Attribute( + value=Subscript( + value=Name(id='cfg', ctx=Load()), + slice=Constant(value='email'), + ctx=Load()), + attr='getint', + ctx=Load()), + args=[ + Constant(value='auth_notice_min_interval_seconds')], + keywords=[ + keyword( + arg='fallback', + value=Constant(value=86400))])), + Assign( + targets=[ + Name(id='last_raw', ctx=Store())], + value=BoolOp( + op=Or(), + values=[ + Call( + func=Name(id='meta_get', ctx=Load()), + args=[ + Name(id='con', ctx=Load()), + Constant(value='last_auth_notice_ts')]), + Constant(value='0')])), + Try( + body=[ + Assign( + targets=[ + Name(id='last', ctx=Store())], + value=Call( + func=Name(id='int', ctx=Load()), + args=[ + Name(id='last_raw', ctx=Load())]))], + handlers=[ + ExceptHandler( + type=Name(id='ValueError', ctx=Load()), + body=[ + Assign( + targets=[ + Name(id='last', ctx=Store())], + value=Constant(value=0))])]), + If( + test=Compare( + left=BinOp( + left=Name(id='now_ts', ctx=Load()), + op=Sub(), + right=Name(id='last', ctx=Load())), + ops=[ + GtE()], + comparators=[ + Name(id='interval', ctx=Load())]), + body=[ + If( + test=Call( + func=Name(id='send_mail', ctx=Load()), + args=[ + Name(id='cfg', ctx=Load()), + Name(id='secrets', ctx=Load()), + Constant(value='Нужна повторная авторизация'), + JoinedStr( + values=[ + Constant(value=''), + FormattedValue( + value=Name(id='final_url', ctx=Load()), + conversion=-1), + Constant(value=''), + FormattedValue( + value=Call( + func=Name(id='utc_now', ctx=Load())), + conversion=-1), + Constant(value='')])]), + body=[ + Expr( + value=Call( + func=Name(id='meta_set', ctx=Load()), + args=[ + Name(id='con', ctx=Load()), + Constant(value='last_auth_notice_ts'), + Call( + func=Name(id='str', ctx=Load()), + args=[ + Name(id='now_ts', ctx=Load())])]))])])], + returns=Constant(value=None)) +MONITOR_DUMP_SHA256=396252a7a870238ab735e22192d95a704509acc56af3bca2289e5e307c4e5f10 +MONITOR_DUMP_TRUNCATED=false +MONITOR_DUMP_END=maybe_send_auth_required +MONITOR_DUMP_BEGIN=run_once +FunctionDef( + name='run_once', + args=arguments(), + body=[ + Assign( + targets=[ + Name(id='lock', ctx=Store())], + value=Call( + func=Name(id='acquire_lock', ctx=Load()))), + If( + test=Compare( + left=Name(id='lock', ctx=Load()), + ops=[ + Is()], + comparators=[ + Constant(value=None)]), + body=[ + Expr( + value=Call( + func=Name(id='log', ctx=Load()), + args=[ + Constant(value='LOCK_BUSY previous run still active')])), + Expr( + value=Call( + func=Name(id='write_health', ctx=Load()), + args=[ + Constant(value='LOCK_BUSY')])), + Return( + value=Constant(value=0))]), + Assign( + targets=[ + Tuple( + elts=[ + Name(id='cfg', ctx=Store()), + Name(id='secrets', ctx=Store())], + ctx=Store())], + value=Call( + func=Name(id='load_config', ctx=Load()))), + Assign( + targets=[ + Name(id='con', ctx=Store())], + value=Call( + func=Name(id='connect_db', ctx=Load()))), + Try( + body=[ + Assign( + targets=[ + Tuple( + elts=[ + Name(id='final_url', ctx=Store()), + Name(id='text', ctx=Store())], + ctx=Store())], + value=Call( + func=Name(id='fetch_reports_page', ctx=Load()), + args=[ + Name(id='cfg', ctx=Load()), + Name(id='secrets', ctx=Load())])), + If( + test=Call( + func=Name(id='login_required', ctx=Load()), + args=[ + Name(id='final_url', ctx=Load()), + Name(id='text', ctx=Load())]), + body=[ + Expr( + value=Call( + func=Name(id='maybe_send_auth_required', ctx=Load()), + args=[ + Name(id='con', ctx=Load()), + Name(id='cfg', ctx=Load()), + Name(id='secrets', ctx=Load()), + Name(id='final_url', ctx=Load())])), + Expr( + value=Call( + func=Name(id='write_health', ctx=Load()), + args=[ + Constant(value='AUTH_REQUIRED')], + keywords=[ + keyword( + arg='url', + value=Name(id='final_url', ctx=Load()))])), + Return( + value=Constant(value=2))]), + Assign( + targets=[ + Name(id='reports', ctx=Store())], + value=Call( + func=Name(id='parse_reports', ctx=Load()), + args=[ + Name(id='text', ctx=Load()), + Name(id='cfg', ctx=Load())])), + If( + test=UnaryOp( + op=Not(), + operand=Name(id='reports', ctx=Load())), + body=[ + Expr( + value=Call( + func=Name(id='write_health', ctx=Load()), + args=[ + Constant(value='ERROR')], + keywords=[ + keyword( + arg='reason', + value=Constant(value='no_reports_parsed')), + keyword( + arg='url', + value=Name(id='final_url', ctx=Load()))])), + Expr( + value=Call( + func=Name(id='log', ctx=Load()), + args=[ + Constant(value='ERROR no reports parsed')])), + Return( + value=Constant(value=1))]), + Assign( + targets=[ + Tuple( + elts=[ + Name(id='new_events', ctx=Store()), + Name(id='resolved_events', ctx=Store())], + ctx=Store())], + value=Call( + func=Name(id='process_reports', ctx=Load()), + args=[ + Name(id='con', ctx=Load()), + Name(id='cfg', ctx=Load()), + Name(id='secrets', ctx=Load()), + Name(id='reports', ctx=Load())])), + Assign( + targets=[ + Name(id='open_count', ctx=Store())], + value=Call( + func=Name(id='sum', ctx=Load()), + args=[ + GeneratorExp( + elt=Constant(value=1), + generators=[ + comprehension( + target=Name(id='r', ctx=Store()), + iter=Name(id='reports', ctx=Load()), + ifs=[ + Compare( + left=Subscript( + value=Name(id='r', ctx=Load()), + slice=Constant(value='status'), + ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='open')])], + is_async=0)])])), + Assign( + targets=[ + Name(id='resolved_count', ctx=Store())], + value=Call( + func=Name(id='sum', ctx=Load()), + args=[ + GeneratorExp( + elt=Constant(value=1), + generators=[ + comprehension( + target=Name(id='r', ctx=Store()), + iter=Name(id='reports', ctx=Load()), + ifs=[ + Compare( + left=Subscript( + value=Name(id='r', ctx=Load()), + slice=Constant(value='status'), + ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='resolved')])], + is_async=0)])])), + Expr( + value=Call( + func=Name(id='write_health', ctx=Load()), + args=[ + Constant(value='OK')], + keywords=[ + keyword( + arg='url', + value=Name(id='final_url', ctx=Load())), + keyword( + arg='reports', + value=Call( + func=Name(id='len', ctx=Load()), + args=[ + Name(id='reports', ctx=Load())])), + keyword( + arg='open', + value=Name(id='open_count', ctx=Load())), + keyword( + arg='resolved', + value=Name(id='resolved_count', ctx=Load())), + keyword( + arg='new_events', + value=Name(id='new_events', ctx=Load())), + keyword( + arg='resolved_events', + value=Name(id='resolved_events', ctx=Load())), + keyword( + arg='smtp_configured', + value=IfExp( + test=Call( + func=Name(id='smtp_ready', ctx=Load()), + args=[ + Name(id='secrets', ctx=Load())]), + body=Constant(value='yes'), + orelse=Constant(value='no')))])), + Expr( + value=Call( + func=Name(id='log', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='OK reports='), + FormattedValue( + value=Call( + func=Name(id='len', ctx=Load()), + args=[ + Name(id='reports', ctx=Load())]), + conversion=-1), + Constant(value=' open='), + FormattedValue( + value=Name(id='open_count', ctx=Load()), + conversion=-1), + Constant(value=' resolved='), + FormattedValue( + value=Name(id='resolved_count', ctx=Load()), + conversion=-1), + Constant(value=' new='), + FormattedValue( + value=Name(id='new_events', ctx=Load()), + conversion=-1), + Constant(value=' done='), + FormattedValue( + value=Name(id='resolved_events', ctx=Load()), + conversion=-1)])])), + Return( + value=Constant(value=0))], + handlers=[ + ExceptHandler( + type=Attribute( + value=Attribute( + value=Name(id='urllib', ctx=Load()), + attr='error', + ctx=Load()), + attr='HTTPError', + ctx=Load()), + name='e', + body=[ + Expr( + value=Call( + func=Name(id='write_health', ctx=Load()), + args=[ + Constant(value='ERROR')], + keywords=[ + keyword( + arg='error', + value=JoinedStr( + values=[ + Constant(value='HTTPError '), + FormattedValue( + value=Attribute( + value=Name(id='e', ctx=Load()), + attr='code', + ctx=Load()), + conversion=-1)]))])), + Expr( + value=Call( + func=Name(id='log', ctx=Load()), + args=[ + JoinedStr( + values=[ + Constant(value='ERROR HTTPError '), + FormattedValue( + value=Attribute( + value=Name(id='e', ctx=Load()), + attr='code', + ctx=Load()), + conversion=-1)])])), + Return( + value=Constant(value=1))]), + ExceptHandler( + type=Name(id='Exception', ctx=Load()), + name='e', + body=[ + Expr( + value=Call( + func=Name(id='write_health', ctx=Load()), + args=[ + Constant(value='ERROR')], + keywords=[ + keyword( + arg='error', + value=Call( + func=Name(id='repr', ctx=Load()), + args=[ + Name(id='e', ctx=Load())]))])), + Expr( + value=Call( + func=Name(id='log', ctx=Load()), + args=[ + BinOp( + left=BinOp( + left=BinOp( + left=Constant(value='ERROR '), + op=Add(), + right=Call( + func=Name(id='repr', ctx=Load()), + args=[ + Name(id='e', ctx=Load())])), + op=Add(), + right=Constant(value=' ')), + op=Add(), + right=Call( + func=Attribute( + value=Name(id='traceback', ctx=Load()), + attr='format_exc', + ctx=Load())))])), + Return( + value=Constant(value=1))])], + finalbody=[ + Try( + body=[ + Expr( + value=Call( + func=Attribute( + value=Name(id='fcntl', ctx=Load()), + attr='flock', + ctx=Load()), + args=[ + Call( + func=Attribute( + value=Name(id='lock', ctx=Load()), + attr='fileno', + ctx=Load())), + Attribute( + value=Name(id='fcntl', ctx=Load()), + attr='LOCK_UN', + ctx=Load())])), + Expr( + value=Call( + func=Attribute( + value=Name(id='lock', ctx=Load()), + attr='close', + ctx=Load())))], + handlers=[ + ExceptHandler( + type=Name(id='Exception', ctx=Load()), + body=[ + Pass()])])])], + returns=Name(id='int', ctx=Load())) +MONITOR_DUMP_SHA256=eceb52bc948ca75d79fddb992ecc9e3c61ae10413339a5d6d14b5c20b00407db +MONITOR_DUMP_TRUNCATED=false +MONITOR_DUMP_END=run_once +MONITOR_DUMP_BEGIN=show_status +FunctionDef( + name='show_status', + args=arguments(), + body=[ + If( + test=Call( + func=Attribute( + value=Name(id='HEALTH_PATH', ctx=Load()), + attr='exists', + ctx=Load())), + body=[ + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + Call( + func=Attribute( + value=Name(id='HEALTH_PATH', ctx=Load()), + attr='read_text', + ctx=Load()), + keywords=[ + keyword( + arg='encoding', + value=Constant(value='utf-8'))])], + keywords=[ + keyword( + arg='end', + value=Constant(value=''))]))], + orelse=[ + Expr( + value=Call( + func=Name(id='print', ctx=Load()), + args=[ + Constant(value='STATUS=UNKNOWN')]))]), + Return( + value=Constant(value=0))], + returns=Name(id='int', ctx=Load())) +MONITOR_DUMP_SHA256=ee45eb0e5db867e890df5fce7f7afa8ad77ba828845e20e5e7d1dcfdab13e551 +MONITOR_DUMP_TRUNCATED=false +MONITOR_DUMP_END=show_status +MONITOR_DUMP_BEGIN=main +FunctionDef( + name='main', + args=arguments(), + body=[ + Assign( + targets=[ + Name(id='parser', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='argparse', ctx=Load()), + attr='ArgumentParser', + ctx=Load()))), + Expr( + value=Call( + func=Attribute( + value=Name(id='parser', ctx=Load()), + attr='add_argument', + ctx=Load()), + args=[ + Constant(value='cmd')], + keywords=[ + keyword( + arg='choices', + value=List( + elts=[ + Constant(value='run'), + Constant(value='status')], + ctx=Load())), + keyword( + arg='nargs', + value=Constant(value='?')), + keyword( + arg='default', + value=Constant(value='run'))])), + Assign( + targets=[ + Name(id='args', ctx=Store())], + value=Call( + func=Attribute( + value=Name(id='parser', ctx=Load()), + attr='parse_args', + ctx=Load()))), + If( + test=Compare( + left=Attribute( + value=Name(id='args', ctx=Load()), + attr='cmd', + ctx=Load()), + ops=[ + Eq()], + comparators=[ + Constant(value='status')]), + body=[ + Return( + value=Call( + func=Name(id='show_status', ctx=Load())))]), + Return( + value=Call( + func=Name(id='run_once', ctx=Load())))], + returns=Name(id='int', ctx=Load())) +MONITOR_DUMP_SHA256=02ad6bee6cd63312a57b18daedc366b2edfc1b747c3ac27f5bd9cfd71210fb2e +MONITOR_DUMP_TRUNCATED=false +MONITOR_DUMP_END=main +MONITOR_SCAN_OK=true UNIT_PROBE_QM_RC=0 UNIT_PROBE_STDERR_PRESENT=false UNIT_PROBE_JSON=true @@ -65,10 +3888,9 @@ success 0 MAIL_DRY_RUN_ONLY=true MAIL_SENT=false -AST_CONFIRM_EXITCODE=1 -DECISION=HOLD_TITLE_SOURCE_RCA_INCOMPLETE -NEXT_GATE=TITLE_SOURCE_PROBE_RECONCILE -TASK_RESULT=SKLADCHIK_COMPLAINTS_TITLE_SOURCE_RCA +DECISION=PASS_TITLE_AND_ALERT_SOURCE_RCA +NEXT_GATE=DESIGN_ATOMIC_FALSE_ALERT_AND_TITLE_REPAIR_FROM_99564 +TASK_RESULT=SKLADCHIK_COMPLAINTS_TITLE_TOKEN_RCA CHANGES_MADE=false ROLLBACK_STARTED=false ROLLBACK_RESTORED=null