Open Computer and Software Inventory Next Generation (OCS) es un software libre que permite a los Administradores de TI gestionar el inventario de sus activos de TI. OCS-NG recopila información sobre el hardware y software de equipos que hay en la red que ejecutan el programa de cliente OCS («agente OCS de inventario»). OCS puede utilizarse para visualizar el inventario a través de una interfaz web. Además, OCS comprende la posibilidad de implementación de aplicaciones en los equipos de acuerdo a criterios de búsqueda. Además, tiene muchas opciones más como escanear la red por medio del IPDiscovery, o instalar aplicaciones remotamente creando Builds.

Funcionamiento Interno

OCS se basa en los estándares vigentes. El diálogo entre los equipos clientes y el servidor se basa en HTTP (Hypertext Transfer Protocol) y el formato de los datos se realiza en XML.

Servidor

El servidor de administración utiliza Apache, MySQL y Perl. OCS es multiplataforma y gracias a su simple diseño y el uso de mod_perl, el rendimiento del lado del servidor es muy bueno. Una máquina con pocos requerimientos podría realizar el inventario de miles de máquinas sin ningún tipo de problemas. El servidor, puede ser instalado en los siguientes sistemas operativos:

  • GNU/Linux (Ubuntu, Debian, Suse, RedHat, Gentoo, Knoppix, Slackware, Mandriva, Fedora y Centos).
  • Windows (Vista, XP, server 2003, server 2008, 7, server 2012 R2, 8, 8.1, 10).
  • Mac OS X.
  • Sun Solaris, OpenBSD, NetBSD, FreeBSD.

Agentes

Para recoger el máximo de la información posible, hay agentes que pueden ser instalados en los equipos clientes. Estos agentes están disponibles para:

  • GNU/Linux (Ubuntu, Debian, Suse, RedHat, Gentoo, Knoppix, Slackware, Mandriva, Fedora, Centos y Trustix).
  • Windows (Vista, XP, server 2003, server 2008, 7, server 2012 R2, 8, 8.1, 10).
  • Mac OS X
    Sun Solaris, OpenBSD, NetBSD, FreeBSD, IBM AIX, HP-UX,
    Android.

Interfaz de Web

Una interfaz de web opcional escrita en PHP ofrece servicios complementarios:

  • consulta del inventario
  • gestión de derechos de usuario
  • una interfaz de desglose servicio (o Helpdesk) para los técnicos

Pre-Requisitos para instalar OCS Inventory

Antes de instalar OCS Inventory tenemos que instalar las siguientes dependencias:

LAMP

Instalamos apache, Mysql, PHP apt-get install make apache2 mysql-server php perl libapache2-mod-perl2 libapache2-mod-php

Dependencias

Instalamos las siguiente dependencias:

apt install libio-compress-perl libxml-simple-perl libdbi-perl libdbd-mysql-perl 
apt install libapache-dbi-perl libsoap-lite-perl libnet-ip-perl
apt install php-mysql php-gd php7.0-dev php-mbstring php-soap php-curl

Preparamos el servidor para instalar OCS Inventory

Primero editamos el fichero /etc/php/7.0/apache2/php.ini y modificamos las siguiente lineas:

#Estas:
post_max_size = 8M
upload_max_filesize = 2M

#Por estas:
post_max_size = 128M
upload_max_filesize = 128M

Por ultimo editamos el fichero /etc/apache2/apache2.conf y añadimos la siguiente linea:

ServerName localhost

Y reiniciamos el servicio systemctl restart apache2.service

Instalar OCS Inventory

Lo primero sera descargar del github oficial de ocs el software, lo descomprimimos y nos dirigimos a la carpeta correspondiente.

wget https://github.com/OCSInventory-NG/OCSInventory-ocsreports/releases/download/2.2.1/OCSNG_UNIX_SERVER-2.2.1.tar.gz
tar -xvzf OCSNG_UNIX_SERVER-2.2.1.tar.gz
cd OCSNG_UNIX_SERVER-2.2.1

