snipe-it icon indicating copy to clipboard operation
snipe-it copied to clipboard

SnipeIT doesn't mail out alerts

Open heizung76 opened this issue 10 years ago • 12 comments

Expected Behavior (or desired behavior if a feature request)

When reducing the number of one inventory item under the set up threshold i expect to get an alert-email.


Actual Behavior

When reducing the number of one inventory item under the set up threshold i don't get any alerts via EMail. Only the small notification icon on the webpage has the info message.


Please confirm you have done the following before posting your bug report:


Please provide answers to these questions before posting your bug report:

  • Version of Snipe-IT you're running: v3.5.1-2-gd7222ae
  • What OS and web server you're running Snipe-IT on: Ubuntu 16.04.1 LTS, Apache2
  • What method you used to install Snipe-IT: install.sh
  • If you're getting an error in your browser, include that error: no errors in Browser
  • What specific Snipe-IT page you're on, and what specific element you're interacting with to trigger the error: I'm reducing the amount of items to trigger an alert
  • If a stacktrace is provided in the error, include that too: No stacktrace
  • Any errors that appear in your browser's error console: no
  • Confirm whether the error is reproduceable on the demo.: No
  • Include any additional information you can find in app/storage/logs and your webserver's logs.: See below
  • Include what you've done so far in the installation, and if you got any error messages along the way.
  • Indicate whether or not you've manually edited any data directly in the database: No

Expected to get a fully working SnipeIT after using install.sh. Then i noticed that the mail-alert notification has to be configured via crontab. So i crafted the following line for my crontab: */1 * * * * /usr/bin/php /var/www/snipeit/artisan schedule:run >> /dev/null 2>&1

So i tested this command before setting up the crontab. The following output occured:

infosys@snipeit:~$  /usr/bin/php /var/www/snipeit/artisan schedule:run
No scheduled commands are ready to run.

I read on your documentation page that i have to give artisan also the "alerts:expiring" argument. So i tested the command and the following stacktrace output is generated:

infosys@snipeit:~$ /usr/bin/php /var/www/snipeit/artisan alerts:expiring
PHP Fatal error:  Uncaught UnexpectedValueException: The stream or file "/var/www/snipeit/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/snipeit/bootstrap/cache/compiled.php:13906
Stack trace:
#0 /var/www/snipeit/bootstrap/cache/compiled.php(13836): Monolog\Handler\StreamHandler->write(Array)
#1 /var/www/snipeit/bootstrap/cache/compiled.php(13596): Monolog\Handler\AbstractProcessingHandler->handle(Array)
#2 /var/www/snipeit/bootstrap/cache/compiled.php(13694): Monolog\Logger->addRecord(400, Object(UnexpectedValueException), Array)
#3 /var/www/snipeit/bootstrap/cache/compiled.php(13389): Monolog\Logger->error(Object(UnexpectedValueException), Array)
#4 /var/www/snipeit/bootstrap/cache/compiled.php(13360): Illuminate\Log\Writer->writeLog('error', Object(UnexpectedValueException), Array)
#5 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(57): Illuminate\Log\Writer->error(Object(UnexpectedValueException))
#6 /var/www/snipeit/app/Excepti in /var/www/snipeit/bootstrap/cache/compiled.php on line 13906
PHP Fatal error:  Uncaught UnexpectedValueException: The stream or file "/var/www/snipeit/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/snipeit/bootstrap/cache/compiled.php:13906
Stack trace:
#0 /var/www/snipeit/bootstrap/cache/compiled.php(13836): Monolog\Handler\StreamHandler->write(Array)
#1 /var/www/snipeit/bootstrap/cache/compiled.php(13596): Monolog\Handler\AbstractProcessingHandler->handle(Array)
#2 /var/www/snipeit/bootstrap/cache/compiled.php(13694): Monolog\Logger->addRecord(400, Object(Symfony\Component\Debug\Exception\FatalErrorException), Array)
#3 /var/www/snipeit/bootstrap/cache/compiled.php(13389): Monolog\Logger->error(Object(Symfony\Component\Debug\Exception\FatalErrorException), Array)
#4 /var/www/snipeit/bootstrap/cache/compiled.php(13360): Illuminate\Log\Writer->writeLog('error', Object(Symfony\Component\Debug\Exception\FatalErrorException), Array)
#5 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(57): Illumin in /var/www/snipeit/bootstrap/cache/compiled.php on line 13906

I don't receive mails about items below quantity level. But i do receive emails when i try to reset my password. So i think that my mail configuration is working.

heizung76 avatar Nov 02 '16 14:11 heizung76

PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/var/www/snipeit/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied

So that looks like your permissions are not set correctly. That directory (and all subdirectories) needs to be writable by the web server.

snipe avatar Nov 02 '16 20:11 snipe

I've done root@snipeit:/var/www# chown -R www-data:www-data snipeit/ and root@snipeit:/var/www# chmod -R 775 snipeit/ but the error is still the same...

heizung76 avatar Nov 03 '16 08:11 heizung76

Are you running SELinux?

snipe avatar Nov 03 '16 11:11 snipe

I think no. Just installed Ubuntu 16.04.1 LTS and then snipe it

heizung76 avatar Nov 03 '16 12:11 heizung76

@heizung76 I'm having the exact same issue as you are. Ubuntu 16.04.1 as well.

Did you find a solution yet? I'm still messing with permissions trying to pin it down, but not finding that to be the fix.

imthatjeremyguy avatar Nov 03 '16 19:11 imthatjeremyguy

@imthatjeremyguy didn’t find a solution yet. @snipe do you need further information’s to help?

heizung76 avatar Nov 04 '16 12:11 heizung76

The logs say it can't write to the laravel log file. It has to be permissions. Please check if you're running SElinux and check the documentation for how to handle it if you are.

snipe avatar Nov 04 '16 17:11 snipe

@snipe SElinux is not installed. Running "getenforce", "sestatus" or "cat /etc/sysconfig/selinux" to check states the program is not installed and gives the command to install it.

imthatjeremyguy avatar Nov 04 '16 17:11 imthatjeremyguy

@imthatjeremyguy same for me.

I changed the permissons

infosys@snipeit:~$ sudo chmod 777 /var/www/snipeit/storage/logs/laravel.log

And tested the command again,

infosys@snipeit:~$ sudo /usr/bin/php /var/www/snipeit/artisan alerts:expiring

Now I get a new error message:

[Symfony\Component\Console\Exception\CommandNotFoundException] There are no commands defined in the "alerts" namespace.

heizung76 avatar Nov 07 '16 09:11 heizung76

Just chiming in, I get the same message as @heizung76 when running artisan alerts:expiring.

[Symfony\Component\Console\Exception\CommandNotFoundException] There are no commands defined in the "alerts" namespace.

steveelwood avatar Nov 10 '16 13:11 steveelwood

https://snipe-it.readme.io/docs/configuring-alerts

That's not the correct artisan command. https://snipe-it.readme.io/docs/configuring-alerts#bypassing-the-scheduler

snipe avatar Nov 12 '16 04:11 snipe

Please run the below command for SnipeIT to send alerts email. /usr/bin/php /var/www/snipe-it/artisan snipeit:expiring-alerts

Note: Snipe-IT Version - v3.6.6

~ Mithun

viewmithun avatar Sep 13 '17 11:09 viewmithun