Error in cronjob for archiving job

I posted it already under “general questions” but here is the better group:

Hi,

my crontab on our piwik installation server (Linux SLES11) is the following:
5 * * * * /usr/bin/php /srv/www/vhosts/lxapp57.esag.net/project/piwik/console core:archive --url=http://lxapp57.esag.net/project/piwik/ > /srv/www/vhosts/lxapp57.esag.net/project/piwik/piwik-archive.log
→ So the job runs 5 mins past every hour.

As admin I got about 3 times a day the following mail with the following error text:

ERROR CoreConsole[2015-01-02 04:05:11] [3e6ee] Got invalid response from API request: http://lxapp57.esag.net/project/piwik/index.php?module=API&method=API.get&idSite=1&period=month&date=last2&format=php&token_auth=xxx&trigger=archivephp. Response was '

There is an error. Please report the message (Piwik 2.9.1) and full backtrace in the Piwik forums (please do a Search first as it might have been reported already!).

Warning:
file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /srv/www/vhosts/lxapp57.esag.net/project/piwik/core/Http.php on line 408

Backtrace →

#0 Piwik\Error::errorHandler(…) called at [:]
#1 file_get_contents(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/core/Http.php:408]
#2 Piwik\Http::sendHttpRequestBy(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/core/Http.php:94]
#3 Piwik\Http::sendHttpRequest(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/core/UpdateCheck.php:72]
#4 Piwik\UpdateCheck::check(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/plugins/CoreUpdater/CoreUpdater.php:156]
#5 Piwik\Plugins\CoreUpdater\CoreUpdater->updateCheck(…) called at [:]
#6 call_user_func_array(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/core/EventDispatcher.php:121]
#7 Piwik\EventDispatcher->postEvent(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/core/Piwik.php:684]
#8 Piwik\Piwik::postEvent(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/core/Fr
ontController.php:451]
#9 Piwik\FrontController->init(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/core/dispatch.php:35]
#10 require_once(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/index.php:46]
#11 require_once(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/core/CliMulti/RequestCommand.php:53]
#12 Piwik\CliMulti\RequestCommand->execute(…) called at
[/srv/www/vhosts/lxapp57.esag.net/project/piwik/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:252]
#13 Symfony\Component\Console\Command\Command->run(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/vendor/symfony/console/Symfony/Component/Console/Application.php:889]
#14 Symfony\Component\Console\Application->doRunCommand(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/vendor/symfony/console/Symfony/Component/Console/Application.php:193]
#15 Symfony\Component\Console\Applica
tion->doRun(…) called at [:]
#16 call_user_func(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/core/Console.php:60]
#17 Piwik{closure}(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/core/Access.php:454]
#18 Piwik\Access::doAsSuperUser(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/core/Console.php:61]
#19 Piwik\Console->doRun(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/vendor/symfony/console/Symfony/Component/Console/Application.php:124]
#20 Symfony\Component\Console\Application->run(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/console:30]


There is an error. Please report the message (Piwik 2.9.1) and full backtrace in the Piwik forums (please do a Search first as it might have been reported already!).

Warning:
file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /srv/www/vhosts/lxapp57.esag.net/project/piwik/core/Http.php on line 408

Backtrace →

#0 Piwik\Error::errorHandler(…) called at [:]
#1 file_get_contents(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/core/Http.php:408]
#2 Piwik\Http::sendHttpRequestBy(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/core/Http.php:94]
#3 Piwik\Http::sendHttpRequest(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/core/UpdateCheck.php:72]
#4 Piwik\UpdateCheck::check(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/plugins/CoreUpdater/CoreUpdater.php:156]

#5 Piwik\Plugins\CoreUpdater\CoreUpdater->updateCheck(…) called at [:]
#6 call_user_func_array(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/core/EventDispatcher.php:121]
#7 Piwik\EventDispatcher->postEvent(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/core/Piwik.php:684]
#8 Piwik\Piwik::postEvent(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/core/FrontController.php:451]
#9 Piwik\FrontController->init(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/core/dispatch.php:35]
#10 require_once(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/index.php:46]
#11 require_once(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/core/CliMulti/RequestCommand.php:53]
#12 Piwik\CliMulti\RequestCommand->execute(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/piwik/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:252]<br /