Ejecutamos instalador

Ahora ejecutamos el instalador es importante estar pendientes de dos valores cuyas lineas resaltare en la ejecución del instalador:

root@ocs-server:~/OCSNG_UNIX_SERVER-2.2.1# bash setup.sh

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

Trying to determine whitch OS or Linux distribution you use
+----------------------------------------------------------+
| Checking for Apache web server binaries !                             |
+----------------------------------------------------------+

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)? ENTER
Assuming Communication server 1.0 RC2 or previous is not installed
on this computer.

Starting OCS Inventory NG Management server setup from folder /root/OCSNG_UNIX_SERVER-2.2.1
Storing log in file /root/OCSNG_UNIX_SERVER-2.2.1/ocs_server_setup.log

+----------------------------------------------------------+
| Checking for database server properties...                      |
+----------------------------------------------------------+

Your MySQL client seems to be part of MySQL version 5.7.
Your computer seems to be running MySQL 4.1 or higher, good ;-)

Which host is running database server [localhost] ? ENTER
OK, database server is running on host localhost ;-)

On which port is running database server [3306] ? ENTER
OK, database server is running on port 3306 ;-)


+----------------------------------------------------------+
| Checking for Apache web server daemon...                              |
+----------------------------------------------------------+

Where is Apache daemon binary [/usr/sbin/apache2ctl] ? ENTER
OK, using Apache daemon /usr/sbin/apache2ctl ;-)


+----------------------------------------------------------+
| Checking for Apache main configuration file...                  |
+----------------------------------------------------------+

Where is Apache main configuration file [/etc/apache2/apache2.conf] ?/etc/apache2/apache2.conf
OK, using Apache main configuration file /etc/apache2/apache2.conf ;-)


+----------------------------------------------------------+
| Checking for Apache user account...                                    |
+----------------------------------------------------------+

Which user account is running Apache web server [www-data] ? ENTER
OK, Apache is running under user account www-data ;-)


+----------------------------------------------------------+
| Checking for Apache group...                                                  |
+----------------------------------------------------------+

Which user group is running Apache web server [www-data] ? ENTER
OK, Apache is running under users group www-data ;-)


+----------------------------------------------------------+
| Checking for Apache Include configuration directory...   |
+----------------------------------------------------------+

Setup found Apache Include configuration directory in
/etc/apache2/conf-available.
Setup will put OCS Inventory NG Apache configuration in this directory.
Where is Apache Include configuration directory [/etc/apache2/conf-available] ?/etc/apache2/conf-enabled
OK, Apache Include configuration directory /etc/apache2/conf-enabled found ;-)


+----------------------------------------------------------+
| Checking for PERL Interpreter...                                              |
+----------------------------------------------------------+

Found PERL Intrepreter at </usr/bin/perl> ;-)
Where is PERL Intrepreter binary [/usr/bin/perl] ? ENTER
OK, using PERL Intrepreter /usr/bin/perl ;-)


Do you wish to setup Communication server on this computer ([y]/n)? ENTER


+----------------------------------------------------------+
|             Checking for Make utility...                 |
+----------------------------------------------------------+

OK, Make utility found at </usr/bin/make> ;-)

+----------------------------------------------------------+
|        Checking for Apache mod_perl version...           |
+----------------------------------------------------------+

Checking for Apache mod_perl version 1.99_22 or higher
Found that mod_perl version 1.99_22 or higher is available.
OK, Apache is using mod_perl version 1.99_22 or higher ;-)

+----------------------------------------------------------+
|    Checking for Communication server log directory...    |
+----------------------------------------------------------+

Communication server can create detailed logs. This logs can be enabled
by setting integer value of LOGLEVEL to 1 in Administration console
menu Configuration.
Where to put Communication server log directory [/var/log/ocsinventory-server] ? ENTER
OK, Communication server will put logs into directory /var/log/ocsinventory-server ;-)

