📜 ⬆️ ⬇️

Inventory of computers on the network without getting up from the chair or OCS Inventory + GLPI

Good day to all!


As can be seen from the title, two programs will be discussed:
1. Open Computers and Software Inventory
OCS-Inventory is based on distributed modules installed on inventory machines that send detailed system information, connected devices and installed software to a dedicated database.
The following OS are supported: Microsoft Windows, Linux, * BSD, Sun Solaris, IBM AIX, HP-UX, MacOS X

2. GPLI - Guestion Libre de Parc Informatique
The project is designed to work with the IT database and telecommunications equipment installed in the enterprise. It is also possible to keep records of consumables and organize technical support services on a schedule and at the request of users.

On the Internet, there is a lot of information about how to configure this bundle, but I have not met a single detailed how to, where all the issues with localization would be resolved. Therefore, I will present a compilation of the solutions found and my own modifications.

So, let's begin!


Installing OCS Inventory.
OCS Version: Ver. 1.3.2
As a server OS for data collection, I will be running FreeBSD OS. I will not describe the installation and configuration of LAMP (in this case FAMP =)). We will proceed from the fact that you have already set it up.
Before you start installing and configuring OCS Inventory, check whether the following ports are installed
/usr/ports/www/mod_perl2
/usr/ports/sysutils/logrotate
/usr/ports/lang/perl

The apache config should have the string
LoadModule perl_module libexec/apache22/mod_perl.so
Check if the following perl modules are installed
Apache::DBI -- 1.08
BSD::Resource -- 1.2904
Bundle::NetSNMP -- ???
Class::Inspector -- 1.24
Compress::Raw::Bzip2 -- 2.030
Compress::Raw::Zlib -- 2.030
DBD::mysql -- 4.017
DBI -- 1.613
Digest::SHA1 -- 2.13
ExtUtils::MakeMaker -- undef
HTML::Parser -- 3.68
HTML::Tagset -- 3.20
IO::Compress -- ???
LWP -- 5.836
Locale::gettext -- 1.05
Net::IP -- 1.25
Perl -- 5.8.9
SOAP::Lite -- 0.712
Storable -- 2.21
Task::Weaken -- 1.03
URI -- 1.55
XML::Entities -- 1.0000
XML::Parser -- 2.36
XML::Simple -- 2.18
mod_perl2 -- 2.000004

to do this, just run this script
#!/usr/local/bin/perl
use ExtUtils::Installed;
my $instmod = ExtUtils::Installed->new();
foreach my $module ($instmod->modules()) {
my $version = $instmod->version($module) || "???";
print "$module -- $version\n";
}

If you have something from the above list, then install the command
#cpan -e ModulName

1. Download the patched server

OCSNG to UTF8 . Thanks to a certain linvinus!
The author of the patch did everything for us, we just need to fix a small defect. Open the archive, find the file /ocsinventory-server-1.3.2/ocsreports/languages/russian.txt, change windows-1251 to utf8 in the first line and save it in UTF8 encoding. Tarbol with the corrected russian.txt can be taken here.
')
2. Unpacking the archive to a folder on the server (I have this / usr / local / www / ocs /).

#tar -xf OCSNG_UNIX_SERVER-1.3.2-linvinus-with-utf8_patch.tar.gz

3. Create a directory for logrotate

#mkdir /etc/logrotate.d

4. Change the owner of the folder

# chown -R www:www /usr/local/www/ocs/

5. Next, go to the folder and run setup.sh

#sh setup.sh

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

Starting OCS Inventory NG Management server setup from folder /usr/local/www/ocs
Storing log in file /usr/local/www/ocs/ocs_server_setup.log

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

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

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

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

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

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

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

Where is Apache main configuration file [/usr/local/etc/apache22/httpd.conf] ?
OK, using Apache main configuration file /usr/local/etc/apache22/httpd.conf ;-)

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

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

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

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

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

Setup found Apache Include configuration directory in
.
Setup will put OCS Inventory NG Apache configuration in this directory.
Where is Apache Include configuration directory [] ?/usr/local/etc/apache22/Includes
OK, Apache Include configuration directory /usr/local/etc/apache22/Includes found ;-)

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

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

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

