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