Code Monkey home page Code Monkey logo

weathermap-history's Introduction

What is this?

This repo is just the web html to display the animated weathermap GIFs based on chosen date.

Please follow the guide below, which will walk you through the shell scripts which create GIF animations of the weathermap daily.


Prerequisites

  • "convert" command (yum install ImageMagick , and on ubuntu apt install imagemagick ) - used to convert pngs to gif
  • "pngquant" command (yum install pngquant , apt install pngquant) - PNG Optimization
  • "gifsicle" command (yum install gifsicle, apt install gifsicle) - GIF Optimization which shows a GIF filesize reduction of 87%
  • Assumes your librenms path is /opt/librenms (otherwise you will need to edit the scripts)

How do I use this?

mkdir -p /opt/weathermap-history/history

cd /opt/weathermap-history

vim getweather.sh (edit MAPNAME.png and file path if wrong)

#!/bin/bash
DATE=`date '+%y%m%d%H%M'`
cp /opt/librenms/html/plugins/Weathermap/output/MAPNAME.png /opt/weathermap-history/history/MAPNAME_$DATE.png

chmod +x getweather.sh

vim makeGIF.sh

#!/bin/bash

DATE=$(date "+%Y-%m-%d" -d "yesterday")
mkdir -p /opt/librenms/html/plugins/Weathermap/output/history/$DATE
cd /opt/weathermap-history/history/
pngquant --force --quality=60-70 *.png -f --ext .png
convert  -delay 30 -loop 0 *.png /opt/librenms/html/plugins/Weathermap/output/history/$DATE/$DATE.gif
gifsicle -O3 /opt/librenms/html/plugins/Weathermap/output/history/$DATE/$DATE.gif -o /opt/librenms/html/plugins/Weathermap/output/history/$DATE/$DATE.gif
rm /opt/weathermap-history/history/*

chmod +x makeGIF.sh

Open Roots cronjob

crontab -e

(First line will create PNGs at 5 minute intervals between 18:00 up to 23:55, change this to your busiest periods but i would keep up to a 6 hour period otherwise you end up with huge file sized GIFs)
(Second line creates the GIF at 3am, i would leave this because we explicitly set -d yesterday to compensate the date)

*/5 18-23 * * * /opt/weathermap-history/getweather.sh >> /dev/null 2>&1
0 3 * * * /opt/weathermap-history/makeGIF.sh >> /dev/null 2>&1

cd /opt/librenms/html/plugins/Weathermap/output

Now clone the repo into the history folder like so

git clone https://github.com/chasgames/Weathermap-History history

In 24 hours you should have the date folder and GIF created in this folder opt/librenms/html/plugins/Weathermap/output/history/

You can go to the web front end here: http://1.1.1.1/plugins/Weathermap/output/history/index.html


Troubleshooting

When selecting a date, GIF doesn't show - Depending on GIF size it can take a while to load, 1M < GIF should take less than 10 seconds. 5M GIF can take up to 30 seconds so you will need to shorten the time period or use the resize function in gifsicle. Use chrome inspect tool to find out the GIF link it's trying to pull and check it exists on the filesystem.

GIF is not made - Try running ./getweather.sh manually it should copy the weathermap into /opt/weathermap-history/history as a temporary location to hold the pngs for the time period. Check that works first. Then redirect the cronjobs to a log file instead of /dev/null to see what the problem is.


Acknowledgments

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.