Instalação e Configuração do OCS no Debian Squeeze
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/confinicialsqueeze_en para que não falte nenhum pacote ou configuração.
O que vou utilizar:
- Nome Servidor: ocs
- Ip LAN: 192.168.1.31
Vamos fazer um update dos repositórios e um upgrade do sistema
aptitude update && aptitude dist-upgrade -y
Agora vamos mandar instalar o bando de dados MySQL
aptitude install mysql-server -y
Aqui vamos ser questionados sobre a senha do usuário root, informe ela e confirme.
Agora precisamos fazer um ajuste no arquivo de configuração do MySQL
vim /etc/mysql/my.cnf [...] max_allowed_packet = 32M
Agora vamos reiniciar o MySQL
/etc/init.d/mysql restart
Agora vamos instalar o apache e o php
aptitude install apache2 php5 php5-mysql php5-gd -y
Agora vamos instalar o módulo perl para o apache
aptitude install libapache2-mod-perl2 -y
Agora vamos instalar alguns módulos perl que são necessários para o OCS funcionar
apt-get install libxml-simple-perl libcompress-zlib-perl libdbi-perl libdbd-mysql-perl libapache-dbi-perl libnet-ip-perl libsoap-lite-perl -y
Agora vamos instalar o CPAN e mais alguns módulos necessários
perl -MCPAN -e shell cpan[1]> install CPAN cpan[2]> reload CPAN cpan[3]> force install YAML cpan[4]> force install XML::Entities cpan[5]> force install Nmap::Parser cpan[6]> force install Proc::PID::File cpan[7]> quit Terminal does not support GetHistory. Lockfile removed
Agora vamos mandar instalar o snmp e o nmap
aptitude install nmap snmp -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.1. 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/apache2] ? #ENTER OK, using Apache daemon /usr/sbin/apache2 ;-) +----------------------------------------------------------+ | Checking for Apache main configuration file... | +----------------------------------------------------------+ Where is Apache main configuration file [/etc/apache2/apache2.conf] ? #ENTER 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.d/. Setup will put OCS Inventory NG Apache configuration in this directory. Where is Apache Include configuration directory [/etc/apache2/conf.d/] ? #ENTER OK, Apache Include configuration directory /etc/apache2/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 Found that mod_perl version 1.99_22 or higher is available. 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 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/apache2/conf.d//ocsinventory-reports.conf +----------------------------------------------------------+ | OK, Administration server installation finished ;-) | | | | Please, review /etc/apache2/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 35 Server version: 5.1.63-0+squeeze1 (Debian) Copyright (c) 2000, 2011, 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.01 sec) mysql> grant all privileges on ocsweb.* to ocsweb@localhost identified by 'senha'; Query OK, 0 rows affected (0.02 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/apache2/conf.d/z-ocsinventory-server.conf sed -i 's/PerlSetVar OCS_DB_PWD ocs/PerlSetVar OCS_DB_PWD senha/g' /etc/apache2/conf.d/z-ocsinventory-server.conf sed -i 's/PerlSetEnv OCS_OPT_SUPPORT 1/PerlSetEnv OCS_OPT_SUPPORT 0/g' /etc/apache2/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/php5/apache2/php.ini [...] 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/apache2/conf.d/ocsinventory-reports.conf [...] php_value post_max_size 300m php_value upload_max_filesize 300m
Agora vamos mandar reiniciar o apache
/etc/init.d/apache2 restart
Agora vamos acessar http://192.168.1.31/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
Agora vamos instalar o agente no servidor pois ele vai ser cliente tambem
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
Agora vamos ver a configuração de um cliente CentOS
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.31/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
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.31/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