+----------------------------------------------------------------------------+
|    Checking for Communication server plugins configuration directory...    |
+----------------------------------------------------------------------------+

Communication server need a directory for plugins configuration files.
Where to put Communication server plugins configuration files [/etc/ocsinventory-server/plugins] ?  ENTER
OK, Communication server will put plugins configuration files into directory /etc/ocsinventory-server/plugins ;-)

+-------------------------------------------------------------------+
|   Checking for Communication server plugins perl directory...     |
+-------------------------------------------------------------------+

Communication server need a directory for plugins Perl modules files.
Where to put Communication server plugins Perl modules files [/etc/ocsinventory-server/perl] ?
OK, Communication server will put plugins Perl modules files into directory /etc/ocsinventory-server/perl ;-)


+----------------------------------------------------------+
| Checking for required Perl Modules...                                 |
+----------------------------------------------------------+

Checking for DBI PERL module...
Found that PERL module DBI is available.
Checking for Apache::DBI PERL module...
Found that PERL module Apache::DBI is available.
Checking for DBD::mysql PERL module...
Found that PERL module DBD::mysql is available.
Checking for Compress::Zlib PERL module...
Found that PERL module Compress::Zlib is available.
Checking for XML::Simple PERL module...
Found that PERL module XML::Simple is available.
Checking for Net::IP PERL module...
Found that PERL module Net::IP is available.
Checking for SOAP::Lite Perl module...
Found that PERL module SOAP::Lite is available.
Checking for Archive::Zip Perl module...
Found that PERL module Archive::Zip is available.

+----------------------------------------------------------+
|         Checking for optional Perl Modules...            |
+----------------------------------------------------------+

Checking for Apache2::SOAP PERL module...
*** Warning: PERL module Apache2::SOAP is not installed !
This module is only required by OCS Inventory NG SOAP Web Service.
Do you wish to continue ([y]/n] ?y
Checking for XML::Entities PERL module...
*** Warning: PERL module XML::Entities is not installed !
This module is only required by OCS Inventory NG SOAP Web Service.
Do you wish to continue ([y]/n] ?y


+----------------------------------------------------------+
|                 OK, looks good ;-)                       |
|                                                          |
|     Configuring Communication server Perl modules...     |
+----------------------------------------------------------+

Generating a Unix-style Makefile
Writing Makefile for Apache::Ocsinventory
Writing MYMETA.yml and MYMETA.json

+----------------------------------------------------------+
|                 OK, looks good ;-)                       |
|                                                          |
|      Preparing Communication server Perl modules...      |
+----------------------------------------------------------+


+----------------------------------------------------------+
|                 OK, prepare finshed ;-)                  |
|                                                          |
|     Installing Communication server Perl modules...      |
+----------------------------------------------------------+


+----------------------------------------------------------+
| OK, Communication server Perl modules install finished;-)|
|                                                          |
|     Creating Communication server log directory...       |
+----------------------------------------------------------+

Creating Communication server log directory /var/log/ocsinventory-server.

Fixing Communication server log directory files permissions.
Configuring logrotate for Communication server.
Removing old communication server logrotate file /etc/logrotate.d/ocsinventory-NG
Writing communication server logrotate to file /etc/logrotate.d/ocsinventory-server


+----------------------------------------------------------------------+
|        OK, Communication server log directory created ;-)            |
|                                                                      |
|   Creating Communication server plugins configuration directory...   |
+----------------------------------------------------------------------+

Creating Communication server plugins configuration directory /etc/ocsinventory-server/plugins.


+----------------------------------------------------------------------+
| OK, Communication server plugins configuration directory created ;-) |
|                                                                      |
|        Creating Communication server plugins Perl directory...       |
+----------------------------------------------------------------------+

Creating Communication server plugins Perl directory /etc/ocsinventory-server/perl.


+----------------------------------------------------------------------+
|     OK, Communication server plugins Perl directory created ;-)      |
|                                                                      |
|               Now configuring Apache web server...                   |
+----------------------------------------------------------------------+

To ensure Apache loads mod_perl before OCS Inventory NG Communication Server,
Setup can name Communication Server Apache configuration file
'z-ocsinventory-server.conf' instead of 'ocsinventory-server.conf'.
Do you allow Setup renaming Communication Server Apache configuration file
to 'z-ocsinventory-server.conf' ([y]/n) ?
OK, using 'z-ocsinventory-server.conf' as Communication Server Apache configuration file
Removing old communication server configuration to file /etc/apache2/conf-enabled/ocsinventory.conf
Writing communication server configuration to file /etc/apache2/conf-enabled/z-ocsinventory-server.conf

+----------------------------------------------------------------------+
|       OK, Communication server setup successfully finished ;-)       |
|                                                                      |
| Please, review /etc/apache2/conf-enabled/z-ocsinventory-server.conf |
|         to ensure all is good. Then restart Apache daemon.           |
+----------------------------------------------------------------------+


Do you wish to setup Administration Server (Web Administration Console)
on this computer ([y]/n)? ENTER

+----------------------------------------------------------+
|    Checking for Administration Server directories...     |
+----------------------------------------------------------+

CAUTION: Setup now install files in accordance with Filesystem Hierarchy
Standard. So, no file is installed under Apache root document directory
(Refer to Apache configuration files to locate it).
If you're upgrading from OCS Inventory NG Server 1.01 and previous, YOU
MUST REMOVE (or move) directories 'ocsreports' and 'download' from Apache
root document directory.
If you choose to move directory, YOU MUST MOVE 'download' directory to
Administration Server writable/cache directory (by default
/var/lib/ocsinventory-reports), especially if you use deployment feature.

Do you wish to continue ([y]/n)? ENTER
Assuming directories 'ocsreports' and 'download' removed from
Apache root document directory.

Where to copy Administration Server static files for PHP Web Console
[/usr/share/ocsinventory-reports] ? ENTER
OK, using directory /usr/share/ocsinventory-reports to install static files ;-)

Where to create writable/cache directories for deployment packages,
administration console logs, IPDiscover and SNMP [/var/lib/ocsinventory-reports] ?
OK, writable/cache directory is /var/lib/ocsinventory-reports ;-)


+----------------------------------------------------------+
|         Checking for required Perl Modules...            |
+----------------------------------------------------------+

Checking for DBI PERL module...
Found that PERL module DBI is available.
Checking for DBD::mysql PERL module...
Found that PERL module DBD::mysql is available.
Checking for XML::Simple PERL module...
Found that PERL module XML::Simple is available.
Checking for Net::IP PERL module...
Found that PERL module Net::IP is available.

+----------------------------------------------------------+
|      Installing files for Administration server...       |
+----------------------------------------------------------+

Creating PHP directory /usr/share/ocsinventory-reports/ocsreports.
Copying PHP files to /usr/share/ocsinventory-reports/ocsreports.
Fixing permissions on directory /usr/share/ocsinventory-reports/ocsreports.
Creating database configuration file /usr/share/ocsinventory-reports/ocsreports/dbconfig.inc.php.
Creating IPDiscover directory /var/lib/ocsinventory-reports/ipd.
Fixing permissions on directory /var/lib/ocsinventory-reports/ipd.
Creating packages directory /var/lib/ocsinventory-reports/download.
Fixing permissions on directory /var/lib/ocsinventory-reports/download.
Creating snmp mibs directory /var/lib/ocsinventory-reports/snmp.
Fixing permissions on directory /var/lib/ocsinventory-reports/snmp.
Creating Administration server log files directory /var/lib/ocsinventory-reports/logs.
Fixing permissions on directory /var/lib/ocsinventory-reports/logs.
Creating Administration server scripts log files directory /var/lib/ocsinventory-reports/scripts.
Fixing permissions on directory /var/lib/ocsinventory-reports/scripts.
Configuring IPDISCOVER-UTIL Perl script.
Installing IPDISCOVER-UTIL Perl script.
Fixing permissions on IPDISCOVER-UTIL Perl script.
Writing Administration server configuration to file /etc/apache2/conf-enabled/ocsinventory-reports.conf

