Skip to content

Instantly share code, notes, and snippets.

# --- Update things to make sure we have the latest patches ---
# Add EPEL so we can get reasonably recent packages
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# --- Install all the packages --- #
yum -y install python-whisper python-carbon graphite-web graphite-web-selinux python-memcached python-ldap httpd memcached
yum -y groupinstall "Development Tools"
# ===== Firewall and Security =====
sed -i '/REJECT/ i\-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport http -j ACCEPT' /etc/sysconfig/iptables
# Configure Graphite Carbon
#
# Add UDP:2003 port to Firewall (before reject line)
sed -i '/REJECT/ i\-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 2003 -j ACCEPT' /etc/sysconfig/iptables
# Turn on UDP in Carbon Aggregator
sed -i 's/ENABLE_UDP_LISTENER = False/ENABLE_UDP_LISTENER = True/g' /etc/carbon/carbon.conf
# ===== Restart services =====
service carbon-cache restart
@gardart
gardart / create_files_from_template
Last active July 1, 2022 01:57
Create multiple html files from csv file using a template
#!/bin/bash
# Create multiple html files from csv file using a template
# CSV file has the structure:
# filename href
#
INPUT=data.csv
OLDIFS=$IFS
IFS=,
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read flname href
@gardart
gardart / gist:2964be65156d654ebaa9
Last active August 29, 2015 14:06
Windows - Stop IIS services, archive logs and restart IIS
@echo off
:: Stop services, archive logs and start them again
:: Create date variables
for /f "tokens=2-4 delims=. " %%a in ('date /T') do set year=%%c
for /f "tokens=2-4 delims=. " %%a in ('date /T') do set month=%%b
for /f "tokens=2-4 delims=. " %%a in ('date /T') do set day=%%a
:: Set Log File location
@gardart
gardart / gist:1dbc5800b977b39390c0
Last active August 29, 2015 14:13
OneLiner: Send SQL query as mail with timestamp in the body
echo "USE dbname; SELECT COUNT(*) FROM votes;" | mysql --skip-column-names --user=dbuser --password=dbpassword dbname | awk '{ print strftime("%Y-%m-%d %H:%M:%S"), "application:", "Number of votes:", $0;fflush(); }' | mail -s "Number of votes" mail@example.com
@gardart
gardart / install-nagios-thruk-adagios-RHEL7.txt
Last active June 10, 2022 13:22
Install Nagios / Thruk / Adagios - RHEL7
yum update -y
yum install -y epel-release
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
#########################
@gardart
gardart / install-nagios-thruk-adagios-RHEL6.txt
Last active February 3, 2016 11:20
install-nagios-thruk-adagios-RHEL6.txt
yum update -y
yum install -y epel-release
yum clean all
# Add repos
rpm -Uvh "https://labs.consol.de/repo/stable/rhel6/i386/labs-consol-stable.rhel6.noarch.rpm"
rpm -ihv http://opensource.is/repo/ok-release.rpm
yum update -y ok-release
#########################
rpm -ihv http://opensource.is/repo/ok-release.rpm
yum install ok-release
yum install epel-release
yum install nagios-okconfig-nrpe
sed -i 's|allowed_hosts=127.0.0.1|allowed_hosts=127.0.0.1,nagios_server_ip_address|g' /etc/nagios/nrpe.cfg
sed -i 's|dont_blame_nrpe=0|dont_blame_nrpe=1|g' /etc/nagios/nrpe.cfg
sed -i 's|command\[check_load\]|#command\[check_load\]|g' /etc/nagios/nrpe.cfg
sudo /etc/init.d/nrpe restart
@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
@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