FIBERHOME – NAGIOS PLUGIN – CHECANDO STATUS DE PORTAS PON

Share Button

English Title: Fiberhome – Nagios Plugin – checking pon status

Recentemente re-escrevi o plugin usando SNMP que realiza leituras em OLTs da Fiberhome e indica se uma determinada porta PON possui ONUs conectadas.

O legal é poder integrar isso ao nagios ou a outros sistemas de monitoramento e conseguir receber avisos de um rompimento ou defeito na porta de maneira automática.

https://github.com/jorgeluiztaioque/check_pon_fiberhome

#!/usr/bin/python
#-----------------------------------------------------------------------
# Nagios check PON in OLT Fiberhome
# Written by Jorge Luiz Taioque
# This plugin check status of all ONUs connected in a specific PON 
# and return if these ONUs operational state is UP or DOWN
#
# ----
# -----
# Usage:
# ./check_pon_fiberhome [IP_OLT] [PON_SLOT/PON_PORT]
# Like:
# ./check_pon_fiberhome 10.10.10.1 1/8
# put only the slot_number and pon_number before and after slash /
#
#
# In nagios service.cfg use:
# check_command:	check_pon_fiberhome!10.10.10.1!1/8
#-----------------------------------------------------------------------

__author__ = 'Jorge Luiz Taioque'
__version__= 0.1

import os
import commands
import netsnmp
import sys

olt_ip = sys.argv[1]
olt_port = sys.argv[2]

pon_name = commands.getoutput("snmpwalk -Os -c adsl -v 1 "+olt_ip+" 1.3.6.1.4.1.5875.800.3.9.3.4.1.2")

pon_name_list =  pon_name.split()

indices = 0
for i, elem in enumerate(pon_name_list):
	if olt_port in elem:
		indice = i

mib =  pon_name_list[indice-4]
mib_port = mib[-9:]

mib_status = "1.3.6.1.4.1.5875.800.3.9.3.4.1.5"

readport = commands.getoutput("snmpwalk -Os -c adsl -v 1 "+olt_ip+" "+mib_status+"."+mib_port+"")

status = readport[-1:]

status = int(status)

if status == 0:
        print 'PON is Down'
        sys.exit(2)

if  status == 1:
        print 'PON is Up'
        sys.exit(0)

	

Automatizando Backup de OLTs Fiberhome via terminal

Share Button

English title: Automating Backups of Fiberhome OLTs over line comand

downloadbk-olt-fiberhome.py é um simples script para automatização de backup de OLTs Fiberhome, sem a necessidade do software de gerencia ANM2000 instalado.

Usage
./bk-olt-fiberhome.py IP_ADDRESS

Configuration
Don’t forgot to configure all variables in file bk-olt-fiberhome.py
=======================================================================
user = ‘GEPON’
password = ‘GEPON’
FTPSERVER = ‘200.200.200.200’
ftpuser = ‘user’
ftppassword = ‘123456’
=======================================================================

Link para o GitHub


#!/usr/bin/python
#-------------------------------------
#by Jorge Luiz Taioque
#jorgeluiztaioque at gmail dot com
#www.networktips.com.br
#-------------------------------------
#backup OLTs and ONUs fiberhome
#Usage 
#./bk-olt-fiberhome.py IP_ADDRESS


import sys,pexpect
import getpass
import time

HOST = sys.argv[1]

#configure here all variables following you system 
#=======================================================================
user = 'GEPON'
password = 'GEPON'
FTPSERVER = '200.200.200.200'
ftpuser = 'user'
ftppassword = '123456'
#=======================================================================


child = pexpect.spawn ('telnet '+HOST) #option needs to be a list
child.timeout = 150
child.logfile = sys.stdout #display progress on screen

#loging to OLT IP
time.sleep(2)
child.expect ('Login: ') #waiting for login
child.sendline (user) #sending login name
child.expect('Password:') #waiting for password
child.sendline (password) #sending password
child.expect('>')

time.sleep(3)

#go up enable configuration
child.sendline ('EN'+'\r') #going to ENABLE configuration
child.expect('Password:') #waiting enable password
child.sendline (password) #sending enable password 
time.sleep(3)
child.expect('#')

#sending commando to copy configuration file to remote FTP server
child.sendline ('upload ftp config '+FTPSERVER+' '+ftpuser+' '+ftppassword+' bk-olt-'+HOST+'-.cfg')
time.sleep(10)

#exiting connection
child.expect('#')
child.sendline ('exit \r')
child.sendline ('exit \r')