Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


HELP changing icon with the current time

 
Post new topic   Reply to topic    Cacti Forum Index -> Plugin: (Network Weather Map)
Author Message
john123



Joined: 08 May 2008
Posts: 1

PostPosted: Thu May 08, 2008 10:00 am    Post subject: HELP changing icon with the current time Reply with quote

Hi

I want to change the icon of a node, depending the current hour of the day.
like if its 12 pm it will show an icon with stars, and if its 12 am it will show an icon with a sun, but i want to make it to change the icon for all 24h of the day, is there a way to do it?

thanks
Back to top
Howie
Cacti Guru User


Joined: 16 Sep 2004
Posts: 2132
Location: United Kingdom

PostPosted: Thu May 08, 2008 1:40 pm    Post subject: Reply with quote

This is cheesy, and I haven't tested it, but if you set up a NODE like this:
Code:


SCALE daynight 0 33 255 255 255 images/nighticon.png
SCALE daynight 33 75 255 255 255 images/dayicon.png
SCALE daynight 75 100 255 255 255 images/nighticon.png

NODE my_time_icon
   ICON {node:this:inscaletag}
   MAXVALUE 24
   TARGET !whathour.sh
   USESCALE daynight
   POSITION 50 50


then you have a node where the icon changes with the percentage through the day (the label stays white, if you add one). 'inscaletag' gets the string from the end of the SCALE line that was 'hit', which in this case is an image filename. The ugly part is that you have to specify the time bands as percentages of a day - mine is night from 6pm to 8am.

So now all you need is a script called whathour.sh:
Code:

#!/bin/sh

date "+%H"
date "+%H"
echo ignored
echo ignored


It must produce 4 lines of output, and the first two are the 'in' and 'out' value. The date commands will produce a number from 00 to 23 depending on the hour.

The 'external script' target (with the ! prefix) is pretty rarely tested by me, but it did work last time I tried it.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Plugin: (Network Weather Map) All times are GMT - 5 Hours
Page 1 of 1

 



Powered by phpBB © 2001, 2005 phpBB Group