Elasticsearch Downgrade von Version 6.x zu Version 5.x

elasticsearch deinstallieren

dpkg -r --force-all elasticsearch

sources.list anpassen – Es dürfen keine Repositories der Version 6.x angegeben werden:

cat /etc/apt/sources.list
deb https://artifacts.elastic.co/packages/5.x/apt stable main

Elasticsearch Version 5.x installieren

apt-get update
apt-get install --reinstall elasticsearch

Zur Sicherheit noch mal beide Pakete zammad und elasticsearch reinstallieren

apt-get install --reinstall elasticsearch zammad

Den Zammad Index neu builden

zammad run rake searchindex:rebuild

Ubuntu 18.04 LTS installieren

ACHTUNG: Bitte die ISO-Datei mit dem traditionellem Installer downloaden.
http://cdimage.ubuntu.com/releases/18.04/release/ubuntu-18.04-server-amd64.iso

In der neuen Version ist keine Möglichkeit vorhanden ein LVM einzurichten.

sudo passwd

vi /etc/ssh/sshd_config

PermitRootLogin yes

/etc/init.d/ssh restart

vi /etc/netplan/01-netcfg.yaml

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
ens160:
dhcp4: no
addresses: [192.168.0.11/24]
gateway4: 192.168.0.1
nameservers:
addresses: [192.168.0.3,145.253.2.11]

netplan apply

Zammad in Ubuntu 18.04 Server

ACHTUNG: Bitte elasticsearch in Version 5.x verwenden! Version 6.x wird derzeit nicht unterstützt!

sysctl -w vm.max_map_count=262144

wget -qO – https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add –

echo „deb https://artifacts.elastic.co/packages/5.x/apt stable main“ >> /etc/apt/sources.list

apt-get update

apt install openjdk-8-jre-headless

apt install elasticsearch

/usr/share/elasticsearch/bin/elasticsearch-plugin install ingest-attachment

wget -qO- https://dl.packager.io/srv/zammad/zammad/key | sudo apt-key add –

wget -O /etc/apt/sources.list.d/zammad.list \
https://dl.packager.io/srv/zammad/zammad/develop/installer/ubuntu/18.04.repo

apt-get update

apt-get install zammad

Elementanzahl in SMB Share

Es soll ein Check auf Filecount implementiert werden. Auf dem abzufragenden Server kann jedoch kein check_mk Agent installiert werden. Es kann jedoch mit User / Passwort / Domain auf einen UNC-Pfad zugegriffen werden. Um die Dateianzahl darüber zu ermittelt habe ich das kleine check_smb_count.sh Plugin geschrieben (/opt/omd/versions/default/lib/nagios/plugins/check_smb_count.sh):

#!/bin/bash 
# 
# Check count of lines for smbclient 
# 
# smbclient //host/share SecretPassword  -U Username -W Domainname -c ls | wc -l 
# Domain=[DOMAIN] OS=[Windows 7 Professional 7601 Service Pack 1] Server=[Windows 7 Professional 6.1] 
# 18 
# 
# (c) 2018 Steffen Berg 
#  
server="host" 
share="share1" 
user="user1" 
password="secret" 
domain="WORKGROUP" 
critical="20" 
subdir="/subdir1/subdir2/*"  

elemcountraw=`smbclient //$server/$share $password -U $user -W $domain -c "ls $subdir" 2> /dev/null | wc -l` 

elemcount=$(($elemcountraw - 4))  

if [ "$elemcount" -lt "$critical" ] then   
echo "0 SMB-ElementCount - OK SMB-ElementCount $elemcount/$critical OK"
  exit 0 
else   echo "2 SMB-ElementCount - CRITICAL SMB-ElementCount $elemcount/$critical CRIT"
  exit 2 
fi

Einbindung über /omd/sites/<site>/etc/check_mk/conf.d/legacy.mk

# Definition of the Nagios command for SMB extra_nagios_conf += r""" define command {   command_name check_smb_count   command_line /opt/omd/versions/default/lib/nagios/plugins/check_smb_count.sh } """  # Create service definition legacy_checks += [   (( "check_smb_count", "ElementCountSMB", True), [ "host" ] ), ]

Kleines Expect-Script für alte Cisco Switches un err-disabled

Expect-Script

#!/usr/bin/expect

set host [lindex $argv 0]

spawn telnet $host
expect „Password:“
send „YourPassword\n“
log_file ./err-status-$host.log

send „term len 0\n“
send „show int status err-disabled\n“
expect „end\r“
send „\n“
send „exit\n“
log_file

Bash-Wrapper

cat check-state.sh
/usr/bin/expect ./check-state.expect 1.2.3.4
sleep 2
/usr/bin/expect ./check-state.expect 1.2.3.5
sleep 2

check_mk Powershell KV-Safenet Status eines Routers abfragen – KAMP-Safebox

#0=ok; 1=warn; 2=crit
$OK = 0
$Warning = 1
$Critical = 2

c:\skript\curl.exe -s -k https://your-safebox.address:8443/netaccess/connstatus.html > C:\Skript\kv-safenet-state.log

if (Select-String -Quiet -Path c:\skript\kv-safenet-state.log -Pattern „You are logged in.“) {
  $status = $OK
  $statustext = „OK“
  $detail = „KV-Safenet Verbindnung OK“
}
else {
  $status = $CRITICAL
  $statustext = „CRITICAL“
  $detail = „KV-Safenet Verbindnung CRITICAL“
}

Write-Host „$status KV-Safenet – $($statustext) – $detail“

check_mk local Bash Script Auswertung SQLPlus DB-FULL Logfiles

