Skip to content

Instantly share code, notes, and snippets.

@gardart
gardart / BAC_RHEL7_G2_1611.md
Last active March 23, 2023 22:27
Golden image for RHEL7 on Hyper-V (VMM)

Step 1: Create build and capture machine for RHEL7 Step 2: Update machine, install packages Step 3: Create checkpoint Step 4: Sysprep Step 5: Copy vhdx file to your VMM library Step 6: Create template from your last BAC vhdx file Step 7: Revert to checkpoint created yearlier

To update RHEL7 template start at Step 3 and down to step 7.

@gardart
gardart / nagios_check_sql_query
Created January 24, 2017 11:22
nagios check sql query plugin using sqlplus
#!/bin/bash
PROGNAME=`/bin/basename $0`
PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'`
. $PROGPATH/utils.sh
#export PATH=$PATH:/usr/lib64/nagios/plugins:/usr/lib/nagios/plugins:/usr/lib/oracle/11.2/client64/bin
#export ORACLE_HOME=/usr/lib/oracle/11.2
#export TNS_ADMIN=/etc
#export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib

Keybase proof

I hereby claim:

  • I am gardart on github.
  • I am gardart (https://keybase.io/gardart) on keybase.
  • I have a public key ASCEaKt49AJeVMuAmMUN_-424hmrA0dC-3qtzaxIDR7LrQo

To claim this, I am signing this object:

# Install Nagios NRPE client with okconfig/adagios support
sudo rpm -ihv http://opensource.is/repo/ok-release.rpm
sudo yum update -y ok-release
sudo yum install -y nrpe nagios-plugins-load nagios-plugins-procs nagios-plugins-swap
sudo yum --enablerepo=ok-testing install -y nagios-plugins-check_cpu nagios-okconfig-nrpe
sudo yum enable nrpe
# Fix allowed hosts and dont blame nrpe in nrpe settings
export NAGIOS_SERVER='192.168.1.100'
sed -i "/^allowed_hosts=/ s/$/,$NAGIOS_SERVER/" /etc/nagios/nrpe.cfg
@gardart
gardart / pynag-commands.txt
Last active August 31, 2016 14:08
Nagios - Pynag - Commands
Get Number of hosts down:
pynag livestatus --get hosts --columns "name state plugin_output" --filter "state = 1" | wc -l
@gardart
gardart / nagios-set-downtime.sh
Created August 26, 2016 13:50
Nagios - Schedule Downtime from the command line (from any host)
#!/bin/bash
# Bash script to schedule downtime for Host
function die {
echo $1;
exit 1;
}
if [ $# -lt 1 ]; then
@gardart
gardart / date-hourly.sh
Created August 14, 2016 21:52
Print out timestamp for each hour between date range
#!/bin/bash
# Print out timestamp for each hour between date range
begin_date=`date +%Y-%m-%d" "%H":00:00" -d "01/01/2016"`
end_date=`date +%Y-%m-%d" "%H":00:00" -d "01/30/2016"`
while [ "$begin_date" != "$end_date" ] ;
do
begin_date=`date -d "${begin_date}"'1 hour' +%Y-%m-%d" "%H":00:00"`
converted_date=`date -d "${begin_date}" +%Y%m%d%H`
echo $converted_date
done
input {
file {
# Example file generation :
# $ curl "http://brunnur.vedur.is/athuganir/athtafla/2016071410.html" 2>/dev/null | grep -i -e '</\?TABLE\|</\?TD\|</\?TR' | tr -d '\n' | se d 's
/Ig' | sed 's/<\/\?\(TABLE\|TR\)[^>]*>//Ig' | sed 's/^<T[DH][^>]*>\|<\/\?T[DH][^>]*>$//Ig' | sed 's/<\/T[DH][^>]*><T[DH][^>]*>/,/Ig' | sed 's/<[
ed 's/^[\ \t]*//g' | sed '/^\s*$/d' | sed 's/^/2016071410,/' > /tmp/weather/data7.csv
#
@gardart
gardart / Icelandic-Weather-Data-html2csv
Last active April 11, 2018 02:00
Convert icelandic weather html data (all stations) from html table to csv format - http://brunnur.vedur.is/athuganir/athtafla
# Convert icelandic weather html data (all stations) from html table to csv format
$ curl "http://brunnur.vedur.is/athuganir/athtafla/2015081210.html" 2>/dev/null | grep -i -e '</\?TABLE\|</\?TD\|</\?TR'| tr -d '\n' | sed 's/<\ /TR[^>]*>/\n/Ig' | sed 's/<\/\?\(TABLE\|TR\)[^>]*>//Ig' | sed 's/^<T[DH][^>]*>\|<\/\?T[DH][^>]*>$//Ig' | sed 's/<\/T[DH][^>]*><T[DH][^>]*>/,/Ig' | sed 's/<[^>] \+>//Ig' | sed 's/^[\ \t]*//g' | sed 's/^[\ \t]*//g' | sed '/^\s*$/d' | sed 's/^/2015081210,/'
Output:
2015081210,33751,Siglufjarðarvegur_Herkonugil,-99,6.9,6.9,7.9,80,6.7,7.1,10.2,92,-99
2015081210,33643,Stafá,40,9.3,8.9,9.5,38,4.9,4.9,7.1,79,-99
2015081210,32474,Steingrímsfjarðarheiði,440,4.4,3.9,4.5,65,11.5,11.6,14.2,99,-99
2015081210,31950,Stórholt,70,9.9,9.3,9.9,81,6.7,6.7,8.5,82,-99
@gardart
gardart / install-naemon-thruk-adagios-RHEL7.txt
Created May 13, 2016 15:10
install naemon thruk adagios on RHEL7
yum update -y
yum install -y epel-release
yum update -y
yum clean all
# Add repos
rpm -Uvh "https://labs.consol.de/repo/stable/rhel7/i386/labs-consol-stable.rhel7.noarch.rpm"
rpm -ihv http://opensource.is/repo/ok-release.rpm
yum update -y ok-release