def detect_config_change():
 net_devices = NetworkDevice.objects.all()
 config_changed = False
 for a_device in net_devices:
  if ('cisco' in a_device.device_class):
   if (not a_device.cfg_file):
    print 'Initial device backup: {}'.format(a_device.device_name)
    backup_config(a_device)
    config_changed = True
    continue
   last_changed = int(snmp_wrapper(a_device, oid=global_params.OID_RUNNING_LAST_CHANGED))
   if (last_changed > a_device.cfg_last_changed):
    print '>>>Running configuration changed: {}'.format(a_device.device_name)
    config_diffs = backup_config(a_device)
    config_changed = True
    if config_diffs:
     print 'Sending email notification regarding changes\n'
     subject = 'Network Device Changed: {}'.format(a_device.device_name)
     send_mail(global_params.EMAIL_RECIPIENT, subject, config_diffs, global_params.EMAIL_SENDER)
   else:
    a_device.cfg_last_changed = last_changed
    a_device.save()
 if config_changed:
  print 'Checking configuration changes into git'
  git_handling()

def detect_config_change ( ) : net_devices = NetworkDevice . objects . all ( ) config_changed = False for a_device in net_devices : if ( 'cisco' in a_device . device_class ) : if ( not a_device . cfg_file ) : print 'Initial device backup: {}' . format ( a_device . device_name ) backup_config ( a_device ) config_changed = True continue last_changed = int ( snmp_wrapper ( a_device , oid = global_params . OID_RUNNING_LAST_CHANGED ) ) if ( last_changed > a_device . cfg_last_changed ) : print '>>>Running configuration changed: {}' . format ( a_device . device_name ) config_diffs = backup_config ( a_device ) config_changed = True if config_diffs : print 'Sending email notification regarding changes\n' subject = 'Network Device Changed: {}' . format ( a_device . device_name ) send_mail ( global_params . EMAIL_RECIPIENT , subject , config_diffs , global_params . EMAIL_SENDER ) else : a_device . cfg_last_changed = last_changed a_device . save ( ) if config_changed : print 'Checking configuration changes into git' git_handling ( )
use snmp to detect configuration changes .