jamey wrote:I have added an if statement that should be doing this by changing the name of the icon it is loading around line 910 of Weathermap.class.php. Note I have also added a hostname (hostn) option to the config so that I can lookup the status of that host in the cacti database on the fly.
Personally, I'd do this by using the hostid as the nodename (something like host32), and save having another parameter. Less parameters means less ReadConfig, less WriteConfig, less editor and less weird little special cases.
jamey wrote:
I've ran some debug, and the if seems to be working correctly, and switching the image path according to what is set in the config, however, the regular up image always displays.
if (in_array($this->hostn,$downhost)){
$temp_im=imagecreatefrompng($this->downiconfile);
} else {
$temp_im=imagecreatefrompng($this->iconfile);
};
That looks like it should work, assuming that downiconfile is set correctly, and the scope of $downhost makes it visible...
There's a --dumpafter option for the command-line script that dumps the whole of the Weathermap object after the config is read, so you can see for sure about that part. You could also add some tracing to see what's going on for sure - the debug() function logs to stderr for cli weathermap, or Cacti's debug log for the cacti plugin.
Finally, if you are using different sized icons, things will go wrong with link offsets, unless you change calc_size() around line 710 or so, too. See what I mean about the little special cases?
That particular issue will go away in 0.9, which draws nodes in a different way, to make the editor able to share code and do drag&drop editing.