Skip to content

Possible a problem in evaluation logic #8

@Bjoern-10101

Description

@Bjoern-10101

Hi,

I have started to use check_interfaces and found a possible problem with the evaluation logic.
When I use the bandwith parameter the checkresult will show a warning in the second line of the output if the threshold is reached. However the overall status will still show ok.
I described the probelm at the Icinga2 community page, because I was not sure that the observed behaviour was wanted. https://community.icinga.com/t/question-about-plugin-output-and-the-service-status/1918/6

Michael Friedrich answered my questions and directed me to github to file an issue.

I have looked at the sourcecode of snmp_bulkget.c and found at line 1031 a possible fix for the problem.
Here is the original code:

if (lastcheck && (interfaces[i].speed || speed)) {
        inbitps = (subtract64(interfaces[i].inOctets, oldperfdata[i].inOctets) / (u64)lastcheck) * 8ULL;
        outbitps = (subtract64(interfaces[i].outOctets, oldperfdata[i].outOctets) / (u64)lastcheck) * 8ULL;
        if (speed) {
            inload = (long double)inbitps / ((long double)speed/100L);
            outload = (long double)outbitps / ((long double)speed/100L);
        } else {
            /* use the interface speed if a speed is not given */
            inload = (long double)inbitps / ((long double)interfaces[i].speed/100L);
            outload = (long double)outbitps / ((long double)interfaces[i].speed/100L);
        }
        if ( (bw > 0) && ((int)inload > bw || (int)outload > bw))
            warn++;
    }

I've changed it to the following:

if (lastcheck && (interfaces[i].speed || speed)) {
            inbitps = (subtract64(interfaces[i].inOctets, oldperfdata[i].inOctets) / (u64)lastcheck) * 8ULL;
            outbitps = (subtract64(interfaces[i].outOctets, oldperfdata[i].outOctets) / (u64)lastcheck) * 8ULL;
            if (speed) {
                inload = (long double)inbitps / ((long double)speed/100L);
                outload = (long double)outbitps / ((long double)speed/100L);
            } else {
                /* use the interface speed if a speed is not given */
                inload = (long double)inbitps / ((long double)interfaces[i].speed/100L);
                outload = (long double)outbitps / ((long double)interfaces[i].speed/100L);
            }

            if ( (bw > 0) && ((int)inload > bw || (int)outload > bw)) {
                warnflag++;
                warn++;
            }
        }

I’ve extended the last if clause with “warnflag++” and put it in curly braces.

I hope that this is usefull. This is my very first post at github and I am a little bit scared (I am not a programmer at all :-) )

Kind regards
Bjoern

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions