web2py with MongoHQ deploy at openshift: RuntimeError: no driver available ('pymongo',) - openshift

I'm trying to deploy my app to openshift, but I got error message. Following are my logs:
==> app-root/logs/web2py.log <==
127.5.151.1, 2014-06-01 18:08:10, GET, /admin/static/images/questions.png, HTTP/1.1, 304, 0.010710
127.5.151.1, 2014-06-01 18:11:12, HEAD, /, HTTP/1.1, 303, 0.000809
127.5.151.1, 2014-06-01 18:11:13, HEAD, /, HTTP/1.1, 303, 0.004810
127.5.151.1, 2014-06-01 18:41:05, GET, /MarkIt/, HTTP/1.1, 500, 5.459672
127.5.151.1, 2014-06-01 18:49:36, GET, /MarkIt/, HTTP/1.1, 500, 5.658112
127.5.151.1, 2014-06-01 18:54:00, GET, /MarkIt/, HTTP/1.1, 500, 5.682422
127.5.151.1, 2014-06-01 19:10:50, HEAD, /, HTTP/1.1, 303, 0.000960
127.5.151.1, 2014-06-01 19:10:50, HEAD, /, HTTP/1.1, 303, 0.001024
127.5.151.1, 2014-06-01 19:56:22, GET, /MarkIt/, HTTP/1.1, 500, 5.487744
127.5.151.1, 2014-06-01 20:04:03, GET, /MarkIt/, HTTP/1.1, 500, 5.431559
==> app-root/logs/python.log <==
[Sun Jun 01 20:04:02 2014] [error] DEBUG: connect attempt 4, connection error:
[Sun Jun 01 20:04:02 2014] [error] Traceback (most recent call last):
[Sun Jun 01 20:04:02 2014] [error] File "/var/lib/openshift/538b85575973cad5cc000794/app-root/runtime/repo/libs/gluon/dal.py", line 7409, in __init__
[Sun Jun 01 20:04:02 2014] [error] self._adapter = ADAPTERS[self._dbname](**kwargs)
[Sun Jun 01 20:04:02 2014] [error] File "/var/lib/openshift/538b85575973cad5cc000794/app-root/runtime/repo/libs/gluon/dal.py", line 5240, in __init__
[Sun Jun 01 20:04:02 2014] [error] if do_connect: self.find_driver(adapter_args)
[Sun Jun 01 20:04:02 2014] [error] File "/var/lib/openshift/538b85575973cad5cc000794/app-root/runtime/repo/libs/gluon/dal.py", line 746, in find_driver
[Sun Jun 01 20:04:02 2014] [error] raise RuntimeError("no driver available %s" % str(self.drivers))
[Sun Jun 01 20:04:02 2014] [error] RuntimeError: no driver available ('pymongo',)
97.77.53.27 - - [01/Jun/2014:20:03:56 -0400] "GET /MarkIt/ HTTP/1.1" 500 843 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/537.75.14"
I'm using MongoHQ, the app runs totally fine if I run it locally.
The way I connect to MongoHQ is in db.py:
if not request.env.web2py_runtime_gae:
## if NOT running on Google App Engine use SQLite or other DB
#db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
db = DAL("mongodb://username:password#oceanic.mongohq.com:10017/MarkIt",
check_reserved=["mongodb_nonreserved",], adapter_args={"safe":False})
Only one of my applications in web2py uses MongoHQ and that's the one I could not open. Other work fine.
I think it might be dependency issue but I don't know how to resolve it.
I also did rhc cartridge add mongodb-2.4 -a my app but it does not help.

Related

Google cloud compute engine freeze

