I tried to synchronize the organization name from my database to itop.
I tried these 2 methods: SQL and JSON Collector but I always get the same error message for these 2 cases: [Error] Empty Synchro Data Source definition for the collector 'OrgSQLCollector' [Error] Exception: Cannot create Collector (empty JSON definition)
orgcollector.class.inc.php
<?php
class OrgSQLCollector extends SQLCollector
{
}
I generated the json file with this command line after I created my data synchro on itop:
php toolkit/dump_tasks.php --task-name="OrgSQLCollector" > collectors/orgcollector.json
Did I forget a step?
Thanks for your help.
Regards,
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
PHP Notice: Undefined variable: index in /root/Collector/mycollector/collectors/main.php on line 3 [2020-11-18 22:04:38][Debug] OK, the required PHP version to run this application is 5.6.0. The current PHP version is 7.3.22. [2020-11-18 22:04:38][Debug] OK, the required extension 'simplexml' is installed (current version: 7.3.22 >= 0.1). [2020-11-18 22:04:38][Debug] OK, the required extension 'dom' is installed (current version: 20031129 >= 1.0). [2020-11-18 22:04:38][Debug] The following configuration files were loaded (in this order):
I succedeed to get the data synchro working with SQLCollector.
But I have a new problem with names that have an accent.
The db source and db target (itop) have a same charset UTF-8.
The problem is in the generation of the CSV file because it replaces the accents by special characters.
If i understand well, SQLCollector executes a SQL query, generates a CSV file and uploads it to the "synchro_data_organization_1" table (in my case) and finally copies it to the organization table. Is that right?
<?xml version="1.0" encoding="utf8"?><!-- Default values for parameters. Do NOT alter this file, use params.local.xml instead --><parameters><itop_url>http://localhost/</itop_url><itop_login>admin</itop_login><itop_password>mypassword</itop_password><contact_to_notify>soji@toto.com</contact_to_notify><synchro_user>admin</synchro_user><json_placeholderstype="hash"><full_load_interval>60</full_load_interval></json_placeholders><sql_host>mydbserver</sql_host><sql_database>mydb</sql_database><sql_login>u_itop</sql_login><sql_password>mypassword</sql_password><myCollector_query>SELECTidasprimary_key,name,partner_idasparent_id,idascode,statusFROMmydb.customers</myCollector_query><defaults><status>active</status></defaults><myCollector_ignored_attributestype="array"><attribute>deliverymodel_id</attribute></myCollector_ignored_attributes>
Hi guys,
I tried to synchronize the organization name from my database to itop.
I tried these 2 methods: SQL and JSON Collector but I always get the same error message for these 2 cases:
[Error] Empty Synchro Data Source definition for the collector 'OrgSQLCollector'
[Error] Exception: Cannot create Collector (empty JSON definition)
I followed this procedure:
https://www.itophub.io/wiki/page?id=extensions%3Aitop-data-collector-base#creating_the_json_definition_file
Here are my config files:
params.local.xml
<parameters>
<itop_url>http://localhost/</itop_url>
<itop_login>admin</itop_login>
<itop_password>password</itop_password>
<console_log_level>9</console_log_level>
<sql_engine>mysql</sql_engine>
<sql_host>192.168.1.1</sql_host>
<sql_database>company</sql_database>
<sql_login>u_itop</sql_login>
<sql_password>password</sql_password>
<orgsqlcollector_query>SELECT id as primary_key, name, parent_id FROM company</orgsqlcollector_query>
</parameters>
main.php
<?php
require_once(APPROOT.'collectors/orgcollector.class.inc.php');
Orchestrator::AddCollector(1, 'OrgSQLCollector');
orgcollector.class.inc.php
<?php
class OrgSQLCollector extends SQLCollector
{
}
I generated the json file with this command line after I created my data synchro on itop:
php toolkit/dump_tasks.php --task-name="OrgSQLCollector" > collectors/orgcollector.json
Did I forget a step?
Thanks for your help.
Regards,
I just try data synchro with CSVCollector but I got the same error message...
php exec.php --config_file=conf/params.local.xml --console_log_level=9
Hello, it's me again.
I succedeed to get the data synchro working with SQLCollector.
But I have a new problem with names that have an accent.
The db source and db target (itop) have a same charset UTF-8.
The problem is in the generation of the CSV file because it replaces the accents by special characters.
If i understand well, SQLCollector executes a SQL query, generates a CSV file and uploads it to the "synchro_data_organization_1" table (in my case) and finally copies it to the organization table. Is that right?
srvitop#cat data/myCollector-1.csv
primary_key;name;parent_id;code;status
1001;"Company S?rl";;1001;0
I got this error message:
On the core/collector.class.inc.php, I changed
After that, the sync works but it imports with this name "Company Srl" (without ? character)
How can I forced the csv file to use utf8?
I changed this parameter on config file:
'csv_file_default_charset' => 'utf8',
But anything change...
Any idea?
Hello Soji,
how did you generate the CSV file with special characters?
did you try the CSV collector and provided the encoding parameter?
https://www.itophub.io/wiki/page?id=extensions%3Aitop-data-collector-base#csv_collector
for SQL /Json collectors can you please provide your setup to let us check?
Best regards
Olivier
Hello Odain,
Thanks for your answer.
The CSV file will generate by Collector class (core/collector.class.inc.php).
Here my configs:
collectors/myCollector.class.inc.php
collectors/main.php
conf/params.distrib.xml
data/myCollector-1.csv
mydbserver and db itop use the same charset.
Problem solved with mysqlcollector.