Skip to content

Instantly share code, notes, and snippets.

View lazyfrosch's full-sized avatar
📢
Hack the planet! Hack the planet!

Markus Frosch lazyfrosch

📢
Hack the planet! Hack the planet!
View GitHub Profile
@lazyfrosch
lazyfrosch / config.yaml
Last active January 18, 2024 21:08
Fail2Ban configuration for Grafana's Loki promtail
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /data/positions.yaml
clients:
- url: ${LOKI_HOST}/loki/api/v1/push
basic_auth:
@lazyfrosch
lazyfrosch / nagvis-reset-password.md
Last active May 2, 2023 21:58
How to create a new admin or reset password for NagVis
{
"Command": {
"cluster_services": {
"arguments": {
"output": {
"skip_key": true,
"value": {
"type": "Function",
"body": "var count_ok = 0\r\nvar count_warning = 0\r\nvar count_critical = 0\r\nvar count_unknown = 0\r\nvar outputs = []\r\n\r\nvar hosts = macro(\"$cluster_hosts$\")\r\nvar service = macro(\"$cluster_service$\")\r\nvar label = macro(\"$cluster_label$\")\r\nvar icingaweb = macro(\"$icingaweb_baseurl$\")\r\nif (!icingaweb) {\r\n icingaweb = \"\/icingaweb2\"\r\n}\r\n\r\nfor (var host in hosts) {\r\n var s = get_service(host, service)\r\n var link = \"<a class=\\\"action-link\\\" href=\\\"\" + icingaweb + \"\/monitoring\/service\/show?host=\" + host + \"&service=\" + service +\"\\\">\" + host + \"<\/a>\"\r\n var line = \"[\" + link + \"] \"\r\n if (s) {\r\n if (s.state == 0) {\r\n count_ok += 1\r\n line += \"[OK] \"\r\n } else if (s.state == 1) {\r\n
@lazyfrosch
lazyfrosch / apache-icinga-kerberos.conf
Last active March 15, 2023 13:15
Apache Auth for Icinga Against Kerberos and 2 AD domains
#LogLevel authnz_ldap:debug auth_kerb:debug authz_core:debug
<AuthzProviderAlias ldap-group de.example.com CN=Icinga_Prod,OU=Global-Groups,DC=de,DC=example,DC=com>
AuthLDAPBindDN "CN=icingaldap,OU=Global-Users,DC=de,DC=example,DC=com"
AuthLDAPBindPassword "xxx"
AuthLDAPURL "ldap://de.example.com:3268/DC=de,DC=example,DC=com?sAMAccountName?sub?(objectClass=user)"
</AuthzProviderAlias>
<AuthzProviderAlias ldap-group example.com CN=Icinga_Prod,OU=Global-Groups,DC=de,DC=example,DC=com>
AuthLDAPBindDN "CN=icingaldap,OU=Global-Users,DC=de,DC=example,DC=com"
@lazyfrosch
lazyfrosch / net.go
Created December 20, 2022 16:50
golang: Calculating network usable area from
package net
import (
"encoding/binary"
"fmt"
"net"
)
// GetNetworkRange returns begin and end address for hosts in a network.
//
@lazyfrosch
lazyfrosch / test-dict-similar.py
Last active November 7, 2022 17:44
Example class for a strange problem passing **kwargs to a class init function, when other args are passed as keywords too.
"""
Example class for a strange problem passing **kwargs to a class init function, when other args are passed as keywords too.
DictSimilar behaves as a wrapper around dict, to provide an object for dict structures.
Works in CPython 3.10.8
Does NOT work in Pypy:
Python 3.9.12 (05fbe3aa5b0845e6c37239768aa455451aa5faba, Mar 29 2022, 08:15:34)
[PyPy 7.3.9 with GCC 10.2.1 20210130 (Red Hat 10.2.1-11)]
@lazyfrosch
lazyfrosch / flatcar_content.tf
Last active October 18, 2022 16:53
Example of creative loops and local variables, here updating Flatcar Container Linux images in a vSphere Content Library
variable "flatcar_stages" {
type = list(string)
default = [ "stable", "beta", "lts" ]
}
data "http" "flatcar_version_data" {
for_each = toset(var.flatcar_stages)
url = "https://${each.key}.release.flatcar-linux.net/amd64-usr/current/version.txt"
}
@lazyfrosch
lazyfrosch / flatcar_content.tf
Created October 18, 2022 16:52
Example of creative loops and local variables
variable "flatcar_stages" {
type = list(string)
default = [ "stable", "beta", "lts" ]
}
data "http" "flatcar_version_data" {
for_each = toset(var.flatcar_stages)
url = "https://${each.key}.release.flatcar-linux.net/amd64-usr/current/version.txt"
}
@lazyfrosch
lazyfrosch / bluetooth-a2dp.png
Last active June 15, 2022 09:57
Toggle Bluetooth Profiles with Pulseaudio
bluetooth-a2dp.png
<?php
$list = array(array("key1"=>"value","key4"=>"value"),array("key3"=>"value"),array("key2"=>"value"));
function uniqueKeysOfList($list) {
$keys = [];
foreach ($list as $obj) {
foreach ($obj as $k => $v) {
$keys[$k] = 1;