1 /* Licensed to the public under the Apache License 2.0. */
6 return baseclass.extend({
9 rrdargs: function(graph, host, plugin, plugin_instance, dtype) {
10 var inst = plugin_instance.replace(/^openvpn\.(.+)\.status$/, '$1');
11 const types = graph.dataTypes(host, plugin, plugin_instance);
14 const typeinstances = graph.dataInstances(host, plugin, plugin_instance, "if_octets").sort();
16 function find_instances(dtype, wanted) {
17 const matching = graph.dataInstances(host, plugin, plugin_instance, dtype).filter(function(instance) {
18 return wanted.indexOf(instance) > -1;
20 return matching.length ? { [dtype]: matching } : null;
23 if ((instances = find_instances('if_octets', ['overhead', 'traffic'])) !== null) {
25 title: "%%H: OpenVPN \"%s\" - Traffic".format(inst),
29 if_octets: [ "traffic", "overhead" ]
32 if_octets: [ "tx", "rx" ]
35 if_octets_traffic_tx : { weight: 0, title: "Bytes (TX)", total: true, color: "00ff00" },
36 if_octets_overhead_tx: { weight: 1, title: "Overhead (TX)", total: true, color: "ff9900" },
37 if_octets_overhead_rx: { weight: 2, title: "Overhead (RX)", total: true, flip: true, color: "ff00ff" },
38 if_octets_traffic_rx : { weight: 3, title: "Bytes (RX)", total: true, flip: true, color: "0000ff" }
43 for (const tinstance of typeinstances) {
44 const rx = "if_octets_%s_rx".format(tinstance);
45 const tx = "if_octets_%s_tx".format(tinstance);
47 opts[tx] = { weight: 0, title: "Bytes " + tinstance + " (TX)", total: true, color: "00ff00" };
48 opts[rx] = { weight: 1, title: "Bytes " + tinstance + " (RX)", total: true, flip: true, color: "0000ff" };
51 title: "%%H: OpenVPN Server \"%s\" - User Traffic - ".format(inst) + tinstance,
55 if_octets: [ tinstance ]
58 if_octets: [ "tx", "rx" ]
66 if (types.indexOf('users') > -1) {
67 let optionUsers = `users_${plugin_instance}`;
69 optsUsers[optionUsers] = { title: "Total users connected", color: "00ff00" };
70 let userInstances = graph.dataInstances(host, plugin, plugin_instance, 'users');
71 if (userInstances.length > 0) {
73 title: `%H: OpenVPN Server "${inst}" - Connected Users`,
76 alt_autoscale_max: true,
77 number_format: "%3.0lf",
86 console.error('Source "value" not found in any user instances:', sources);
90 if (types.indexOf('compression') > -1) {
92 title: "%%H: OpenVPN \"%s\" - Compression".format(inst),
96 compression: [ "data_out", "data_in" ]
99 compression: [ "uncompressed", "compressed" ]
102 compression_data_out_uncompressed: { weight: 0, title: "Uncompressed (TX)", total: true, color: "00ff00" },
103 compression_data_out_compressed : { weight: 1, title: "Compressed (TX)", total: true, color: "008800" },
104 compression_data_in_compressed : { weight: 2, title: "Compressed (RX)", total: true, flip: true, color: "000088" },
105 compression_data_in_uncompressed : { weight: 3, title: "Uncompressed (RX)", total: true, flip: true, color: "0000ff" }