<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
	<id>https://wiki.cless.pro/index.php?action=history&amp;feed=atom&amp;title=Zabbix._Task._Getting_JSON_with_SEVERAL_variables._Python</id>
	<title>Zabbix. Task. Getting JSON with SEVERAL variables. Python - История изменений</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.cless.pro/index.php?action=history&amp;feed=atom&amp;title=Zabbix._Task._Getting_JSON_with_SEVERAL_variables._Python"/>
	<link rel="alternate" type="text/html" href="https://wiki.cless.pro/index.php?title=Zabbix._Task._Getting_JSON_with_SEVERAL_variables._Python&amp;action=history"/>
	<updated>2026-10-22T23:55:02Z</updated>
	<subtitle>История изменений этой страницы в вики</subtitle>
	<generator>MediaWiki 1.36.2</generator>
	<entry>
		<id>https://wiki.cless.pro/index.php?title=Zabbix._Task._Getting_JSON_with_SEVERAL_variables._Python&amp;diff=1681&amp;oldid=prev</id>
		<title>Cless: Cless переименовал страницу Zabbix. Task. Getting JSON with several variables for putting them to autodiscoverable Items and Triggers в Zabbix. Task. Getting JSON with SEVERAL variables. Python без оставления перенаправления</title>
		<link rel="alternate" type="text/html" href="https://wiki.cless.pro/index.php?title=Zabbix._Task._Getting_JSON_with_SEVERAL_variables._Python&amp;diff=1681&amp;oldid=prev"/>
		<updated>2023-10-05T13:33:13Z</updated>

		<summary type="html">&lt;p&gt;Cless переименовал страницу &lt;a href=&quot;/index.php?title=Zabbix._Task._Getting_JSON_with_several_variables_for_putting_them_to_autodiscoverable_Items_and_Triggers&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Zabbix. Task. Getting JSON with several variables for putting them to autodiscoverable Items and Triggers (страница не существует)&quot;&gt;Zabbix. Task. Getting JSON with several variables for putting them to autodiscoverable Items and Triggers&lt;/a&gt; в &lt;a href=&quot;/index.php?title=Zabbix._Task._Getting_JSON_with_SEVERAL_variables._Python&quot; title=&quot;Zabbix. Task. Getting JSON with SEVERAL variables. Python&quot;&gt;Zabbix. Task. Getting JSON with SEVERAL variables. Python&lt;/a&gt; без оставления перенаправления&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Версия 13:33, 5 октября 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Cless</name></author>
	</entry>
	<entry>
		<id>https://wiki.cless.pro/index.php?title=Zabbix._Task._Getting_JSON_with_SEVERAL_variables._Python&amp;diff=1680&amp;oldid=prev</id>
		<title>Cless в 13:32, 5 октября 2023</title>
		<link rel="alternate" type="text/html" href="https://wiki.cless.pro/index.php?title=Zabbix._Task._Getting_JSON_with_SEVERAL_variables._Python&amp;diff=1680&amp;oldid=prev"/>
		<updated>2023-10-05T13:32:46Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Версия 13:32, 5 октября 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l56&quot;&gt;Строка 56:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Строка 56:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;__ОБЯЗАТЕЛЬНОЕ_ОГЛАВЛЕНИЕ__&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;__ОБЯЗАТЕЛЬНОЕ_ОГЛАВЛЕНИЕ__&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;__БЕЗ_РЕДАКТИРОВАНИЯ_РАЗДЕЛА__&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;__БЕЗ_РЕДАКТИРОВАНИЯ_РАЗДЕЛА__&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Категория:Python]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Cless</name></author>
	</entry>
	<entry>
		<id>https://wiki.cless.pro/index.php?title=Zabbix._Task._Getting_JSON_with_SEVERAL_variables._Python&amp;diff=1678&amp;oldid=prev</id>
		<title>Cless: Новая страница: «= Description = Getting JSON with several variables ('''{#DOMAINNAME}''', '''{#SERVICETYPE}''', '''{#SERVICEID}''') for putting them to autodiscoverable Items and...»</title>
		<link rel="alternate" type="text/html" href="https://wiki.cless.pro/index.php?title=Zabbix._Task._Getting_JSON_with_SEVERAL_variables._Python&amp;diff=1678&amp;oldid=prev"/>
		<updated>2023-10-05T13:29:30Z</updated>

		<summary type="html">&lt;p&gt;Новая страница: «= Description = Getting JSON with several variables (&amp;#039;&amp;#039;&amp;#039;{#DOMAINNAME}&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;{#SERVICETYPE}&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;&amp;#039;{#SERVICEID}&amp;#039;&amp;#039;&amp;#039;) for putting them to autodiscoverable Items and...»&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Description =&lt;br /&gt;
Getting JSON with several variables ('''{#DOMAINNAME}''', '''{#SERVICETYPE}''', '''{#SERVICEID}''') for putting them to autodiscoverable Items and Triggers using Python.&lt;br /&gt;
&lt;br /&gt;
= Configuration =&lt;br /&gt;
&lt;br /&gt;
=== Source json &amp;quot;'''servicesList'''&amp;quot;: ===&lt;br /&gt;
 {'answer': {'services': [{'creation_date': '2017-02-26', 'dname': 'cless.pro', 'expiration_date': '2023-02-26', 'service_id': 26891995, 'servtype': 'domain', 'state': 'A', 'subtype': &amp;lt;nowiki&amp;gt;''&amp;lt;/nowiki&amp;gt;, 'uplink_service_id': 0}]}, 'charset': 'utf-8', 'messagestore': None, 'result': 'success'}&lt;br /&gt;
&lt;br /&gt;
=== Python Script ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python3&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
# null string list of services&lt;br /&gt;
trunksNamesListJsonForZabbix = &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# add str data to str json&lt;br /&gt;
trunksNamesListJsonForZabbix = (trunksNamesListJsonForZabbix + &amp;quot;{\&amp;quot;data\&amp;quot;:[&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# for each service in list&lt;br /&gt;
for x in range(len(servicesList)):&lt;br /&gt;
&lt;br /&gt;
    # get dict of services&lt;br /&gt;
    serviceDict = servicesList[x]&lt;br /&gt;
&lt;br /&gt;
    # debug&lt;br /&gt;
    #print(type(serviceDict).__name__)&lt;br /&gt;
&lt;br /&gt;
    # define vars&lt;br /&gt;
    serviceName = serviceDict['dname']&lt;br /&gt;
    serviceType = serviceDict['servtype']&lt;br /&gt;
    serviceId = serviceDict['service_id']&lt;br /&gt;
&lt;br /&gt;
    # debug&lt;br /&gt;
    #print(serviceName + ' ' + serviceType + ' ' + str(serviceId))&lt;br /&gt;
&lt;br /&gt;
    # construct json for zabbix&lt;br /&gt;
    trunksNamesListJsonForZabbix = (&lt;br /&gt;
                trunksNamesListJsonForZabbix + &amp;quot;{\&amp;quot;{#DOMAINNAME}\&amp;quot;&amp;quot; + &amp;quot;:&amp;quot; + &amp;quot;\&amp;quot;&amp;quot; + serviceName + &amp;quot;\&amp;quot;&amp;quot; + &amp;quot;,&amp;quot;&lt;br /&gt;
                + &amp;quot;\&amp;quot;{#SERVICETYPE}\&amp;quot;&amp;quot; + &amp;quot;:&amp;quot; + &amp;quot;\&amp;quot;&amp;quot; + serviceType + &amp;quot;\&amp;quot;&amp;quot; + &amp;quot;,&amp;quot;&lt;br /&gt;
                + &amp;quot;\&amp;quot;{#SERVICEID}\&amp;quot;&amp;quot; + &amp;quot;:&amp;quot; + &amp;quot;\&amp;quot;&amp;quot; + str(serviceId) + &amp;quot;\&amp;quot;&amp;quot; + &amp;quot;}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    # add coma if not final service in list&lt;br /&gt;
    if not x == len(servicesList) - 1:&lt;br /&gt;
        trunksNamesListJsonForZabbix = (trunksNamesListJsonForZabbix + &amp;quot;,&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# add final round bracket to json for zabbix&lt;br /&gt;
trunksNamesListJsonForZabbix = (trunksNamesListJsonForZabbix + &amp;quot;]}&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
# print json of services for zabbix to output&lt;br /&gt;
print(trunksNamesListJsonForZabbix)&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== There will be a JSON &amp;quot;trunksNamesListJsonForZabbix&amp;quot; at the output: ===&lt;br /&gt;
 {&amp;quot;data&amp;quot;:[{&amp;quot;{#DOMAINNAME}&amp;quot;:&amp;quot;cless.pro&amp;quot;,&amp;quot;{#SERVICETYPE}&amp;quot;:&amp;quot;domain&amp;quot;,&amp;quot;{#SERVICEID}&amp;quot;:&amp;quot;26891995&amp;quot;}]}&lt;br /&gt;
[[Категория:Zabbix]]&lt;br /&gt;
__ОБЯЗАТЕЛЬНОЕ_ОГЛАВЛЕНИЕ__&lt;br /&gt;
__БЕЗ_РЕДАКТИРОВАНИЯ_РАЗДЕЛА__&lt;/div&gt;</summary>
		<author><name>Cless</name></author>
	</entry>
</feed>