xxsokolov / Zabbix-Notification-Telegram

Sending notification from Zabbix server to the Telegram
MIT License
83 stars 28 forks source link

xml_parsing() - zbxTelegram.py:89 - ERROR: Exception occurred: syntax error: line 1, column 0 #10

Closed rmalenko closed 4 years ago

rmalenko commented 4 years ago

Привет! У менея такая ошибка xml_parsing() - zbxTelegram.py:89 - ERROR: Exception occurred: syntax error: line 1, column 0

actions выглядит так, дефолтный

<?xml version="1.0" encoding="UTF-8" ?>
<root>
    <body>
        <messages>
<![CDATA[
Host: {HOST.HOST} [{HOST.IP}]
Last value: {ITEM.LASTVALUE1} ({TIME})
DESC: {INVENTORY.NOTES1}
Duration: {EVENT.AGE}]]>
        </messages>
    </body>
    <settings>
        <graphs>True</graphs>
        <graphlinks>True</graphlinks>
        <triggerlinks>True</triggerlinks>
        <tag>True</tag>
        <keyboard>True</keyboard>
        <graphs_period>10800</graphs_period>
        <itemid>{ITEM.ID1}</itemid>
        <triggerid>{TRIGGER.ID}</triggerid>
        <eventid>{EVENT.ID}</eventid>
        <actionid>{ACTION.ID}</actionid>
        <title><![CDATA[{HOST.HOST} - {EVENT.NAME}]]></title>
        <triggerurl><![CDATA[{TRIGGER.URL}]]></triggerurl>
        <tags><![CDATA[{EVENT.TAGS}]]></tags>
    </settings>
</root>

Спасибо

xxsokolov commented 4 years ago

Привет, включай дебаг и скидывай лог, ток замаж токен и юзернэйм.

config_debug_mode = True config_exc_info = True

mrTall commented 4 years ago

I have similar issue, clear install and XML from action.example

[2020-01-20 08:11:40,628] - PID:1297 - main() - zbxTelegram.py:371 - INFO: Send to @ action: Test subject
[2020-01-20 08:11:40,628] - PID:1297 - main() - zbxTelegram.py:372 - DEBUG: Send to @
action: Test subject
xml: This is the test message from Zabbix
[2020-01-20 08:11:40,628] - PID:1297 - xml_parsing() - zbxTelegram.py:96 - ERROR: Exception occurred: syntax error: line 1, column 0
Traceback (most recent call last):
  File "/usr/lib/zabbix/alertscripts/zbxTelegram.py", line 62, in xml_parsing
    data = dict(xmltodict.parse(data, process_namespaces=True)['root'])
  File "/usr/lib/zabbix/alertscripts/venv/lib/python3.6/site-packages/xmltodict.py", line 327, in parse
    parser.Parse(xml_input, True)
xml.parsers.expat.ExpatError: syntax error: line 1, column 0

Screen Shot 2020-01-20 at 12 18 28 AM

mrTall commented 4 years ago

My bad, Subject and Message MUST be "test"

xxsokolov commented 4 years ago

Fill it like this: Send to: @your_username Subject: test Message: test

dvigok89 commented 6 months ago

Привет все у меня таже проблемма

[2024-03-04 22:44:33,735] - PID:1907438 - xml_parsing() - zbxTelegram.py:129 - ERROR: Exception occurred: No XML in zabbix actions or it's not valid (xml parsing error). XML: syntax error: line 1, column 0 Traceback (most recent call last): File "/usr/lib/zabbix/alertscripts/zbxTelegram.py", line 73, in xml_parsing data = dict(xmltodict.parse(data, process_namespaces=True)['root']) File "/usr/lib/zabbix/alertscripts/venv/lib/python3.8/site-packages/xmltodict.py", line 378, in parse parser.Parse(xml_input, True) xml.parsers.expat.ExpatError: syntax error: line 1, column 0 [2024-03-04 22:44:43,742] - PID:1907463 - main() - zbxTelegram.py:498 - INFO: Send to BOT action: HOST-GROUP Problem: PostgreSQL: Cache hit ratio too low (under 90 in 5m) [2024-03-04 22:44:43,743] - PID:1907463 - main() - zbxTelegram.py:499 - DEBUG: sys.argv: ['BOT', 'HOST-GROUP Problem: PostgreSQL: Cache hit ratio too low (under 90 in 5m)', 'Problem started at 22:44:31 on 2024.03.04\r\nProblem name: PostgreSQL: Cache hit ratio too low (under 90 in 5m)\r\nHost: pg3\r\nSeverity: Warning\r\n\r\nOriginal problem ID: 503536\r\n'] [2024-03-04 22:44:43,743] - PID:1907463 - main() - zbxTelegram.py:500 - DEBUG: Send to BOT action: HOST-GROUP Problem: PostgreSQL: Cache hit ratio too low (under 90 in 5m) xml: Problem started at 22:44:31 on 2024.03.04 Problem name: PostgreSQL: Cache hit ratio too low (under 90 in 5m) Host: HOST Severity: Warning

Original problem ID: 503536 image