Skip to content

Instantly share code, notes, and snippets.

View realtebo's full-sized avatar
💭
I may be slow to respond.

Mirko Tebaldi realtebo

💭
I may be slow to respond.
  • Somewhere over the raimbow
  • Ferrara, Italy
View GitHub Profile
@realtebo
realtebo / Install NRPE (to remote host, NOT on the controller)
Last active June 17, 2021 08:59
Install NRPE (to remote host, NOT on the controller)
# Use nrpe on remote host instead of ncpa only if ncpa is not working
# this setup require BOTH nrpe AND plugins
# Use this when on debian 7/8
################
# NRPE #
################
# Execute all as super user !
@realtebo
realtebo / Nagios 4.4.6 + plugins 2.3.3 on Debian 10 and nginx
Last active May 6, 2021 09:59
Nagios Core 4.4.6 + Nagios plugins 2.3.3 on Debian 10 with Nginx
# Source of truth
# https://support.nagios.com/kb/article/nagios-core-installing-nagios-core-from-source-96.html#Debian
# About nginx installation
# https://olivertappin.com/command-line-tools/installing-nagios-nginx-php-fpm-nagiosgraph-ubuntu-16-04/
# All steps on debian require root AND `-` to use full env
su -
# Prerequisites
@realtebo
realtebo / count_apt_upgradable.sh
Created April 23, 2021 14:26
Nagios Plugin to monitor number of upgradable packages
#!/usr/bin/env bash
PACKAGES=`apt list --upgradable 2>/dev/null | wc -l`
echo "Trovati $PACKAGES package da aggiornare"
# soglie da default
WARNING=10
CRITICAL=20
# Leggo i valori delle opzioni
@realtebo
realtebo / Example of nginx configuration for nagios - nagios.conf
Last active April 2, 2021 15:41
Example of nginx configuration for nagios - nagios.conf
server {
#### NOTE: UPDATE THE DOMAIN ACCORDING TO YOUR SETUP ####
server_name nagios.test;
#### NOTE: UPDATE THE PATH ACCORDING TO YOUR SETUP ####
#### This is my Debian 10 vps ####
#### Some systems uses /usr/share/nagios/share ####
root /usr/local/nagios/share;
@realtebo
realtebo / Install NCPA on a Debian 10 [on the remote machine to be controlled by nagios]
Last active November 25, 2020 17:01
Install NCPA on a Debian 10 [on the remote machine to be controlled by nagios]
# All steps on debian require root
# DO NOT TRY THIS ON DEBIAN 8 - It will not works !
# Note the `-`. Is important !
su -
cd /tmp
wget https://assets.nagios.com/downloads/ncpa/ncpa-latest.d9.amd64.deb
# NOTE: if you got this problem or similar :
# dpkg: warning: 'start-stop-daemon' not found in PATH or not executable
# you are not using `su -`.
@realtebo
realtebo / ansible_vault.md
Last active November 3, 2020 00:28
How to use encrypted vault files for storing sensitive da ta and NOT enter a password every time :)

How to use the vault with ansible

Prerequisites

pip install cryptography

Create the file

The EDITOR const is optional, but I use to show how to force the use of an editor instead of another.

@realtebo
realtebo / configure_for_ansible_winrm.ps1
Last active August 10, 2020 03:28
Configure the local Windows 10 machine for be controlled remotely from ansible
##############################################################################################################
# https://docs.ansible.com/ansible/latest/user_guide/windows_setup.html#upgrading-powershell-and-net-framework
#
# The username and password parameters are stored in plain text in the registry. Make sure the Remove-Item
# commands are run, check them after the script finishes to ensure no credentials are still stored on the host.
#
# The ConfigureRemotingForAnsible.ps1 script is intended for training and development purposes only and
# should not be used in a production environment, since it enables settings (like Basic authentication)
# that can be inherently insecure.
##############################################################################################################
@realtebo
realtebo / ncpa_debian_10.txt
Last active July 23, 2020 07:29
Install NCPA for Nagios on Debian 10 (on the remote controlled server, not on the controller)
# Nota - Se eseguendo dpk c'è un errore di comandi non trovati
# su
# nano /root/.bashrc
# appendero in fondo
# export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# salvare
# source /root/.bashrc
su
@realtebo
realtebo / install_ansible.sh
Last active March 31, 2020 22:24
Install ansible on a Ubuntu 18.04 Server
#!/bin/bash
# Download and run
# curl https://gist.githubusercontent.com/realtebo/3451070eba5a55186afb686d1690abd2/raw/install_ansible.sh?_=$(date +%s) | bash
sudo apt-get update && sudo apt-get install software-properties-common -y
sudo apt-add-repository universe -y
sudo apt-add-repository ppa:ansible/ansible -y
sudo apt-get update && sudo apt-get install ansible python-pip -y
pip install "pywinrm>=0.3.0"

Configure mysql to log query on file

Change the file /etc/mysql/conf.d/mysql.cnf (require elevated privileges) adding

[mysqld]
general_log = on
general_log_file=/var/log/query

If you change the filename, keep it consistent in the following steps !