Today I found out that my vm instance in the google cloud had an issue.
I could not connect via gcloud compute ssh. The only solution was to shut the vm down and restart it.
I guess I found the right log file where the error happened.
/var/log/daemon.log
Nov 23 17:39:01 globo-de systemd[1]: Started Clean php session files.
Nov 23 18:09:01 globo-de systemd[1]: Starting Clean php session files...
Nov 23 18:09:03 globo-de systemd[1]: Started Clean php session files.
Nov 23 18:39:01 globo-de systemd[1]: Starting Clean php session files...
Nov 23 18:39:04 globo-de systemd[1]: Started Clean php session files.
Nov 23 18:56:49 globo-de google-ip-forwarding: WARNING Exception running ['ip', 'route', 'ls', 'table', 'local', 'type', 'local', 'scope', 'host', 'dev', 'eth0', 'proto', '66']. [Errno 12] Cannot allocate memory.
Nov 23 18:57:43 globo-de google-accounts: ERROR Exception calling the response handler. [Errno 12] Cannot allocate memory.#012Traceback (most recent call last):#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/metadata_watcher.py", line 196, in WatchMetadata#012 handler(response)#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/accounts_daemon.py", line 259, in HandleAccounts#012 self.oslogin.UpdateOsLogin(enable=False)#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 79, in UpdateOsLogin#012 status = self._GetStatus()#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 60, in _GetStatus#012 retcode = self._RunOsLoginControl('status')#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 47, in _RunOsLoginControl#012 return subprocess.call([constants.OSLOGIN_CONTROL_SCRIPT, action])#012 File "/usr/lib/python2.7/subprocess.py", line 168, in call#012 return Popen(*popenargs, **kwargs).wait()#012 File "/usr/lib/python2.7/subprocess.py", line 390, in __init__#012 errread, errwrite)#012 File "/usr/lib/python2.7/subprocess.py", line 916, in _execute_child#012 self.pid = os.fork()#012OSError: [Errno 12] Cannot allocate memory
Nov 23 18:58:02 globo-de google-ip-forwarding: WARNING Exception running ['ip', 'route', 'ls', 'table', 'local', 'type', 'local', 'scope', 'host', 'dev', 'eth0', 'proto', '66']. [Errno 12] Cannot allocate memory.
Nov 23 18:59:35 globo-de google-ip-forwarding: WARNING Exception running ['ip', 'route', 'ls', 'table', 'local', 'type', 'local', 'scope', 'host', 'dev', 'eth0', 'proto', '66']. [Errno 12] Cannot allocate memory.
Nov 23 18:59:54 globo-de google-accounts: ERROR Exception calling the response handler. [Errno 12] Cannot allocate memory.#012Traceback (most recent call last):#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/metadata_watcher.py", line 196, in WatchMetadata#012 handler(response)#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/accounts_daemon.py", line 259, in HandleAccounts#012 self.oslogin.UpdateOsLogin(enable=False)#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 79, in UpdateOsLogin#012 status = self._GetStatus()#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 60, in _GetStatus#012 retcode = self._RunOsLoginControl('status')#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 47, in _RunOsLoginControl#012 return subprocess.call([constants.OSLOGIN_CONTROL_SCRIPT, action])#012 File "/usr/lib/python2.7/subprocess.py", line 168, in call#012 return Popen(*popenargs, **kwargs).wait()#012 File "/usr/lib/python2.7/subprocess.py", line 390, in __init__#012 errread, errwrite)#012 File "/usr/lib/python2.7/subprocess.py", line 916, in _execute_child#012 self.pid = os.fork()#012OSError: [Errno 12] Cannot allocate memory
Nov 23 19:03:53 globo-de google-ip-forwarding: WARNING Exception running ['ip', 'route', 'ls', 'table', 'local', 'type', 'local', 'scope', 'host', 'dev', 'eth0', 'proto', '66']. [Errno 12] Cannot allocate memory.
Nov 23 19:07:52 globo-de google-accounts: ERROR Exception calling the response handler. [Errno 12] Cannot allocate memory.#012Traceback (most recent call last):#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/metadata_watcher.py", line 196, in WatchMetadata#012 handler(response)#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/accounts_daemon.py", line 259, in HandleAccounts#012 self.oslogin.UpdateOsLogin(enable=False)#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 79, in UpdateOsLogin#012 status = self._GetStatus()#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 60, in _GetStatus#012 retcode = self._RunOsLoginControl('status')#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 47, in _RunOsLoginControl#012 return subprocess.call([constants.OSLOGIN_CONTROL_SCRIPT, action])#012 File "/usr/lib/python2.7/subprocess.py", line 168, in call#012 return Popen(*popenargs, **kwargs).wait()#012 File "/usr/lib/python2.7/subprocess.py", line 390, in __init__#012 errread, errwrite)#012 File "/usr/lib/python2.7/subprocess.py", line 916, in _execute_child#012 self.pid = os.fork()#012OSError: [Errno 12] Cannot allocate memory
Nov 23 19:09:37 globo-de google-ip-forwarding: WARNING Exception running ['ip', 'route', 'ls', 'table', 'local', 'type', 'local', 'scope', 'host', 'dev', 'eth0', 'proto', '66']. [Errno 12] Cannot allocate memory.
Nov 23 19:11:32 globo-de systemd[1]: phpsessionclean.service: Failed to fork: Cannot allocate memory
Nov 23 19:11:56 globo-de systemd[1]: phpsessionclean.service: Failed to run 'start' task: Cannot allocate memory
Nov 23 19:12:24 globo-de systemd[1]: Failed to start Clean php session files.
Nov 23 19:12:50 globo-de systemd[1]: phpsessionclean.service: Unit entered failed state.
Nov 23 19:13:37 globo-de systemd[1]: phpsessionclean.service: Failed with result 'resources'.
Nov 23 19:14:58 globo-de systemd[1]: apt-daily.service: Failed to fork: Cannot allocate memory
Nov 23 19:16:13 globo-de systemd[1]: apt-daily.service: Failed to run 'start' task: Cannot allocate memory
What can I do to prevent that from happening again?
I guess the problem was that the google-cloud-compute engine vm had no swap file. So I created one with the following commands I found on google.
sudo dd if=/dev/zero of=/var/swap bs=2048 count=524288
sudo chmod 600 /var/swap
sudo mkswap /var/swap
sudo swapon /var/swap
Then I added the following line to /etc/fstab to make it permanent.
/var/swap none swap sw 0 0
Another solution is to avoid swapping setting vm.swappiness to 0.
# sysctl -w vm.swappiness=0
However, it sounds me more like an OS image issue than google clouds.

