+function value_to_string (value) /* {{{ */
+{
+ var abs_value;
+ var v2s = function (value)
+ {
+ var tmp = Math.round (100.0 * value) / 100.0;
+ return ("" + tmp);
+ }
+
+ if (value == null)
+ return ('NaN');
+ else if (value == 0)
+ return ('0');
+
+ abs_value = Math.abs (value);
+
+ if ((abs_value < 10000) && (abs_value >= 0.1))
+ return (v2s (value));
+ else if (abs_value > 1)
+ {
+ if (abs_value < 10000000)
+ return (v2s (value / 1000) + "k");
+ else if (abs_value < 10000000000)
+ return (v2s (value / 1000000) + "M");
+ else if (abs_value < 10000000000000)
+ return (v2s (value / 1000000000) + "G");
+ else
+ return (v2s (value / 1000000000000) + "T");
+ }
+ else
+ {
+ if (abs_value >= 0.001)
+ return (v2s (value * 1000) + "m");
+ else if (abs_value >= 0.000001)
+ return (v2s (value * 1000000) + "u");
+ else
+ return (v2s (value * 1000000000) + "n");
+ }
+} /* }}} function value_to_string */
+
+function instance_get_params (inst) /* {{{ */
+{
+ var graph_selector = inst.graph_selector;
+ var inst_selector = inst.instance_selector;
+ var selector = {};
+
+ if (graph_selector.host == inst_selector.host)
+ {
+ selector.host = graph_selector.host;
+ }
+ else
+ {
+ selector.graph_host = graph_selector.host;
+ selector.inst_host = inst_selector.host;
+ }
+
+ if (graph_selector.plugin == inst_selector.plugin)
+ {
+ selector.plugin = graph_selector.plugin;
+ }
+ else
+ {
+ selector.graph_plugin = graph_selector.plugin;
+ selector.inst_plugin = inst_selector.plugin;
+ }
+
+ if (graph_selector.plugin_instance == inst_selector.plugin_instance)
+ {
+ selector.plugin_instance = graph_selector.plugin_instance;
+ }
+ else
+ {
+ selector.graph_plugin_instance = graph_selector.plugin_instance;
+ selector.inst_plugin_instance = inst_selector.plugin_instance;
+ }
+
+ if (graph_selector.type == inst_selector.type)
+ {
+ selector.type = graph_selector.type;
+ }
+ else
+ {
+ selector.graph_type = graph_selector.type;
+ selector.inst_type = inst_selector.type;
+ }
+
+ if (graph_selector.type_instance == inst_selector.type_instance)
+ {
+ selector.type_instance = graph_selector.type_instance;
+ }
+ else
+ {
+ selector.graph_type_instance = graph_selector.type_instance;
+ selector.inst_type_instance = inst_selector.type_instance;
+ }
+
+ return (selector);
+} /* }}} instance_get_params */
+
+function ident_clone (ident) /* {{{ */
+{
+ var ret = {};
+
+ ret.host = ident.host;
+ ret.plugin = ident.plugin;
+ ret.plugin_instance = ident.plugin_instance;
+ ret.type = ident.type;
+ ret.type_instance = ident.type_instance;
+
+ return (ret);
+} /* }}} ident_clone */
+
+function inst_get_defs (inst) /* {{{ */