How to install OCS-NG and GLPI on CENTOS

Inventory is a client server utility which allows you to inventory Linux and Windows servers, PCs, laptops, etc. OCS Inventory installs as a server on either Linux or Windows, but this guide assumes CentOS. The clients are referred to as agents and check in with the server to gather information about the host.

This guide will also show you how to integrate OCS Inventory into the well known GLPI web inventory software package where you get a much more detailed inventory. GLPI handles not only equipment, but also software and contracts making it perfect to import OCS Inventory into.

Install Remi Repository

wget http://rpms.famillecollet.com/el5.i386/remi-release-5-.el5.remi.noarch.rpm
wget http://rpms.famillecollet.com/el5.i386/remi-release-5-6.el5.remi.noarch.rpm
rpm -Uvh remi-release-5*.rpm

Server Installation

Installation of the server consists of configuring a MySQL, Apache, and PHP server. Some of the software might already be installed.

MySQL and Apache Setup

First install a MySQL and Apache server if you don’t already have one running:

yum install mysql-server mysql httpd

Configure at least the Apache ServerName directive and start the httpd service.

vim /etc/httpd/conf/httpd.conf

ServerName: ocs-inventory:80

service httpd start; chkconfig httpd on

Web browse to your host to make sure the web server is actually running. Next, start the mysql service to allow it to run through its initial setup, and then change the password to secure MySQL so your server isn’t running a wide open MySQL instance.

service mysqld start; chkconfig mysqld on

Set a MySQL database root password:

mysqladmin -u root password 'desired_password'

Perl and PHP Setup

Next, install some needed Perl module packages from the RPMForge repo.

yum install perl-XML-Simple perl-Compress-Zlib perl-DBI perl-DBD-MySQL perl-Apache-DBI perl-Net-IP perl-SOAP-Lite

Next, install some PHP requirements and dependencies for the OCS admin console.

yum install php-pecl-zip php-mysql php-devel zlib-devel php-pear php-gd gcc

After you get the packages installed, you’ll need to add zip support to your PHP installation. This requires adding a line to the configuration file.

pecl install zip
vim /etc/php.ini
;Add zip support
extension=zip.so

Restart apache for the changes to take effect.

service httpd restart

This should complete all the requirements prior to installing the actual OCS inventory server. If you run across any asserted Perl module deficiency that you can’t figure out how to solve from RPMForge, then ask on the RPMForge mailing list about a needed item.

Some remember from using perl elsewhere that an admin can also install perl modules from CPAN (see: CPAN and source compiles related). While this may be so, doing so bypasses the protections for dependency and requirements conflicts checking; does NOT provide a path for package system based updates; and does NOT inform the packaging system of what has been added.

This said, you CAN choose to use CPAN, and so convert your machine from being a CentOS box into something you alone support and maintain, by:

perl -MCPAN -e 'install PERL::PACKAGE'

The result after doing so is something, but it is certainly no longer CentOS

OCS Server Installation

OCS Install Script

The next step is to install the OCS software. You can obtain more documentation and the actual packages from the following links.

OCS Support Pages

Installing the management server only takes a few answers to some questions.

yum install --enablerepo=rem ocsinventory*

Configuration and database schema creation :

Connect to  http://localhost/ocsreports/install.php (must be modified if you are connected to the server from another computer).

* Step 1 : enter the MySQL administrator login and password, then Send.

* Step 2 : schema creation. If all is ok (must be true using the RPM), clic on Send

* Step 3 : installation final step. write somewhere the account created  (admin/admin) and clic on Click here to enter OCS-NG GUI.

* Step 4 : choose your language (using the flag on the right top)

* Step 5 : connect to the application (admin/admin)

Congratulations. You have OCS installed  !

Some required configuration options : open the  pipe wrench / Configuration / Config and then the Server tabs:

* LOGLEVEL = On (really usefull when you encounter an issue)

* PROLOG_FREQ = 24 (time between 2 inventory)

* AUTO_DUPLICATE_LVL = crtieria used to detect that 2 computers are the same (I use Model +  Serial + Mac Address).

* TRACE_DELETED = On (required by GLPI).

* SESSION_VALIDITY_TIME = 600 (session duration, the empty value provided is not valid).

Changing the application admin password is also really a good idea (don’t forget it) : use the “key” icon on the right top.

During the installation step a new database ocsweb is created and a MySQL account ocs with a default password = ocs, which is really not secure.
We need to change the MySQL password :

mysql -uroot -prootsecret
mysql UPDATE mysql.user SET Password = PASSWORD('ocssecret') WHERE User = 'ocs';
mysql; FLUSH PRIVILEGES;
mysql exit

 

And to update the configuration file with this new password :

In the  /etc/httpd/conf.d/ocsinventory-server.conf file (arround line 31) :

PerlSetVar OCS_DB_PWD ocssecret

In the /etc/ocsinventory/ocsinventory-reports/dbconfig.inc.php file :

$_SESSION["PSWD_BASE"]="ocssecret"

Tell apache to reload his configuration for perl module to read the new parameter value:

service httpd reload

First computer

To test the inventory feature, we are going to install the inventory agent on a first computer. Of course it will be on our server.

 yum install ocsinventory-agent

Now, send the inventory:

