Problem weathermap lines with plugin check_centreon_snmp_traffic

(Maxime) #1

I have a problem with my weathermap lines on Nagvis 1.9.11 running with Centreon 18.10.2. My lines represents a service that monitors the bandwidth of links, the problem is that the line style --%–><–%-- and the style --BW–><–BW-- are reversed and my lines do not change color based on the percentage of bandwidth used, I think it’s related to this inversion problem.

Here is a preview of the result when I chose the type of lines --%+BW-><-BW+%-- (the percentage should be at the top and the bandwidth should not be bitwise) :

And here is the result I would like to get :

I also have the following error that randomly appears (I translate it to the fact that since the bit data is reversed with the percentage, Nagvis has no percentage value and so I think it does not take the data in the right place) :

I think that there are things to modify either in the Javascript files or in the return of perfdata but I have no knowledge in programming …


Modify object -> Tab “Label”, enable “label_show” and setting it to “no” should remove the label.

ElementLine.js should be the file to change to exchange the performance data.

(Maxime) #3

Thanks for your reply. Why do you want to remove the label ?
I want to have percentage and bandwidth display.

Yes I also think it’s in the ElementLine.js file, I’ve seen lines of code that correspond to the Weathermap lines but I have no knowledge of Javascript and it’s very difficult to edit such a file…


“Bande passante” isn’t shown in the “And here is the result I would like to get :” Image ;-).

(Maxime) #6

Oh ok, that was not a problem !
I’ve removed it since, in what I would like to get only the color change according to the percentage and the display of values ​​interest me :slight_smile:


Edit .../share/server/core/mapcfg/default.php and try to change the contents of 13, 14 and 15:

