Files
scripts-conlxsyslog03/mail_port_error.sh
conetadm 5718e70f15 init
2024-11-14 21:11:06 +01:00

27 lines
3.5 KiB
Bash
Executable File

#!/bin/bash
echo "select a.hostname, b.timestamp, b.msg from syslog b inner join devices a on b.device_id=a.device_id where b.msg like '%LINK-3-UPDOWN%' and b.timestamp > DATE_SUB(NOW(), INTERVAL 3 DAY);" > /tmp/select_input
echo "select a.hostname, b.timestamp, b.msg from syslog b inner join devices a on b.device_id=a.device_id where b.msg like '%PORT-5-IF_DOWN%' and b.timestamp > DATE_SUB(NOW(), INTERVAL 3 DAY);" >> /tmp/select_input
echo "select a.hostname, b.timestamp, b.msg from syslog b inner join devices a on b.device_id=a.device_id where b.msg like '%LINEPROTO-5-UPDOWN%' and b.timestamp > DATE_SUB(NOW(), INTERVAL 3 DAY);" >> /tmp/select_input
echo "select a.hostname, b.timestamp, b.msg from syslog b inner join devices a on b.device_id=a.device_id where b.msg like '%PORT-5-IF_UP%' and b.timestamp > DATE_SUB(NOW(), INTERVAL 3 DAY);" >> /tmp/select_input
echo "select a.hostname, b.timestamp, b.msg from syslog b inner join devices a on b.device_id=a.device_id where b.msg like '%CANNOT_BUNDLE%' and b.timestamp > DATE_SUB(NOW(), INTERVAL 3 DAY);" >> /tmp/select_input
echo "select a.hostname, b.timestamp, b.msg from syslog b inner join devices a on b.device_id=a.device_id where b.msg like '%SNMP-4-HIGHCPU%' and b.timestamp > DATE_SUB(NOW(), INTERVAL 3 DAY);" >> /tmp/select_input
echo "select a.hostname, b.timestamp, b.msg from syslog b inner join devices a on b.device_id=a.device_id where b.msg like '%Excessive Broadcast%' and b.timestamp > DATE_SUB(NOW(), INTERVAL 3 DAY);" >> /tmp/select_input
echo "select a.hostname, b.timestamp, b.msg from syslog b inner join devices a on b.device_id=a.device_id where b.msg like '%Excessive CRC%' and b.timestamp > DATE_SUB(NOW(), INTERVAL 3 DAY);" >> /tmp/select_input
echo "select a.hostname, b.timestamp, b.msg from syslog b inner join devices a on b.device_id=a.device_id where b.msg like '%Duplex Mismatch%' and b.timestamp > DATE_SUB(NOW(), INTERVAL 3 DAY);" >> /tmp/select_input
echo "select a.hostname, b.timestamp, b.msg from syslog b inner join devices a on b.device_id=a.device_id where b.msg like '%Excessive late%' and b.timestamp > DATE_SUB(NOW(), INTERVAL 3 DAY);" >> /tmp/select_input
echo "select a.hostname, b.timestamp, b.msg from syslog b inner join devices a on b.device_id=a.device_id where b.msg like '%Excessive link state%' and b.timestamp > DATE_SUB(NOW(), INTERVAL 3 DAY);" >> /tmp/select_input
echo "select a.hostname, b.timestamp, b.msg from syslog b inner join devices a on b.device_id=a.device_id where b.msg like '%High collision%' and b.timestamp > DATE_SUB(NOW(), INTERVAL 3 DAY);" >> /tmp/select_input
echo "select a.hostname, b.timestamp, b.msg from syslog b inner join devices a on b.device_id=a.device_id where b.msg like '%Excessive undersized%' and b.timestamp > DATE_SUB(NOW(), INTERVAL 3 DAY);" >> /tmp/select_input
echo "select a.hostname, b.timestamp, b.msg from syslog b inner join devices a on b.device_id=a.device_id where b.msg like '%Excessive jabbering%' and b.timestamp > DATE_SUB(NOW(), INTERVAL 3 DAY);" >> /tmp/select_input
echo "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'></head><body>" > /tmp/mail_output
mysql -H -uroot -p@Defender2013! -Dobservium < /tmp/select_input >> /tmp/mail_output
echo "</body></html>" >> /tmp/mail_output
cat /tmp/mail_output | mail -a "From: conlxsyslog02" -a "Content-Type: text/html" -s "Switchportfehler der letzten 3 Tage" ageissler@conet.de
rm /tmp/select_input
rm /tmp/mail_output