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

F5 Velos memory not working V11.2.4 #338

Open
rajav2 opened this issue Oct 9, 2024 · 10 comments
Open

F5 Velos memory not working V11.2.4 #338

rajav2 opened this issue Oct 9, 2024 · 10 comments

Comments

@rajav2
Copy link

rajav2 commented Oct 9, 2024

This is F5 Velos device. Can you advise why this error is coming out?
First error I suppose it is due to not supported device but second error is new.

[nagios@MYUCBPNAGIAPP01 libexec]$ ./check_nwc_health --hostname 10.106.20.182 --timeout=50 --community test--mode memory-usage --warning 70 --critical 85 : Use of uninitialized value $mem_available in multiplication (*) at ./check_nwc_health line 90286.
Use of uninitialized value in division (/) at ./check_nwc_health line 90286.
Illegal division by zero at ./check_nwc_health line 90286.

If I rename the plugin, I get this error. Previous versions did not have this issue.
[nagios@MYUCBPNAGIAPP01 libexec]$ ./check_nwc_health.1124 --hostname 10.106.20.182 --timeout=50 --community test--mode memory-usage --warning 70 --critical 85 :
Can't locate object method "run_plugin" via package "CheckNwcHealth.1124" (perhaps you forgot to load "CheckNwcHealth.1124"?) at ./check_nwc_health.1124 line 99134.

Copy link

codeautopilot bot commented Oct 9, 2024

Potential solution

To solve the bug, we need to address the issues related to uninitialized values, incorrect SNMP OIDs, and module loading errors. The plan involves verifying and updating SNMP OIDs for compatibility with F5 Velos devices, initializing memory-related variables, and ensuring proper module loading and naming conventions. Additionally, we should implement error handling to manage unexpected values and improve documentation for naming requirements.

What is causing this bug?

  1. Uninitialized Values: The error messages indicate that variables like $mem_available are being used without proper initialization. This is likely due to SNMP OIDs not returning valid data, especially if they are not compatible with F5 Velos devices.

  2. Division by Zero: This occurs when the total memory values (sysStatMemoryTotal or sysHostMemoryTotal) are zero or undefined, leading to illegal division operations.

  3. Compatibility Issues: The SNMP OIDs used in the script might not be supported by F5 Velos devices, resulting in undefined values.

  4. Module Loading Errors: The error related to the run_plugin method suggests issues with module loading or naming conventions, especially when the plugin is renamed.

Code

Here are the implementation details and code snippets to address the issues:

  1. Verify and Update SNMP OIDs:

    • Check the SNMP OIDs used in MemSubsystem.pm and update them to ensure compatibility with F5 Velos devices.
  2. Initialize Memory Variables:

    # Ensure memory variables are initialized
    my $mem_available = 0;
    my $mem_total = 0;
  3. Add Error Handling:

    # Check for undefined or zero values before calculations
    if (defined $mem_total && $mem_total > 0) {
        my $mem_usage = ($mem_available / $mem_total) * 100;
    } else {
        warn "Memory total is undefined or zero, skipping calculation.";
    }
  4. Ensure Proper Module Loading:

    • Verify that all necessary modules are loaded and accessible. Check for naming conventions and ensure they match expected values.
  5. Documentation:

    • Update documentation to clarify naming or path requirements for the plugin.

How to replicate the bug

  1. Run the check_nwc_health script with the specified parameters on an F5 Velos device.
  2. Observe the error messages related to uninitialized values and division by zero.
  3. Rename the plugin and attempt to run it again to see the module loading error.

By following these steps, you should be able to replicate the bug and verify the effectiveness of the proposed solution.

Click here to create a Pull Request with the proposed solution

Files used for this task:

Changes on plugins-scripts/CheckNwcHealth/F5/F5BIGIP/Component/MemSubsystem.pm

