Luci-Statistics / collectd-ping definition

I'm facing a problem with the collectd-mod-ping as the defintion file has been moved and changed at some point in the development.

Build: OpenWrt SNAPSHOT r12394-1d4f2ca610 / LuCI Master git-20.061.59543-0d68d0a
collectd-mod-ping: 5.10.0-3
luci-app-statistics: git-20.061.59543-0d68d0a-1

I'm trying to monitor some hosts in seperate instances and put the hostnames/IP's as title.
In the past I was able to achieve this with the following config: Collectd ping plugin, adding a min ping statistic possible? but for some reason the definition file isn't stored under /usr/lib/lua/luci/statistics/rrdtool/definitions/ping.lua anymore, instead it's at /www/luci-static/resources/statistics/rrdtool/definitions/ping.js and the style of the defintion has been changed.

'use strict';return L.Class.extend({title:_('Ping'),rrdargs:function(graph,host,plugin,plugin_instance,dtype){var ping={title:"%H: ICMP Round Trip Time",vlabel:"ms",number_format:"%5.1lf ms",data:{sources:{ping:["value"]},options:{ping__value:{noarea:true,overlay:true,title:"%di"}}}};var droprate={title:"%H: ICMP Drop Rate",vlabel:"%",number_format:"%5.2lf %%",data:{types:["ping_droprate"],options:{ping_droprate:{noarea:true,overlay:true,title:"%di",transform_rpn:"100,*"}}}};var stddev={title:"%H: ICMP Standard Deviation",vlabel:"ms",number_format:"%5.1lf ms",data:{types:["ping_stddev"],options:{ping_stddev:{noarea:true,overlay:true,title:"%di"}}}};return[ping,droprate,stddev];}});

So my goal is to implement the following into the new definition file:

{ per_instance=true,
		  title = "%pi %di: ICMP Round Trip Time",

Replacing ping={title:"%H: ICMP Round Trip Time" with ping={title = "%pi %di: ICMP Round Trip Time" works fine but I haven't figured out where I need to place per_instance=true at the new definition file. I've tried to add it at the correct place but it made luci-statistik fail and I had to revert to the default config.
Last try: {var ping={per_instance=true,title:"%pi %di: ICMP Round Trip Time"....

It would be great if someone can give me a helping hand as I couldn't find anything in several search engines about it.

1 Like

The following definition seems works fine: {var ping={per_instance:true,title:"%pi %di: ICMP Round Trip Time",vlabel:"ms",number_format:"%5.1lf ms",data:{sources:{ping:["value"]},options:{ping__value:{noarea:true,overlay:true,title:"%di"}}}}
but with this config there are two small blank pictures under my second and third host graph. This only happens when adding more than one hosts. Also the hosts aren't in correct order and I have no idea why:


Any idea how to fix this? I would also like to just monitor "ICMP RTT" and I don't need a graph for "ICMP Drop rate" and "ICMP Standard Deviation" but I have no idea where to cut the definition. Any help is much appreciated...

As my ping.js defintion was somehow messed up and everyhing was just a single straight line of text I went ahead and replaced the definition with the following one to get at least a decent overlook of the definition: https://github.com/openwrt/luci/commit/9680fdea9e2e38bfafe0d97967925dd9fc836a05#diff-9f46c4eeb4014b62c7e89d12e95179a8
But that didn't solve my problem with those two small blank pictures under every host (per_instance: true).

The next thing that I've tried was to only show the RTT per host/instance so I went ahead and replaced the default definition with the following one:

'use strict';

return L.Class.extend({
	title: _('Ping'),

	rrdargs: function(graph, host, plugin, plugin_instance, dtype) {
		var ping = { per_instance: true,
			title: "%pi %di: ICMP Round Trip Time",
			vlabel: "ms",
			number_format: "%5.1lf ms",
			data: {
				sources: {
					ping: [ "value" ]
				},
				options: {
					ping__value: {
						noarea: true,
						overlay: true,
						title: "%di"
					}
				}
			}
		};

		return [ ping ];
	}
});

....followed by rm -rf /tmp/luci-indexcache /tmp/luci-modulecache/ + /etc/init.d/luci_statistics restart and for some reason the small blank pictures disappeared. But they are visible again If I add "ICMP Drop Rate + Standard Deviation" to the definition.

Here is my current definition where under the every but not the first host on the list two small blank pictures appearing:

'use strict';

return L.Class.extend({
	title: _('Ping'),

	rrdargs: function(graph, host, plugin, plugin_instance, dtype) {
		var ping = { per_instance: true,
			title: "%pi %di: ICMP Round Trip Time",
			vlabel: "ms",
			number_format: "%5.1lf ms",
			data: {
				sources: {
					ping: [ "value" ]
				},
				options: {
					ping__value: {
						noarea: true,
						overlay: true,
						title: "%di"
					}
				}
			}
		};

var droprate = {
			title: "ICMP Drop Rate",
			vlabel: "%",
			number_format: "%5.2lf %%",
			data: {
				types: [ "ping_droprate" ],
				options: {
					ping_droprate: {
						noarea: true,
						overlay: true,
						title: "%di",
						transform_rpn: "100,*"
					}
				}
			}
		};

		var stddev = {
			title: "ICMP Standard Deviation",
			vlabel: "ms",
			number_format: "%5.1lf ms",
			data: {
				types: [ "ping_stddev" ],
				options: {
					ping_stddev: {
						noarea: true,
						overlay: true,
						title: "%di"
					}
				}
			}
		};

		return [ ping, droprate, stddev ];
	}
});

Any idea how to solve this problem? @hnyman maybe?

Hi, thank for the new definition file location. BTW, have you solve the problem?
I mange to solve it by this line of code.

'use strict';return L.Class.extend({title:_('Ping'),rrdargs:function(graph,host,plugin,plugin_instance,dtype){var ping={title:"%di: ICMP Round Trip Time",vlabel:"ms",number_format:"%5.1lf ms",data:{sources:{ping:["value"]},options:{ping__value:{noarea:true,overlay:true,title:"%di"}}}};return[ping];}});