Gone are the days when organizations used to maintain server details in spreadsheets and manually update the spreadsheet whenever needed. These spreadsheets failed to keep up mainly because things became more complex over time. More powerful applications were then developed to maintain server inventory and provide details whenever required.
A server inventory is a list of all the assets in your organization. It stores all the important information about hardware and software components in the organization. This includes server types, capacity, memory and information type. This valuable information is important for several needs in the organization such as maintenance, upgrading, troubleshooting and phasing out.
Open Computers and Software Inventory Next Generation abbreviated as OCS inventory NG is an open-source tool that allows users to maintain IT assets. It collects information about the hardware and software of networked machines running the OCS client program (OCS Inventory Agent). It is also capable of discovering assets without an agent. For this case, IP discovery is used and SNMP collects the data from the IP scan. With OCS inventory, you can collect data from several devices such as printers, scanners, switches, routers etc.
The main features offered by OCS Inventory NG are:
- It provides network discovery
- It supports several plugins through APIs
- It has a friendly web-based interface.
- Its web service can be accessed through the SOAP interface
- It offers an advanced broadcasting system for deploying software installations or executing scripts and commands on computers without overloading the network
- It provides relevant inventory information
The OCS Inventory Server comprises:
- Communication server: It handles HTTP communications between the database server and agents.
- Administration console: It allows administrators to query the database server using their favourite browser.
- Deployment server: It is used to store all package deployment configurations (requires HTTPS!).
- Database server: It stores the inventory information.
This guide aims to demonstrate how to install and use OCS Inventory Server on Rocky Linux 8 / AlmaLinux 8.
#1. Update Your Rocky Linux 8 / AlmaLinux 8 System
It is always important to work on an updated server. To achieve that, issue the below command on your system.
sudo dnf -y update
Once the process is complete, you need to restart the system for any updates that require a reboot to take effect.
sudo reboot
#2. Install and Configure a Database for OCS Inventory Server
A database is an essential component in the OCS Inventory Server architecture. In this guide, we will use MariaDB as our database server. Install it on Rocky Linux 8 / AlmaLinux 8 using the command:
sudo dnf install -y @mariadb
Once complete, start and enable the service:
sudo systemctl enable --now mariadb
Now harden the MariaDB instance:
$ sudo mysql_secure_installation
.....
Enter current password for root (enter for none):
....
Change the root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
.....
Remove anonymous users? [Y/n] y
....
Disallow root login remotely? [Y/n] y
...
Remove test database and access to it? [Y/n] y
....
Reload privilege tables now? [Y/n] y
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
Once the root password has been set, use it to access the shell
mysql -u root -p
Now create a database for the OCS Inventory Server
CREATE DATABASE ocsweb;
GRANT ALL PRIVILEGES ON ocsweb.* TO ocs@localhost IDENTIFIED BY "StrongPassw0rd";
FLUSH PRIVILEGES;
QUIT;
#3. Install Apache and PHP on Rocky Linux 8 / AlmaLinux 8
OCS Inventory NG requires the following:
- Apache version 2.2 or higher.
- Mod_perl version 1.29 or higher.
- PHP 7 or higher, with ZIP and GD support, enabled.
- php_curl
- php_soap
- php_mbstring
- php_xml
Begin by adding the EPEL and REMI repositories to the system:
sudo dnf install dnf-utils epel-release -y
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm -y
Once added, enable the REMI and PowerTools repository:
sudo yum-config-manager --enable remi
sudo dnf config-manager --set-enabled powertools
Set the PHP module PHP
sudo dnf module reset php -y
sudo dnf -y module install php:remi-8.0
Now install Apache, PHP and all the extensions required:
sudo dnf -y install php-{curl,zip,gd,soap,xml,mbstring} @httpd mod_perl
Once the installation is complete, check the PHP version.
$ php -v
PHP 8.0.26 (cli) (built: Nov 22 2022 17:44:09) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.26, Copyright (c) Zend Technologies
Start and enable the Apache and PHP-FPM services:
sudo systemctl enable --now php-fpm httpd
Check the status of the services:
$ systemctl status php-fpm httpd
php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2022-12-06 04:51:35 EST; 7s ago
Main PID: 6031 (php-fpm)
Status: "Ready to handle connections"
Tasks: 6 (limit: 23198)
Memory: 12.2M
CGroup: /system.slice/php-fpm.service
├─6031 php-fpm: master process (/etc/php-fpm.conf)
├─6037 php-fpm: pool www
├─6038 php-fpm: pool www
├─6039 php-fpm: pool www
├─6040 php-fpm: pool www
└─6041 php-fpm: pool www
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/httpd.service.d
└─php-fpm.conf
Active: active (running) since Tue 2022-12-06 04:51:36 EST; 6s ago
Docs: man:httpd.service(8)
Main PID: 6042 (/usr/sbin/httpd)
Status: "Started, listening on: port 443, port 80"
Tasks: 213 (limit: 23198)
Memory: 32.5M
CGroup: /system.slice/httpd.service
├─6042 /usr/sbin/httpd -DFOREGROUND
├─6044 /usr/sbin/httpd -DFOREGROUND
├─6045 /usr/sbin/httpd -DFOREGROUND
├─6046 /usr/sbin/httpd -DFOREGROUND
└─6047 /usr/sbin/httpd -DFOREGROUND
Allow HTTP and HTTPS through the firewall
sudo firewall-cmd --zone=public --add-service=http --permanent
sudo firewall-cmd --zone=public --add-service=https --permanent
sudo firewall-cmd --reload
#4. Install and Configure the OCS Inventory server
to be able to install the OCS Inventory server on Rocky Linux 8 / AlmaLinux 8, we need to add the RPM repository to the system. This can be done using the command:
sudo dnf -y install https://rpm.ocsinventory-ng.org/ocsinventory-release-latest.el8.ocs.noarch.rpm
The added repository provides:
- ocsinventory-server: Contain the server
- ocsinventory: Meta package for OCS inventory-server and OCS inventory-reports
- ocsinventory-reports: Contain OCS reports, the Admin GUI
- ocsinventory-agent: Meta package for OCS inventory-agent-core and full dependencies
- ocsinventory-agent-core: Contain the agent with the minimal dependencies
For this guide, we will install the ocsinventory
package:
sudo yum install ocsinventory
After the installation, import the database schema:
mysql -f -hlocalhost -uroot -p ocsweb < /usr/share/ocsinventory-reports/ocsreports/files/ocsbase.sql >log.log
Provide the root password to proceed. Once imported, make adjustments to PHP:
sudo vim /etc/php.ini
In the file, edit the below lines:
upload_max_filesize = 10M
post_max_size = 10M
max_execution_time = 300
max_input_time = 300
memory_limit = 256M
For the changes made to apply, restart the Apache and PHP-FPM services:
sudo systemctl restart httpd php-fpm
#5. Access OCS Inventory Web Interface
Now you are set to access the OCS Inventory Web interface. To access the Interface, use the URL http://IP_address/ocsreports/install.php

