pnp4nagios extracting graphs
Bash script to extract graphs for previous month
#!/bin/bash # WDIR=/path/to/script OUTDIR=$WDIR/output/monthly_graphs mkdir -p $OUTDIR INPFILE=$WDIR/month_graphs.txt GRZIP=$WDIR/month_graphs.zip # # 1st day of last month stime=$(date -d "`date +%Y%m01` -1 month" +%s) # 1st day of this month etime=$(date -d "`date +%Y%m01`" +%s) # while read HN DB; do GURL="http://localhost/pnp4nagios/image?host=${HN}&srv=${DB}&view=1&start=${stime}&end=${etime}" PNGF="$OUTDIR/graph_${HN}_${DB}.png" wget -O $PNGF -q --user=nagiosadmin --password=ENTERPASSWORD "$GURL" done < $INPFILE # rm $GRZIP zip -r -j -q $GRZIP $OUTDIR echo "" | mutt -a $GRZIP -s monthtly_graphs -- someone@example.org exit
File: month_graphs.txt
server1 CPU server1 Memory server2 CPU etc ...