|
Linux: "Asynchrone FTP Schnittstelle" |
Dieses Script dient in unserem Beispiel dazu, Dateien welche z.B. mittels des ystemmanagement Tools NAGIOS erzeugt wurden an ein Drittsystem (hier ITSM) zu übergeben.
Einfach mit einen Unix Editor eine Shellscript-Datei erzeugen. Zum Beispiel "vi /usr/bin/local/copy_nagios_to_itsm.sh". Die Scriptcode reinkopieren und speichern. Jetzt nur noch die Datei mit "chmod -x /usr/bin/local/copy_nagios_to_itsm.sh" ausführbar machen. Die Datei kann jetzt mit root-Rechten /usr/bin/local/install_csync.sh ausgeführt werden.
Haftungsausschluss beachten!
|
#!/bin/bash
# Don't delete this script!
# This ist the location where Nagios creates the export files for ITSM (SAP-PM)
TRANSFER="/var/transfer"
# The remote target directory
TARGETDIR="/nagios"
# The interval should not be less than two minutes and not longer than the CRON job schedule
INTERVALL=2
# FTP Konfiguration
ftps="???" # FTP target server
ftpu="???" # FTP user
tppp="???" # FTP password
##########################################
# Do not change anything below this line #
##########################################
[[ ! -d $TRANSFER/move/ ]] && mkdir -p $TRANSFER/move/
for i in $(find $TRANSFER -maxdepth 1 -type f -mmin +$INTERVALL -print)
do
mv -uf $i $TRANSFER/move/
done
if [ `ls /var/transfer/move/ | wc -l` -ge 0 ]; then
ftp -ni $ftps <<EOF >/tmp/nagios_to_itsm.log
quote USER $ftpu
quote PASS $tppp
lcd $TRANSFER/move/
cd $TARGETDIR
mput *
quit
EOF
# FTP success/error handler
if [ `cat /tmp/nagios_to_itsm.log | wc -l` -le 2 ]; then
rm $TRANSFER/move/*
else
echo "`date '+%b %d %X'` Error: Schnittstelle zwischen Nagios und ITSM ist gestoert!" >>/var/log/messages
fi
fi
exit
|
|