Script Query works on CLI but not in Cacti

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

nafets
Posts: 12
Joined: Fri Sep 30, 2022 8:24 am

Re: Script Query works on CLI but not in Cacti

Post by nafets »

My recent encounter with the problem of different results in the CLI and in Cacti was with a shell script with some sed, awk and cut to manipulate the output of an SNMPwalk. Since you're also doing some text manipulation I'll share my experience.

I found the cuplrit by redirecting the output of every step of manipulation to a different /tmp/file. I had already done this many times in the CLI, but I only spotted a difference when I let Cacti run the script with the redirections. In a certain step the output in the CLI read TER01, while the output of the same step run by Cacti read "TER01". I couldn't see the quotes in the CLI, probably because of a terminal setting or whatnot.

Anyway, from the moment I inserted

Code: Select all

| tr -d '"' |
in my manipulation, the output between CLI and Cacti were the same. So it wasn't the shebang line, it wasn't the login shell for the cacti user (www-data for me), it wasn't shell/subshell miscommunication of variables, it wasn't chmod/chown/chgrp on my script, and it wasn't a multitude of other ideas I had in the three weeks it took me to solve this.
User avatar
phalek
Developer
Posts: 2838
Joined: Thu Jan 31, 2008 6:39 am
Location: Kressbronn, Germany
Contact:

Re: Script Query works on CLI but not in Cacti

Post by phalek »

Try running this, as it should execute the commands as the apache user (change that user to whatever your webserver is running under):

Code: Select all

sudo -u apache perl /cacti/cacti/scripts/chb_rhel_inodes.pl 'XXXXXXXX.XXXXX.XXX' 'index'
sudo -u apache perl /cacti/cacti/scripts/chb_rhel_inodes.pl 'XXXXXXXX.XXXXX.XXX' 'num_indexes'
sudo -u apache perl /cacti/cacti/scripts/chb_rhel_inodes.pl 'XXXXXXXX.XXXXX.XXX' 'get' var
sudo -u apache perl /cacti/cacti/scripts/chb_rhel_inodes.pl 'XXXXXXXX.XXXXXX.XXX' 'query'
That should hopefully give a few more details on the issue.
Greetings,
Phalek
---
Need more help ? Read the Cacti documentation or my new Cacti 1.x Book
Need on-site support ? Look here Cacti Workshop
Need professional Cacti support ? Look here CereusService
---
Plugins : CereusReporting
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests