更新CPAN模块后NPCD持续报错返回码255,功能正常却日志刷屏
Hey there, let's sort out this annoying log-spamming error you're seeing after updating CPAN modules. That return code 255 typically means the process_perfdata.pl script is hitting an uncaught fatal error mid-execution—even though your charts and data are still working, we need to nip this in the bud to stop clogging up your system logs.
First: Get Detailed Error Output by Running the Script Manually
You mentioned running the script manually, but let's crank up the verbosity to see exactly what's breaking. Run this command:
/etc/pnp4nagios/libexec/process_perfdata.pl -n --bulk /var/spool/icinga2/perfdata/host-perfdata.1524923929 -v -v
The double -v will dump super-detailed logs, including module load failures, permission issues, or malformed perfdata that's tripping up the script.
Common Causes & Fixes
1. CPAN Module Version Conflicts
Since you just updated CPAN modules, this is the most likely culprit. Some newer module versions might break compatibility with PNP4Nagios' older code. For example:
- DateTime/DateTime::Format::Strptime: Updates to these time-handling modules can change how timestamps in perfdata are parsed.
- File::Copy/IO::File: Changes to file operation APIs might prevent the script from reading/writing perfdata files correctly.
Fixes:
- Roll back to a compatible version of the problematic module. For example, if DateTime is the issue:
(Use a version that's known to work with your PNP4Nagios release—check the project's docs or GitHub issues for recommendations.)cpanm DateTime@1.59 - If you're unsure which module is causing the problem, use
perl -c /etc/pnp4nagios/libexec/process_perfdata.plto check for syntax/module load errors first.
2. Permission Issues
Even though data is generating, the script might be hitting a permission snag at some step (like writing temp files or logs). Let's verify:
- Run the script as the same user NPCD uses (usually
icingaornagios):
If this throws an error, check permissions on:sudo -u icinga /etc/pnp4nagios/libexec/process_perfdata.pl -n --bulk /var/spool/icinga2/perfdata/host-perfdata.1524923929- The perfdata spool directory:
/var/spool/icinga2/perfdata/ - PNP4Nagios log directory:
/var/log/pnp4nagios/ - The system temp directory:
/tmp
Adjust permissions withchownorchmodas needed to give the user read/write access.
- The perfdata spool directory:
3. Malformed Perfdata File
Occasionally, a single corrupted perfdata file can trigger this error. Let's test that:
- Move the problematic file out of the spool directory:
If the errors stop, that file was the issue. You can either delete it or investigate why it's malformed (maybe a plugin output glitch in Icinga2).mv /var/spool/icinga2/perfdata/host-perfdata.1524923929 /tmp/
4. Outdated PNP4Nagios
If your PNP4Nagios version is several years old, it might not support newer CPAN modules. Consider upgrading to the latest stable release—this often resolves compatibility issues with updated Perl dependencies.
Final Check
After applying a fix, restart the NPCD service to make sure changes take effect:
systemctl restart npcd
Then monitor your system logs (like /var/log/syslog or /var/log/messages) to confirm the error messages are gone.
内容的提问来源于stack exchange,提问作者user3788685

