infraestrutura:cacti

Cacti

Cacti é uma ferramenta de geração de gráficos desenhada para fazer uso da robustez do modelo de armazenamento de dados do RRDTool e plota-los de maneira funcional e elegante. Cacti provem um poller, modelos de gráficos avançados, multiplos métodos de aquisições de informação e gerenciamento de usuários por padrão. Tuda essa suíte vem embalada em uma intiuitiva e de fácil uso interface que faz sentido desde instalações mínimas as mais complexas.

Hostname: cacti.ifce.edu.br
IPv4: 200.17.33.19
OS: Ubuntu-14.04.1-LTS-amd64
Username: operador
Passwd: 1Password @ Dominios -> ifce.edu.br -> HP BladeSystem -> cacti
vCPU's: 1
RAM: 1GiB
HDD: 10GiB
cacti-0.8.8b+dfsg-3
cacti-spine-0.8.8a-3
vim-2:7.4.000-1ubuntu2
rrdtool-1.4.7-2ubuntu2
php5-snmp-5.5.3+dfsg-1ubuntu2.6
snmpd-5.7.2~dfsg-8ubuntu1.1
snmp-mibs-downloader-1.1
apache2-2.4.6-2ubuntu2.2
ntp-1:4.2.6.p5+dfsg-3ubuntu2

O cacti pode ser instalado via apt-get com o comando:

sudo apt-get install ntp cacti vim cacti-spine rrdtool php php5-snmp snmpd snmp-mibs-downloader apache2

Os diretórios relacionados ao serviço são:

  • /var/lib/cacti/rra/ - Arquivos RRD referentes as informações obtidas
  • /usr/share/cacti/site - Arquivos da interface web servidor pelo Apache2
  • /usr/share/cacti/cli - Arquivos referentes a comandos que devem ser executados APENAS pela interface de linha de comando - cli
  • /etc/cacti - Arquivos de configuração do spine
  • /var/log/cacti/ - Arquivos de log

Arquivos de configuração

Encontram-se no diretório /etc/cacti e /etc/snmp, os arquivos de configuração do cacti e do snmp.

Iniciando o serviço snmp

Inicia-se o serviço do snmp através do comando:

sudo service snmpd start

Iniciando o serviço Apache

Inicia-se o serviço do Apache através do comando:

sudo service apache2 start

Parando o serviço snmp

Para-se o serviço do snmp através do comando:

sudo service snmpd stop

Parando o serviço Apache

Para-se o serviço do Apache através do comando:

sudo service apache2 stop

Reiniciando o serviço snmp

Reinicia-se o serviço do snmp através do comando:

sudo service snmpd restart

Parando o serviço Apache

Reinicia-se o serviço do Apache através do comando:

sudo service apache2 restart
spine.conf
 
snmpd.conf
###############################################################################
#
#  AGENT BEHAVIOUR
#  Listen for connections from the local system only
agentAddress  udp:127.0.0.1:161
#  Listen for connections on all interfaces (both IPv4 *and* IPv6)
#agentAddress udp:161,udp6:[::1]:161
 
 
###############################################################################
#
#  ACCESS CONTROL
#
view   systemonly  included   .1.3.6.1.2.1.1
view   systemonly  included   .1.3.6.1.2.1.25.1
rocommunity public  default    -V systemonly
rouser   authOnlyUser
 
###############################################################################
#
#  SYSTEM INFORMATION
#
sysLocation    Instituto Federal de Educacao Ciencia e Tecnologia do Ceara
sysContact     DGTI <suporte.devops@ifce.edu.br>
sysServices    72
 
 
#
#  Process Monitoring
#
proc  mountd
proc  ntalkd    4
proc  sendmail 10 1
 
disk       /     10000
disk       /var  5%
includeAllDisks  10%
load   12 10 5
 
 
###############################################################################
#
#  ACTIVE MONITORING
#
 
 trapsink     localhost public
###############################################################################
#  Event MIB - automatically generate alerts
#
iquerySecName   internalUser       
rouser          internalUser
defaultMonitors          yes
linkUpDownNotifications  yes
 
###############################################################################
#
#  EXTENDING THE AGENT
#  Arbitrary extension commands
#
 extend    test1   /bin/echo  Hello, world!
 extend-sh test2   echo Hello, world! ; echo Hi there ; exit 35
#
#  AgentX Sub-agents
#
 master          agentx
spine.conf
DB_Host         mysql.ifce.edu.br
DB_Database     cacti
DB_User         cacti
DB_Pass         senha-encontra-se-no-1password

Interface web

A interface web do cacti, faz uso do seguinte arquivo:

operador@cacti:~$ ls -lah /usr/share/cacti/site/include | grep config.php
lrwxrwxrwx 1 root root   21 Aug 30  2013 config.php -> /etc/cacti/debian.php
operador@cacti:~$ 
debian.php
<?php
/*
 Debian note:
 This file is based on and replaces the include/config.php file normaly
 found in the cacti source. Most cacti configuration is done via the
 web-interface and stored in a mysql database, however, some things need
 to be defined or can be overwritten here.
 
 Database access settings are automatically generated from 
 /etc/dbconfig-common/cacti.conf by /usr/sbin/dbconfig-generate-include
 
 By default this file is managed via ucf, so you shouldn't have to
 worry about manual changes being silently discarded.  *However*,
 you'll probably also want to edit the configuration file mentioned
 above too.
*/
 
/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "mysql.ifce.edu.br";
$database_username = "cacti";
$database_password = "senha-encontra-se-no-1password";
$database_port = "3306";
$database_ssl = false;
 
/*
   Edit this to point to the default URL of your Cacti install
   ex: if your cacti install as at http://serverip/cacti/ this
   would be set to /cacti/
 
   Debian addition:
   If used together with a http deamon, it should be configured
   consistently. Using an empty path makes all links relative.
*/
//$url_path = "/cacti/";
 
/* Default session name - Session name must contain alpha characters */
//$cacti_session_name = "Cacti";
$plugins = array();
$plugins[] = 'weathermap';
?>

Interface web

Utilizamos a interface web do cacti para gerar mapas no estio Weathermap, onde visualizamos de uma maneira holísitca toda a rede monitorada.

Antes de mais nada, precisamos adicionar as rotinas do cacti, os nós os quais ele deve monitorar. Para tal tarefa, acesse a interface web do cacti: http://cacti.ifce.edu.br/ Uma vez autenticado - se não tiver credenciais de acesso, solicite-as via suporte.devops@ifce.edu.br - no menu lateral esquerdo, abra a interface de gerência de dispositivos: ManagementDevices:

No canto superior direito, clique em Add:

  • No campo Description coloque uma breve descrição do nó a ser monitorado;
  • No campo Hostname coloque o FQDN ou o endereço de IP do nó a ser monitorado;
  • No campo Host Template, selecione o template que melhor se adequa ao nó a ser monitorado;
  • No campo SNMP Version, selecione a opção Version 2
  • No campo SNMP Community, coloque a comunidade a qual o nó a ser monitorado pertence;
  • No campo SNMP Port, coloque a porta padrão do protocolo: 161
  • Em seguida clique em Create

Dentro do diretóio /usr/share/cacti/site/plugins/weathermap/configs estão os arquivos de configuração dos mapas. Para cada arquivo aqui gerado, um novo mapa é gerado na interface web. Neste arquivo, instanciamos os NODES, fazeno referencia aos nós adicionados no passo anterior e em seguida, os LINKS entre os NODES, gerando assim os gráficos no modelo weathermap:

Exemplo

benfica.conf
FONTDEFINE 100 docs/example/Vera.ttf 10
 
WIDTH 1024
HEIGHT 900
HTMLSTYLE overlib
KEYFONT 1
TITLE IFCE-Campus-Benfica
TIMEPOS 805 760 Criado em: %d de %b %Y %H:%M:%S
KEYPOS DEFAULT 585 800 Utilizacao de Trafego
KEYSTYLE  DEFAULT horizontal
KEYTEXTCOLOR 0 0 0
KEYOUTLINECOLOR 0 0 0
KEYBGCOLOR 255 255 255
BGCOLOR 255 255 255
TITLECOLOR 0 0 0
TIMECOLOR 0 0 0
SCALE DEFAULT 0     0.01  0    0    0 
SCALE DEFAULT 0.02  1	  160  240  75
SCALE DEFAULT 1     25    160  240  75
SCALE DEFAULT 25    75    90   160  25  
SCALE DEFAULT 75    80    235  192  0  
SCALE DEFAULT 80    90    255  192  0  
SCALE DEFAULT 90    100   255  90   90  
 
SET nowarn_clipping 1
 
# End of global section
 
 
# TEMPLATE-only NODEs:
NODE DEFAULT
	LABELOFFSET S
	LABELFONT 1
	MAXVALUE 100
 
 
# TEMPLATE-only LINKs:
LINK DEFAULT
	WIDTH 3
	ARROWSTYLE compact
	BWFONT 1
	BWLABEL none
	COMMENTSTYLE center
	VIASTYLE curved
 
# regular NODEs:
NODE Internet
        LABEL Internet
        INFOURL /cacti/graph.php?rra_id=all&local_graph_id=296
        ICON 80 80 images/ifce-internet.png
        POSITION 30 30
 
NODE sw-core-ben
	LABEL sw-core-ben
	INFOURL /cacti/graph.php?rra_id=all&local_graph_id=293
	ICON 60 60 images/ifce-sw-core-extreme-networks.png
	POSITION 240 165
 
NODE sw-core-ensino
	LABEL sw-core-ensino
	INFOURL /cacti/graph.php?rra_id=all&local_graph_id=298
	ICON 60 60 images/ifce-sw-extreme-networks.png
	POSITION 340 290
 
NODE r11-sw-dst
	LABEL r11-sw-dst
	INFOURL /cacti/graph.php?rra_id=all&local_graph_id=283
	ICON 60 60 images/ifce-sw-generico.png
	POSITION 100 420
 
NODE dmz-ifce-ben
	LABEL dmz-ifce-ben
	INFOURL /cacti/graph.php?rra_id=all&local_graph_id=299
	ICON 60 60 images/ifce-sw-generico.png
	POSITION 430 290
 
NODE r1-sw-dst
	LABEL r1-sw-dst
	INFOURL /cacti/graph.php?rra_id=all&local_graph_id=297
	ICON 60 60 images/ifce-sw-generico.png
	POSITION 165 290
 
NODE r2-sw-dst
	LABEL r2-sw-dst
	INFOURL /cacti/graph.php?rra_id=all&local_graph_id=253
	ICON 60 60 images/ifce-sw-generico.png
	POSITION 200 420
 
NODE CPQT
        LABEL CPQT
        INFOURL /cacti/graph.php?rra_id=all&local_graph_id=301
        ICON 60 60 images/ifce-radio.png
        POSITION 245 290
 
 
# regular LINKs:
LINK sw-core-ben-Internet
        INFOURL /cacti/graph.php?rra_id=all&local_graph_id=296
	OVERLIBGRAPH /cacti/graph_image.php?local_graph_id=296
        TARGET /var/lib/cacti/rra/16/388.rrd
        NODES sw-core-ben Internet
        BANDWIDTH 1G 1G
	VIA 190 50
 
LINK sw-core-ben-dmz-ifce-ben
        INFOURL /cacti/graph.php?rra_id=all&local_graph_id=298
        OVERLIBGRAPH /cacti/graph_image.php?local_graph_id=298
        TARGET /var/lib/cacti/rra/16/391.rrd
        TARGET /var/lib/cacti/rra/16/391.rrd
        NODES sw-core-ben dmz-ifce-ben
        BANDWIDTH 1G 1G
 
LINK sw-core-ben-sw-core-ensino
	INFOURL /cacti/graph.php?rra_id=all&local_graph_id=298
	OVERLIBGRAPH /cacti/graph_image.php?local_graph_id=298
	TARGET /var/lib/cacti/rra/16/390.rrd
	NODES sw-core-ben sw-core-ensino
	BANDWIDTH 1G 1G
 
LINK sw-core-ben-CPQT
	INFOURL /cacti/graph.php?rra_id=all&local_graph_id=301
	OVERLIBGRAPH /cacti/graph_image.php?local_graph_id=301
	TARGET /var/lib/cacti/rra/16/393.rrd
	NODES sw-core-ben CPQT
	BANDWIDTH 50M 50M
 
LINK sw-core-ben-r1-sw-dst
	INFOURL /cacti/graph.php?rra_id=all&local_graph_id=297
	OVERLIBGRAPH /cacti/graph_image.php?local_graph_id=297
	TARGET /var/lib/cacti/rra/16/389.rrd
	NODES sw-core-ben r1-sw-dst
	BANDWIDTH 1G 1G
 
LINK r1-sw-dst-r11-sw-dst
	INFOURL /cacti/graph.php?rra_id=all&local_graph_id=283
	OVERLIBGRAPH /cacti/graph_image.php?local_graph_id=283
	TARGET /var/lib/cacti/rra/12/284.rrd
	NODES r1-sw-dst r11-sw-dst
	BANDWIDTH 300M 300M
 
LINK r1-sw-dst-r2-sw-dst
	INFOURL /cacti/graph.php?rra_id=all&local_graph_id=253
	OVERLIBGRAPH /cacti/graph_image.php?local_graph_id=253
	TARGET /var/lib/cacti/rra/14/345.rrd
	NODES r1-sw-dst r2-sw-dst
	BANDWIDTH 1G 1G
 
# r1: BBS
# r2:  Telefonista
# r3:  Telematica
# r4:  Industria
# r5:  Biblioteca
# r6:  Poliesportivo
# r7:  Construcao Civil
# r8:  Quimica
# r9:  Almoxarifado
# r10: Artes
# r11: DGTI
# r12: CAET
# r13: ppget

Luca do Amaral Saboya 2015/03/24 07:19

  • infraestrutura/cacti.txt
  • Última modificação: 2021/08/25 10:33
  • (edição externa)