Developers:Unified Agent 2.x
From OCS Inventory NG
Contents |
Presentation
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.
Vocabulary
- Task: it's a feature of the agent (inventory, network scan, wol)
Suggestions
Module namespaces
Ocsinventory::Agent # the agent itself
Create a module herarchy per task
Ocsinventory::Agent::Task::$TaskName
Eg:
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
Workflow
- ocsinventory-agent is started
- It checks another agent is not running, if so → []
- It loads it settings from the cfg and the params like today
- It removes $VARDIR/$pid if needed (TODO, lock mechanism)
- It store() the $config object $VARDIR/config.dump
- It goes to background if daemon/service mode is requested
- For every servers, if it get a remove wakeup of if the next_timefile is done
- It contacts the server (PROLOG) and get back the PROLOG response (Ocsinventory::Agent::XML::Response::Prolog) with the parameter for the different “task”
- It write the PROLOG response object in $VARDIR/prolog.dump
- it starts the “task” modules (perl -MOcsinventory::Agent::Task::$TaskName -e'Ocsinventory::Agent::Task::$TaskName::main()' -- $VARDIR)
- Remove the prolog.dump
Q: What to do if the server doesn't anwser to the prolog?
A:
HTTP server
For now we will use HTTP::Daemon::SSL.
These HTTP error code are used:
- 200
- 403
- 500
Wake up
Purpose: Force the agent to contact the servers.
URI parameters:
- action: wakeup
- deviceid: deviceid from the INVENTORY
http://client:62354/?action=wakeup&deviceid=$DEVICEID
Returns 403 if $DEVICEID is different to the machine deviceid.
Download
Purpose: Download a file. The file have to be in the $VARDIR/shared
URI parameters:
- action: download
- file: filename
http://client:62354/?action=download?file=/124567890/1234567890-1
Log
Purpose: Get the last log file of the agent
URI parameters:
- action: log
- deviceid: $DEVICEID
http://client:62354/?action=wakeup&deviceid=$DEVICEID
Returns an err 403 if $DEVICEID != machine deviceid
Log
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