+----------------------------------------------------------+
| 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 detailled logs. This logs can be enabled
by setting interger value of LOGLEVEL to 1 in Administration console
menu Configuration.
Where to put Communication server log directory [/var/log/ocsinventory-server] ?
OK, Communication server will put logs into directory /var/log/ocsinventory-server ;-)

+----------------------------------------------------------+
| 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 optional Perl Modules... |
+----------------------------------------------------------+

Checking for SOAP::Lite PERL module...
Found that PERL module SOAP::Lite is available.
Checking for XML::Entities PERL module...
Found that PERL module XML::Entities is available.

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

Writing Makefile for Apache::Ocsinventory

+----------------------------------------------------------+
| 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.
/usr/local/www/ocs
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 ;-) |
| |
| 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) ?y
OK, using 'z-ocsinventory-server.conf' as Communication Server Apache configuration file
Removing old communication server configuration to file /usr/local/etc/apache22/Includes/ocsinventory.conf
Writing communication server configuration to file /usr/local/etc/apache22/Includes/z-ocsinventory-server.conf

+----------------------------------------------------------+
| OK, Communication server setup sucessfully finished ;-) |
| |
| Please, review /usr/local/etc/apache22/Includes/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)?n

Setup has created a log file /usr/local/www/ocs/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 ;-)

6. Create a virtualhost file

#ee /usr/local/etc/apache22/Includes/ocs.conf
<VirtualHost *:80>
ServerAdmin webmaster@domen.ru
DocumentRoot /usr/local/www/ocs/ocsreports
ServerName ocs.domen.ru
ServerAlias www.ocs.domen.ru
ErrorLog "|/usr/local/sbin/rotatelogs /var/log/httpd/http.ocs.domen.ru-error_log.%Y-%m-%d-%H_%M_%S 86400"
CustomLog "|/usr/local/sbin/rotatelogs /var/log/httpd/http.ocs.domen.ru-access_log.%Y-%m-%d-%H_%M_%S 86400" common

<Directory />
Order deny,allow
Allow from 192.168.0.0/16
Options Indexes FollowSymLinks
DirectoryIndex index.php
AllowOverride Options
php_flag file_uploads on


7. Connect to mysql and create a user with the necessary permissions.

# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3495
Server version: 5.1.41 FreeBSD port: mysql-server-5.1.41

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

mysql> GRANT ALL PRIVILEGES ON ocsweb.* TO 'ocs'@'localhost' IDENTIFIED BY 'ocs';


8. We are almost there, open our favorite firefox browser and enter

http: // ip_address / ocsreports
In the line "Nombre del servidor" enter localhost
image

click "Send request"
image
Click on the link
image

We select the flag of our Motherland and enter admin / admin

image

9. We check the performance of our OCSNG server

In order for us to come to the server with reports on hardware stuffing of computers and installed software, it is necessary to install an agent on the computers of our network. To do this, go to ftp linvinus again and download the patched agent .
On the server we execute the command
tail -F /var/log/httpd/http.ocs.domen.ru-error_log.2010-09-14-00_00_00
and proceed to install the agent. During the installation process we will be asked to specify the server for data collection.
image
do not forget to put a tick in the screenshot, so that after installation the agent sends information to the server
If in the log we see a swearing like this
[Tue Sep 14 19:16:34 2010] [error] [client 192.168.254.2] Can't call method "rollback" on an undefined value at /usr/local/lib/perl5/site_perl/5.8.9/Apache/Ocsinventory/Server/System.pm line 265.\n
it is necessary to check the correctness of the connection settings to mysql in the file
/usr/local/www/ocs/ocsreports/dbconfig.inc.php
and in
/usr/local/etc/apache22/Includes/z-ocsinventory-server.conf
If everything is in order, then a new entry will appear in the OCS web interface, something like the screenshot =)
image

10. The final touch is to deploy the agent in the network using Active Directory.

On the OCS wiki, there is a script that needs only a minor fix, in accordance with the realities of your network.
@echo off