On the above page, provide the credentials of the user who can create tables, databases and indexes. For his case, we will use the root user. So we will provide:
- MySQL username (root)
- MySQL root user password
- MySQL hostname
- MySQL database(ocsweb)
Once the details have been provided, click send and proceed to the below page:

Perform a database update

Now click on “Click here to enter OCS-NG GUI” to access the below UI.

On this page, log in using the default credentials.

The credentials are:
username: admin
password: admin
Once logged in, you will see the below interface:

Remove the error using the command:
sudo mv /usr/share/ocsinventory-reports/ocsreports/install.php /usr/share/ocsinventory-reports/ocsreports/install.php.original
Also, update the below file:
sudo vim /etc/httpd/conf.d/ocsinventory-server.conf
Set the username and password for the ocs user as created:
# Master Database settings
# Replace localhost by hostname or ip of MySQL server for WRITE
PerlSetEnv OCS_DB_HOST localhost
# Replace 3306 by port where running MySQL server, generally 3306
PerlSetEnv OCS_DB_PORT 3306
# Name of database
PerlSetEnv OCS_DB_NAME ocsweb
PerlSetEnv OCS_DB_LOCAL ocsweb
# User allowed to connect to database
PerlSetEnv OCS_DB_USER ocs
# Password for user
PerlSetVar OCS_DB_PWD StrongPassw0rd
...
For changes to take effect, restart Apache and PHP-FPM:
sudo systemctl restart httpd php-fpm
#6. Setup the OCS Inventory Agent
To be able to manage the client machines, we will install and configure the ocsinventory-agent
package. Now on your desired client machine, install the package as shown:
- On Debian/Ubuntu
Export the codename:
distribution_codename=your-code-name
Replace your code name appropriately and proceed. For example:
distribution_codename=bullseye
#Or
distribution_codename=focal
Add the repository:
##On Debian
curl -sS http://deb.ocsinventory-ng.org/pubkey.gpg | sudo apt-key add -
echo "deb http://deb.ocsinventory-ng.org/debian/ $distribution_codename main" | sudo tee /etc/apt/sources.list.d/ocsinventory.list
##On Ubuntu
curl -sS http://deb.ocsinventory-ng.org/pubkey.gpg | sudo apt-key add -
curl -fsSL http://deb.ocsinventory-ng.org/pubkey.gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/ocs-archive-keyring.gpg
echo "deb http://deb.ocsinventory-ng.org/ubuntu/ $distribution_codename main" | sudo tee /etc/apt/sources.list.d/ocsinventory.list
Install the packages:
sudo apt update && sudo apt install ocsinventory-agent libsnmp-perl
Proceed with the configuration as shown:
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
?> 0
Do you want to create the directory /etc/ocsinventory?
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/ocsinventory-agent.cfg,
What is the address of your ocs server?> http://192.168.205.2/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?> debian11
Please enter 'y' or 'n'?> [y] y
Where do you want the agent to store its files? (You probably don't need to change i
t)?> [/var/lib/ocsinventory-agent]
Please enter 'y' or 'n'?> [y]
Should I remove the old unix_agent
Please enter 'y' or 'n'?> [n] n
Do you want to activate debug configuration option ?
Please enter 'y' or 'n'?> [y] y
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/ocsinventory-agent/ocsinventory-agent.log
Do you want disable SSL CA verification configuration option (not recommended) ?
Please enter 'y' or 'n'?> [n] n
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] y
Now create the log directory:
sudo mkdir -p /var/log/ocsinventory-agent
sudo touch /var/log/ocsinventory-agent/ocsinventory-agent.log
sudo chmod 775 /var/log/ocsinventory-agent/ocsinventory-agent.log
- On RHEL/Rocky Linux/Alma Linux/CentOS
Add the repositories with the commands:
##On RHEL 7/Rocky Linux 7/Alma Linux 7/CentOS 7
sudo wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo wget https://rpm.ocsinventory-ng.org/ocsinventory-release-latest.el7.ocs.noarch.rpm
sudo yum install ocsinventory-release-latest.el7.ocs.noarch.rpm epel-release-latest-7.noarch.rpm
##On RHEL 8/Rocky Linux 8/Alma Linux 8/CentOS 8
sudo dnf -y install https://rpm.ocsinventory-ng.org/ocsinventory-release-latest.el8.ocs.noarch.rpm epel-release
##On RHEL 9/Rocky Linux 9/Alma Linux 9/CentOS 9
sudo dnf -y install https://rpm.ocsinventory-ng.org/ocsinventory-release-latest.el9.ocs.noarch.rpm epel-release yum-utils
sudo yum-config-manager --enable crb
Once the repository has been added, install the packages:
sudo yum install ocsinventory-agent net-snmp-perl perl-Net-SNMP
Once installed, start and enable the required service:
sudo /sbin/mpathconf --enable
Configure OCS Inventory Agent
The OCS Inventory Agent stores its configuration file at /etc/ocsinventory/ocsinventory-agent.cfg. This configuration file can be modified as desired to communicate with your server.
sudo vim /etc/ocsinventory/ocsinventory-agent.cfg
In the file, add the below lines:
# Server URL, unconmment if needed
server = http://your.ocs.ip/ocsinventory
tag = your_tag
##Change the line below##
basevardir = /var/lib/ocsinventory-agent
By default, the Cron Job will send data to the OCS server every hour. We can configure it to send data once a day by moving it to ‘cron.daily‘ as shown:
##On Debian/Ubuntu
sudo mv /etc/cron.d/ocsinventory-agent /etc/cron.daily/
##On RHEL/Rocky Linux/Alma Linux/CentOS
sudo mv /etc/cron.hourly/ocsinventory-agent /etc/cron.daily/
Now force data to be sent immediately by executing the command:
sudo ocsinventory-agent
View the logs in case you have an error:
$ sudo cat /var/log/ocsinventory-agent/ocsinventory-agent.log
[Tue Dec 6 13:06:20 2022][info] PROLOG_FREQ has changed since last process(old=,new=24)
[Tue Dec 6 13:06:20 2022][info] [download] Download is off.
[Tue Dec 6 13:06:26 2022][info] [download] Beginning work. I am 41047.
[Tue Dec 6 13:06:26 2022][info] [download] Option turned off. Exiting.
[Tue Dec 6 13:07:16 2022][info] [download] Download is off.
[Tue Dec 6 13:07:22 2022][info] [download] Beginning work. I am 41325.
[Tue Dec 6 13:07:22 2022][info] [download] Option turned off. Exiting.
Now back on the OCS Inventory server web interface, you should see the agents added.

To view information about the device, click on all computers and select the desired computer name

You can see the administrative data:

View the hardware:

View software information:

You can also view the network, configuration, deployment and other miscellaneous information desired.
Verdict
We have successfully walked through how to install and use OCS Inventory Server on Rocky Linux 8 / AlmaLinux 8. We have seen how easy it is to add a client device and manage it from the OCS Inventory Server web interface. I hope this was important to you.
See more:
- How To Install OCS Inventory Server on CentOS 8
- How To Install OCS Inventory Server on Debian
- Install OCS Inventory on Ubuntu
- Install Quipucords / QPC on CentOS 8 | RHEL 8