Skip to content

Instantly share code, notes, and snippets.

@justincjahn
justincjahn / 10-cisco-elasticsearch.conf
Last active March 10, 2024 17:36
Logstash: Processing Cisco Logs
#
# INPUT - Logstash listens on port 8514 for these logs.
#
input {
udp {
port => "8514"
type => "syslog-cisco"
}
@MrXermon
MrXermon / netbox-graph.php
Last active September 3, 2023 15:50
Display interface graphs in Netbox fetched from LibreNMS.
<?php
/*
* Display LibreNMS interface graphs in Netbox
*
* 1. Upload this file into the plugin folder of LibreNMS.
* 2. Generate an API key in LibreNMS and insert the connection details below.
* 3. Create graphs in Netbox using the following URL scheme.
* https://nms.level66.network/plugins/netbox-graph.php?device={{ obj.device.name }}&interface={{ obj.name }}&duration=8h
* 4. Save time in your daily work!
*
@DanSheps
DanSheps / timevardemo.py
Last active March 26, 2020 00:38
TimeVariable for Netbox Scripts
from extras.scripts import ScriptVariable
class TimeVar(ScriptVariable):
"""
An time entry
"""
form_field = forms.TimeZoneFormField
def __init__(self, choices, *args, **kwargs):
async def async_ssh(host, port=22, user='vagrant', password='vagrant'):
conn = await asyncssh.connect(host, port=port,
username=user, password=password,
client_keys=None, known_hosts=None)
output = await conn.run(command)
# print(f'{host}, {output.stdout.strip()}, {output.exit_status}')
conn.close()
def netmiko_ssh(host, port=22, user='vagrant', password='vagrant'):
@mkrizek
mkrizek / ansible-jinja-types.md
Last active June 7, 2024 11:59
Ansible, Jinja2 and Types

Ansible, Jinja2 and Types

Strings, strings everywhere

Jinja2 is a templating engine and as such its primary use case is to render templates into text; which is usually HTML output saved into text file.

Consider the following Ansible play that uses Jinja2 templates to evaluate expressions:

- hosts: localhost
  gather_facts: no
@NWMichl
NWMichl / grafana_ping_panel.json
Created January 10, 2021 22:43
Grafana panel idea to visualize Telegraf inputs.ping metrics, a nice alternative to Smokeping.
{
"aliasColors": {},
"dashLength": 10,
"datasource": "InfluxDB",
"fieldConfig": {
"defaults": {
"custom": {},
"links": []
},
"overrides": []
@tyler-8
tyler-8 / site_circuit_validation.py
Last active July 1, 2022 01:57
A Custom Validator for NetBox 3.0+ to prevent sites from being retired if they have circuits that aren't deprovisioning or decommissioned.
from extras.validators import CustomValidator
from circuits.models import Circuit
class SiteStatusCircuitValidator(CustomValidator):
"""
Prevent sites from being retired if they have circuits that aren't in deprovisioning or decommissioned status.
"""
def validate(self, site):
circuit_count = Circuit.objects.filter(terminations__site=site).exclude(
@tyler-8
tyler-8 / netbox_validator_unique_vm_names.py
Last active July 4, 2022 14:59
Enforce case-insensitive unique VM names.
from extras.validators import CustomValidator
from virtualization.models import VirtualMachine
class UniqueVirtualMachineNamesCasefold(CustomValidator):
"""Enforce case-insensitive unique VM names.
Your configuration.py file would contain something like this:
CUSTOM_VALIDATORS = {
# roles/template_test/filter_plugins/eth_builder.py
# -*- coding: utf-8 -*-
# Copyright 2020 Red Hat
# GNU General Public License v3.0+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
"""
sample use of dataclass in filter plugin
# -*- coding: utf-8 -*-
# Copyright 2020 Red Hat
# GNU General Public License v3.0+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
"""
flatten a complex object to dot bracket notation
"""
from __future__ import absolute_import, division, print_function