FIWARE Wirecloud: Error using X-FI-WARE-OAuth-Token request header

We are part of the FINISH accelerator and are deploying Wirecloud and KeyRock on our own servers using the docker containers provided by fiware.
We have KeyRock-IdM set up and linked to Wirecloud. We are trying to pass the logged-in users token to an API which returns data to a widget.
We found documentation about the "X-FI-WARE..." headers in the github code and wrote a test widget (main.js shown below). When deployed on the fiware labs instance, it works out of the box. When deployed on our local installation with a docker container it gives the following error: "Current user has not an active FIWARE profile". I scoured the settings.py file but have no idea where this error is coming from. I have DEBUG=True but nothing show up in the log. The user running the widget was logged in through the KeyRock IdM.
/*jshint globalstrict:true */
/*global MashupPlatform, ObjectStorageAPI, StyledElements*/
(function () {
"use strict";
var token_available = MashupPlatform.context.get('fiware_token_available');
var username = MashupPlatform.context.get('username');
alert(username + " has token?: " + token_available);
var url = MashupPlatform.prefs.get('keyRock_url');
var request = MashupPlatform.http.makeRequest(url, {
requestHeaders: {
"X-FI-WARE-OAuth-Token": "true",
"X-FI-WARE-OAuth-GET-Parameter": "access_token"
},
method: "GET",
onSuccess: function (response) {
alert("Success:" + JSON.stringify(response.responseText));
document.getElementById('response').textContent = response.responseText;
},
onFailure: function (response) {
alert("Failed:" + JSON.stringify(response.responseText));
},
onComplete: function () {
}
}
);
})();
How can i find out what is going wrong?
From the comment below, changed a python script:
edited the /usr/local/lib/python2.7/site-packages/wirecloud/fiware/proxy.py file in the docker container and replaced line 37 from raise ValidationError(error_msg) to a simple raise.
the log from /var/log/apache2/error.log is below
[Fri May 06 07:12:33.745550 2016] [wsgi:error] [pid 13:tid 139955375367936] Internal Server Error: /cdp/https/account.lab.fiware.org/user
[Fri May 06 07:12:33.745580 2016] [wsgi:error] [pid 13:tid 139955375367936] Traceback (most recent call last):
[Fri May 06 07:12:33.745584 2016] [wsgi:error] [pid 13:tid 139955375367936] File "/usr/local/lib/python2.7/site-packages/wirecloud/proxy/views.py", line 234, in proxy_request
[Fri May 06 07:12:33.745587 2016] [wsgi:error] [pid 13:tid 139955375367936] response = WIRECLOUD_PROXY.do_request(request, url, request_method, workspace)
[Fri May 06 07:12:33.745589 2016] [wsgi:error] [pid 13:tid 139955375367936] File "/usr/local/lib/python2.7/site-packages/wirecloud/proxy/views.py", line 144, in do_request
[Fri May 06 07:12:33.745592 2016] [wsgi:error] [pid 13:tid 139955375367936] processor.process_request(request_data)
[Fri May 06 07:12:33.745594 2016] [wsgi:error] [pid 13:tid 139955375367936] File "/usr/local/lib/python2.7/site-packages/wirecloud/fiware/proxy.py", line 59, in process_request
[Fri May 06 07:12:33.745597 2016] [wsgi:error] [pid 13:tid 139955375367936] token = get_access_token(request['user'], _('Current user has not an active FIWARE profile'))
[Fri May 06 07:12:33.745599 2016] [wsgi:error] [pid 13:tid 139955375367936] File "/usr/local/lib/python2.7/site-packages/wirecloud/fiware/proxy.py", line 33, in get_access_token
[Fri May 06 07:12:33.745602 2016] [wsgi:error] [pid 13:tid 139955375367936] if oauth_info.access_token is None:
[Fri May 06 07:12:33.745604 2016] [wsgi:error] [pid 13:tid 139955375367936] File "/usr/local/lib/python2.7/site-packages/social/storage/base.py", line 41, in access_token
[Fri May 06 07:12:33.745615 2016] [wsgi:error] [pid 13:tid 139955375367936] return self.extra_data.get('access_token')
[Fri May 06 07:12:33.745618 2016] [wsgi:error] [pid 13:tid 139955375367936] AttributeError: 'unicode' object has no attribute 'get'
Seems that the problem is related to the use of python-social-auth v0.2.18. Please update to v0.2.19. See this ticket in github for more info about this problem.
I guess you are adding an extra "-". Try "X-fiware-..."
Docker Hub contains bogus 'Official' images
After trying Alonzo's suggestion and the log not yielding an obvious solution, i decided to double check that the docker image i was using was trustworthy.
It turns out the docker image i was using (wirecloud/fiware-wirecloud) which states to be the official reference implementation is in fact an old version (0.8) owned by someone called 'Wirecloud'. If you search Wirecloud on docker hub or in Kitematic it is the first entry to show up.
I upgraded to the docker image fiware/wirecloud which is version 0.9, and now it works. I can see the access token passed to my back-end services.
Curiously, my test widget which i had modelled on the objectstorage.wgt example on https://wirecloud.conwet.etsiinf.upm.es/slides/attachments/objectstorage.wgt required updating to the new config.xml format before i could test.
I suggest:
a link to the correct wirecloud image on docker hub in the documentation.
contacting the 'Wirecloud' user and asking them to change the description of their image, or adding a comment with information about the official docker image.

