Skip to content

Instantly share code, notes, and snippets.

View dgarros's full-sized avatar

Damien Garros dgarros

View GitHub Profile
@dgarros
dgarros / jinja_filters.py
Created February 23, 2022 23:10
Nautobot Jinja Filter - ntc_description
"""Computed fields."""
from django_jinja import library
from nautobot.circuits.models import CircuitTermination
from nautobot.dcim.models import Interface
@library.filter
def ntc_description(obj):
"""Create an interface description dynamically."""
@dgarros
dgarros / influx.md
Last active May 28, 2019 16:41
Influxdb Queries

Calculate the BPS per LAG from the absolute bytes counter from each interface.

SELECT SUM(bps) 
FROM ( 
     SELECT non_negative_derivative(max("input-bytes"), 1s) * 8 as bps 
     FROM  "jnpr_interface_stat" 
     WHERE ("interface" =~ /et/)  AND $timeFilter 
     GROUP BY time($interval), "device", "interface"
 ) 
GROUP BY time($interval), "parent"
@dgarros
dgarros / duplicate_ip.py
Created October 25, 2018 16:35
Netbox Report Duplicate IP
from django.db.models import Q
from extras.reports import Report
from collections import defaultdict
from dcim.models import Device
from ipam.models import IPAddress
from ipam.constants import IPADDRESS_ROLE_ANYCAST, IPADDRESS_ROLE_VIP
class UniqueIPReport(Report):
@dgarros
dgarros / pb.show_var.yaml
Last active May 11, 2017 04:25
Ansible Variable loading issue with Multiple inventory
- name: Print Variables
hosts: all
gather_facts: no
connection: local
tasks:
- name: Variables for dev_aaa
debug: var=hostvars['host_aaa'].myvar
- name: Variables for dev_bbb
@dgarros
dgarros / playbook.yaml
Last active July 21, 2016 21:22
Create sub interface config for Junos using jinja2
## Playbook file for Ansible
- name: Generate sub int Template
hosts: all
connection: local
gather_facts: no
tasks:
- name: Build sub interface
template: src=sub.j2 dest=./sub.conf
{% for user in global.users %}
set system login user {{ user.name }} uid {{ user.uid }}
set system login user {{ user.name }} class {{ user.class }}
{% if user.sshkey is defined %}
{% for key in user.sshkey %}
set system login user {{ user.name }} authentication ssh-rsa "{{ key }}";
{% endfor %}
{% endif %}
#!/bin/bash
##
## This script will launch vagrant 10 times and measured how long it takes for the topology to boot up
## Topology will be destroyed after the test
c=1
while [ $c -le 10 ]
do
START=$(date +%s);
@dgarros
dgarros / Ansible_2.1_playbook
Last active October 20, 2016 18:54
Ansible 2.1 - Junos Modules Playbook examples
Playbooks examples for Ansible 2.1