commands (../nagios/libexec) in perl/PHP v/s C

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
zaji_nms
Posts: 616
Joined: Tue Oct 16, 2012 12:28 am

commands (../nagios/libexec) in perl/PHP v/s C

Post by zaji_nms »

Dear Expert

Yes, Perl & PHP are easy to write small script for specific output via Config , Command.....however if we manage to write in C, will it perform very fast compare to perl/PHP and if your answer is Yes, then how much % will be faster (approximate).

Will you advice/prefer to write in C over Perl/PHP ?

Regards
Zajil NMS
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: commands (../nagios/libexec) in perl/PHP v/s C

Post by tmcdonald »

It is nearly impossible to tell you how fast a plugin will run when written in C compared to perl/PHP, but it will almost certainly be faster. My advice is to write whatever you are comfortable with, using whichever language is the right tool for the job. Generally speaking I prefer to write in higher languages when possible, since my time as a human is more valuable than the time a computer spends running it. Only when I need to write in C will I do so.
Former Nagios employee
bwallace
Posts: 1145
Joined: Tue Nov 17, 2015 1:57 pm

Re: commands (../nagios/libexec) in perl/PHP v/s C

Post by bwallace »

Avoid using interpreted plugins. One thing that will significantly reduce the load on your monitoring host is the use of compiled (C/C++, etc.) plugins rather than interpreted script (Perl, etc) plugins. While Perl scripts and such are easy to write and work well, the fact that they are compiled/interpreted at every execution instance can significantly increase the load on your monitoring host if you have a lot of service checks. If you want to use Perl plugins, consider compiling them into true executables using perlcc(1) (a utility which is part of the standard Perl distribution) or compiling Nagios with an embedded Perl interpreter (see below).
... the above quote is from https://assets.nagios.com/downloads/nag ... uning.html
Although that doc is for Nagios Core, it applies to XI as well.
Be sure to check out the Knowledgebase for helpful articles and solutions!
Locked