Core OWASP ModSecurity - Allowing JSON

I've had ModSecurity and the Core OWASP Rule Set ver.2.2.5 installed for some months now, but a JSON endpoint on the site has recently stopped responding, and the Apache log gets the following:
[Tue Jul 21 10:41:12 2015] [error] [client 194.54.11.146] ModSecurity:
Warning. Match of "streq %{SESSION.IP_HASH}" against "TX:ip_hash"
required. [file
"/etc/modsecurity/activated_rules/modsecurity_crs_16_session_hijacking.conf"]
[line "35"] [id "981059"] [msg "Warning - Sticky SessionID Data
Changed - IP Address Mismatch."] [hostname "************"] [uri
"/api/campaigns/d3c735cb-0773-11e4-98bd-02f651afdab5"] [unique_id
"Va4hyKwfKiYAAAYSLigAAAAJ"]
[Tue Jul 21 10:41:12 2015] [error] [client 194.54.11.146] ModSecurity:
Warning. Match of "streq %{SESSION.UA_HASH}" against "TX:ua_hash"
required. [file
"/etc/modsecurity/activated_rules/modsecurity_crs_16_session_hijacking.conf"]
[line "36"] [id "981060"] [msg "Warning - Sticky SessionID Data
Changed - User-Agent Mismatch."] [hostname "************"] [uri
"/api/campaigns/d3c735cb-0773-11e4-98bd-02f651afdab5"] [unique_id
"Va4hyKwfKiYAAAYSLigAAAAJ"]
[Tue Jul 21 10:41:12 2015] [error] [client 194.54.11.146] ModSecurity:
Warning. Operator EQ matched 2 at TX:sticky_session_anomaly. [file
"/etc/modsecurity/activated_rules/modsecurity_crs_16_session_hijacking.conf"]
[line "37"] [id "981061"] [msg "Possible Session Hijacking - IP
Address and User-Agent Mismatch."] [hostname "************"] [uri
"/api/campaigns/d3c735cb-0773-11e4-98bd-02f651afdab5"] [unique_id
"Va4hyKwfKiYAAAYSLigAAAAJ"]
[Tue Jul 21 10:41:12 2015] [error] [client 194.54.11.146] ModSecurity:
Warning. Match of "rx ^%{tx.allowed_request_content_type}$" against
"TX:0" required. [file
"/etc/modsecurity/activated_rules/modsecurity_crs_30_http_policy.conf"]
[line "64"] [id "960010"] [msg "Request content type is not allowed by
policy"] [data "application/json"] [severity "WARNING"] [tag
"POLICY/ENCODING_NOT_ALLOWED"] [tag "WASCTC/WASC-20"] [tag
"OWASP_TOP_10/A1"] [tag "OWASP_AppSensor/EE2"] [tag "PCI/12.1"]
[hostname "************"] [uri
"/api/campaigns/d3c735cb-0773-11e4-98bd-02f651afdab5"] [unique_id
"Va4hyKwfKiYAAAYSLigAAAAJ"]
I'm new to mod_security and the OWASP rules (I basically followed the guide here) but as I understand, rules are scored, and if a request passes a threshold, it's nuked. I assume this is what I'm seeing here.
The final one is the one that concerns me - "application/json" should certainly be allowed. From looking at /etc/modsecurity/modsecurity_crs_10_setup.conf, I see:
setvar:'tx.allowed_request_content_type=application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/x-amf'
My question is:
1. Can I just add application/json in here to make the error go away?
2. Is that the correct way to do it?
Yes you can so it reads like this:
setvar:'tx.allowed_request_content_type=application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/x-amf|application/json'
Yes that is the correct way of doing this.

