Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tech:linux:pnp4nagios_graphs [2017/01/04 06:25]
tech:linux:pnp4nagios_graphs [2017/01/04 06:25] (current)
Line 1: Line 1:
 +====== pnp4nagios extracting graphs ======
 +Bash script to extract graphs for previous month
 +<code bash>
 +#!/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
 +</​code>​
 +
 +
 +File: month_graphs.txt
 +<​code>​
 +server1 CPU
 +server1 Memory
 +server2 CPU
 +etc ...
 +</​code>​
  

QR Code
QR Code tech:linux:pnp4nagios_graphs (generated for current page)