Developers:Unified Agent 2.x

From OCS Inventory NG
Jump to: navigation, search


This is a draft about the futur development of the Perl agent (AKA OCS Inventory Unified Agent) (AKA OCS Inventory UNIX Agent).

Current issue with the 1.x series

  • Memory usage. Currently the agent uses 40MB of memory. It's even worst with daemon mode because this memory is not given back to the system when there is no activity.
  • Limited module mechanism. It was designed for inventory and don't feet weel with the new needs (software deployment, SNMP, WoL, ...)
  • Only one OCS Inventory server per agent.


  • Task: it's a feature of the agent (inventory, network scan, wol)


Module namespaces

Ocsinventory::Agent # the agent itself

Create a module herarchy per task



Ocsinventory::Agent::Task::Inventory # Main Inventory module
Ocsinventory::Agent::Task::Inventory::OS::Linux # Get inventory information from Linux
Ocsinventory::Agent::Task::Deploy # Software deployment job
Ocsinventory::Agent::Task::SNMP # SNMP feature module
Ocsinventory::Agent::Task::SNMP::XXXXXX # The private modules for SNMP

Split in subprocesses

In order to free the memory, every “task” has it own process. A minimalist main script will be used to launch them (ocsinventory-agent).

Minimalist main script

  • Very light
  • A minimalist HTTP server listen on the 62354 port

Task processes

  • Limited execution time (Max 10 minutes)
  • Can contact the server themself


  1. ocsinventory-agent is started
  2. It checks another agent is not running, if so → []
  3. It loads it settings from the cfg and the params like today
  4. It removes $VARDIR/$pid if needed (TODO, lock mechanism)
  5. It store() the $config object $VARDIR/config.dump
  6. It goes to background if daemon/service mode is requested
  7. For every servers, if it get a remove wakeup of if the next_timefile is done
    1. It contacts the server (PROLOG) and get back the PROLOG response (Ocsinventory::Agent::XML::Response::Prolog) with the parameter for the different “task”
    2. It write the PROLOG response object in $VARDIR/prolog.dump
    3. it starts the “task” modules (perl -MOcsinventory::Agent::Task::$TaskName -e'Ocsinventory::Agent::Task::$TaskName::main()' -- $VARDIR)
    4. Remove the prolog.dump

Q: What to do if the server doesn't anwser to the prolog?


HTTP server

For now we will use HTTP::Daemon::SSL.

These HTTP error code are used:

  • 200
  • 403
  • 500


Purpose: Download a file. The file have to be in the $VARDIR/shared

URI parameters:

  • action: download
  • file: filename


Purpose: Get the last log file of the agent

URI parameters:

  • action: log
  • deviceid: $DEVICEID

Returns an err 403 if $DEVICEID != machine deviceid


Ocsinventory::Agent::Logger will be used. We need to extend it to record the $TaskName too.

[core][ERROR]This is an example from ocsinventory-agent
[SNMP][ERROR]This is another example from the SNMP task
[Inventory][ERROR]Yet another example from Inventory task