917 ergebnisse gefunden
Kleines Script um 2 Dateien zu Vergleichen und die Ausgabe in eine weitere Datei zu schreiben.
#!/usr/bin/bash
# Deklaration Variablen
aix=/home/svc.aix_ansible/twe/aix.out
vio=/home/svc.aix_ansible/twe/vio.out
ansible=/home/svc.aix_ansible/twe/ansible.out
check=/home/svc.aix_ansible/twe/check.out
result=/home/svc.aix_ansible/twe/result.out
clear
# Abfrage
echo "Starte die Abfrage . . ."
/srv/lpar2rrd/pwrdata/search_lpar.py | grep -i AIX | sort | awk '{print $1}' > $aix
/srv/lpar2rrd/pwrdata/search_lpar.py | grep -i VIOS | sort | awk '{print $1}' > $vio
cat /etc/ansible/hosts | grep "ansible_host" | sort | awk '{print $1}' > $ansible
# Zusammenfuehren der Dateien aix und vio
cat $aix $vio | sort > $check
# Unterschiede pruefen und Ausgabe in Datei schreiben
rm $result
touch $result
echo "+-----------------------------------------------------------------------+" >> $result
printf "|%9s | %52s | %1s |\n" AIX_LPAR "" "VIO" >> $result
echo "+-----------------------------------------------------------------------+" >> $result
sdiff $check $ansible >> $result
# Dateien, bis auf result.out loeschen
rm $aix $vio $ansible $check
echo "Das Ergebnis wir in der Datei result.out festgehalten. Die linke Spalte enthaelt AIX LPAR und VIO"
echo "Die rechte Spalte enthaelt die Ansible Systeme."
Für die Überwachung der Datenbankreplizierung (Master/Master/Slave) auf Linux Systemen, habe ich ein Shell Script erstellt.
Das Script prüft, ob der mySQL Prozess läuft und ob die Replizierung ebenfalls aktiv ist.
Das Script sollte auf den DB Systemen unter /var/prtg/scripts abgelegt werden.
cat mysql-status.sh
#Mysql Check danach Slave IO & Slave SQL Check
#!/bin/bash
SQLout=`mysql -u root --password=xxx mysql -e "show slave status \G" | grep -i "Slave_SQL_Running"|awk '{print $2}'`
IOout=`mysql -u root --password=xxx mysql -e "show slave status \G" | grep -i "Slave_IO_Running"|awk '{print $2}'`
SQLcheck=`mysql -u root --password=xxx mysql -e "quit"`
if [ "$?" = "1" ]; then
#if [ "$SQLcheck" = "false" ]; then
echo "4:1:Database down"
exit 1
elif [ "$SQLout" = "No" ] || [ "$IOout" = "No" ]; then
echo "4:1:Replikationsfehler"
exit 1
fi
echo "0:0:OK"
exit 0
Um zfs Pools automatisch zu prüfen, habe ich vor ein paar Jahren einmal ein Shell Script erstellt, welches via cronjob in regelmässigen Abständen aufgerufen wird. Das Ergebnis wird via e-mail zugestellt.
Einfach die Variablen der eigenen Umgebung anpassen.
#!/bin/bash
# zpoolcheck Script Ver. 1.0
# Date: 03.08.2012
# by: Thomas Weidner
# The script starts a scrub on each ZFS pool (only one at time)
# and will send an e-mail with the result after the scrub is complete.
# e-mail variables
TO=tom@dvs8818.de
LOG=/var/log/zpoolresult
SUBJECTOK="Zpool status from nexenta-01"
SUBJECTERROR="WARNING zpool error from nexenta-01"
# work variables
ERROR=0
SEP=" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "
RUNNING=1
# commands & configuration
ZPOOL=/sbin/zpool
DATE="`date +"%Y-%m-%d %H:%M:%S"`"
echo $DATE > $LOG
# find all pools
pools=$($ZPOOL list -H -o name)
# for each pool
for pool in $pools; do
# start scrub for $pool
echo "starting scrub on $pool" >> $LOG
zpool scrub $pool
RUNNING=1
# wait until scrub for $pool has finished running
while [ $RUNNING = 1 ]; do
# still running?
if $ZPOOL status -v $pool | grep -q "scrub in progress"; then
sleep 60
# not running
else
# finished with this pool, exit
echo "scrub ended on $pool" >> $LOG
echo "`$ZPOOL status -v $pool`" >> $LOG
echo $SEP >> $LOG
RUNNING=0
# check for errors
if ! $ZPOOL status -v $pool | grep -q "No known data errors"; then
echo "data errors detected on $pool" >> $LOG
ERROR=1
fi
fi
done
done
# send result via e-mail
if [ $ERROR = 1 ]; then
mailx -s "$SUBJECTERROR" $TO < $LOG
else
mailx -s "$SUBJECTOK" $TO < $LOG
fi
Wer mal fix eine IP Range via Shell Script pingen möchte. Es werden nur die IPs ausgegeben, die den Ping beantworten. Ein kleines aber sehr schnelles Script.
root@bacula-dev:/# for i in {1..254} ;do (ping 10.1.92.$i -c 1 -w 5 >/dev/null && echo "10.1.92.$i" &) ;done
10.1.92.1
10.1.92.2
10.1.92.4
10.1.92.75
10.1.92.99
10.1.92.105
10.1.92.104
10.1.92.106
10.1.92.113
10.1.92.151
10.1.92.152
10.1.92.155
10.1.92.154
10.1.92.153
10.1.92.156
10.1.92.157
10.1.92.159
10.1.92.207
10.1.92.208
10.1.92.209
10.1.92.211
10.1.92.210
Das Regal habe ich nun endlich angebracht.
Es macht sich wirklich gut an dem Verkaufswagen auf dem Wochenmarkt.