function listLineTypes() {
    return Array(
        '10' => '-------><-------',
        '11' => '--------------->',
        '12' => '----------------',
        '13' => '---%---><---%---',
        '14' => '--%+BW-><-%+BW--',
        '15' => '---BW--><--BW---',
(Maxime) #8

Thanks for your help, it was well tried but it only changes the position of the lines in modify object/apppearance/line-type, my problem is that it is not the good information returned, when I chose the type of line -%-><-%- the label displayed is the bandwidth in bit and when I chose the type of line -BW-><-BW- the label displayed is the percentage used … What I really want is for my link to change color according to the percentage and I think it comes from there!

Look what I have on Nagvis, the top line should be purple and the bottom blue, but all my lines are blue regardless of the percentage …


It seems to depends on the format of the value:

    // Check_MK if/if64 checks support switching between bytes/bits. The detection
    // can be made by some curios hack. The most hackish hack I've ever seen. From hell.
    // Well, let's deal with it.
    var display_bits = false;
    if(oldPerfdata.length >= 11 && oldPerfdata[10][5] == '0.0')
        display_bits = true;
(Maxime) #10

I’m not sure I understand, do you think it’s related to these lines of code? The error message I have is (Weathermap line error: Value 0 is not a percentage value. Weathermap line error: Value 1 is not a percentage value.) As if it were taking the value in bit instead of the value in percentage to return the correct color.

This error message corresponds to the following lines of code :

calcWeathermapColor: function(id) {
   if (this.obj.conf.summary_state == "ERROR")
       return oStates["ERROR"].color;

   if (!this.perfdata)
      return '#FFCC66';

   if (this.perfdata[id][2] == '%' && this.perfdata[id][1] !== null) {
       return this.getColorFill(this.perfdata[id][1]);
   } else {
       this.obj.conf.summary_output += ' (Weathermap Line Error: Value '
                                       + id +' is not a percentage value)';
       return oStates["ERROR"].color;

Depending on the format of your performance data values the unit seems to be selected as “Mb” or “MB”.

So far I have no idea what the performance data might look like (you showed the output).

(Maxime) #12

Oh ok, but I dont think that’s the problem?

That’s right, sorry! Here is the perfdata I get with the check_centreon_snmp_traffic command :

./check_centreon_snmp_traffic -H 172.x.x.10 -v 2c -i 1 -T 100 --64-bits

Traffic In : 4.58 Mb/s (4.6 %), Out : 28.45 Mb/s (28.5 %) |traffic_in=4581712,0Bits/s;80000000;95000000;0;100000000 traffic_out=28451917,3Bits/s;80000000;95000000;0;100000000 load_In=4.6%;80000000;95000000;0;0 load_Out=28.5%;80000000;95000000;0;0 traffic_In=4.58Mb;80000000;95000000;0;0 traffic_Out=28.45Mb;80000000;95000000;0;0

These are the data that Nagvis uses !


One problem might be that your language settings provide data with a decimal comma ("28451917,3") instead of a decimal point so the above detection of Bytes/bits fails.

(Maxime) #14

Yes I see, it’s true that it’s a possibility, what should I change to have a result that gives the data a decimal point ?


One solution is to write a wrapper script like this:

unset LANG

another might be to prepend the plugin with the unset

unset LANG; .../your/plugin/call

(Maxime) #16

The result when i add the unset before my command :

unset LANG; ./check_centreon_snmp_traffic -H 172.x.x.10 -v 2c -i 1 -T 100 --64-bits

Traffic In : 8.17 Mb/s (8.2 %), Out : 9.40 Mb/s (9.4 %) |traffic_in=8166355,8Bit >s/s;80000000;95000000;0;100000000 traffic_out=9402644,4Bits/s;80000000;95000000; >0;100000000 load_In=8.2%;80000000;95000000;0;0 load_Out=9.4%;80000000;95000000;0 >;0 traffic_In=8.17Mb;80000000;95000000;0;0 traffic_Out=9.40Mb;80000000;95000000; >0;0

No change, but I’m not sure how to use the unset :confused:

(Maxime) #17

It’s good, I change the plugin so that it is a point instead of a “,”. It was not a language problem! Now I have the unit in Bits that appears in my label but it’s the only thing that has changed!

Look at the result :

It’s still better but not what I want. Your help is precious to me !


Well, to be honest “Bits/s” is not a valid unit. If you can change “Bits/s” to “Mb”…

(Maxime) #19

Yes but the problem is Nagvis does not return the good value of the perfdata it is not even the Bits / s which is displayed but only Bits. If Nagvis gets the good perfdata value that matches Traffic In and Traffic Out, we would get the following result
LigneWM_Nagvis1_7_10 :

The unit adjusts itself, it is the plugins that manages it and returns it in the variables Traffic In and Traffic Out at the output of the command check_centreon_snmp_traffic :

Traffic In : 23.75 Mb/s (23.8 %), Out : 35.10 Mb/s (35.1 %) |traffic_in=23752568.0Bits/s;80000000;95000000;0;100000000 traffic_out=35100325.0Bits/s;80000000;95000000;0;100000000 load_In=23.8%;80000000;95000000;0;0 load_Out=35.1%;80000000;95000000;0;0 traffic_In=23.75Mb;80000000;95000000;0;0 traffic_Out=35.10Mb;80000000;95000000;0;0


Well, it is the plugin which is not delivering a correct UOM. I’d change the line as follows:

printf("|traffic_in=".$in_perfparse_traffic_str."b;$warningBit;$criticalBit;0;$speed_card traffic_out=".$out_perfparse_traffic_str."b;$warningBit;$criticalBit;0;$speed_card\n");

The following lines are the reason why unsetting LANG doesn’t change anything

$in_perfparse_traffic_str =~ s/\./,/g;
$out_perfparse_traffic_str =~ s/\./,/g;

I dislike such things…

(Maxime) #21

Yes, indeed I think we can succeed to have a conclusive result by modifying the plugin to have a perfdata that Nagvis will interpret correctly. The question is in what way? I modified my plugin as you advise me by changing my second printf but now my Nagvis lines are orange and I have an error message (Value 3 is empty). There must be something missing.

printf(“Traffic In : %.2f “.$in_prefix.“b/s (”.$in_usage.” %%), Out : %.2f “.$out_prefix.“b/s (”.$out_usage.” %%) “, $in_traffic, $out_traffic);
if ($opt_S) {
printf(” - Link Speed : %d”, $speed_card);
printf("|traffic_in=".$in_perfparse_traffic_str.“b;$warningBit;$criticalBit;0;$speed_card traffic_out=”.$out_perfparse_traffic_str.“b;$warningBit;$criticalBit;0;$speed_card\n”);

Here is the current return of my plugin:

Traffic In : 15.61 Mb/s (15.6 %), Out : 3.44 Mb/s (3.4 %) |traffic_in=15607556.6b;80000000;95000000;0;100000000 traffic_out=3436225.1b;80000000;95000000;0;100000000

Indeed these are the lines that I modified to get a point !