Time Zones & Localtime
Moderators: Developers, Moderators
Time Zones & Localtime
I'm still stunned at how cool Weathermap is.
I've got a map of nodes around the world broken down by timezone bands.
Is there a method via Weathermap that would allow me to assign a timestamp or timezone to a node and have it adjust for localtime?
For instance, It's now 1332 GMT. I would like to get GMT-8, GMT-5, GMT, GMT+7 printed out on 4 different nodes,
Node 1
0532
Node2
0832
Node3
1332
Node4
2032
and have the times update at each redraw of the PNG.
Any ideas?
Thanks!
I've got a map of nodes around the world broken down by timezone bands.
Is there a method via Weathermap that would allow me to assign a timestamp or timezone to a node and have it adjust for localtime?
For instance, It's now 1332 GMT. I would like to get GMT-8, GMT-5, GMT, GMT+7 printed out on 4 different nodes,
Node 1
0532
Node2
0832
Node3
1332
Node4
2032
and have the times update at each redraw of the PNG.
Any ideas?
Thanks!
- Howie
- Cacti Guru User
- Posts: 5508
- Joined: Thu Sep 16, 2004 5:53 am
- Location: United Kingdom
- Contact:
There's isn't even a method to get the current time, so no, not really.
You could write a datasource plugin to do it.
OR
You could write a shell script that produces a tab-separated file and then use that as a datasource:
And then make sure the nodes are named for the first part of each line of the tsv file:
You need the %04d because weathermap expects numbers and it will chop the leading zeros normally. This ALSO means you can't format the time at all - it must be 4 digits like that.
You could write a datasource plugin to do it.
OR
You could write a shell script that produces a tab-separated file and then use that as a datasource:
Code: Select all
#!/bin/sh
cat /dev/null > times.txt
TZ="Europe/London" date +"london:%H%M:%H%M" >> times.txt
TZ="Europe/Paris" date +"paris:%H%M:%H%M" >> times.txt
TZ="Japan" date +"tokyo:%H%M:%H%M" >> times.txt
TZ="US/Eastern" date +"newyork:%H%M:%H%M" >> times.txt
# couldn't figure out how to get date to produce tabs, so this is a bodge
tr ":" "\\t" < times.txt > times.tsv
Code: Select all
NODE newyork
TARGET times.tsv
LABEL {node:this:bandwidth_in:%04d}
POSITION 100 100
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!)
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!)
Closer?
Howie,
Thanks for the pointers. I think I'm getting closer.
This is what I have in the .conf file:
And the configs/times.tsv file looks like this:
And when I run the weathermap manually, I get a rather strange error.
Thanks for the pointers. I think I'm getting closer.
This is what I have in the .conf file:
Code: Select all
NODE EST
TARGET configs/times.tsv
LABEL {node:this:bandwidth_in:%04d}
POSITION 490 50
ICON configs/clock-10-10_33484_th.gif
NODE GMT
TARGET configs/times.tsv
LABEL {node:this:bandwidth_in:%04d}
POSITION 650 50
ICON configs/clock-10-10_33484_th.gif
Code: Select all
GMT 2201 2201
CET 2301 2301
HKT 2201 2201
EST 1701 1701
CST 1601 1601
PST 1401 1401
Code: Select all
$ /usr/bin/php ./weathermap --config /data/apache/secure/htdocs/cacti/plugins/weathermap/configs/World_map.conf --output /data/apache/secure/htdocs/cacti/weathermaps/World_map.conf.png --htmloutput /data/apache/secure/htdocs/cacti/weathermaps/World_map.conf.html
WARNING: /data/apache/secure/htdocs/cacti/plugins/weathermap/configs/World_map.conf: NewColourFromPercent: Clipped 1701% to 100% for item EST
WARNING: /data/apache/secure/htdocs/cacti/plugins/weathermap/configs/World_map.conf: NewColourFromPercent: Clipped 1701% to 100% for item EST
WARNING: /data/apache/secure/htdocs/cacti/plugins/weathermap/configs/World_map.conf: NewColourFromPercent: Clipped 2201% to 100% for item GMT
WARNING: /data/apache/secure/htdocs/cacti/plugins/weathermap/configs/World_map.conf: NewColourFromPercent: Clipped 2201% to 100% for item GMT
Content-type: text/html
X-Powered-By: PHP/4.3.9
and the result is a solid black rectangle where the 4 digit time zone should be.
Weathermap is trying to use the 4 digit integer as an RGB color indicator it would appear.
I've never seen an error like this before, have you?
I'm running the current cacti and current weathermap code (0.96a).
Thanks!
- Howie
- Cacti Guru User
- Posts: 5508
- Joined: Thu Sep 16, 2004 5:53 am
- Location: United Kingdom
- Contact:
no, it's not using it as RGB, it's using it as a value, then calculating a percentage, and using that to colour.
So the default maxvalue for a node is 100. 2333/100 is much more than 100%. (so you get the 'clipped' message).
You probably don't want the nodes to change colour, so you should add:
MAXVALUE 2500
USESCALE none in
to each node. The MAXVALUE means that the resulting percentage is below 100%, and the USESCALE says to not colour the node.
So the default maxvalue for a node is 100. 2333/100 is much more than 100%. (so you get the 'clipped' message).
You probably don't want the nodes to change colour, so you should add:
MAXVALUE 2500
USESCALE none in
to each node. The MAXVALUE means that the resulting percentage is below 100%, and the USESCALE says to not colour the node.
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!)
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!)
- Howie
- Cacti Guru User
- Posts: 5508
- Joined: Thu Sep 16, 2004 5:53 am
- Location: United Kingdom
- Contact:
And this morning while I was fixing a couple of bugs, I found that I had already written a time DS plugin, and that it was in 0.96a too! I must have forgotten about it and failed to document it
Try this:
The DS plugin always returns 0 for in and out values, but it sets 3 extra variables:
time_time12 (12 hour format)
time_time12ap (12 hour format with AM/PM)
time_time24 (24 hour format)
No need for tab-separated files, OR a shell script.
How embarrassing!
(It REQUIRES php 5 or newer, to get the timezone info)
Try this:
Code: Select all
NODE node2
POSITION 500 200
TARGET time:Europe/London
LABEL {node:this:time_time12ap}
USESCALE none
time_time12 (12 hour format)
time_time12ap (12 hour format with AM/PM)
time_time24 (24 hour format)
No need for tab-separated files, OR a shell script.
How embarrassing!
(It REQUIRES php 5 or newer, to get the timezone info)
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!)
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!)
Actually, I think it requires 5.2.x or newer to get it by default, according to this page http://us2.php.net/manual/en/datetime.installation.phpHowie wrote: (It REQUIRES php 5 or newer, to get the timezone info)
Since I'm trying to use the OS provided PHP in RHEL5.3, I've got 5.1.6 to work with and it complains that there is "Class 'DateTimeZone' not found"Note: Experimental DateTime support in PHP 5.1.x
Although the DateTime class (and related functions) are enabled by default since PHP 5.2.0, it is possible to add experimental support into PHP 5.1.x by using the following flag before configure/compile: CFLAGS=-DEXPERIMENTAL_DATE_SUPPORT=1
I'm not a PHP guru, I don't even play one on TV. Correct as necessary. Now to upgrade PHP.
Thanks Howie!
- Howie
- Cacti Guru User
- Posts: 5508
- Joined: Thu Sep 16, 2004 5:53 am
- Location: United Kingdom
- Contact:
Sounds about right to me (and in fact my CentOS 5.2 box complains too with PHP 5.1.6). I'll update the docs.
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!)
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!)
Who is online
Users browsing this forum: No registered users and 0 guests