borpin
(Brian Orpin)
21
This is the crucial bit of info!

Hello @borpin
May be! But I just can not see this message completely. And it is not recorded in the logs. How and where can I see it?
Hmm. From apache24-error_log
2020-01-06T08:58:09+02:00 DS3615HOME [Mon Jan 06 08:58:09.955111 2020] [proxy_fcgi:error] [pid 17473:tid 140685126588160] [client 192.168.1.200:35066] AH01071: Got error 'PHP message: PHP Warning: file_exists(): open_basedir restriction in effect. File(/usr/sbin/mosquitto) is not within the allowed path(s): (/tmp:/var/services/tmp:/var/services/web:/var/services/homes:/var/lib/phpfiwa:/var/lib/phpfina:/var/lib/phptimeseries:/var/log/emoncms) in /volume1/web/emoncms/Modules/admin/admin_model.php on line 318\nPHP message: PHP Notice: Undefined index: total in /volume1/web/emoncms/Modules/admin/admin_main_view.php on line 304\nPHP message: PHP Notice: Undefined index: free in /volume1/web/emoncms/Modules/admin/admin_main_view.php on line 306\n', referer: http://192.168.1.254/emoncms/feed/view
I am not use mosquitto
borpin
(Brian Orpin)
25
@Tehnoinstyle_Aleksey can you try this and see if it fixes the issue?
from Modules/admin/admin_model.php delete:
public static function mqtt_version() {
$v = '?';
if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$v = "n/a";
} else {
if (file_exists('/usr/sbin/mosquitto')) {
$v = exec('/usr/sbin/mosquitto -h | grep -oP \'(?<=mosquitto\sversion\s)[0-9.]+(?=\s*)\'');
}
}
return $v;
}
and paste:
public static function mqtt_version() {
}
} catch (Error $e) {
global $log;
$log->info(_('Issue checking /usr/sbin/mosquitto').' - '.$e->getMessage());
$v = "n/a";
}
}
return $v;
yes or no?
p.s. I’m sorry, but I really have little knowledge in the code.
borpin
(Brian Orpin)
27
NO!
The lines of the file above are collapsed - click on
to see it all.
Better to click on the 3 dots to the right, and View File.
public static function mqtt_version() {
$v = '?';
if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$v = "n/a";
} else {
try {
if (file_exists('/usr/sbin/mosquitto')) {
$v = exec('/usr/sbin/mosquitto -h | grep -oP \'(?<=mosquitto\sversion\s)[0-9.]+(?=\s*)\'');
}
} catch (Error $e) {
global $log;
$log->info(_('Issue checking /usr/sbin/mosquitto').' - '.$e->getMessage());
$v = "n/a";
}
}
return $v;
}
thanks. I’m going to try now.
1 Like
public static function mqtt_version() {
$v = '?';
if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$v = "n/a";
} else {
try {
if (file_exists('/usr/sbin/mosquitto')) {
$v = exec('/usr/sbin/mosquitto -h | grep -oP \'(?<=mosquitto\sversion\s)[0-9.]+(?=\s*)\'');
}
} catch (Error $e) {
global $log;
$log->info(_('Issue checking /usr/sbin/mosquitto').' - '.$e->getMessage());
$v = "n/a";
}
}
return $v;
}
the same? only for 319 line:
2020-01-06T14:08:22+02:00 DS3615HOME [Mon Jan 06 14:08:22.465623 2020] [proxy_fcgi:error] [pid 18027:tid 140132736743168] [client 178.151.206.206:34582] AH01071: Got error 'PHP message: PHP Warning: file_exists(): open_basedir restriction in effect. File(/usr/sbin/mosquitto) is not within the allowed path(s): (/tmp:/var/services/tmp:/var/services/web:/var/services/homes:/var/lib/phpfiwa:/var/lib/phpfina:/var/lib/phptimeseries:/var/log/emoncms) in /volume1/web/emoncms/Modules/admin/admin_model.php on line 319\nPHP message: PHP Notice: Undefined index: total in /volume1/web/emoncms/Modules/admin/admin_main_view.php on line 304\nPHP message: PHP Notice: Undefined index: free in /volume1/web/emoncms/Modules/admin/admin_main_view.php on line 306\n', referer: http://192.168.1.254/emoncms/feed/list
p.s. I have returned the original admin_model.php file so far.
borpin
(Brian Orpin)
30
@emrys, looks like there are various conditions that will create an issue on a Non-Pi system. But I’ve just notice this is a WARNING not an ERROR so Try/Catch does not help!
Is this line right? If I’m not mistaken it always evaluates to true?
[edit]
For mosquitto, why not check if the service is running first? If not running locally, it is pointless information.
emrys
(Emrys Roberts)
31
changed the try/catch for a custom error handler. this should catch (and log) the error if there is a directory restriction set for the install.
here’s what I changed…
direct link to commit:
[added try/catch block arround file_exists() code by emrysr · Pull Request #1495 · emoncms/emoncms · GitHub]
this was added to the original pull request
emrys
(Emrys Roberts)
32
@borpin, yes this snippet seems to always return true? (with the additional ‘@’ to suppress any php warnings)
if (@is_readable('/proc/cpuinfo') || true) {
unsure of the reason for this || true condition? only used on this line.
It’s the sort of trick I do when testing - I think you’ll only find out if you ask whoever put it there.
borpin
(Brian Orpin)
34
Ah, so could we use that trick to suppress the warnings on the file_exists call as well? (useful to know).
@TrystanLea @glyn.hudson my feeling this should not be there!
emrys
(Emrys Roberts)
35
@borpin - I don’t like using the @ operator to suppress error messages. Better to use the custom error handler in the pull request to catch expected errors.
silently ignoring errors wont help anyone to fix the issue.
1 Like
borpin
(Brian Orpin)
36
Don’t disagree, just suggest that we are consistent
.
Happy for it to be changed. Let me know when your ready @emrys for changes to be merged.
emrys
(Emrys Roberts)
38
@TrystanLea - I think is ok to merge pull request (unless other changes needed):
borpin
(Brian Orpin)
39
I think it might be good to pull this into a new branch on the emoncms repo for a bit more testing to see if it breaks other things. I’d like to see a ‘dev’ branch for this sort of thing.
A bit OT but the always ‘true’ condition needs sorting and lets be consistent on the use of @. if warnings can be caught then let’s do so.
2 Likes