Error occurred while closing statement in dbal

In my silex web aplication I have this function:
function obtener_visible($conn, $articulo, $wid)
{
$q= $conn
->prepare('call vn2008.article_visible_single(?, ?)');
$q->execute(array(0 => $wid, 1=>$articulo));
$result = $q->fetch();
$conn->close();
return $result['suma'];
}
But when I call this function, I receive this error:
[Wed Oct 1 07:47:01 2014] PHP Warning: obtener_visible(): Error occurred while closing statement in /home/nelo/web/silex/almacen.php on line 0
[Wed Oct 1 07:47:01 2014] PHP Stack trace:
[Wed Oct 1 07:47:01 2014] PHP 1. {main}() /home/nelo/web/silex/index.php:0
[Wed Oct 1 07:47:01 2014] PHP 2. Silex\Application->run() /home/nelo/web/silex/index.php:38
[Wed Oct 1 07:47:01 2014] PHP 3. Silex\Application->handle() /home/nelo/web/silex/vendor/silex/silex/src/Silex/Application.php:481
[Wed Oct 1 07:47:01 2014] PHP 4. Symfony\Component\HttpKernel\HttpKernel->handle() /home/nelo/web/silex/vendor/silex/silex/src/Silex/Application.php:504
[Wed Oct 1 07:47:01 2014] PHP 5. Symfony\Component\HttpKernel\HttpKernel->handleRaw() /home/nelo/web/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php:61
[Wed Oct 1 07:47:01 2014] PHP 6. call_user_func_array() /home/nelo/web/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php:117
[Wed Oct 1 07:47:01 2014] PHP 7. {closure:/home/nelo/web/silex/index.php:18-22}() /home/nelo/web/silex/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php:117
[Wed Oct 1 07:47:01 2014] PHP 8. executeFacade() /home/nelo/web/silex/index.php:20
[Wed Oct 1 07:47:01 2014] PHP 9. Verdnatura\Almacen\obtener_articulo->execute() /home/nelo/web/silex/facade.php:28
[Wed Oct 1 07:47:01 2014] PHP 10. obtener_visible() /home/nelo/web/silex/almacen/obtener_articulo.php:56
Can someone help me solve this error?

