How can I install OCS Inventory Agent on Debian 12/Debian 11/Debian 10. This is a step by step guide to take you through this process.
Table of Contents
Installing OCS Inventory Agent on Debian 12|11|10
Run system update
apt update
Install OCS Inventory Agent
There are two ways in which you can install OCS inventory agent.
- Installing OCS Inventory Agent from OCS APT Repos
- Compiling and Installing OCS Inventory Agent
Install OCS Inventory Agent from OCS APT Repos
This is the easiest of installing OCS inventory agent
Install OCS Inventory Agent Debian APT Repos
Currently there is no available repos for Debian 12.
Thus, on Debian 12/Debian 11
To use this method, install the OCS APT repository;
apt install gnupg2 curl wget -y
curl -sS http://deb.ocsinventory-ng.org/pubkey.gpg | \
gpg --dearmor -o /etc/apt/trusted.gpg.d/ocs.gpg
echo "deb http://deb.ocsinventory-ng.org/debian/ bullseye main" | \
tee /etc/apt/sources.list.d/ocsinventory.list
On Debian 10;
apt install gnupg2 curl wget -y
curl -sS http://deb.ocsinventory-ng.org/pubkey.gpg | \
gpg --dearmor -o /etc/apt/trusted.gpg.d/ocs.gpg
echo "deb http://deb.ocsinventory-ng.org/debian/ buster main" | \
tee /etc/apt/sources.list.d/ocsinventory.list
Installing OCS Inventory Agent from OCS APT Repos
Once you have the repositories in place, then proceed to run system package cache update.
apt update
Check the available version of OCS inventory agent package;
apt-cache policy ocsinventory-agent
ocsinventory-agent:
Installed: (none)
Candidate: 2:2.10.0
Version table:
2:2.10.0 500
500 http://deb.ocsinventory-ng.org/debian bullseye/main amd64 Packages
2:2.8-1 500
500 http://deb.debian.org/debian bullseye/main amd64 Packages
The current version of OCS inventory agent is v2.10.0 as releases page.
Thus, run the command below to install it;
sudo apt install ocsinventory-agent
During the installation, you will be prompted to setup OCS agent.
Go through each prompt and provide your appropriate answer;
Do you want to configure the agent
Please enter 'y' or 'n'?> [y] y
Where do you want to write the configuration file?
0 -> /etc/ocsinventory
1 -> /usr/local/etc/ocsinventory
2 -> /etc/ocsinventory-agent
?> 2
Do you want to create the directory /etc/ocsinventory-agent?
Please enter 'y' or 'n'?> [y] y
Should the old unix_agent settings be imported ?
Please enter 'y' or 'n'?> [y] n
[info] The config file will be written in /etc/ocsinventory-agent/ocsinventory-agent.cfg,
What is the address of your ocs server?> asset-mgr.kifarunix-demo.com
Do you need credential for the server? (You probably don't)
Please enter 'y' or 'n'?> [n] n
Do you want to apply an administrative tag on this machine
Please enter 'y' or 'n'?> [y] y
tag?> debian12
Do yo want to install the cron task in /etc/cron.d
Please enter 'y' or 'n'?> [y] y
Where do you want the agent to store its files? (You probably don't need to change it)?> [/var/lib/ocsinventory-agent]
Do you want to create the /var/lib/ocsinventory-agent directory?
Please enter 'y' or 'n'?> [y] y
Should I remove the old unix_agent
Please enter 'y' or 'n'?> [n] y
Do you want to activate debug configuration option ?
Please enter 'y' or 'n'?> [y] n
Do you want to use OCS Inventory NG UNix Unified agent log file ?
Please enter 'y' or 'n'?> [y] y
Specify log file path you want to use?> /var/log/ocs-agent.log
Do you want disable SSL CA verification configuration option (not recommended) ?
Please enter 'y' or 'n'?> [n] y
Do you want to set CA certificates file path ?
Please enter 'y' or 'n'?> [y] n
Do you want to use OCS-Inventory software deployment feature?
Please enter 'y' or 'n'?> [y] n
Do you want to use OCS-Inventory SNMP scans feature?
Please enter 'y' or 'n'?> [y] y
Do you want to send an inventory of this machine?
Please enter 'y' or 'n'?> [y] y
Setting OCS Inventory NG server address...
And that is it.
The package will also install a cronjob that iventories your system on daily basis;
cat /etc/cron.d/ocsinventory-agent
PATH=/usr/sbin:/usr/bin:/sbin:/bin
15 9 * * * root /usr/bin/ocsinventory-agent --lazy > /dev/null 2>&1
It will also create configs under /etc/ocsinventory-agent/ocsinventory-agent.cfg
.
cat /etc/ocsinventory-agent/ocsinventory-agent.cfg
basevardir=/var/lib/ocsinventory-agent
logfile=/var/log/ocs-agent.log
ssl=0
server=http://asset-mgr.kifarunix-demo.com/ocsinventory
debug=
tag=debian12
You can also run system inventory manually;
ocsinventory-agent
Compiling and Installing OCS Inventory Agent on Debian
This method guarantees the installation of a specific version, including new release versions.
Install Required Libraries
To install OCS Inventory agent will all the required packages, run the command below;
apt install make gcc libmodule-install-perl dmidecode libxml-simple-perl \ libcompress-zlib-perl openssl libnet-ip-perl libwww-perl libdigest-md5-perl \ libdata-uuid-perl libcrypt-ssleay-perl libnet-snmp-perl libproc-pid-file-perl \ libproc-daemon-perl net-tools libsys-syslog-perl pciutils smartmontools read-edid \ nmap libnet-netmask-perl sudo
To install a newer version of OCS Agent, navigate to the OCS Inventory downloads page and grab the source file for the new version.
For example, this guide uses OCS Agent v2.10.0 and can be downloaded as follows;
wget https://github.com/OCSInventory-NG/UnixAgent/releases/download/v2.10.0/Ocsinventory-Unix-Agent-2.10.0.tar.gz
Once the download is done, extract the source code.
tar xzf Ocsinventory-Unix-Agent-2.10.0.tar.gz
Installing OCS Inventory Agent from Source
Navigate to OCS Inventory agent source directory
cd Ocsinventory-Unix-Agent-2.10.0
OCS Agent can be installed interactively or non-interactively.
To install OCS agent non-interactively, simply run the commands below;
sudo env PERL_AUTOINSTALL=1 perl Makefile.PL
sudo make
sudo make install
Then you can configure it;
perl postinst.pl --nowizard --server=https://asset-mgr.kifarunix-demo.com/ocsinventory --crontab --nossl --verbose --now
To install OCS agent interactively, simply run the commands below;
sudo perl Makefile.PL
sudo make
sudo make install
While setting up the address of your ocs server, if you are using hostname, ensure that it is resolvable.
...
Do you want to configure the agent
Please enter 'y' or 'n'?> [y] y
Where do you want to write the configuration file?
0 -> /etc/ocsinventory
1 -> /usr/local/etc/ocsinventory
2 -> /etc/ocsinventory-agent
?> 2
Do you want to create the directory /etc/ocsinventory-agent?
Please enter 'y' or 'n'?> [y] y
Should the old unix_agent settings be imported ?
Please enter 'y' or 'n'?> [y] y
[info] The config file will be written in /etc/ocsinventory-agent/ocsinventory-agent.cfg,
What is the address of your ocs server?> https://asset-mgr.kifarunix-demo/ocsinventory
Do you need credential for the server? (You probably don't)
Please enter 'y' or 'n'?> [n] n
Do you want to apply an administrative tag on this machine
Please enter 'y' or 'n'?> [y] y
tag?> test-deb10
Do yo want to install the cron task in /etc/cron.d
Please enter 'y' or 'n'?> [y] y
Where do you want the agent to store its files? (You probably don't need to change it)?> [/var/lib/ocsinventory-agent]
Do you want to create the /var/lib/ocsinventory-agent directory?
Please enter 'y' or 'n'?> [y] y
Should I remove the old unix_agent
Please enter 'y' or 'n'?> [n] y
Do you want to activate debug configuration option ?
Please enter 'y' or 'n'?> [y] n
Do you want to use OCS Inventory NG UNix Unified agent log file ?
Please enter 'y' or 'n'?> [y] y
Specify log file path you want to use?> /var/log/ocs-agent.log
Do you want disable SSL CA verification configuration option (not recommended) ?
Please enter 'y' or 'n'?> [n]
Do you want to set CA certificate chain file path ?
Please enter 'y' or 'n'?> [y]
Specify CA certificate chain file path?> /etc/ocsinventory-agent/cacert.pem
Do you want to use OCS-Inventory software deployment feature?
Please enter 'y' or 'n'?> [y]
Do you want to use OCS-Inventory SNMP scans feature?
Please enter 'y' or 'n'?> [y]
Do you want to send an inventory of this machine?
Please enter 'y' or 'n'?> [y]
...
OCS Inventory Agent-Server Communication
By default, OCS inventory agent is set to communicate with the server once a day via the daily cron job, /etc/cron.d/ocsinventory-agent.
To force the agent to communicate to the server immediately, you can run;
ocsinventory-agent
Or specify address of the server;
ocsinventory-agent --server http://ocsinv.example.com/ocsinventory
Verify Assets Details on OCS Inventory Servery
You can now login to your OCS Inventory server and verify that the assets have been inventoried.
Click on All Computers tab to see a list your assets.
You can also configure OCS Agent to inventory the system hourly via the cron job.
mv /etc/cron.daily/ocsinventory-agent /etc/cron.hourly
Well, that is just it on how to install OCS Agent on Debian 12/Debian 11/Debian 10. Feel free to explore this tool further.