Instalação e Configuração do OCS no CentOS 6.3
OCS Inventory é um software livre que permite aos usuários conhecerem seus ativos de TI. OCS-NG coleta informações sobre o hardware e software de máquinas em rede rodando o programa cliente OCS (“OCS Inventory Agent”). OCS pode ser usado para visualizar o inventário através de uma interface web. Além disso, OCS compreende a possibilidade de implantação de aplicativos nos computadores de acordo com os critérios de pesquisa. Agente de lado-IpDiscover torna possível saber a totalidade de computadores em rede e dispositivos
Prepare o seu sistema com o seguinte script http://wiki.douglasqsantos.com.br/doku.php/confinicialcentos6_en para que não falte nenhum pacote ou configuração.
O que vou utilizar:
- Nome Servidor: ocs
- Ip LAN: 192.168.1.40
Vamos fazer um update dos repositórios e um upgrade do sistema
yum check-update && yum update -y
Agora vamos mandar instalar o bando de dados MySQL
yum install mysql-server -y
Agora vamos colocar o mysql na inicialização do sistema
chkconfig --add mysqld chkconfig mysqld on
Agora vamos mandar iniciar o serviço
/etc/init.d/mysqld start
Agora vamos definir uma senha para o root do banco de dados
/usr/bin/mysqladmin -u root password 'S3NH4'
Agora precisamos fazer um ajuste no arquivo de configuração do MySQL
vim /etc/my.cnf [mysqld] [...] symbolic-links=0 max_allowed_packet=32M [...]
Agora vamos reiniciar o MySQL
/etc/init.d/mysqld restart
Agora vamos instalar o apache e o php
yum install httpd php php-mysql php-gd php-mbstring libtalloc libtdb libxslt perl-Apache2-SOAP php-xml samba-client samba-common \ samba-winbind samba-winbind-clients -y
Agora vamos instalar os módulo perl
yum install perl-libxml-perl perl-Compress-Zlib perl-Class-DBI-mysql perl-SOAP-Lite perl-SOAP-Lite perl-CPAN mod_perl perl-BSD-Resource \ perl-YAML perl-XML-Entities perl-Nmap-Parser perl-Proc-PID-File perl-Apache-DBI perl-Net-IP perl-XML-Simple perl-Digest-SHA1 -y
Agora vamos mandar instalar o snmp e o nmap
yum install nmap net-snmp net-snmp-perl net-snmp-utils -y
Agora precisamos obter o ocs vamos acessar o diretório /usr/src e vamos obter ele
cd /usr/src wget -c http://wiki.douglasqsantos.com.br/Downloads/monitoring/OCSNG_UNIX_SERVER-2.0.5.tar.gz
Agora vamos desempacotar ele
tar -xzvf OCSNG_UNIX_SERVER-2.0.5.tar.gz
Agora vamos acessar o diretório do ocs
cd OCSNG_UNIX_SERVER-2.0.5/
Agora vamos mandar instalar ele
./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)?y #Aqui temos que informar y para continuar Assuming Communication server 1.0 RC2 or previous is not installed on this computer. Starting OCS Inventory NG Management server setup from folder /usr/src/OCSNG_UNIX_SERVER-2.0.5 Storing log in file /usr/src/OCSNG_UNIX_SERVER-2.0.5/ocs_server_setup.log
Agora aqui temos a configuração do banco de dados
+----------------------------------------------------------+ | Checking for database server properties... | +----------------------------------------------------------+ Your MySQL client seems to be part of MySQL version 5.5. 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 ;-)
Agora nós temos a configuração do Apache
+----------------------------------------------------------+ | Checking for Apache web server daemon... | +----------------------------------------------------------+ Where is Apache daemon binary [/usr/sbin/httpd] ? #ENTER OK, using Apache daemon /usr/sbin/httpd ;-) +----------------------------------------------------------+ | Checking for Apache main configuration file... | +----------------------------------------------------------+ Where is Apache main configuration file [/etc/httpd/conf/httpd.conf] ? #ENTER OK, using Apache main configuration file /etc/httpd/conf/httpd.conf ;-) +----------------------------------------------------------+ | Checking for Apache user account... | +----------------------------------------------------------+ Which user account is running Apache web server [apache] ? #ENTER OK, Apache is running under user account apache ;-) +----------------------------------------------------------+ | Checking for Apache group... | +----------------------------------------------------------+ Which user group is running Apache web server [apache] ? #ENTER OK, Apache is running under users group apache ;-) +----------------------------------------------------------+ | Checking for Apache Include configuration directory... | +----------------------------------------------------------+ Setup found Apache Include configuration directory in /etc/httpd/conf.d/. Setup will put OCS Inventory NG Apache configuration in this directory. Where is Apache Include configuration directory [/etc/httpd/conf.d/] ? #ENTER OK, Apache Include configuration directory /etc/httpd/conf.d/ found ;-)
Agora temos a configuração do Perl
+----------------------------------------------------------+ | 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)?y #Aqui precisamos informar y para continuar +----------------------------------------------------------+ | 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 Checking for Apache mod_perl version 1.99_21 or previous Setup is unable to determine your Apache mod_perl version. Apache must have module mod_perl enabled. As configuration differs from mod_perl 1.99_21 or previous AND mod_perl 1.99_22 or higher, Setup must know which release Apache is using. You can find which release you are using by running the following command - On RPM enabled OS, rpm -q mod_perl - On DPKG enabled OS, dpkg -l libapache*-mod-perl* Enter 1 for mod_perl 1.99_21 or previous. Enter 2 for mod_perl 1.99_22 and higher. Which version of Apache mod_perl the computer is running ([1]/2) ?2 #Aqui caso seja questionado sobre a versão selecione a 2 OK, Apache is using mod_perl version 1.99_22 or higher ;-)
Agora temos a configuração dos logs
+----------------------------------------------------------+ | 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] ? #ENTER 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... | +----------------------------------------------------------+ Checking if your kit is complete... Looks good 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
Agora temos a configuração os alias para o apache
+----------------------------------------------------------+ | 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 #Aqui precisamos informar y OK, using 'z-ocsinventory-server.conf' as Communication Server Apache configuration file Removing old communication server configuration to file /etc/apache2/conf.d//ocsinventory.conf Writing communication server configuration to file /etc/apache2/conf.d//z-ocsinventory-server.conf +----------------------------------------------------------+ | OK, Communication server setup sucessfully finished ;-) | | | | Please, review /etc/apache2/conf.d//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)?y # Aqui precisamos informar y para continuar +----------------------------------------------------------+ | 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), especialy if you use deployement feature. Do you wish to continue ([y]/n)?y #Aqui precisamos informar y para continuar 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] ? #Aqui pressione ENTER OK, using directory /usr/share/ocsinventory-reports to install static files ;-) Where to create writable/cache directories for deployement packages, administration console logs, IPDiscover [/var/lib/ocsinventory-reports] ? #Aqui pressione ENTER 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 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/httpd/conf.d//ocsinventory-reports.conf +----------------------------------------------------------+ | OK, Administration server installation finished ;-) | | | | Please, review /etc/httpd/conf.d//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 /usr/src/OCSNG_UNIX_SERVER-2.0.5/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 ;-)
Agora vamos criar a base de dados para o nosso ocs
mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.5.28 MySQL Community Server (GPL) Copyright (c) 2000, 2012, 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> create database ocsweb; Query OK, 1 row affected (0.00 sec) mysql> grant all privileges on ocsweb.* to ocsweb@localhost identified by 'senha'; Query OK, 0 rows affected (0.01 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> quit Bye
Agora precisamos fazer um ajuste no arquivo de controle da configuração dos clientes que vão se conectar no ocs
sed -i 's/PerlSetEnv OCS_DB_USER ocs/PerlSetEnv OCS_DB_USER ocsweb/g' /etc/httpd/conf.d/z-ocsinventory-server.conf sed -i 's/PerlSetVar OCS_DB_PWD ocs/PerlSetVar OCS_DB_PWD senha/g' /etc/httpd/conf.d/z-ocsinventory-server.conf sed -i 's/PerlSetEnv OCS_OPT_SUPPORT 1/PerlSetEnv OCS_OPT_SUPPORT 0/g' /etc/httpd/conf.d/z-ocsinventory-server.conf
Agora vamos ajustar algumas variáveis do php, para caso aja a necessidade de enviar algum programa ou msi para o ocs nós vamos ter uma limitação de tamanho que eu estou ajustando para 300MB
vim /etc/php.ini [...] date.timezone = America/Sao_Paulo [...] max_execution_time = 180 [...] max_input_time = 180 [...] memory_limit = 256M [...] upload_max_filesize = 300M [...] post_max_size = 300M
Agora vamos ajustar agora as variáveis do php do ocsinventory
vim /etc/httpd/conf.d/ocsinventory-reports.conf [...] php_value post_max_size 300m php_value upload_max_filesize 300m
Agora vamos mandar iniciar o apache
chkconfig --add httpd chkconfig httpd on /etc/init.d/httpd start
Agora vamos acessar http://192.168.1.40/ocsreports
Aqui vamos informar:
- No primeiro campo precisamos informar: ocsweb
- No segundo campo precisamos informar: senha
- No terceiro campo precisamos informar: ocsweb
- No ultimo campo precisamos informar: localhost
- Agora precisamos clicar no botão de envio.
- Na próxima página é só clicar em Enviar
- Agora é só clicarmos em Click here to enter OCS-NG GUI
Agora fomos direcionado para a tela de login usuário: admin senha: admin, para mudarmos o idioma é só selecionar a bandeira do país desejado
Aqui vamos ter o seguinte aviso
SECURITY ALERT! Your install.php exists in your installation directory. The default login/password is activate on OCS-NG GUI
Agora precisamos remover o script de instalação
rm -rf /usr/share/ocsinventory-reports/ocsreports/install.php
Agora no ocs selecione o icone com uma carinha:
- Agora selecione adicionar um novo usuário
- Aqui informe o user ID ex: douglas
- Em tipo selecione: Super administradores
- Agora em nome informe o nome ex: Douglas
- Agora em LASTNAME informe o sobrenome ex: Santos
- Em email informe o email ex: douglas@douglasqsantos.com.br
- Em comentário se quiser colocar algo fique avontade
- Agora informe uma senha
- Agora selecione o icone verde.
Agora na parte superior da tela selecione o icone vermelho para fazer o logout
Agora logue novamente com o usuário criado.
Agora selecione novamente o icone com uma carinha
- Agora selecione Super administradores
- Agora no usuário admin selecione Apaga e confirme a exclusão
- Agora faça logout novamente para a mensagem de aviso desaparecer
Instalação e Configuração do Plugin para identificação do Office
Vamos obter o nosso plugin
cd /usr/src wget -c http://wiki.douglasqsantos.com.br/Downloads/monitoring/PluginOcsOfficekey-2.2.4.tar.gz
Agora vamos desempacotar o nosso plugin
tar -xzvf PluginOcsOfficekey-2.2.4.tar.gz
Agora precisamos importar os arquivos sql deste plugin para o OCS
mysql -u ocsweb -psenha ocsweb < /usr/src/PluginOcsOfficekey-2.2.4/officepack.sql mysql -u ocsweb -psenha ocsweb < /usr/src/PluginOcsOfficekey-2.2.4/officepack-guid-fr.sql
Agora precisamos ajustar o arquivo que controla os plugins do OCS
vim /usr/local/share/perl5/Apache/Ocsinventory/Map.pm [...] #No final do arquivo tem que ficar da seguinte forma #Plugin MS OFFICE PACK officepack => { mask => 0, multi => 1, auto => 1, delOnReplace => 1, sortBy => 'OFFICEVERSION', writeDiff => 0, cache => 0, fields => { OFFICEKEY => {}, OFFICEVERSION => {}, PRODUCT => {}, PRODUCTID => {}, TYPE => {}, GUID => {}, INSTALL => {}, NOTE => {}, } }, ); 1;
Este arquivo é somente leitura então force gravar as alterações
Agora vamos acessar o diretório que contem os plugins do OCS
cd /usr/share/ocsinventory-reports/ocsreports/plugins/computer_detail
Agora vamos copiar o nosso plugin
cp -Rf /usr/src/PluginOcsOfficekey-2.2.4/cd_officepack .
Agora vamos ajustar as permissões
chown -R root:apache cd_officepack chmod -R 755 cd_officepack
Agora vamos acessar o diretório que armazena os ícones dos plugins
cd /usr/share/ocsinventory-reports/ocsreports/plugins/computer_detail/img
Agora vamos copiar os ícones para do Office
cp -Rf /usr/src/PluginOcsOfficekey-2.2.4/img/cd_officepack* .
Agora vamos ajustar as permissões
chown -R root:apache * chmod 755 *
Agora precisamos ajustar a ativação do nosso plugin como o plugin 21 não é usado vamos desativar ele e colocar no lugar dele o office
vim /usr/share/ocsinventory-reports/ocsreports/plugins/computer_detail/cd_config.txt <ORDER> ....... ....... 21:cd_officepack </ORDER> <LBL> ....... ....... cd_officekey:cd_officepack </LBL> <ISAVAIL> ....... ....... cd_officepack:officepack </ISAVAIL> <URL> ....... cd_officepack:21 ....... </URL>
Agora quando algum cliente for cadastrado e tiver o office vai aparecer o ícone do Office habilitado para visualizar a sua chave e versão.
Configuração do Cliente
Agora vamos instalar o agente no servidor pois ele vai ser cliente também, a configuração dos novos clientes CentOS Linux vai ser a mesma
yum install ocsinventory-agent -y
Agora vamos configurar o ocsinventory-agent deixe o arquivo como abaixo
vim /etc/ocsinventory/ocsinventory-agent.cfg [...] # Server URL, unconmment if needed server = 192.168.1.40/ocsinventory #local = /var/lib/ocsinventory-agent
Agora vamos registrar o nosso servidor no ocs
ocsinventory-agent [info] Accountinfo file doesn't exist. I create an empty one. [info] PROLOG_FREQ has changed since last process(old=,new=24)
Agora é só acessar o ocsweb e verificar o servidor cadastrado
Agora vamos deixar ele no cron para ele se atualizar automaticamente no OCS
vim /etc/sysconfig/ocsinventory-agent [...] OCSMODE[0]=cron [...] OCSSERVER[0]=http://192.168.1.40/ocsinventory [...]
Agora vamos ver como configuramos um cliente Debian
aptitude install ocsinventory-agent -y
Aqui informe
- http
Agora vamos registrar o nosso servidor no ocs
ocsinventory-agent [info] Accountinfo file doesn't exist. I create an empty one. [info] PROLOG_FREQ has changed since last process(old=,new=24)
Agora é só acessar o ocsweb e verificar o servidor cadastrado
Para instalação dos agente em novos clientes linux é só seguir o mesmo procedimento.
A instalação em máquinas Windows podemos fazer da seguinte forma:
- Precisamos obter o arquivo: http://wiki.douglasqsantos.com.br/Downloads/monitoring/OCSNG-Windows-Agent-2.0.zip
- Descompacte o arquivo;
- Execute o programa OCS-NG-Windows-Agent-Setup.exe
- Selecione Next
- Selecione I Agree
- Selecione Next
- Informe o Endereço do servidor http://192.168.1.40/ocsinventory e clique em Next
- Clique em Next
- Marque o checkbox Immediatly launch inventory… e Selecione em Next
- Selecione Install
- Agora selecione Finish
Agora é só conferir a nova máquina no ocs