linux

warning: Creating default object from empty value in /data/web/1/000/027/003/273448/htdocs/panticz.de/modules/taxonomy/taxonomy.pages.inc on line 33.

Create Debian Wheezy DomU

wget https://raw.githubusercontent.com/panticz/xen/master/domains/debian.wheezy.sh -O - | bash -

#!/bin/bash

# configure domU
DOMAIN_NAME=wheezy
DOMAIN_MAC=00:10:01:01:aa:bb
DOMAIN_RAM=2Gb
DOMAIN_HDD=8Gb
 
# create domU on LVM (for image file use --dir=/root, --pygrub)
xen-create-image \
 --hostname=${DOMAIN_NAME} \
 --dist=wheezy \
 --lvm=vg0 \
 --size=${DOMAIN_HDD} \
 --fs=ext4 \
 --role=udev \
 --memory=${DOMAIN_RAM} \
 --swap=${DOMAIN_RAM} \
 --dhcp \
 --mac=${DOMAIN_MAC} \
 --genpass=0 \
 --password=t00r \
 --apt_proxy=http://apt-cacher:3142/ \
 --vcpus $(cat /proc/cpuinfo | grep processor | wc -l)
 
# rename vm config
mv /etc/xen/${DOMAIN_NAME}.cfg /etc/xen/${DOMAIN_NAME}
 
# OPTIONAL: add to autostart
ln -s /etc/xen/${DOMAIN_NAME} /etc/xen/auto
 
# start domU
xm create -c ${DOMAIN_NAME}

# disable pc speaker
echo 'blacklist snd-pcsp' >> /etc/modprobe.d/blacklist.conf

# check for updates
touch /etc/apt/apt.conf.d/10periodic
if [ $(cat /etc/apt/apt.conf.d/10periodic | grep -c Update-Package-Lists) -eq 0 ]; then
 echo 'APT::Periodic::Update-Package-Lists "1";' >> /etc/apt/apt.conf.d/10periodic
fi

# fix FQDN
sed -i "s|$(hostname) $(hostname)|$(hostname -A)$(hostname)|g" /etc/hosts
 
user: root
password: t00r

OPTIONAL: enable auto updates
http://www.panticz.de/debian-ubuntu-automatic-upgrades

Ubuntu / Debian: Install and configure lm-sensors

wget -q https://raw.githubusercontent.com/panticz/installit/master/install.lm-sensors.sh -O - | bash -

#!/bin/bash

# ensure that this script is run by root
if [ $(id -u) -ne 0 ]; then
  sudo $0
  exit
fi

# install lm-sensors
apt-get install -y lm-sensors

# install the latest version
if [ "$1" == "-n" ]; then
  wget http://mirrors.kernel.org/ubuntu/pool/universe/l/lm-sensors/lm-sensors_3.3.3-1ubuntu1_amd64.deb -P /tmp/
  dpkg -i /tmp/lm-sensors_*.deb
  rm /tmp/lm-sensors_*.deb
fi

# auto configure
yes | /usr/sbin/sensors-detect

Search for motherboard configuration
sudo dmidecode -t baseboard | grep "Product Name"
http://www.lm-sensors.org/wiki/Configurations/

Motherboard configurations
# MSI X58 Pro-E (MS-7522) / Fintek f71882fg
echo "f71882fg" >> /etc/modules
echo "#coretemp" >> /etc/modules
modprobe f71882fg
wget http://dl.panticz.de/lm-sensors/ms-7522.conf -O /etc/sensors.d/f71882fg.conf
sensors -s

# ASUS M2N32 WS Professional
cat /etc/sensors.d/asus_m2n.conf
wget http://dl.panticz.de/lm-sensors/m2n32_ws_professional.conf -O /etc/sensors.d/m2n32_ws_professional.conf

# SuperMicro PDSMi-LN4+
wget http://dl.panticz.de/lm-sensors/pdsmi-ln4.conf -O /etc/sensors.d/pdsmi-ln4.conf

View raw sensor data
sensors -u

# default config file
/etc/sensors3.conf

