Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible a problem in evaluation logic #8

Closed
Bjoern-10101 opened this issue Aug 12, 2019 · 3 comments
Closed

Possible a problem in evaluation logic #8

Bjoern-10101 opened this issue Aug 12, 2019 · 3 comments

Comments

@Bjoern-10101
Copy link

Bjoern-10101 commented Aug 12, 2019

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

SuperPlusUser added a commit to SuperPlusUser/check_interfaces that referenced this issue Dec 2, 2019
- Change overall status to "warning" if an interface exceeds bandwidth limit (see NETWAYS#8 thanks to Bjoern-10101 )
- Do not show (incorrect) performance data for Interfaces which are admin down
- Correct output for down interfaces if crit_on_down_flag is not true
@SuperPlusUser
Copy link
Contributor

I think this should now be fixed after #9 is merged with the changes mentioned above.

@martialblog
Copy link
Member

Fixes in #9

@martialblog
Copy link
Member

@SuperPlusUser Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants