[SOLVED] Are regular expressions work correct in Slackware 14.2 and current? Cacti problem
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Are regular expressions work correct in Slackware 14.2 and current? Cacti problem
After upgrade from Slack 14.1 to 14.2 my Cacti stopped to show load average.
It's because perl script loadavg.pl, which before produced correct data, now put one stupid comma in output. I don't now why?
Should be
Code:
0.20 0.15 0.14
but script output is
Code:
0.20 0.15, 0.14
Cacti don't like this comma and says:
Code:
Result from CMD not valid. Partial Result: 0.20 0.15, 0.14
Can You check script below on Yours systems?
And how to fix it?
My loadavg.pl (in original script there isn't "LC_ALL=C" but without it I get more commas)
See man perlre for the details on regular expressions and the s/// substitution operator, and man perlop as well. What you need is a "g" in the third to last line.
Also, "perl" is far more powerful than "awk" so you can safely replace the calls to "awk" with native perl.
Last edited by Turbocapitalist; 12-04-2016 at 02:17 PM.
Thank You for help. I try to study man perl, but a don't now Perl at all.
Or maybe I'll use this perlless script
And please note:
1. The "loadavg.pl" script was delivered by Cacti package from SBo, so now will make problems not only for me, I thing.
2. This script work fine on Slackware 14.1 so what changed in Slackware 14.2 ?
I build the cacti Package from SBo and I found: var/www/htdocs/cacti/scripts/loadavg.pl in the resulting Package.
The Code provided by the Cacti Devs in loadavg.pl is broken.
I am not sure why that same script worked on Slackware 14.1 ... there was a major perl update but as Turbocapitalist said, $avg =~ s/,//; will only remove the first comma ( it has been that way since perl 4 ).
In addition, your LC_ALL=C patch is probably REQUIRED these days because some LOCALES use commas instead of dots for the decimal char.
The LC_ALL=C Environment will assure that the decimals are dots.
I would say that the Cacti Devs need to patch their loadavg.pl script.
Being a coder myself, I am hesitant to criticize code written by other coders but here goes ...
As Turbocapitalist said, there is no need to invoke gawk inside a perl script.
As allend said the same thing can be done without perl at all.
IMO, the loadavg.pl script is VERY primative in that it invokes gawk with back-ticks in a perl script to do something that perl capable of doing very well all by itself ( what Turbocapitalist said ).
While that particular script shouldn't be dangerous security-wise, it is however VERY poorly designed ( Larry Wall might have a Camel if he saw it )
I am not sure what other plugins are provided by the Cacti Devs, but given what I see in loadavg.pl, I would tend to be careful deploying their stuff on internet-facing web servers without auditing their code.
The output is different than loadavg.pl but it is a pure-d perl script ( no `gawk` backtick commands ) and the $avg =~ RegEX accounts for optional commas between the 1,5,15 load avg numbers.
Finally i found that now, with cacti-0.8.8h the only way is to use loadavg_multi.pl script.
It's funny that on Slackware 14.1 with cacti-0.8.81_p1 loadavg.pl script worked fine.
Now, on clean new install of Cacti loadavg_multi.pl script is used by default.
All because I upgraded my system instead of building everything from scratch
I guess so current Cacti not accept output of loadavg.pl script any more.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.