rrdcgi double graph problem: Unable to connect to rrdcached: Permission denied - rrdtool

I try to draw two graphs, but the second one fails to draw with the message "Unable to connect to rrdcached: Permission denied". The output looks like this:
+--------------------+
| the first graph |
+--------------------+
[ERROR Unable to connect to rrdcached: Permission denied]
If i make a mistake in the parameters of the first graph, the output looks like this
[ERROR 'EAREA' is not a valid function name in EAREA:cel1#00a000:in]
+--------------------+
| the second graph |
+--------------------+
What am i doing wrong? apache2 web server if this is important.
The script:
#!/usr/bin/rrdcgi
<HTML>
<HEAD>
<TITLE>test</TITLE>
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=utf-8">
</HEAD>
<BODY>
<table border=0 width=500>
<tr><td>
<RRD::GRAPH ../htdoc/tmp/images/first.png
--imginfo '<IMG SRC=/tmp/images/%s WIDTH=%lu HEIGHT=%lu >'
--lazy --start -2d --end now --width 600 --height 150
DEF:cel1='../collectd.rrd/rrd/test/snmp/if_octets-Ethernet1_0_10.rrd':rx:AVERAGE
AREA:cel1#00a000:"in"
>
</td></tr>
<tr><td>
<RRD::GRAPH ../htdoc/tmp/images/second.png
--imginfo '<IMG SRC=/tmp/images/%s WIDTH=%lu HEIGHT=%lu >'
--lazy --start -5y --end now --width 600 --height 150
DEF:cel2='../collectd.rrd/rrd/test/snmp/if_octets-Ethernet1_0_10.rrd':tx:AVERAGE
AREA:cel2#00a000:"out"
>
</td></tr>
</table>
</BODY>
</HTML>

I haven't found a solution with rrdcached but there is a way to disable its use:
<RRD::SETENV RRDCACHED_ADDRESS "" >

Related

Google one tap Login With Django ( The given origin is not allowed for the given client ID issue )

I'm trying to connect Google One Tap Login with Django framework, but I'm having issue.
I'm not sure why this is displaying an issue. I followed all of the guidelines described in the Google documentation.
issue -
The given origin is not allowed for the given client ID
Here is my Google API client configuration for the javascript origin url.
Here is the login html template code.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Hi Reddit</h1>
<script src="https://accounts.google.com/gsi/client" async defer></script>
<div id="g_id_onload" data-client_id="i don't want to shere"
data-context="signin" data-ux_mode="popup" data-login_uri="http://localhost:8000/google/login/"
data-auto_select="true" data-itp_support="true">
</div>
<div class="g_id_signin" data-type="standard" data-shape="pill" data-theme="outline" data-text="continue_with"
data-size="large" data-logo_alignment="left">
</div>
</body>
</html>
I'm not sure why this is displaying an issue.
Is it possible to load Google One Tap Javascript in Django?
What should I do to load Google One Tap Javascript in Django?

AR.JS - Inconsistent Results with Barcode Markers

I am getting inconsistent results from barcode markers in AR.JS, no matter which collection I choose from https://github.com/nicolocarpignoli/artoolkit-barcode-markers-collection (which seems to be the canonical collection of markers). From the same collection, some markers work and some don't, even when the matrixCodeType is the same for all. I would expect that either all work or all don't work within a collection. Any ideas why there would be inconsistent result?
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<script src="https://aframe.io/releases/1.0.0/aframe.min.js"></script>
<script src="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar.js"></script>
</head>
<body style="margin:0px; overflow:hidden;">
<a-scene embedded arjs="debugUIEnabled:false; detectionMode:mono_and_matrix; matrixCodeType:4x4_BCH_13_9_3;" vr-mode-ui="enabled:false">
<a-assets>
<img id="station_01" src="assets/images/station_01.jpg">
<img id="station_02" src="assets/images/station_02.jpg">
<img id="station_03" src="assets/images/station_03.jpg">
</a-assets>
<a-marker-camera type="barcode" value="1">
<a-image src="#station_01" scale="2 3 1" rotation="-90 0 0"></a-image>
</a-marker-camera>
<a-marker-camera type="barcode" value="2">
<a-image src="#station_02" scale="2 3 1" rotation="-90 0 0"></a-image>
</a-marker-camera>
<a-marker-camera type="barcode" value="3">
<a-image src="#station_03" scale="2 3 1" rotation="-90 0 0"></a-image>
</a-marker-camera>
<a-entity camera></a-entity>
</a-scene>
</body>
</html>
I was struggling with the same issue recently and in my case it turned out it was due to lighting conditions. Uneven or poor lighting sometimes created shadows and contrast differences that seemed irrelevant to the naked eye but interfered with pattern recognition and tracking.

Error 503 while accessing /bigdata/dataloader at wikidata local

I get this error when running the following command:
$ ./loadRestAPI.sh -n wdq -d `pwd`/data/split/wikidump-000000001.ttl.gz
See https://github.com/wikimedia/wikidata-query-rdf/blob/master/docs/getting-started.md
Loading with properties...
quiet=false
verbose=0
closure=false
durableQueues=true
#Needed for quads
#defaultGraph=
com.bigdata.rdf.store.DataLoader.flush=false
com.bigdata.rdf.store.DataLoader.bufferCapacity=100000
com.bigdata.rdf.store.DataLoader.queueCapacity=10
#Namespace to load
namespace=wdq
#Files to load
fileOrDirs=/data/split
#Property file (if creating a new namespace)
propertyFile=/home/tsc/projects/TestSPARQL/wikidata-query-rdf-0.2.1/dist/target/service-0.2.1/RWStore.properties
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 503 </title>
</head>
<body>
<h2>HTTP ERROR: 503</h2>
<p>Problem accessing /bigdata/dataloader. Reason:
<pre> Service Unavailable</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>
</body>
</html>
It works when runing Blazegraph with 'sudo'...

Replace local images with base 64

I am building some emails template in which I include some local pictures.
I am trying to write a shell script to replace turn my images to base64. So basically automatically turn:
<img width="100%" src="./img/my_image.gif" />
to
<img width="100%" src="data:image/gif;base64,XXXXXXX" />
For now I used this script:
#!/bin/bash
awk -F'[()]' -v q="'" '
/src="(.*)"/ {
cmd=sprintf("openssl enc -base64 -in %s | tr -d %c\\n%c",$2,q,q)
cmd | getline b64
close(cmd)
$0=$1 "(data:image/gif;base64," b64 ");"
}1' ./my_template.html
I run into two issues:
- my regex doesn't seem to be correct even though it worked fine on regex101
- this regex would also catch the images which are not local (src="https://....")
How can I tweak it to make it work here?
I don't know your file, but IMHO editing html using awk isn't the best idea. In the general, i would to use better tool, like perl and such.
Here is an example using xmlstarlet. The following script:
#!/bin/bash
htmlfile=t.html
encode_image() {
local img="$1"
ext="${img##*.}"
printf "data:image/%s;base64,%s" "$ext" $(openssl base64 -A -in "$img")
}
while read -r src; do
encoded=$(encode_image "$src")
xmlstarlet ed --inplace -u "//img[#src='$src']/#src" -v "$encoded" t.html
done < <(xmlstarlet sel -t -v '//img/#src' -n "$htmlfile")
from this t.html
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8"/>
</head>
<body>
<p>bla</p>
<img width="100%" src="./img/my_image.gif" />
<p>otherbla</p>
<img width="100%" src="./img/my_image2.gif" />
</body>
</html>
create this:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8"/>
</head>
<body>
<p>bla</p>
<img width="100%" src="data:image/gif;base64,iVB....="/>
<p>otherbla</p>
<img width="100%" src="data:image/gif;base64,iVBO...="/>
</body>
</html>
Of course, the HTML must be correctly formatted, otherwise the parser will die.

Rest Webservice hosted in WAS return HTML for error status codes

we are hosting rest based webservices on WAS 8.0. The issue is when we return a error status code with a message, server is adding its own HTML response and then my plain text message. Any idea on how to disable WAS server adding its own HTML
ex.
when I return
Response getEntity(String entityId){
...
...
...
return Response.status(Status.NOT_FOUND).entity("Entity you are searching for is not found").type(MediaType.TEXT_PLAIN).build();
}
the response I get is
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>404 - File or directory not found.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
<div class="content-container"><fieldset>
<h2>404 - File or directory not found.</h2>
<h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3>
</fieldset></div>
</div>
</body>
</html>
Entity you are searching for is not found
any configuration settings I must do in WAS server to avoid the HTML?
Thanks and Regards
The solution was, we were accessing webervice in was via a IIS Server (reverse proxy) the HTML was getting added by the IIS not WAS. Follow instructions at https://blogs.msdn.microsoft.com/webdevelopertips/2009/08/24/tip-93-did-you-know-php-and-custom-error-pages-configuration/ and the issue got resolved.