ocsinventory-agent --server=localhost

If all is ok, your server should be in the computer list in OCS.

You can enable the automatic inventory of this computer, edit the  /etc/sysconfig/ocsinventory-agent:

OCSMODE[0]=cron
OCSSERVER[0]=http://localhost/ocsinventory

GLPI

To start, we are going to create the database schema and the MySQL  accounts for GLPI. Using the administrator (root) account is really a  bad idea.

The glpi account will be used by the application, and the synchro account for the synchronizaton process (to read the ocsweb database from glpi with only minimum rights).

N.B. in this example, the synchro user rights are reduce to the  minimal. In the case you want to use some special plugins (uninstall  p.e.), full right are required.

mysql -uroot -prootsecret
mysql; CREATE USER 'glpi'@'%' IDENTIFIED BY 'glpisecret';
mysql GRANT USAGE ON *.* TO 'glpi'@'%' IDENTIFIED BY 'glpisecret';
mysql; CREATE DATABASE IF NOT EXISTS `glpi` ;
mysql GRANT ALL PRIVILEGES ON `glpi`.* TO 'glpi'@'%';
mysql CREATE USER 'synchro'@'%' IDENTIFIED BY 'syncsecret';
mysq GRANT USAGE ON *.* TO 'synchro'@'%' IDENTIFIED BY 'syncsecret';
mysql GRANT SELECT ON `ocsweb`.* TO 'synchro'@'%';
mysql GRANT DELETE ON `ocsweb`.`deleted_equiv` TO 'synchro'@'%';
mysql GRANT UPDATE (`CHECKSUM`) ON `ocsweb`.`hardware` TO 'synchro'@'%';
mysql FLUSH PRIVILEGES;
mysql exit

Installation :

yum install glpi* -y
service httpd reload

Database schema creation and configuration

Connect to the application : http://localhost/glpi/ it will launch the configuration wizard.

* select your language and : OK.

* read and accept the license (GPL) : Continue

* start the installation : Installation

* step 0 : prerequisites check (must be ok with the RPM) : Continue

* step 1 : enter the database connexion parameters (localhost / glpi / glpisecret) : Continue

* step 2 : select the glpi database and Continue

* step 3 : write somewhere the adminstrateur login and password (glpi/glpi) et Continue

* step 4 : also write the other account informations : Use GLPI

* Authentificate yourself with the new account : glpi/glpi

Congratulations (again) : you have GLPI installed !

OCSNG mode configuration

OCSNG mode activation :

* Menu Setup / General

* Restrictions tabs

* Activate OCSNG mode : Yes, and Post

Server Configuration :

* Menu Setup / OCSNG mode

* Select the server created during installation: localhost

* Name: My OCS Server

* OCSweb host: localhost

* Name of the OCS database: ocsweb

* OCSweb database user: synchro

* OCSweb user password: syncsecret

* Post

You must get the Connection to OCS database successful message.

Now, we must configure the informations that will be imported from OCS to GLPI. Here is a few examples :

* Monitors : Unit import on Serial number

* Logiciels : Unit Import

* Use the software dictionary of OCS: No

* Number of computers to synchronize using the cron: 0 (we are going to use another solution)

* General informations Computers : Yes for all that you are interested by.

* Components : Yes for what you want.

* etc, etc (you should notice that a lot of behavior are configurable)

* Post

Check :

* Menu Tools / OCSNG

* Import new computers

In the displayed list, you should see your server (on which we have installed the agent).

Don’t ask for it to be imported as we are going to see how to use automatic synchronization.

Automatic OCSNG synchronization

Connect into GLPI to install / configure the plugin :

* Menu Setup / Plugins

* Link : OCS massive Import

* Link : Install OCS massive import plugin (plugin tables creation)

* Default OCS server: My OCS Server

* Post the configuration page

* Enable the synchronization

The planified task configured by the RPM will be launched every 5 minutes.

Be patient, your first computer should be imported into GLPI.

Tu supervise the synchronization :

* Menu : Plugins / OCS Massive Import

* Tab :  Informations about scripts execution

Conclusion

We have configured one of the best inventory and asset management solution in a few minutes (probably the best, as it is OpenSource)

You can now continue to deploy the inventory agent on your other computers, it’s available for most OS.

Take also some time to read the official documentation to be able to tune your configuration to fully suite your need:

* OCS Documentation

* GLPI Documentation

Don’t forget than OpenSource projects exists thanks to their community and to their users contributions.

So when you’ll have seen what OCS and GLPI can do for you, don’t forget to do something for this projects:

* OCS NG donations

* Contribute to GLPI

Comments and support

Of course, comments on this guide are welcome and could be posted here.

For support questions, please, use each application official forums:

* OCS Forums

* GLPI Forums

* Forums – Les RPM de Remi for questions about this tutorial or the RPM.

 

You may also like...

2 Responses

  1. Mohamed Fathy says:

    Thanks, I think the first step in OCS Server installation should be “in the it should be
    yum install –enablerepo=remi ocsinventory*
    (remi not rem)

  2. Mohamed Fathy says:

    I’ve reached the OCS First computer inventory, but didn’t find it in computers !, any clues
    I may send you the steps I followed in detail if needed

Leave a Reply