Agent to import configitem periodically [SOLVED]

Moderator: crythias

Locked
dtamajon
Znuny newbie
Posts: 15
Joined: 21 Aug 2012, 19:47
Znuny Version: 3.6.0
Real Name: Daniel
Company: Lite Solutions

Agent to import configitem periodically [SOLVED]

Post by dtamajon »

I'm new in OTRS, and I have been learning for the last few days. Now I have my configuration done, including the ITSM module installed and working.

My CMDB is outside OTRS, so I have created a template to import data through a CSV and it is working properly.

Now, I would like to create an agent to invoke the import module over a file periodically, so the OTRS CMDB is updated with the incoming data.

I know I have to create a file my agent file (hardwareImportAgent.pm) in '<OTRS path>/Kernel/System/GenericAgent'. But I don't know how to invoke import procedure in 'run' function, and what should I operate in 'new' function.

Thanks for your help!!
Last edited by dtamajon on 19 Sep 2012, 12:35, edited 1 time in total.
Linux Ubuntu 10.04 TLS / PostgreSQL 9.1 / Perl 5.10.1
OTRS 3.1.10 / ITSM 3.1.6
Wolfgangf
Znuny ninja
Posts: 1029
Joined: 13 Apr 2009, 12:26
Znuny Version: 6.0.13
Real Name: Wolfgang Fürtbauer
Company: PBS Logitek GmbH
Location: Pinsdorf

Re: Agent to import configitem periodically

Post by Wolfgangf »

why don't you use the "Import/Export" modules for that?
Produktiv:
OTRS 6.0.13/ ITSM 6.0.13
OS: SUSE Linux (SLES 12, Leap), MySql 5.5.x, 5.6.x
Windows 2012 AD Integration (agents and customers), Nagios integration (incidents, CMDB), Survey, TimeAccounting
dtamajon
Znuny newbie
Posts: 15
Joined: 21 Aug 2012, 19:47
Znuny Version: 3.6.0
Real Name: Daniel
Company: Lite Solutions

Re: Agent to import configitem periodically

Post by dtamajon »

I have used the module to test my templates... but I need to do it every day... so it's a work for an agent, not for a human being.

What I want to do is to invoke the "Import/Export" module from an agent... how can I do it?
Linux Ubuntu 10.04 TLS / PostgreSQL 9.1 / Perl 5.10.1
OTRS 3.1.10 / ITSM 3.1.6
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Agent to import configitem periodically

Post by crythias »

dtamajon wrote:I have used the module to test my templates... but I need to do it every day
so run it scheduled as a task or cron job.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
dtamajon
Znuny newbie
Posts: 15
Joined: 21 Aug 2012, 19:47
Znuny Version: 3.6.0
Real Name: Daniel
Company: Lite Solutions

Re: Agent to import configitem periodically

Post by dtamajon »

Ok, that's a good solution... but I don't figure out how to call the module from cron, without authentication and the input type file for telling where is the file to import.

I can do something like this, but it won't work because input type file must be used on 'post' statements, not 'get' (maybe I'm wrong?):
{cron schedule} wget http://localhost/otrs/index.pl?Action=A ... myfile.csv

And even if it works, it should be authenticated to execute that sentence. I have seen the source code, and the login form is sent by post too.

If you tell me to write a Perl script to do that, I'm at the beginning... :(
Linux Ubuntu 10.04 TLS / PostgreSQL 9.1 / Perl 5.10.1
OTRS 3.1.10 / ITSM 3.1.6
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Agent to import configitem periodically

Post by crythias »

OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
dtamajon
Znuny newbie
Posts: 15
Joined: 21 Aug 2012, 19:47
Znuny Version: 3.6.0
Real Name: Daniel
Company: Lite Solutions

Re: Agent to import configitem periodically

Post by dtamajon »

Thank you! I had read that thread before but I lost the module reference in my mind.

Now it's working!!

The complete sentence I use is:

perl /opt/otrs/bin/ImportExport.pl -n <templateId> -a import -i <filenameToImport>
Linux Ubuntu 10.04 TLS / PostgreSQL 9.1 / Perl 5.10.1
OTRS 3.1.10 / ITSM 3.1.6
Locked