103 lines
4.0 KiB
Bash
Executable File
103 lines
4.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
xyz=bsg3m
|
|
# 2016-03-01
|
|
AUSGABEDIR=/var/www/html/$xyz-report/
|
|
MAILREC=$1
|
|
MANDAT=$2
|
|
|
|
function get_png {
|
|
d=$1; t=$2; i=$3; a=$START; e=$ENDE; h=$IMGH; w=$IMGW;
|
|
if [[ $t == alert* ]]
|
|
then
|
|
rm -f $d$t.png
|
|
echo "http://10.101.0.11/graph.php?device=$d&type=$t&id=$i&from=$a&to=$e&width=$w&height=$h"
|
|
wget -q -O $d$t.png "http://10.101.0.11/graph.php?device=$d&type=$t&id=$i&from=$a&to=$e&width=$w&height=$h"
|
|
else
|
|
rm -f $d$t.png
|
|
echo "http://10.101.0.11/graph.php?device=$d&type=$t&from=$a&to=$e&width=$w&height=$h"
|
|
wget -q -O $d$t.png "http://10.101.0.11/graph.php?device=$d&type=$t&from=$a&to=$e&width=$w&height=$h"
|
|
fi
|
|
}
|
|
|
|
function get_id {
|
|
id=$(echo "select entity_id from group_table where group_id=$1;" | mysql -u root -plunakoshix -D observium | grep -v entity | sed 's/$/"/' | sed 's/^/"/g' | tr -d "\n" | sed "s/^/[/" | sed "s/$/]/" | sed 's/""/","/g' | base64 | tr -d '\n')
|
|
}
|
|
|
|
|
|
function init {
|
|
mkdir -p $AUSGABEDIR && pushd $AUSGABEDIR
|
|
|
|
if [ "$MANDAT" == "" ]
|
|
then
|
|
ENDE=`date +%s`
|
|
MDATE=`date +%Y-%m-%d`
|
|
REPDATE=$MDATE
|
|
else
|
|
ENDE=`date -d $MANDAT +%s`
|
|
MDATE=$MANDAT
|
|
REPDATE=`date +%Y-%m --date="$MDATE -1 month"`
|
|
fi
|
|
|
|
MONAT=`expr 60 \* 60 \* 24 \* 31 \* 3`
|
|
START=`expr $ENDE - $MONAT`
|
|
|
|
IMGW=390
|
|
IMGH=`expr $IMGW / 3`
|
|
}
|
|
|
|
function destruct {
|
|
popd
|
|
}
|
|
|
|
init;
|
|
|
|
get_id 53
|
|
echo "http://10.101.0.11/graph.php?from=$START&to=$ENDE&type=multi-storage_usage&height=$IMGH&width=$IMGW&id=$id"
|
|
wget -q -O connac53m.png "http://10.101.0.11/graph.php?from=$START&to=$ENDE&type=multi-storage_usage&height=$IMGH&width=$IMGW&id=$id"
|
|
|
|
get_id 54
|
|
echo "http://10.101.0.11/graph.php?from=$START&to=$ENDE&type=multi-storage_usage&height=$IMGH&width=$IMGW&id=$id"
|
|
wget -q -O connac63m.png "http://10.101.0.11/graph.php?from=$START&to=$ENDE&type=multi-storage_usage&height=$IMGH&width=$IMGW&id=$id"
|
|
|
|
|
|
echo "1: $MAILREC"
|
|
echo "2: $MANDAT"
|
|
echo "START: $START"
|
|
echo "ENDE: $ENDE"
|
|
echo "MDATE: $MDATE"
|
|
|
|
|
|
# ldap5 connac5 connac6 vwdw10_1+2 tapp3 tapp4 tdb3 papp5 papp6 papp7 papp8 pdb3 pdb4
|
|
devices="435:1 402:1 403:1 355:1 356:1 424:1 425:1 423:1 426:1 427:1 428:1 429:1 430:1 431:1";
|
|
|
|
#graphs="alert_status device_processor device_ucd_memory device_storage device_ucd_load device_diskio";
|
|
graphs="device_availability alert_status device_ucd_ss_cpu device_ucd_memory device_storage device_ucd_load device_diskio processor device_processor device_NETAPP-MIB_cp_ops device_la device_mempool";
|
|
|
|
for DEV in $devices
|
|
do
|
|
device=$(echo $DEV | cut -f1 -d:)
|
|
id=$(echo $DEV | cut -f2 -d:)
|
|
for GRAPH in $graphs
|
|
do
|
|
type=$GRAPH
|
|
get_png $device $type $id
|
|
done
|
|
done
|
|
|
|
destruct;
|
|
|
|
htmldoc -t pdf14 -f "/var/www/tmp/$xyz-report_$REPDATE.pdf" --book --toclevels 3 --no-numbered --toctitle "Inhaltsverzeichnis" --no-title --linkstyle underline --size A4 --left 0.75in --right 0.50in --top 0.50in --bottom 0.50in --header .t. --header1 ... --footer dt/ --nup 1 --tocheader ... --tocfooter dti --color --no-pscommands --no-xrxcomments --compression=1 --jpeg=90 --fontsize 8.0 --fontspacing 1.2 --headingfont Helvetica --bodyfont Times --headfootsize 8.0 --headfootfont Helvetica --charset iso-8859-1 --links --embedfonts --pagemode outline --pagelayout single --firstpage p1 --pageeffect none --pageduration 10 --effectduration 1.0 --no-encryption --permissions all --owner-password "" --user-password "" --browserwidth 1000 --no-strict --no-overflow /var/www/html/$xyz-report.html
|
|
|
|
for MAIL in $MAILREC
|
|
do
|
|
echo "TO: $MAIL" > /tmp/mailreportfile.tmp
|
|
echo "FROM: CONET Services Monitoring Reporter <help@conet.de>" >> /tmp/mailreportfile.tmp
|
|
echo "SUBJECT: DECIDE Monitoring Quartalsreport $MDATE" >> /tmp/mailreportfile.tmp
|
|
echo "X-CONET-SRC: root@conlxsyslog03:/scripts/bsg3m-report.sh" >> /tmp/mailreportfile.tmp
|
|
echo "" >> /tmp/mailreportfile.tmp
|
|
echo "" >> /tmp/mailreportfile.tmp
|
|
echo "" | mutt -H /tmp/mailreportfile.tmp -a /var/www/tmp/$xyz-report_$REPDATE.pdf -- $MAIL
|
|
rm /tmp/mailreportfile.tmp
|
|
done
|