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 / example config for a server without npa
Created August 19, 2019 07:27
example config for a server without npa
# this config file is an example of config file for handle
# remote host with nrpe insted of the new ncpa
# save this file on the controller, NOT on the controlled machine
define host {
host_name Server 212
address 212.271.149.146
check_command check-host-alive
max_check_attempts 5
@realtebo
realtebo / chustom_check_git
Created August 19, 2019 07:31
chustom_check_git
#!/bin/bash
cd /var/www/credit-sales
git status --porcelain | grep php >> /dev/null
if [ $? -gt 0 ]; then
echo "CRITICAL, folder credit-sales modified"
exit 2
fi
@realtebo
realtebo / chustom_check_mem script for nrpe
Created August 19, 2019 07:36
chustom_check_mem script for nrpe
#### See https://support.nagios.com/forum/viewtopic.php?f=7&t=53059
# Save the content of the file into /usr/local/nagios/libexec/custom_check_mem
# - ownership root:nagios
# - permissions 755
#!/bin/bash
# Script to check real memory usage
# L.Gill 02/05/06 - V.1.0
# ------------------------------------------
# ######## Script Modifications ##########
@realtebo
realtebo / create contacts in nagios
Created September 3, 2019 10:55
create contacts in nagios
# Edit the following file on nagios controller
#
# add an entry like
define contact {
contact_name user_nick_name
use generic-contact
alias Realtebo
@realtebo
realtebo / example of config for a remote with ncpa.ini
Created October 9, 2019 13:08
example of config for a remote with ncpa
define host {
host_name HostNameWithoutSpecialChars
hostgroups NCPA
address 139.xx.yyy.zzzz
check_command check_ncpa!-t 'community_string' -P 5693 -M system/agent_version
max_check_attempts 5
check_interval 5
retry_interval 1
check_period 24x7
contacts nagiosadmin

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 !

@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"
@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 / 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 / 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.