# view hardwired? fan alarm value
cat /sys/class/hwmon/hwmon8/device/fan1_alarm

OPTIONAL: check with icinga
/usr/lib/nagios/plugins/check_sensors

Links
http://www.lm-sensors.org/wiki/Configurations/MSI/X58-Pro-E
http://www.lm-sensors.org/wiki/FAQ/Chapter3#HowdoIsetnewlimits

Install Obnam

Installation
wget https://raw.githubusercontent.com/panticz/installit/master/install.obnam.sh -O - | bash -

#!/bin/bash

# ensure that this script is run by root
if [ $(id -u) -ne 0 ]; then
  sudo $0
  exit
fi

# install the latest version 
if [ "$1" == "-n" ]; then
  # add repository
  echo "deb http://code.liw.fi/debian wheezy main" > /etc/apt/sources.list.d/obnam.list
  wget -q http://code.liw.fi/apt.asc -O - | apt-key add -
  apt-get update
fi

# install obnam
apt-get install -y obnam

# config
cat < /root/.obnam.conf
[config]
repository = sftp://root@itdev/backup/
root = /var/www
log = /var/log/obnam.log
EOF

# add ssh keys
ssh-keygen
ssh-copy-id root@itdev

# backup
obnam backup

# commands
obnam ls
obnam ls --generation=2
obnam diff 2 5

# mount
apt-get install python-fuse #fuse

obnam mount --to /mnt/

Links
http://www.heise.de/artikel-archiv/ct/2013/23/170_Gut-gesichert - Gut gesichert: Verschlüsselte Datensicherung unter Linux mit Obnam

Install pipelight (watch Watchever under Linux / Ubuntu)

wget https://raw.githubusercontent.com/panticz/installit/master/install.pipelight.sh -O - | bash -

#!/bin/bash

# add repository
sudo add-apt-repository -y ppa:pipelight/stable

# update repository
sudo apt-get update

# install pipelight
sudo apt-get install -y pipelight-multi

sudo pipelight-plugin --update
sudo pipelight-plugin --accept --enable silverlight
sudo pipelight-plugin --accept --enable flash
sudo pipelight-plugin --create-mozilla-plugins

Start Watchever
chromium-browser https://www.watchever.de/login

Links
https://wiki.ubuntuusers.de/Pipelight/
http://fds-team.de/cms/pipelight-installation.html

TestServer - fully automated test system

  • iPXE netboot
  • Provisioning
  • Inventory
  • Hardware test
  • Monitoring
  • Automated system installation

Puppet: PHP5 module

create module structure
mkdir -p /etc/puppet/modules/php5/manifests
mkdir -p /etc/puppet/modules/php5/files

download module definiction
wget -q https://raw.githubusercontent.com/panticz/puppet/master/modules/php5/init.pp -O /etc/puppet/modules/php5/manifests/init.pp

class php5 {
    case $::osfamily {
        default: {
            $pkg = 'php5'
        }
    }

    # install PHP and restarts apache to load the module
    #package { ['php54', 'php54-apc', 'php54-mod-php']:
    package { "$pkg":
        ensure  => installed,
        notify  => Service['apache2'],
        #require => [ Package['php5-mysql'], Package['apache'] ],
        require => Package["apache"],
    }

    exec { "/bin/date -I > /tmp/debug": }
#cat /etc/apache2/mods-enabled/php5.conf
#<FilesMatch ".+\.ph(p[345]?|t|tml)|.htm([l]*)$">
}

add include to your client in /etc/puppet/manifests/site.pp
node "client1.local" inherits default {
...
include php5
...
}

Example: index.html

Links

Puppet: Apache module

create module structure
mkdir -p /etc/puppet/modules/apache/manifests
mkdir -p /etc/puppet/modules/apache/files

download module definiction
wget -q https://raw.githubusercontent.com/panticz/puppet/master/modules/apache/init.pp -O /etc/puppet/modules/apache/manifests/init.pp

class apache {
    case $::osfamily {
        'redhat': {
            $apache_name = 'httpd'
        }
        'debian': {
            $apache_name = 'apache2'
        }
        default: {
            $apache_name = 'apache2'
        }
    }

