Python: Subnetmaske, CIDR, Anzahl Hosts rechnen
Hostanzahl -> CIDR CIDR -> Hostanzahl CIDR -> Subnetmask Subnetmask -> CIDR
where do you want LAN bugs today?
Hostanzahl -> CIDR CIDR -> Hostanzahl CIDR -> Subnetmask Subnetmask -> CIDR
Das Beispiel gibt eine Liste mit allen Dateien und dem vollen Pfad zur Datei in allen Ordnern zurück.
Hier eine „einfache“ Variante ein Flask Projekt mit Gunicorn und Caddy zu betreiben. Caddy ist ein Webserver welcher in GO geschrieben ist und von sich aus bereits HTTPS mit Letsencrypt macht, dabei ist Caddy ultraleicht einzurichten. In dem Beispiel verwenden wir Caddy um mit dem Backend Gunicorn Webserver zu sprechen, Caddy fungiert hier als Reverse … Weiterlesen
Hier zur DCACI Schulung die Umsetzung nur auf API in Python, die Schulung ist super, bezieht sich aber hauptsächlich auf die GUI, das Interessante an einem APIC ist ja ich möglichst viel über Automatisierung / die API löse. Alles weitere hier: lanbugs/DCACI_Lab_Solution_REST_API: DCACI training solution only with API (github.com) Beispiel: Lab 3: Task 1 – … Weiterlesen
Ich habe eine schöne Umsetzung gefunden auf Stackoverflow (Quelle: python – How to send email attachments? – Stack Overflow) um E-Mails mit Anhang zu versenden. Mail with attachment (python3) (github.com)
Hier ein kleiner Helfer um eine User => Gruppen Matrix automatisch zu bauen aus dem Active Directory. Anleitung und Code findet Ihr auch auf Github. lanbugs/get_ad_right_matrix: Script to export active directory user => group matrix to excel (github.com)
Wenn man ein System hat das isoliert ist, z.B. in einer DMZ und keinen Internetzugriff hat man aber trotzdem für python Pakete per pip installieren will kann man diese auf einem anderen System herunterladen mit allen Abhängigkeiten und diese dann im Zielsystem installieren. Quell und Zielsystem sollten die gleiche Python Version haben. Download z.B. von … Weiterlesen
SSH Shell Menu written in Python Source: https://github.com/lanbugs/ssm This is a small python script for a shell menu to manage and open ssh connections. Requirements python3 dialog pythondialog Installation Install Debian packages and pip packages Copy ssm to /usr/bin/local Create connections.ini Create folder in home directory and create connections.ini file. For each server create a … Weiterlesen
Normalerweise erzeugt ein Python Dictionary einen „KeyError“ wenn auf einen Key zugegriffen wird der nicht existiert. Mit „defaultdict“ werden die Keys einfach erzeugt wenn sie nicht existieren. Ohne defaultdict: Mit defaultdict: Das Verhalten hat natürlich Vorteile wenn man mehrdimensionale Dictionarys bauen will: Ohne defaultdict: Mit defaultdict: Mehr dazu: https://docs.python.org/3/library/collections.html
Das Script kann als Inventory Plugin verwendet werden für AWX / Tower um Hosts von Check_MK in AWX / Tower zu importieren. Dazu muss ein View angelegt werden mit folgenden Spalten: Host, IPv4 address, Host Tags Der Automation User muss Rechte auf den View und die entsprechende Contact Group haben.
Von ARISTA wird ein Python Paket bereitgestellt um über die eAPI mit dem Switch arbeiten zu können. Dies ist eine Qickanleitung. pyeapi Paket installieren ARISTA eAPI aktivieren Auf dem Arista Switch muss die API Schnittstelle aktiviert werden. Beispiel: Aktuelle running-config auslesen Beispiel: Command execute & result
With this script you can parse the postfix databases / lookuptables which are in berkley database format.
Das Skript verwende ich um aus der Plesk Datenbank alle gültigen E-Mail Adressen für einen Frondend Mailserver zu exportieren.
This tool exports every hardware asset from an Cisco device with a serial number. You can export the list as table or CSV. Download: https://gist.github.com/lanbugs/4dbed5e0e8a7d5b6d29c4ea9b9e93bb2 >python cisco_inventory.py -h usage: cisco_inventory.py [-h] -H HOST -v SNMP_VERSION [-C SNMP_COMMUNITY] [-u SNMP_USER] [-A SNMP_AUTH] [-a SNMP_AUTH_METHOD] [-X SNMP_PRIVACY] [-x SNMP_PRIVACY_METHOD] [-L SNMP_SECURITY] [–csv] Cisco inventory grabber Version 0.1 Written … Weiterlesen
This tool exports all current clients on all APs assigned to the WLC. You can export as CSV or as table. Download: https://gist.github.com/lanbugs/6dc874ad0736424c5c7808f01ec78f96 $ python cisco_ap_clients_grabber.py -h usage: cisco_ap_clients_grabber.py [-h] -H HOST -v SNMP_VERSION [-C SNMP_COMMUNITY] [-u SNMP_USER] [-A SNMP_AUTH] [-a SNMP_AUTH_METHOD] [-X SNMP_PRIVACY] [-x SNMP_PRIVACY_METHOD] [-L SNMP_SECURITY] [–csv] Cisco AP clients grabber Version 0.1 Written … Weiterlesen
This tool exports the complete AP inventory from an Cisco WLC. You can create an CSV export or an table. Download: https://gist.github.com/lanbugs/e86042c0b2afaf7166637a9aa9711cb6 $ python cisco_wlc_ap_grabber.py -h usage: cisco_wlc_ap_grabber.py [-h] -H HOST -v SNMP_VERSION [-C SNMP_COMMUNITY] [-u SNMP_USER] [-A SNMP_AUTH] [-a SNMP_AUTH_METHOD] [-X SNMP_PRIVACY] [-x SNMP_PRIVACY_METHOD] [-L SNMP_SECURITY] [–csv] Cisco AP WLC inventory grabber Version 0.1 Written … Weiterlesen
This a pipe backend for PowerDNS to MongoDB written in Python. Requirements pymongo python library powerdns min. version 4.x The MongoDB schema (for example DB: dns / Collection: records) For SOA records: { „name“:“example.org“, „type“:“SOA“, „content“:““, „ttl“: 300, „primary“: „ns1.example.org“, „mail“: „admin.example.org“, „serial“: 2018030311, „refresh“: 86400, „retry“: 7200, „expire“: 3600000, „nttl“: 3600 } For standard … Weiterlesen
– Kurze Zusammenfassung, ausführlich siehe Quelle am Ende des Artikels – Python Virtual Environment aufsetzen pip install virtualenv virtualenv projekt source projekt/bin/activate pip install uwsgi flask Mini Flask Applikation projekt.py from flask import Flask app = Flask(__name__) @app.route(„/“) def hello(): return „Hello world!“ WSGI Startfile wsgi.py from projekt import app if __name__ == „__main__“: app.run() … Weiterlesen
Ein paar Notizen zu Python und MongoDB 🙂 MongoDB ist eine NoSQL Datenbank, weitere Infos -> Wikipedia 🙂 Aktuelle MongoDB Version installieren (auf Ubuntu 16.04) sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5 echo „deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse“ | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list apt install apt-transport-https apt update apt-get install -y mongodb-org siehe auch: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/ … Weiterlesen