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
#include <iostream>
#include <selinux/selinux.h>
int main(void) {
int enforce;
int rc = selinux_getenforcemode(&enforce);
std::cout << rc << std::endl;
std::cout << enforce << std::endl;
}
SELECT
zo.name1 as zone,
GROUP_CONCAT(zco.name1 ORDER BY zco.name1 ASC SEPARATOR ',') as children
FROM icinga_zones z
INNER JOIN icinga_objects zo ON zo.object_id = z.zone_object_id
LEFT JOIN icinga_zones zc ON zc.parent_zone_object_id = z.zone_object_id
LEFT JOIN icinga_objects zco ON zco.object_id = zc.zone_object_id
WHERE
z.is_global = 0
AND zo.is_active = 1
@lazyfrosch
lazyfrosch / docker-compose.yml
Created October 22, 2019 15:51
Icinga Docker example
---
version: '2'
services:
web:
image: lazyfrosch/icingaweb2
ports:
- 8081:80
depends_on:
- db
{
"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 / patch.sh
Created February 26, 2019 12:29
Self executing patch file
#!/bin/bash
file="$(readlink -f "$0")"
root=/usr/share/acmeapp
exec patch -N -r /dev/null -p1 -d "$root" -i "$file" "$@"
PATCH/DIFF CONTENT
@lazyfrosch
lazyfrosch / playbook.yml
Created September 7, 2018 11:37
Manage multiple SSH authorzied_keys for one user with exclusive mode in Ansible
- name: Test
hosts: localhost
tasks:
- name: Manage SSH keys
authorized_key:
user: admin
exclusive: yes
key: |
{% for file in lookup("fileglob", "sshkeys/*.pub").split(",") -%}
@lazyfrosch
lazyfrosch / check_vip_app
Last active May 29, 2018 12:13
Wrapper for CheckCommand in Icinga Director
#!/bin/bash
plugin_dir=${0%/*}
vip="$1"
shift
command="$1"
shift
if [ ! "$vip_exists" ]; then
@lazyfrosch
lazyfrosch / mailcow-duplicity.sh
Created April 9, 2018 12:03
Mailcow Backup with Duplicity
#!/bin/bash
set -e
SOURCE=/data
cd "$HOME/mailcow-dockerized"
source mailcow.conf
@lazyfrosch
lazyfrosch / example.txt
Last active December 15, 2018 11:41
Convert the icinga2.state file to readable JSON
$ sudo cat /var/lib/icinga2/icinga2.state | ./icinga2-debug-state.py
[
{
"name": "api",
"type": "ApiListener",
"update": {
"log_message_timestamp": 1522659331.677504,
"type": "ApiListener",
"version": 0.0
#!/bin/bash
touchpadString="DLL075B:01 06CB:76AF Touchpad"
touchpadEnabled=$(xinput list-props "$touchpadString" | grep "Device Enabled" | awk -F ":" '{print $2}')
if [ "$touchpadEnabled" -eq 1 ]; then # Enabled now?
xinput --set-prop "$touchpadString" "Device Enabled" 0
notify-send -t 1200 -i input-touchpad "Touchpad disabled"
# Yes, so disable it
else # Must be disabled, so...
xinput --set-prop "$touchpadString" "Device Enabled" 1