    # install apache
    package { "$apache_name":
        ensure => installed,
        #name => 'apache2-mpm-prefork', # httpd if CentOS
        alias  => "apache",
    }

    # enable apache service
    service { 'apache2':
        ensure => running,
        enable => true,
        require => Package['apache']
    }

    file { "/var/www/index.html":
        mode => 644,
        owner => www-data,
        group => www-data,
        source  => "puppet:///modules/apache/index.html",
        require => Package["apache"],
    }
}

add include to your client in /etc/puppet/manifests/site.pp
node "client1.local" inherits default {
...
include apache
...
}

Example: index.html
echo "Hello puppet" > /etc/puppet/modules/apache/files/index.html

Links
http://www.panticz.de/install_webserver
http://github.com/example42/puppet-apache

Puppet: Xen module

create module structure
mkdir -p /etc/puppet/modules/xen/manifests
mkdir -p /etc/puppet/modules/xen/files

download module definiction
wget -q https://raw.githubusercontent.com/panticz/puppet/master/modules/xen/init.pp -O /etc/puppet/modules/xen/manifests/init.pp

class xen {
#    case $operatingsystem {
#        debian: {
            $packagelist = [ "xen-linux-system", "xen-tools", "debootstrap" ]
#        }
#        ubuntu: {
#            $packagelist = [ "xen-linux-system", "xen-tools", "debootstrap" ]
#        }
#    }

    package { $packagelist:
        ensure => installed,
    }

#    service { 'apache2':
#        ensure => running,
#        enable => true,
#        require => Package['nullmailer']
#    }

    exec { ['/bin/mv /etc/grub.d/10_linux /etc/grub.d/25_linux', '/bin/echo "GRUB_DISABLE_OS_PROBER=true" >> /etc/default/grub']:
#        cwd => "/var/tmp",
#        creates => "/var/tmp/myfile",
#        path => ["/bin", "/usr/bin", "/usr/sbin"],

#        require => Package["xen-linux-system"],
        require => Package[$packagelist],
    }

#    file { "/etc/mailname":
#        mode => 644,
#        owner => root,
#        group => root,
#        source => "puppet:///modules/nullmailer/mailname",
#        require => Package["nullmailer"],
#    }

#    file { "/etc/nullmailer/remotes":
#        mode => 600,
#        owner => mail,
#        group => mail,
#        source => "puppet:///modules/nullmailer/remotes",
#        require => Package["nullmailer"],
#    }
}

add include to your client in /etc/puppet/manifests/site.pp
node "client1.local" inherits default {
...
include nullmailer
include xen
...
}

Links
http://www.panticz.de/install-xen

Puppet: Nullmailer module

create module structure
mkdir -p /etc/puppet/modules/nullmailer/manifests
mkdir -p /etc/puppet/modules/nullmailer/files

download module definiction
wget -q https://raw.githubusercontent.com/panticz/puppet/master/modules/nullmailer/init.pp -O /etc/puppet/modules/nullmailer/manifests/init.pp

class nullmailer {
    package { "nullmailer":
        ensure => installed,
    }

    service { 'nullmailer':
        ensure => running,
        enable => true,
        require => Package['nullmailer']
    }

    file { "/etc/mailname":
        mode => 644,
        owner => root,
        group => root,
        source => "puppet:///modules/nullmailer/mailname",
        require => Package["nullmailer"],
    }

    file { "/etc/nullmailer/remotes":
        mode => 600,
        owner => mail,
        group => mail,
        source => "puppet:///modules/nullmailer/remotes",
        require => Package["nullmailer"],
    }
}

add include to your client in /etc/puppet/manifests/site.pp
node "client1.local" inherits default {
...
include nullmailer
...
}

Example: /etc/mailname
example.com

Example: /etc/nullmailer/remotes
smtp.example.com smtp --auth-login --user=YOUR_SMTP_ID --pass=YOUR_SMTP_PASS

Links
http://www.panticz.de/install-nullmailer

Icinga objects: commands.cfg