#13 Symfony\Component\Console\Command\Command->run(…) called at [/srv/www/vhosts/lxapp57.esag.net/project/p
ERROR CoreConsole[2015-01-02 04:05:15] [3e6ee] 1 total errors during this script execution, please investigate and try and fix these errors.

At the other times it is running without errors. Could you please give me a hint, what is wrong configured in our installation?

Thx in advance and kind regards,
Frank

The error seems to be: “getaddrinfo failed: Name or service not known”, which could mean the script cannot resolve the domain “lxapp57.esag.net”. Can you try running “ping lxapp57.esag.net” when logged in into the server?

Are you sure the Piwik URL is correct, and can be accessed from the server?

Hi Matthieu,

thats not the problem because piwik is running on this lxapp57.esag.net server (SLES11 is OS). And why does it work 21 times a day and 3 times there is this error? I start the job manually and it works. I send you the console output and the log file content. All seems ok.

lxapp57:~ # ping lxapp57.esag.net
PING lxapp57.esag.net (10.69.7.141) 56(84) bytes of data.
64 bytes from lxapp57.esag.net (10.69.7.141): icmp_seq=1 ttl=64 time=0.037 ms
64 bytes from lxapp57.esag.net (10.69.7.141): icmp_seq=2 ttl=64 time=0.033 ms
64 bytes from lxapp57.esag.net (10.69.7.141): icmp_seq=3 ttl=64 time=0.036 ms
64 bytes from lxapp57.esag.net (10.69.7.141): icmp_seq=4 ttl=64 time=0.043 ms
64 bytes from lxapp57.esag.net (10.69.7.141): icmp_seq=5 ttl=64 time=0.042 ms
64 bytes from lxapp57.esag.net (10.69.7.141): icmp_seq=6 ttl=64 time=0.047 ms
^C
lxapp57.esag.net ping statistics —
6 packets transmitted, 6 received, 0% packet loss, time 4998ms
rtt min/avg/max/mdev = 0.033/0.039/0.047/0.008 ms
lxapp57:~ # crontab -l

DO NOT EDIT THIS FILE - edit the master and reinstall.

(/tmp/crontab.XXXXiWkmsb installed on Fri Dec 12 08:59:05 2014)

(Cron version V5.0 – $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)

5 * * * * /usr/bin/php /srv/www/vhosts/lxapp57.esag.net/project/piwik/console core:archive --url=http://lxapp57.esag.net/project/piwik/ > /srv/www/vhosts/lxapp57.esag.net/project/piwik/piwik-archive.log
lxapp57:~ # /usr/bin/php /srv/www/vhosts/lxapp57.esag.net/project/piwik/console core:archive --url=http://lxapp57.esag.net/project/piwik/ > /srv/www/vhosts/lxapp57.esag.net/project/piwik/piwik-archive.log
lxapp57:~ #