+----------------------------------------------------------------------+
|        OK, Administration server installation finished ;-)           |
|                                                                      |
| Please, review /etc/apache2/conf-enabled/ocsinventory-reports.conf
|          to ensure all is good and restart Apache daemon.            |
|                                                                      |
| Then, point your browser to http://server//ocsreports
|        to configure database server and create/update schema.        |
+----------------------------------------------------------------------+


Setup has created a log file /root/OCSNG_UNIX_SERVER-2.2.1/ocs_server_setup.log. Please, save this file.
If you encounter error while running OCS Inventory NG Management server,
we can ask you to show us his content !

DON'T FORGET TO RESTART APACHE DAEMON !

Enjoy OCS Inventory NG ;-)

Reiniciamos apache systemctl restart apache2.service

Ejecutamos OCS en un navegador

Para acceder a OCS basta con escribir la ip de la maquina en este caso http://192.168.1.191/ocsreports/:

MySQL login: root

MySQL password: *La contraseña root mysql”

Name of Database: ocsweb (es un ejemplo el nombre, puede ser el que querais. No es necesario este la base de datos creada en mysql.)

MySQL HostName: localhost

Si todo va bien deberemos ver esta pantalla:

Ahora deberemos hacer click en Click here to enter OCS-NG GUI es posible nos solicite una actualizacion de la base de datos.

Una vez actualizada tendremos que volver a hacer click Click here to enter OCS-NG GUI

Como podemos observar en la captura que encontramos mas arriba el usuario es admin y la contraseña admin y seleccionamos como idioma Castellano:

Solución fallos al iniciar sesión

Al siguiente mensaje The install .php exists in ocsreports directory ejecutamos en la maquina el siguiente comando:

mv /usr/share/ocsinventory-reports/ocsreports/install.php /usr/share/ocsinventory-reports/ocsreports/install.php_old

Y para quitar la alerta The default sql login/password is activate on your database: ocsweb deberemos cambiar una serie de parametro:

Contraseña usuario ocs

root@ocs-server:~/OCSNG_UNIX_SERVER-2.2.1# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 22
Server version: 5.7.17-0ubuntu0.16.04.2 (Ubuntu)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SET PASSWORD FOR 'ocs'@'localhost' = PASSWORD('ubuntu');
Query OK, 0 rows affected, 1 warning (0,04 sec)

mysql> SET PASSWORD FOR 'ocs'@'%' = PASSWORD('ubuntu');
Query OK, 0 rows affected, 1 warning (0,00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0,08 sec)

Modificamos fichero de configuracion de acceso OCS

Para ello modificamos el fichero /usr/share/ocsinventory-reports/ocsreports/dbconfig.inc.php para que quede asi:

<?php
define("DB_NAME", "ocsweb");
define("SERVER_READ","localhost");
define("SERVER_WRITE","localhost");
define("COMPTE_BASE","ocs");
define("PSWD_BASE","ubuntu");
?>

Modificaciones fichero z-ocsinventory-server.conf

Vamos a editar el fichero /etc/apache2/conf-enabled/z-ocsinventory-server.conf, en el primero ocs por la contraseña del usuario ocs en base de datos, en nuestro caso ubuntu

  PerlSetVar OCS_DB_PWD ubuntu

Y sustituimos el valor «0» por «1» en la siguiente linea:

  PerlSetEnv OCS_OPT_ACCEPT_TAG_UPDATE_FROM_CLIENT 1

Y ya no tendremos ningún fallo:

Ahora procederemos a instalar OCS inventory Agent en Windows