wget -q https://raw.githubusercontent.com/panticz/icinga/master/objects/commands.cfg -O /etc/icinga/objects/commands.cfg

define command {
  command_name ssh_check_disk
  command_line /usr/lib/nagios/plugins/check_by_ssh -t 20 -H $HOSTADDRESS$ -l root -i /var/lib/nagios/.ssh/id_rsa -C "/usr/lib/nagios/plugins/check_disk -w $ARG2$ -c $ARG3$ -p $ARG1$"
}

define command {
  command_name ssh_check_mem
  command_line /usr/lib/nagios/plugins/check_by_ssh -t 20 -H $HOSTADDRESS$ -l root -i /var/lib/nagios/.ssh/id_rsa -C "/usr/lib/nagios/plugins/check_mem -w $ARG1$ -c $ARG2$ -f -C"
}

define command {
  command_name ssh_check_load
  command_line /usr/lib/nagios/plugins/check_by_ssh -t 20 -H $HOSTADDRESS$ -l root -i /var/lib/nagios/.ssh/id_rsa -C "/usr/lib/nagios/plugins/check_load -w $ARG1$,$ARG2$,$ARG3$ -c $ARG4$,$ARG5$,$ARG6$"
}

define command {
  command_name ssh_check_procs
  command_line /usr/lib/nagios/plugins/check_by_ssh -t 20 -H $HOSTADDRESS$ -l root -i /var/lib/nagios/.ssh/id_rsa -C "/usr/lib/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$"
}

define command {
  command_name ssh_check_procs_zombie
  command_line /usr/lib/nagios/plugins/check_by_ssh -t 20 -H $HOSTADDRESS$ -l root -i /var/lib/nagios/.ssh/id_rsa -C "/usr/lib/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ -s Z"
}

define command {
  command_name ssh_check_users
  command_line /usr/lib/nagios/plugins/check_by_ssh -t 20 -H $HOSTADDRESS$ -l root -i /var/lib/nagios/.ssh/id_rsa -C "/usr/lib/nagios/plugins/check_users -w $ARG1$ -c $ARG2$"
}

define command {
  command_name snmp_check_printer
  command_line /usr/lib/nagios/plugins/check_printer $HOSTADDRESS$ public $ARG1$ $ARG2$
}

define command {
  command_name ssh_check_swap
  command_line /usr/lib/nagios/plugins/check_by_ssh -t 20 -H $HOSTADDRESS$ -l root -i /var/lib/nagios/.ssh/id_rsa -C "/usr/lib/nagios/plugins/check_swap -w $ARG1$ -c $ARG2$"
}

define command {
  command_name ssh_check_apt
  command_line /usr/lib/nagios/plugins/check_by_ssh -t 20 -H $HOSTADDRESS$ -l root -i /var/lib/nagios/.ssh/id_rsa -C "/usr/lib/nagios/plugins/check_apt"
}

define command {
  command_name check_ping_8.8.8.8
  command_line /usr/lib/nagios/plugins/check_ping -H 8.8.8.8 -w 100.0,20% -c 500.0,60%
}

define command {
  command_name ssh_check_log
  command_line /usr/lib/nagios/plugins/check_by_ssh -t 20 -H $HOSTADDRESS$ -l root -i /var/lib/nagios/.ssh/id_rsa -C "/usr/lib/nagios/plugins/check_log -F $ARG1$ -O /dev/null -q '$ARG2$'"
}

define command {
  command_name ssh_check_raid
  command_line /usr/lib/nagios/plugins/check_by_ssh -t 20 -H $HOSTADDRESS$ -l root -i /var/lib/nagios/.ssh/id_rsa -C "/usr/lib/nagios/plugins/check_raid"
}

define command {
  command_name ssh_check_hddtemp
  command_line /usr/lib/nagios/plugins/check_by_ssh -t 20 -H $HOSTADDRESS$ -l root -i /var/lib/nagios/.ssh/id_rsa -C "/usr/lib/nagios/plugins/check_hddtemp /dev/$ARG1$ $ARG2$ $ARG3$"
}

