Skip to content

Instantly share code, notes, and snippets.

@guisea
guisea / needs-restarted
Last active May 30, 2024 18:18
A Custom Check for CheckMK - Checks RHEL/Debian and derived OS's for pending reboots
#!/bin/bash
# Filename: /local/share/check_mk/agents/custom/linux-reboot/lib/local/600/needs-restarted
source /etc/os-release
VERSION=$(echo ${VERSION} | awk -F . '{ print $1 }')
# RHEL and Derivatives
if ([[ $ID_LIKE =~ 'fedora' ]] || [[ $ID =~ 'rhel' ]]) && [[ $VERSION =~ '8' ]];
then
# RHEL 8
@guisea
guisea / postgres.docker.backup.txt
Last active August 27, 2020 17:56 — forked from narankhetani/postgres.docker.backup.txt
How to backup a AWX postgres database in docker.
To backup:
docker exec -u <your_postgres_user> <postgres_container_name> pg_dump -Fc <database_name_here> > db.dump
To drop db (Don't do it on production, for test purpose only!!!):
docker exec -u <your_postgres_user> <postgres_container_name> psql -c 'DROP DATABASE <your_db_name>'
To restore:
docker exec -i -u <your_postgres_user> <postgres_container_name> pg_restore -C -d postgres < db.dump
working example for awx postgres database
@guisea
guisea / excercise01.py
Created January 2, 2018 07:44
PracticePython Exercise 01
# excercise01.py
from datetime import datetime
name = input('What is your name? ')
age = int(input('What is your age {}? '.format(name)))
year = int(datetime.now().year) # Retrieve current year based on system time
copies = int(input('How many lines to print? [default: 1 - Enter to accept]') or 1) # Default lines printed to 1
print(copies * "{0} you will be 100 years old in the year {1}\n".format(name,
((year - age) + 100)
#!/bin/bash
#
# This script will install ansible including sshpass for --ask-pass functionality
# under cygwin.
# Before running this install cygwin and select lynx package to be install.
#
# Script Starts Here
#
#
# fetch apt-cyg via lynx