/srv/www/vhosts/lxapp57.esag.net/project/piwik/piwik-archive.log:
INFO CoreConsole[2015-01-09 07:58:41] [35d6a] ---------------------------
INFO CoreConsole[2015-01-09 07:58:41] [35d6a] INIT
INFO CoreConsole[2015-01-09 07:58:41] [35d6a] Piwik is installed at: http://lxapp57.esag.net/project/piwik/index.php
INFO CoreConsole[2015-01-09 07:58:41] [35d6a] Running Piwik 2.9.1 as Super User
INFO CoreConsole[2015-01-09 07:58:41] [35d6a] ---------------------------
INFO CoreConsole[2015-01-09 07:58:41] [35d6a] NOTES
INFO CoreConsole[2015-01-09 07:58:41] [35d6a] - Reports for today will be processed at most every 10 seconds. You can change this value in Piwik UI > Settings > General Settings.
INFO CoreConsole[2015-01-09 07:58:41] [35d6a] - Reports for the current week/month/year will be refreshed at most every 3600 seconds.
INFO CoreConsole[2015-01-09 07:58:41] [35d6a] - Archiving was last executed without error 1 hours 52 min ago
INFO CoreConsole[2015-01-09 07:58:42] [35d6a] - Will process 1 websites with new visits since 1 hours 52 min , IDs: 1
INFO CoreConsole[2015-01-09 07:58:42] [35d6a] ---------------------------
INFO CoreConsole[2015-01-09 07:58:42] [35d6a] START
INFO CoreConsole[2015-01-09 07:58:42] [35d6a] Starting Piwik reports archiving…
INFO CoreConsole[2015-01-09 07:58:47] [35d6a] Archived website id = 1, period = day, 4504 visits in last last2 days, 931 visits today, Time elapsed: 5.241s
INFO CoreConsole[2015-01-09 07:59:09] [35d6a] Archived website id = 1, period = week, 18837 visits in last last2 weeks, 16043 visits this week, Time elapsed: 21.569s
INFO CoreConsole[2015-01-09 07:59:38] [35d6a] Archived website id = 1, period = month, 45913 visits in last last2 months, 16698 visits this month, Time elapsed: 29.880s
INFO CoreConsole[2015-01-09 07:59:48] [35d6a] Archived website id = 1, period = year, 707476 visits in last last2 years, 16698 visits this year, Time elapsed: 9.295s
INFO CoreConsole[2015-01-09 07:59:48] [35d6a] Archived website id = 1, 4 API requests, Time elapsed: 65.989s [1/1 done]
INFO CoreConsole[2015-01-09 07:59:48] [35d6a] Done archiving!
INFO CoreConsole[2015-01-09 07:59:48] [35d6a] ---------------------------
INFO CoreConsole[2015-01-09 07:59:48] [35d6a] SUMMARY
INFO CoreConsole[2015-01-09 07:59:48] [35d6a] Total visits for today across archived websites: 931
INFO CoreConsole[2015-01-09 07:59:48] [35d6a] Archived today’s reports for 1 websites
INFO CoreConsole[2015-01-09 07:59:48] [35d6a] Archived week/month/year for 1 websites
INFO CoreConsole[2015-01-09 07:59:48] [35d6a] Skipped 0 websites: no new visit since the last script execution
INFO CoreConsole[2015-01-09 07:59:48] [35d6a] Skipped 0 websites day archiving: existing daily reports are less than 10 seconds old
INFO CoreConsole[2015-01-09 07:59:48] [35d6a] Skipped 0 websites week/month/year archiving: existing periods reports are less than 3600 seconds old
INFO CoreConsole[2015-01-09 07:59:48] [35d6a] Total API requests: 4
INFO CoreConsole[2015-01-09 07:59:48] [35d6a] done: 1/1 100%, 931 vtoday, 1 wtoday, 1 wperiods, 4 req, 66131 ms, no error
INFO CoreConsole[2015-01-09 07:59:48] [35d6a] Time elapsed: 66.131s
INFO CoreConsole[2015-01-09 07:59:48] [35d6a] ---------------------------
INFO CoreConsole[2015-01-09 07:59:48] [35d6a] SCHEDULED TASKS
INFO CoreConsole[2015-01-09 07:59:48] [35d6a] Starting Scheduled tasks…
INFO CoreConsole[2015-01-09 07:59:48] [35d6a] No task to run
INFO CoreConsole[2015-01-09 07:59:48] [35d6a] done
INFO CoreConsole[2015-01-09 07:59:48] [35d6a] ---------------------------

The problem was connecting to piwik.org to get the latest version, which was timing out for this request. likely we should not catch that exception and log it instead of bubbling it… what do you think Matt?

@matt good call! I missed the “CoreUpdater” part lower in the stacktrace.

  • exceptions are already catched, so nothing more to do here
  • the error above is a PHP warning, so Http::sendHttpRequest() should (in theory) suppress warnings with @ and throw exceptions instead, but I’m not sure I want to change that because of BC breaks…
  • the warning is dumped into the HTTP response because it’s Piwik 2.9, with the logger refactoring in 2.10 this should not happen anymore

Thx for your answers. I hope I understand it correctly: the errors can be ignored and in version 2.10 they dont appear anymore?

Regards,
Frank

The error was that you server was trying to connect to piwik.org to check for latest versions, and that failed.

So unless the error appears every time, it should be OK to ignore it this time (it was probably a network problem or something like that). In the next version this specific error should not block the archiving.