REM *********** Declare variables *********************************************
REM *********** Adjust to your situation **************************************
SET Version=4061.1
REM IP OCSNG
SET Server=ocs.domen.ru
REM ,
SET SetupPath=\\dc\shareUstPril

REM *********** Install if agent isn't found **********************************
IF EXIST "%PROGRAMFILES%\OCS Inventory agent\OCSInventory.exe" GOTO update
:install
%SetupPath%\OcsAgentSetup.exe /S /SERVER:%Server% /NP /DEBUG
GOTO version

:update
REM *********** Update agent if %Version%.txt isn't found *********************
IF EXIST "%PROGRAMFILES%\OCS Inventory agent\%Version%.txt" GOTO end
:upgrade
%SetupPath%\OcsAgentSetup.exe /S /SERVER:%Server% /NP /UPGRADE /DEBUG

:version
cd /D "%PROGRAMFILES%\OCS Inventory agent\"
echo pwouet > %Version%.txt

:end
REM *********** Cleanup variables *********************************************
SET Version=
SET Server=
SET SetupPath=

Save as install_ocs_agent.bat and configure the GPO accordingly.
On this with OCS finish. It is worth noting that the data from the agents come with a random delay, so after the end of the setup it will take quite a long time before you receive data from all computers.

Installing GLPI.
GLPI Version: glpi-0.72.4_1
1. Install GLPI from ports.

make -c /usr/ports/www/glpi install clean
After that we create an alias or virtualhost (as you like) in the Apache. I have this alias
Alias /glpi "/usr/local/www/glpi"
<Directory "/usr/local/www/glpi">
Options Indexes FollowSymlinks MultiViews
AllowOverride None
Order allow,deny
Allow from 192.168.0.0/16


* For some reason, the closing "/ Directory" was not displayed, so if copy-paste be careful =)

2. Create a user in mysql with the necessary rights

mysql> grant all privileges on glpi.* to 'glpi'@'localhost' identified by 'password_ololo';

3. Go to http: // domen.ru/glpi and follow the steps of the installation wizard

image
image
image
image
image
image
image
image
image

3. Let's a little fix GLPI sources

Rule file
/usr/local/www/glpi/inc/ocsng.class.php
Find a class
class DBocs extends DBmysql
and change the string
$this->dbenc="latin1";
on
$this->dbenc="utf8";

4. Install the plugin to import from OCS

OCS Import

The plugin needs to be unpacked into a folder.
/usr/local/www/glpi/plugins/

Then go to the web interface GLPI
# Main panel>
# Settings>
# Additions
Click "Install", then "Enable"

Next, go to
# Main panel>
# Settings>
# Are common
# Limitations
“Activate OCSNG mode” - Yes

Now
# Main panel>
# Settings>
# OCSNG mode
Set options
image

# Main panel>
# Toolkit>
# OCSNG
# Importing new computers
We do import and voila =)
image

And finally, export to pdf in Russian


1. Replace all utf8_decode calls with utf8_decode_cyr
#sed -e 's/utf8_decode/utf8_decode_cyr/g' /usr/local/www/glpi/inc/export.function.php > /usr/local/www/glpi/inc/export.function.php.new
#mv /usr/local/www/glpi/inc/export.function.php.new /usr/local/www/glpi/inc/export.function.php


2. Add a function to /var/www/glpi/inc/export.function.php
function utf8_decode_cyr($value){
return iconv("UTF-8","Windows-1251",$value);
}


3. Downloading a set of fonts by reference

4. Add files from the archive to / usr / local / www / glpi / lib / ezpdf / fonts /
Now pdf is exported as it should.
image

Fuuuuhhhh ... done!
All, the OCS + GLPI bundle is installed and configured.
It only remains for me to thank for the help and support of Comrade Pascal from the forum of UNIX system administrators and to list the sources of information used =)

1. www.tux.in.ua/articles/1500
2. forums.ocsinventory-ng.org/viewtopic.php?id=4104

ps
GLPI has a lot of interesting features, but they do not fall into the scope of this note.
If someone has troubles with the installation - I wait in the kamentah than I can, as they say.

Source: https://habr.com/ru/post/104141/


All Articles