#!/bin/bash
#
# Skript Logfiles auszuwerten
# speziell RMAN DB FULL Status
#
# Bsp. Format zur Analyse generiert mit SQLPlus
# ===== 09.06.2017 11:23:56 =====
#
# START_TIME END_TIME STATUS INPUT_TYPE INPUT_BYTE OUTPUT_BYT RANG
# ——————– ——————– ——————– ———- ———- ———- ———-
# 08.06.2017 23:00:04 08.06.2017 23:39:09 COMPLETED DB FULL 75.75G 12.36G 1
# 07.06.2017 23:00:04 07.06.2017 23:45:23 COMPLETED DB FULL 75.12G 12.10G 2
# 06.06.2017 23:00:03 06.06.2017 23:46:06 COMPLETED DB FULL 74.57G 11.88G 3
#
# ===== 16.06.2017 10:16:38 =====
#
# START_TIME END_TIME STATUS INPUT_TYPE INPUT_BYTE OUTPUT_BYT RANG
# ——————– ——————– ——————– ———- ———- ———- ———-
# 15.06.2017 23:00:06 15.06.2017 23:42:01 COMPLETED DB FULL 76.19G 12.46G 1
# 14.06.2017 23:00:06 14.06.2017 23:40:42 COMPLETED DB FULL 75.83G 12.38G 2
# 13.06.2017 23:00:04 13.06.2017 23:42:13 COMPLETED DB FULL 75.15G 12.14G 3
#
# End Comments
#

files=./datastore/rman/check_rman*.log

for file in $files
do

  service=`echo „$file“ | cut -d / -f4`
  linecount=`cat $file | awk ‚/\=\=\=\=\=/ {if (count) print count; print; count=0; next} {count++} END {print count}‘ | tail -n1`
  linecount_noheadline=$((linecount – 3))
  lastoutput=`tail -n $linecount_noheadline $file | sed ‚1!G;h;$!d‘ | tail -n1`
  enddate=`echo „$lastoutput“ | cut -d \ -f4`
  state_raw=`echo „$lastoutput“ | cut -d \ -f7`
  day=`echo „$enddate“ | cut -d \. -f1`
  month=`echo „$enddate“ | cut -d \. -f2`
  year=`echo „$enddate“ | cut -d \. -f3`
  date_normalized=`date -d $year-$month-$day +’%Y%m%d’`
  today=`date +’%Y%m%d’`

  if [ $today = $date_normalized ]
    then
      if [ $state_raw = „COMPLETED“ ]
      then
        echo „0 DB-FULL-$service – OK DB-FULL hat den Status COMPLETED! OK“
      elif [ $state_raw = „RUNNING“ ]
      then
        echo „1 DB-FULL-$service – WARN DB-FULL hat den Status RUNNING! WARN“
      elif [ $state_raw = „FAILED“ ]
      then
        echo „2 DB-FULL-$service – CRIT DB-FULL hat den Status FAILED! CRIT“
      fi
    else
    echo „2 DB-FULL-$service – CRIT DB-FULL Letzer Logeintrag zu alt! Logalter: $date_normalized State: $state_raw“
  fi

done

Comet P8541 Temperatur Sensor check_mk Skript

def inventory_temp1(info):
  inventory = []
  for descr in info:
    inventory.append ( ( None, None ) )
  return inventory

def check_temp1(item, params, info):
  temp1 = int(float(info[0][0]))
  perfdata = [ ( „temp“, info[0][0], 24, 25 ) ]
  if temp1 <= 25:
    return (0, „OK Temperature is below 25 – Actual %d“ % temp1, perfdata)
  else:
    return (2, „CRITICAL Temperature is above 25 – Actual %d“ % temp1, perfdata)

check_info[„temp1“] = {
  ‚check_function‘ : check_temp1,
  ‚inventory_function‘ : inventory_temp1,
  ’service_description‘ : ‚Temperatur 1‘,
  ‚has_perfdata‘ : True,
  „snmp_info“ : ( „.1.3.6.1.4.1.22626.1.5.2.1.2“, [„0“]),
}

Exchange verknüpfte Postfächer per Powershell anlegen

Allgemein

Ggf. ist der direkte Set-ADUser-Befehl problematisch, da der AD-Synch nicht so schnell ist. Diesen muss man ggf. wiederholfen.

Beispielliste liste01.csv

Vorname;Nachname;Login Max;Mustermann;mustermann Testvorname;Testnachname;test ...

Skript

$vorname=Import-Csv -Delimiter ";" .\liste01.csv | select -ExpandProperty Vorname $nachname=Import-Csv -Delimiter ";" .\liste01.csv | select -ExpandProperty Nachname $login=Import-Csv -Delimiter ";" .\liste01.csv | select -ExpandProperty Login $cred=Get-Credential "FOREIGNDOMAIN\Administrator" 
Import-Module ActiveDirectory  for ($i=0; $i -lt $vorname.length; $i++) {       New-Mailbox -Database "Mailboxdatabase" -Name "PREFIX_$($nachname[$i]).$($vorname[$i])" -LinkedDomainController "FOREIGNDC" -LinkedMasterAccount DOMAIN\$($login[$i]) `
  -OrganizationalUnit Benutzer_neu -UserPrincipalName PREFIX_$($nachname[$i]).$($vorname[$i])@domain.local -DisplayName "$($nachname[$i]), $($vorname[$i])" `
  -LinkedCredential $cred   
  Set-ADUser -Identity "EKG_$($nachname[$i]).$($vorname[$i])" -Company "FIRMA" -Surname $($nachname[$i]) -GivenName $($vorname[$i])  }