Mysql 4 to 5 - Change script expression

I'm getting this error under error_log Apache
[Fri Nov 29 15:03:49 2013] [error] [client 81.15.135.11] SELECT COUNT(*),COUNT(DISTINCT UserName),COUNT(DISTINCT CallingStationId) FROM radacct WHERE AcctStartTime LIKE '%2013-11-22%', referer: http://www.company.com/caoad/charts.cgi
[Fri Nov 29 15:02:46 2013] [error] [client 81.15.135.11] SELECT SUM(AcctOutputOctets),SUM(AcctInputOctets) FROM radacct WHERE AcctStartTime LIKE '%2013-11-19%', referer: http://www.company.com/caoad/charts.cgi
SELECT COUNT(*),COUNT(DISTINCT UserName),COUNT(DISTINCT CallingStationId)
FROM radacct
WHERE AcctStartTime LIKE '%2013-11-10%'
SELECT SUM(AcctOutputOctets),SUM(AcctInputOctets)
FROM radacct
WHERE AcctStartTime LIKE '%2013-11-09%'
The syntax probably changed from Mysql 4 to 5 and I don't know exactly how should I change it to.
If anyone can give me some pointers that would be great. Thank you.
#!/usr/bin/perl
use Chart::Lines;
do "ho.pl";
$numdays = $forminput{'numdays'};
$partner = $forminput{'partner'};
my $nas = $forminput{'nasidentifier'};
if (!$numdays){
$numdays = 7;
}
$multiplier = 38;
if ($numdays > 30){
$small=1;
$multiplier = 8;
}
$g = Chart::Lines->new(50+($numdays*$multiplier),500);
#day_names = qw(Sun Mon Tue Wed Thu Fri Sat);
$accum=0;
for (my $count=$numdays; $count>0; $count--) {
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time() - 60*60*24*$count);
$mon++;
$montext = sprintf "%02d",$mon;
$mdaytext = sprintf "%02d", $mday;
$year = $year + 1900;
if ($partner){
%hotspotpartners = get_hotspot_trading_partners();
my $matchstring;
my $countage=0;
foreach (keys %hotspotpartners){
if ($hotspotpartners{$_} == $partner){
if ($countage != 0){
$matchstring .= " OR ";
}
$matchstring .= "NASIdentifier='$_'";
$countage++;
}
}
$sql = "SELECT COUNT(*),COUNT(DISTINCT UserName),COUNT(DISTINCT CallingStationId)
FROM radacct
WHERE AcctStartTime LIKE '%"."$year-$montext-$mdaytext%' AND ($matchstring)";
} else { $sql = "SELECT COUNT(*),COUNT(DISTINCT UserName),COUNT(DISTINCT CallingStationId) FROM radacct WHERE AcctStartTime LIKE '%"."$year-$montext-$mdaytext%'";
}
if ($nas){
$sql .= " AND NASIdentifier = '$nas'";
}
print STDERR $sql;
my $sth = $dbh->prepare( $sql );
$sth->execute();
($temp,$unique,$mac) = $sth->fetchrow();
if ($small){
$title="";
} else {
$title = "$day_names[$wday] $mday/$mon";
}
$g->add_pt($title, $temp,$unique,$mac);
$accum = $accum + $temp;
}
$accum = int($accum / $numdays);
my #legend_labels = qw(Total Unique MACS);
$g->set('sub_title' => 'Average : '.$accum.' logins per day');
$g->set('min_val' => 0);
if (!$small){
$g->set('grid_lines' =>'true');
}
$g->set('x_label' =>'Date');
$g->set('y_label' =>'Number of logins');
$g->set('legend_labels' => \#legend_labels);
$g->set('transparent' =>'true');
$g->cgi_png();
#
Error log after make changes on the script to:
use strict;
use warnings;
#
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Scalar value #abbr[$county] better written as $abbr[$county] at /var/www/cgi-bin/ovad/chart-day.cgi line 47., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "$last" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 10., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "%forminput" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 10., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "$last" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 11., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "$last" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 12., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "$last" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 15., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "$last" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 22., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "$last" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 28., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "$last" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 35., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "$g" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 39., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "$sql" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 43., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "$sql" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 44., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "$dbh" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 45., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "$sql" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 45., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "$g" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 47., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "#legend_labels" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 52., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "$g" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 53., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "$g" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 54., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "$g" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 55., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "$g" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 56., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "$g" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 57., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "$g" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 58., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "$g" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 60., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "$g" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 61., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "#legend_labels" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 61., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "$g" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 62., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "$g" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 63., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Global symbol "#data" requires explicit package name at /var/www/cgi-bin/ovad/chart-day.cgi line 63., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Execution of /var/www/cgi-bin/ovad/chart-day.cgi aborted due to compilation errors., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:33 2013] [error] [client 82.15.145.17] Premature end of script headers: chart-day.cgi, referer: /ovad/charts.cgi
[Fri Nov 29 15:36:34 2013] [error] [client 82.15.145.17] Global symbol "$numdays" requires explicit package name at /var/www/cgi-bin/ovad/chart-bandwidthhistory.cgi line 6., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:34 2013] [error] [client 82.15.145.17] Global symbol "%forminput" requires explicit package name at /var/www/cgi-bin/ovad/chart-bandwidthhistory.cgi line 6., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:34 2013] [error] [client 82.15.145.17] Global symbol "$partner" requires explicit package name at /var/www/cgi-bin/ovad/chart-bandwidthhistory.cgi line 7., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:34 2013] [error] [client 82.15.145.17] Global symbol "%forminput" requires explicit package name at /var/www/cgi-bin/ovad/chart-bandwidthhistory.cgi line 7., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:34 2013] [error] [client 82.15.145.17] Global symbol "%forminput" requires explicit package name at /var/www/cgi-bin/ovad/chart-bandwidthhistory.cgi line 8., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:34 2013] [error] [client 82.15.145.17] Global symbol "$numdays" requires explicit package name at /var/www/cgi-bin/ovad/chart-bandwidthhistory.cgi line 9., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:34 2013] [error] [client 82.15.145.17] Global symbol "$numdays" requires explicit package name at /var/www/cgi-bin/ovad/chart-bandwidthhistory.cgi line 10., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:34 2013] [error] [client 82.15.145.17] Global symbol "$multiplier" requires explicit package name at /var/www/cgi-bin/ovad/chart-bandwidthhistory.cgi line 12., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:34 2013] [error] [client 82.15.145.17] Global symbol "$numdays" requires explicit package name at /var/www/cgi-bin/ovad/chart-bandwidthhistory.cgi line 13., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:34 2013] [error] [client 82.15.145.17] Global symbol "$small" requires explicit package name at /var/www/cgi-bin/ovad/chart-bandwidthhistory.cgi line 14., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:34 2013] [error] [client 82.15.145.17] Global symbol "$multiplier" requires explicit package name at /var/www/cgi-bin/ovad/chart-bandwidthhistory.cgi line 15., referer: /ovad/charts.cgi
[Fri Nov 29 15:36:34 2013] [error] [client 82.15.145.17] Global symbol "$g" requires explicit package name at /var/www/cgi-bin/ovad/chart-bandwidthhistory.cgi line 17., referer: /ovad/charts.cgi
What sort of field is 'AcctStartTime'? If it's a datetime field (or similar), I don't think you can use 'like' on it.
You probably want:
where date(acctStartTime) = '2013-11-09'