define command {
  command_name ssh_check_ide_smart
  command_line /usr/lib/nagios/plugins/check_by_ssh -t 20 -H $HOSTADDRESS$ -l root -i /var/lib/nagios/.ssh/id_rsa -C "/usr/lib/nagios/plugins/check_ide_smart -d /dev/$ARG1$ -n"
}

define command {
  command_name ssh_check_cert_expire
  command_line /usr/lib/nagios/plugins/check_by_ssh -t 20 -H $HOSTADDRESS$ -l root -i /var/lib/nagios/.ssh/id_rsa -C "/usr/lib/nagios/plugins/check_cert_expire $ARG1$"
}

define command {
  command_name ssh_check_temp
  command_line /usr/lib/nagios/plugins/check_by_ssh -t 20 -H $HOSTADDRESS$ -l root -i /var/lib/nagios/.ssh/id_rsa -C "/usr/lib/nagios/plugins/check_temp $ARG1$ $ARG2$"
}

define command {
  command_name check_http_uri_regex
  command_line /usr/lib/nagios/plugins/check_http -H $HOSTADDRESS$ -u '$ARG1$' -r '$ARG2$'
}

define command {
  command_name check_http_uri_time
  command_line /usr/lib/nagios/plugins/check_http -t 20 -H $HOSTADDRESS$ -u '$ARG1$' -w '$ARG2$' -c '$ARG3$'
}

define command {
  command_name check_snmp
  command_line /usr/lib/nagios/plugins/check_snmp -H $HOSTADDRESS$ -o '$ARG1$' -w '$ARG2$' -c '$ARG3$'
}

define command {
  command_name check_printer_total_page_count
  command_line /usr/lib/nagios/plugins/check_snmp -H $HOSTADDRESS$ -o 1.3.6.1.2.1.43.10.2.1.4.1.1 -w '$ARG2$' -c '$ARG3$'
}

define command {
  command_name check_snom_registration_status
  command_line /usr/lib/nagios/plugins/check_snmp -H $HOSTADDRESS$ -o 1.3.6.1.2.1.7526.2.3.$ARG1$ -s 1
}

define command {
  command_name check_snom_firmware_version
  command_line /usr/lib/nagios/plugins/check_snmp -H $HOSTADDRESS$ -o 1.3.6.1.2.1.7526.2.4 -r '$ARG1$'
}

define command {
  command_name check_snmp_printer
  command_line /usr/lib/nagios/plugins/check_snmp_printer -H $HOSTADDRESS$ -x "$ARG1$" -w $ARG2$ -c $ARG3$
}

define command {
  command_name check_smb_share
  command_line /usr/lib/nagios/plugins/check_smb_share -H $HOSTADDRESS$ -s "$ARG1$"
}

define command {
  command_name ssh_check_oracle_tns
  command_line /usr/lib/nagios/plugins/check_by_ssh -t 20 -H $HOSTADDRESS$ -l root -i /var/lib/nagios/.ssh/id_rsa -C "/usr/lib/nagios/plugins/check_oracle --tns $ARG1$ "
}

define command {
  command_name ssh_check_mailq
  command_line /usr/lib/nagios/plugins/check_by_ssh -t 20 -H $HOSTADDRESS$ -l root -i /var/lib/nagios/.ssh/id_rsa -C "/usr/lib/nagios/plugins/check_mailq -w $ARG1$ -c $ARG2$ "
}

define command {
  command_name check_http_number
  command_line /usr/lib/nagios/plugins/check_http_number "$ARG1$" "$ARG2$" "$ARG3$"
}

define command {
  command_name ssh_check_sensors
  command_line /usr/lib/nagios/plugins/check_by_ssh -H $HOSTADDRESS$ -l root -i /var/lib/nagios/.ssh/id_rsa -C "/usr/lib/nagios/plugins/check_sensors -d /dev/$ARG1$ -n"
}

define command {
    command_name check_url
    command_line /usr/lib/nagios/plugins/check_http -H '$ARG1$' -p '$ARG2$' -u '$ARG3$' -s '$ARG4$' -f follow
}

Syndicate content