Based on the provided code and the issue description, here are some observations and potential causes for the bug:

  1. Uninitialized Values: The error message indicates that there is an "uninitialized value" being used in a multiplication and division operation. This suggests that one or more of the SNMP OIDs (sysStatMemoryTotal, sysStatMemoryUsed, sysHostMemoryTotal, sysHostMemoryUsed) might not be returning valid data, leading to undefined values in the calculations for stat_mem_usage and host_mem_usage.

  2. Division by Zero: The error "Illegal division by zero" indicates that the denominator in the division operation is zero. This could happen if sysStatMemoryTotal or sysHostMemoryTotal is zero or undefined.

  3. Compatibility with F5 Velos: The code might not be compatible with F5 Velos devices if the SNMP OIDs used are not supported or have different identifiers for these devices. This would result in the SNMP queries returning undefined values.

  4. Error Handling: There is no error handling for cases where the SNMP OIDs return undefined or zero values. Adding checks to ensure that these values are valid before performing arithmetic operations would prevent such runtime errors.

Recommendations:

  • Verify SNMP OIDs: Check if the SNMP OIDs used (sysStatMemoryTotal, sysStatMemoryUsed, sysHostMemoryTotal, sysHostMemoryUsed) are correct and supported by F5 Velos devices. If not, update them to the correct OIDs.

  • Initialize Values: Ensure that the values retrieved from SNMP are initialized and valid before performing calculations. Add checks to handle cases where these values are undefined or zero.

  • Add Error Handling: Implement error handling to manage cases where SNMP data retrieval fails or returns unexpected values. This could include logging warnings and skipping calculations when data is not available.

  • Testing: Test the updated code with an F5 Velos device to ensure compatibility and correct functionality.

By addressing these points, the plugin should be able to handle memory usage checks on F5 Velos devices without encountering uninitialized value errors or division by zero issues.

Changes on plugins-scripts/check_nwc_health.pl

Analysis of check_nwc_health.pl

Potential Causes of the Bug:

  1. Uninitialized Memory Values:

    • The error message indicates that there is an uninitialized value $mem_available being used in a multiplication operation. This suggests that the memory usage values are not being correctly initialized before they are used in calculations.
    • The script should ensure that all memory-related variables are properly initialized and checked for undefined values before performing operations on them.
  2. Device Type Identification:

    • The script needs to correctly identify and initialize the F5 Velos device type. If the device type is not correctly identified, the script might not be using the correct SNMP OIDs or logic specific to F5 Velos devices, leading to uninitialized values.
    • Ensure that the device classification logic includes support for F5 Velos devices.
  3. Module Loading:

    • The error message about not being able to locate the run_plugin method suggests that there might be an issue with module loading or naming conventions.
    • Verify that all necessary modules are loaded and that the naming conventions used in the script match those expected by the modules.
  4. Renaming Plugin Issue:

    • The error encountered when renaming the plugin indicates that the script might be relying on specific naming conventions or paths. Ensure that the script can handle different naming conventions or provide clear documentation on naming requirements.

Recommendations:

  • Initialize Memory Variables: Ensure that all memory-related variables are initialized with default values before they are used in calculations. Add checks to handle undefined values gracefully.

  • Device Type Support: Update the device classification logic to include support for F5 Velos devices. Ensure that the correct SNMP OIDs and logic are used for these devices.

  • Module and Method Verification: Verify that all necessary modules are correctly loaded and that the methods are accessible. Check for any discrepancies in naming conventions that might affect method calls.

  • Documentation and Error Handling: Improve error handling to provide more informative messages when encountering uninitialized values or module loading issues. Update documentation to clarify any naming or path requirements for the plugin.

By addressing these areas, the script should be able to handle memory usage checks for F5 Velos devices more reliably and avoid the errors currently being encountered.

Disclaimer: This comment was entirely generated using AI. Be aware that the information provided may be incorrect.

Current plan usage: 38.89%

Have feedback or need help?
Discord
Documentation
[email protected]

