Animating Weathermap

Support questions about the Network Weather Map plugin

Moderators: Developers, Moderators

Post Reply
bboy8012
Cacti User
Posts: 54
Joined: Thu May 01, 2014 8:27 am

Animating Weathermap

Post by bboy8012 »

All need a little help with the cron/scripting part of animating it. I would like to do daily animations and have the files deleted every night at midnight, but before deleting create the animation and save it to another folder I have modified this script:

Code: Select all

#!/bin/sh

SRC_MAP="/usr/share/cacti/plugins/weathermap/output/weathermap_1.png"
HISTORY_DIR="/usr/share/cacti/plugins/weathermap/history"

DATE=`date '+%y%m%d%H%M'`
cp $SRC_MAP $HISTORY_DIR/map_$DATE.png
find $HISTORY_DIR -name '*.png' -mtime +1 -type f -exec rm {} \;
and pieced this one:

Code: Select all

#!/bin/sh

HISTORY_DIR="/usr/share/cacti/plugins/weathermap/history"
ANIMATION_DIR="/usr/share/cacti/plugins/weathermap/animation"

DATE=`date '+%y%m%d'`

convert $HISTORY_DIR/*.png $ANIMATION_DIR/$DATE.mpg
with my cron for gathering images set to:

Code: Select all

*/1 * * * *  /usr/share/cacti/plugins/weathermap/copy-frames.sh
cron to create animation at midnight everynight and store:

Code: Select all

0 0 * * * /usr/share/cacti/plugins/weathermap/create-animation.sh
Is this correct? Thanks
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: Animating Weathermap

Post by Howie »

Looks about right, except that

Code: Select all

SRC_MAP="/usr/share/cacti/plugins/weathermap/output/weathermap_1.png"
will be a filename with a long hashcode in it, unless you are using a really old version of weathermap.

Also, you may want to check into ffmpeg for video encoding - you get more modern options, including H264 avi... I believe it requires the image files to be sequentially numbered though.

A note for when I finally finish it - this functionality (apart from the animation creation) is built into the poller for the next release, where it's called 'archiving'. I want to add some UI so that you could 'rewind' from inside the cacti UI to see a previous point in time.
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
bboy8012
Cacti User
Posts: 54
Joined: Thu May 01, 2014 8:27 am

Re: Animating Weathermap

Post by bboy8012 »

Cant wait for that release. Thanks for all your help and hard work
ikorzha758
Cacti User
Posts: 164
Joined: Thu Jan 21, 2010 8:41 pm

Re: Animating Weathermap

Post by ikorzha758 »

Yes future is always exciting with Howie, however in a mean time here is a working script that have been posted here previously:
ffmpeg is required install on the server..
I use this script, and it works perfectly for me. I get 48hr mp4 1080p video file that is linked directly from the map.
Anyone who views the map can download and play the video.


NODE video
INFOURL output/JC_Infrastructure_Map.mp4
NOTES Click to open time lapse Video
ICON 34 34 images/timemachine.gif
POSITION 1868 13





#!/bin/sh
SRC_MAP="/var/www/html/plugins/weathermap/output/47bee81be48a9589f34b.png"
HISTORY_DIR="/var/www/html/plugins/weathermap/output/video01/"
TMP_DIR="/var/www/html/plugins/weathermap/output/video01/tmp/"
VIDEO_DIR="/var/www/html/plugins/weathermap/output/"

FULLHOUR=`date '+%M'`

DATE=`date '+%y%m%d%H%M'`
sleep 5
cp $SRC_MAP $HISTORY_DIR/$DATE.png
find $HISTORY_DIR -name '*.png' -mtime +1 -type f -exec rm {} \;

if [ $FULLHOUR -eq 01 ]; then
x=0
for i in $HISTORY_DIR/*.png
do
cp $i $TMP_DIR/`printf "%06d.png" $x`
x=$(($x+1))
done

`nice ffmpeg -f image2 -sameq -b 1800 -r 1 -i $TMP_DIR/%06d.png $VIDEO_DIR/video01_tmp.mp4`
mv -f $VIDEO_DIR/video01_tmp.mp4 $VIDEO_DIR/JC_Infrastructure_Map.mp4
chown apache:apache $VIDEO_DIR/JC_Infrastructure_Map.mp4
rm -f $TMP_DIR/*.png

fi
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: Animating Weathermap

Post by Howie »

Jetpacks in 0.99 ;-)
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests