|
|
| Author |
Message |
john123
Joined: 08 May 2008 Posts: 1
|
Posted: Thu May 08, 2008 10:00 am Post subject: HELP changing icon with the current time |
|
|
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: 1969 Location: United Kingdom
|
Posted: Thu May 08, 2008 1:40 pm Post subject: |
|
|
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 |
|
 |
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|