@rajav2 rajav2 changed the title F5 Velos memory not working F5 Velos memory not working V11.2.4 Oct 9, 2024
@lausser
Copy link
Owner

lausser commented Oct 9, 2024

You can no longer rename the plugin since it was restructured inside. (There is a class CheckNwcHealth, where the name is derived from the plugin's name. This was done to have a common code base for all check_*_health plugins)
When you add -vvvvvvvvvvvvvv to the first run, then you might see the snmp queries and their responses. Look into the code at line 90286 and find out which OID is used to fill $mem_available. This OID is probably missing in the F5's response.

@rajav2
Copy link
Author

rajav2 commented Oct 10, 2024 via email

@lausser
Copy link
Owner

lausser commented Oct 10, 2024 via email

@rajav2
Copy link
Author

rajav2 commented Oct 10, 2024

snmpwalk_check_nwc_health_10.106.20.182.txt

See attached file. Sorry your email address was masked so I cant directly email you.

@lausser
Copy link
Owner

lausser commented Oct 10, 2024

Di you know if Velos is a pretty new product line? Or was it another vendor who was aquired by F5?

@lausser
Copy link
Owner

lausser commented Oct 10, 2024

It's MIBs are different from the (BIG-IP)-MIBS which were implemented in check_nwc_health so far. According to https://clouddocs.f5.com/training/community/velos-training/html/velos_monitoring_snmp.html it is possible to download a mibs_f5os_controller.tar.gz from the device itself. I did not find the MIB files anywhere, can you download the tar.gz and then attach it here? (or mail: gerhard <dot> lausser <at> consol <dot> de)

@rajav2
Copy link
Author

rajav2 commented Oct 11, 2024 via email

@rajav2
Copy link
Author

rajav2 commented Oct 16, 2024

Gerhard,

I have sent the MIBS file to your email.

@rajav2
Copy link
Author

rajav2 commented Oct 28, 2024

I tested the very latest version. It shows only OK only for memory, nothing else.
For cpu-load it is throwing bunch of errors also. I used the latest GLPlugin

[nagios@MYUCBPNAGIAPP01 ~]$ /usr/local/nagios/libexec/check_nwc_health.1012 --hostname 10.106.20.183 --timeout=50 --community test-- mode cpu-load --warning 70 --critical 85
OK - cpu (total): 0.00% | 'cpu_usage'=0%;70;85;0;100
[nagios@MYUCBPNAGIAPP01 ~]$ /usr/local/nagios/libexec/check_nwc_health --hostname 10.106.20.183 --timeout=50 --community test --mode cpu-load --warning 70 --critical 85
Use of uninitialized value in sprintf at /usr/local/nagios/libexec/check_nwc_health line 18887.
Use of uninitialized value $value in numeric gt (>) at /usr/local/share/perl5/Monitoring/GLPlugin/Commandline.pm line 560.
Use of uninitialized value $value in numeric lt (<) at /usr/local/share/perl5/Monitoring/GLPlugin/Commandline.pm line 560.
Use of uninitialized value $value in numeric gt (>) at /usr/local/share/perl5/Monitoring/GLPlugin/Commandline.pm line 583.
Use of uninitialized value $value in numeric lt (<) at /usr/local/share/perl5/Monitoring/GLPlugin/Commandline.pm line 583.
Use of uninitialized value $value in pattern match (m//) at /usr/local/share/perl5/Monitoring/GLPlugin/Commandline.pm line 138.
Use of uninitialized value $value in sprintf at /usr/local/share/perl5/Monitoring/GLPlugin/Commandline.pm line 145.
OK - cpu blade-1 usage is 0.00 | 'cpu_blade-1_usage'=0%;70;85;0;100

[nagios@MYUCBPNAGIAPP01 ~]$ /usr/local/nagios/libexec/check_nwc_health --hostname 10.106.20.183 --timeout=50 --community test --mode memory-usage --warning 70 --critical 85
OK

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

2 participants