Skip to content

juliolix/BandZabbix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BandZabbix - Graphics Easily using Python

This is an external colector Phyton created to improve Zabbix, if you dont wanna wast your time with a lot of bored configurations.

Be happy easly dude ...

Screenshot

1º step - Downloading BandZabbix

# cd /usr/lib/zabbix/externalscripts
# curl -O https://raw.githubusercontent.com/juliolix/BandZabbix/master/BandZabbix
# chown zabbix.zabbix BandZabbix
# chmod 750 BandZabbix

2º step - Install snmpwalk

# cd /usr/lib/zabbix/externalscripts
# apt-get install snmp 
# vim /etc/zabbix/zabbix_server.conf 
change 
          # Timeout=30
to 
            Timeout=30

3º step - lets test the BandZabbix

# ./BandZabbix 10.0.0.7(ip) huehuebr(community) .1.3.6.1.2.1.31.1.1.1.10.1(OID) 
or
# ./BandZabbix 10.0.0.7(ip) huehuebr(community) IF-MIB::ifOutOctets.1(Mibs)

If you note the OID above it is the "ether0" interface's "Mikrotik", however, OIDS aways change. You will need to be patience to find out the correct interface's OID. I can to use MIBs to find out faster. I'm gonna show you how.

#  snmpwalk -v 2c -c huehuebr -On 10.0.0.7 

Screenshot
.1.3.6.1.2.1.31.1.1.1.10.1 = eth0 interface download
or
IF-MIB::ifOutOctets.1 = eth0 interface download

Final Step - Configuring Zabbix

  • Create host
  • Create Item

Screenshot


Result: Status = Enabled
Screenshot You can also configure UPLOAD just setting correct OID Interface, create new item to do it.


Exemple using MIBs. Screenshot

source code:


#!/usr/bin/env python
#criado por: Julio Martins Prefeitura de JF 
#juliolix@gmail.com
#Lembre de Instalar o snmpwalk no servidor Zabbix
#apt-get install net-snmp snmp-utils
#comentar em /etc/snmp/snmp.conf
#mibs :


import sys, commands, string, time


class BzaB:

    def __init__(self, ip, community, oid):
        self.ip = sys.argv[1]          # Pega o primeiro parametro
        self.community = sys.argv[2]   # Pega o segundo parametro      
        self.oid = sys.argv[3]         # Pega o terceiro parametro
        self.time_data = 5             # Timer para 5 segundos
            
   
    def DadoBruto(self):  # Pega o dado bruto do roteador pegando apenas o ultimo campo 
        self.data = commands.getoutput("snmpwalk -c" + self.community + " -v 1 " + self.ip + " " + self.oid) 
        return int((self.data)[(string.find(self.data, ": ")) + 2:-1])
       
    def Cronometro(self):  # Timer de controle 
        time.sleep(self.time_data) 
        return 0
    
    def DadoLapidado(self): # Captura o dado bruto e depois de 5 segundos captura novamente obtendo a diferenca
        return ((self.DadoBruto() + self.Cronometro()) - self.DadoBruto()) * -1
        
    def CalculaVelocidade(self): # Calcula a velocidade convertendo para bytes por segundo
        self.bytes_data = (self.DadoLapidado() / self.time_data)
        return  (self.bytes_data * 8) * 10

   
if __name__ == '__main__':

     zab = BzaB(1, 2, 3)

     print zab.CalculaVelocidade()

Help us to improve it!

Thanks!

About

BandZabbix - Graphics Easily using this External Script.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages