Hello, i have a new installation, everything work fine but when i try to create a new device group i have the flowwing error.
PLease Help.
[2019-06-20 10:54:54] production.ERROR: file_put_contents(/opt/librenms/cache/devices_relationships.cache): failed to open stream: Permission denied {“userId”:1,“email”:“XXXXXXXXXXXXXXXXXX”,“exception”:"[object] (ErrorException(code: 0): file_put_contents(/opt/librenms/cache/devices_relationships.cache): failed to open stream: Permission denied at /opt/librenms/LibreNMS/DB/Schema.php:173)
[stacktrace]
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, ‘file_put_conten…’, ‘/opt/librenms/L…’, 173, Array)
#1 /opt/librenms/LibreNMS/DB/Schema.php(173): file_put_contents(’/opt/librenms/c…’, ‘a:2:{s:7:"versi…’)
#2 /opt/librenms/LibreNMS/Alerting/QueryBuilderFilter.php(92): LibreNMS\DB\Schema->getAllRelationshipPaths()
#3 /opt/librenms/LibreNMS/Alerting/QueryBuilderFilter.php(57): LibreNMS\Alerting\QueryBuilderFilter->generateTableFilter()
#4 /opt/librenms/app/Http/Controllers/DeviceGroupController.php(42): LibreNMS\Alerting\QueryBuilderFilter->__construct(‘group’)
#5 [internal function]: App\Http\Controllers\DeviceGroupController->create()
#6 /opt/librenms/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
#7 /opt/librenms/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction(‘create’, Array)
#8 /opt/librenms/vendor/laravel/framework/src/Illuminate/Routing/Route.php(219): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(App\Http\Cont
Run ./validate.php
and check your permissions. You might need to do chmod g+w /opt/librenms/cache
2 Likes
Christian_Anibal_Lop:
[2019-06-20 10:54:54] production.ERROR: file_put_contents(/opt/librenms/cache/devices_relationships.cache): failed to open stream: Permission denied {“userId”:1,“email”:“XXXXXXXXXXXXXXXXXX”,“exception”:"[object] (ErrorException(code: 0): file_put_contents(/opt/librenms/cache/devices_relationships.cache): failed to open stream: Permission denied at /opt/librenms/LibreNMS/DB/Schema.php:173)
Thanks for the answer, but it does not work.
drwxr-xr-x. 2 librenms librenms 45 Jun 20 11:09 cache
[root@localhost ~]# /opt/librenms/validate.php
Component
Version
LibreNMS
1.52-54-g1a60c44
DB Schema
2019_05_30_225937_device_groups_rewrite (135)
PHP
7.2.17
MySQL
5.5.60-MariaDB
RRDTool
1.4.8
SNMP
NET-SNMP 5.7.2
====================================
[OK] Composer Version: 1.8.6
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct
We also encountered the same problem, for possible file permissions have been adjusted (even 777), still no improvement.
In today test, will be “/opt/librenms/LibreNMS/DB/Schema.PHP” line 173 make annotations, can solve this case:
file_put_contents($cache_file, serialize($cache));
to
// file_put_contents($cache_file, serialize($cache));
But I’m not sure this is causing any other problems, the above provides reference.
Jason_Cheng:
file_put_contents
Please could you check the lines, are two the same.
thanks for the answer.
Yes, I put a double slash on this line to prevent it from executing.
aaaaa, ok thanks a lot, i will try.
Jason_Cheng:
prevent
Thanks a lot, this solve the problem.
We will keep monitoring to check if this generate any other issue.
BR
Don’t do that it will cause a LOT of wasted cpu cycles!
You just need to fix the permissions so both the webserver and the poller can write to that file/directory.
Thanks for the warning Murrat, could you please explain better the way to fix the permission to solve this issue??
BR
Yes, I know it is a permission problem, but I have tried a lot of methods, but there is no way to solve it, as follows:
chmod g+w /opt/librenms/cache
chmod 777 /opt/librenms/cache
touch /opt/librenms/cache/devices_relationships.cache
chown librenms:librenms /opt/librenms/cache/devices_relationships.cache
chmod 664 /opt/librenms/cache/*
setfacl -R -m g::rwx /opt/librenms/cache
Chas
11 July 2019 15:34
13
Ok so i sort of replicated this on my daily branch, my other release branch server is ok but different environment completely.
librenms user is in the www-data group
Click “New Device Group” - Something went wrong, check logs/librenms.log
Full Stack trace https://pastebin.com/raw/qUkPzWZU
devices_relationships.cache was owned by librenms:librenms
File: devices_relationships.cache
Size: 5979 Blocks: 16 IO Block: 4096 regular file
Device: 801h/2049d Inode: 1182620 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 999/librenms) Gid: ( 999/librenms)
Access: 2019-07-11 16:16:17.716875995 +0100
Modify: 2019-07-09 10:23:10.813061295 +0100
Change: 2019-07-11 16:15:42.915964900 +0100
Birth: -
Then i was just playing around,
chown librenms:www-data devices_relationships.cache (didn’t work)
chown www-data:www-data devices_relationships.cache (worked , can now create device group)
changed back:
chown librenms:www-data devices_relationships.cache (worked , didn’t before)
chown librenms:librenms devices_relationships.cache (works again, don’t see what changed)
Hope that might help
2 Likes
@Jason_Cheng is your web server a member of the librenms group?
Ho sorry, my lab this problem is solved after the engineer run daily.sh on July 14,
so it is can’t to confirm whether it was originally in librenms group.
But the lab web (nginx) is librenms group right now.
The following commands should fix the problem, at least it works on my machine.
sudo setfacl -d -m g::rwx /opt/librenms/cache/
sudo chmod -R ug=rwX /opt/librenms/cache/
1 Like
Thank you! This resolved my issue with creating Device Groups!