OCS Inventory Server/Clients

OCS 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.

A few of the required Perl modules are packaged in RPMs that come from other repos, so make sure you follow the appropriate section on the wiki for configuring third-party repos.

There are two versions of OCS currently, 1.01 and 1.02 RC2. I tried installing the latter and had some issues getting things to work. The rest of this guide will assume you are installing version 1.01 server and agents.

System

CentOS 5.1/5.2

References

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.

Installing the management server only takes a few answers to some questions. There is a nice installer script that takes care of everything for you already. Download the package and untar it. You can then launch the shell script for installation.

# tar -xzvf OCSNG_LINUX_SERVER_1.01.tar.gz
# cd OCSNG_LINUX_SERVER_1.01
# sh setup.sh

Pretty much everything is self-explanatory, and for the most part, you can select the defaults. The first screen is only important if you've had a previous version of OCS running on the server.

+----------------------------------------------------------+
|                                                          |
| Welcome to OCS Inventory NG Management server setup !    |
|                                                          |
+----------------------------------------------------------+

CAUTION: If upgrading Communication server from OCS Inventory NG 1.0 RC2 and
previous, please remove any Apache configuration for Communication Server!

Do you wish to continue ([y]/n)?

You can take the defaults from the rest of the questions, unless you desire to make changes, so I won't explain those settings. The next question is where you want to put the files. My document root is /var/www/html, so type in your path to wherever you setup serving your documents out of from Apache.

+----------------------------------------------------------+
| Checking for Apache root document directory...           |
+----------------------------------------------------------+

Where is Apache root document directory [] ?/var/www/html/

OCS is now installed in /var/www/html and the main configuration file will be located in the web server's httpd directory, /etc/httpd/conf.d/ocsinventory.conf, along with logging directory at /var/log/ocsinventory-NG/.

OCS Web Setup

The next step is to use the OCS web setup tool to connect to your MySQL instance, create a database, and populate it. Open up a browser and go to your server's instance. http://your_ocs_server/ocsreports

If you run into any errors or warnings, then make sure you fix the problems, restart Apache, and reload the page. You won't be able to continue until you do so. Otherwise, you should see a login box for your MySQL credentials.

MySQL login: root
MySQL Password: whatever you change it too
MySQL HostName: localhost

If everything goes well, you should see a long list of steps the installer completed. If not, fix the problems and try again. If it succeeded, go ahead and click the submit query button at the very bottom of the page. You can now login to the web interface with username and password of both admin. You can change the default password at the top right-hand side of the browser window.

Installing the Agent/Client

Perl/PHP Dependencies

Next, install some of the Perl and PHP packages required to run the agent. The agent installer actually has everything needed, but I prefer to install them across RPM. You can choose to do as you wish.

# yum install perl-XML-Simple perl-Compress-Zlib perl-Net-IP perl-Net-SSLeay

The perl-LWP and perl-Digest-MD5 packages are not available via RPM in the main archives of CentOS, but ARE in the RPMforge archive.

As with the CPAN discussion above, if you choose to convert your box from being a CentOS box into something you alone support, you can either use the ones in the agent installer, or you can install these via CPAN. Again, its your choice and preference. To install via CPAN, run the following command.

# perl -MCPAN -e shell
cpan> install LWP Digest::MD5

Installing the Agent

After you download the agent package, go ahead and untar the files and then move into the directory to run the setup installer script.

# tar -xzvf OCSNG_LINUX_AGENT_1.01_with_require.tar.gz
# cd OCSNG_LINUX_AGENT_1.01
# sh setup.sh

The agent installer script is very similar to the server setup in appearance. You can install the agent with two different methods, using either a local or http installation. If you choose local, the OCS agent will create a file which you can import into the server. If you choose http, the agent will automatically contact the OCS server. Obviously the latter is preferred, but the local installation is useful in case you have machines not on your network.

Type in the name or IP address of the server that is running the OCS communication server. Port 80 is the default port, so you can just hit enter at this question, unless you setup your Apache instance to run on a different port.

+----------------------------------------------------------+
| Checking for OCS Inventory NG Communication Server...    |
+----------------------------------------------------------+

Which host is running OCS Inventory NG Communication Server [] ? your_server
On which port is running OCS Inventory NG Communication Server [80] ?

All the defaults are fine for the rest of the questions. The installer will go through and check all of your Perl and PHP packages, and then setup a cron.d entry for running the scripts necessary to contact the communication server.

Windows Agents

The installation on Windows PCs doesn't require much effort on your part. Just download the Windows client and run the .exe installer. Point it to your OCS communications server by client name or IP address, and that's about all that's needed. The package contains all the items necessary for the OCS client to run itself. You probably want to install the package as a service so that it runs at startup time as a service. Look for the OcsAgentService.exe file in the package for installation use.

Integrating with GLPI

This section assumes you already have a working version of GLPI up and running. If you don't, please follow the installation instructions at the GLPI website. Once you have GLPI working, log into its web interface with an admin user account. Browse to the following screen:

General -> Restrictions

You'll need to activate the OCSNG settings from this screen before you can use any integration features embedded within GLPI. Change the settings and save your setup.

Next, go to the following screen:

Setup -> OCSNG

From this screen you need to configure the database connection. If you have GLPI installed on the same server as the OCS communication server, then localhost will be used and displayed as the connection to be selected. If you don't have OCS communication server on the same server, create the new settings by clicking the plus sign at the top of the page. This kicks off a blank template which you can fill in the details to where GLPI is supposed to connect to your OCS server.

Once your settings are saved, you're presented with a lot of options. These options specify how you want OCS data to be imported into GLPI. Everything is based upon your own unique preferences, so there is no one way to demonstrate settings. If you want all the general computer information and component information displayed, make sure you change all these settings to yes. Make sure you save all your settings.

Once you have your importing preferences setup, you can go over to the menu where you actual import the database.

Tools -> OCSNG

From here you have four options.

  1. The first is to synchronize computers already imported. What this does is update anything in OCS to any items already contained within GLPI.
  2. The second option is to import new computers, which is self-explanatory.
  3. The third option is to link new OCS computers to existing GLPI computers.
  4. The fourth option is to clean links between GLPI and OCS.

The third option is the most important. This option is perfect if you've already been using GLPI for quite some time and already have entries added in by hand. By using this, you can merge the differences together instead of over writing anything extra you may have added in by hand.

That's basically it for importing items into GLPI. You can now browse or search your inventory from the normal GLPI menu system, except now you'll see tons more information on your equipment. Remember you still have the OCS web interface too, which offers lists and reports. Enjoy your new inventory software.

HowTos/OCSNG (last edited 2009-10-12 12:22:30 by AlanBartlett)