Failure running PHP script - possible permissions issue?

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

Moderators: Developers, Moderators

Post Reply
stennant
Posts: 2
Joined: Thu Feb 11, 2016 6:06 pm
Location: Perth, Australia

Failure running PHP script - possible permissions issue?

Post by stennant »

Howdy all!

First off, I'm running CentOS 7 / Apache 2.4.6 and PHP 5.4.16 + Cacti 0.8.8f

I'm trying to get the NUT UPS (http://www.eric-a-hall.com/software/cacti-nut/) monitor working and have hit a snag. I'm not sure if it is permissions related or a Cacti issue but it is stumping me with my limited Linux knowledge. I've moved the files as required, imported the script - no problems there. When I add the data query to the host, it doesn't work - errors about not being able to establish a TCP connection. Doing a verbose query, I get the following:

Code: Select all

+ Running data query [15].
+ Found type = '6' [Script Query - Script Server].
+ Found data query XML file at '/var/www/html/cacti-0.8.8f/resource/script_server/nut_ups_status.xml'
+ XML file parsed ok.
+ <arg_num_indexes> missing in XML file, 'Index Count Changed' not supported
+ Executing script for list of indexes '"/bin/php" -q /var/www/html/cacti-0.8.8f/scripts/ss_nut_ups_status.php 192.168.2.2:3493:500 index' Index Count: 1
+ Found index: FATAL: Unable to establish TCP session with port 3493 on 192.168.2.2
+ Executing script query '"/bin/php" -q /var/www/html/cacti-0.8.8f/scripts/ss_nut_ups_status.php 192.168.2.2:3493:500 query ups.device'
+ Found item [upsDevice=' Unable to establish TCP session with port 3493 on 192.168.2.2'] index: FATAL
+ Executing script query '"/bin/php" -q /var/www/html/cacti-0.8.8f/scripts/ss_nut_ups_status.php 192.168.2.2:3493:500 query ups.description'
+ Found item [upsDescription=' Unable to establish TCP session with port 3493 on 192.168.2.2'] index: FATAL
However, running the first command (and subsequent commands, too), it works and outputs the result (ups) as I would expect:

Code: Select all

#sudo -H -u apache bash -c "/bin/php -q /var/www/html/cacti-0.8.8f/scripts/ss_nut_ups_status.php 192.168.2.2:3493:500 index"
ups
So it seems PHP works fine, but when it's executed by Cacti it's unable to connect to the device. I'm not sure who the culprit for this issue is, so if I've put this post in the wrong place, apologies.

If anyone could shed some light on where to look next, it would be greatly appreciated.

Cheers.
stennant
Posts: 2
Joined: Thu Feb 11, 2016 6:06 pm
Location: Perth, Australia

Re: Failure running PHP script - possible permissions issue?

Post by stennant »

Ah - got it figured. It was SELinux messing about. I used the following command as root and now it's working from Cacti:

Code: Select all

setsebool -P httpd_can_network_connect=1
Mods, feel free to move this post to the Linux section and close it off.
Post Reply

Who is online

Users browsing this forum: tembarek and 1 guest