Host and Request_Uri in Oracle Session List
In order to see where the request came from the web in the list of sessions on the Oracle server, it is enough to add 7 lines of code to the PHP OCI8 extension.
File
At the beginning
Insert six lines in php_oci_do_connect function
Module and action are visible not only in V $ SESSION, but also in V $ SQLAREA. In addition to host and request_uri, we write a unique end-to-end identifier for the request, which can be further tracked by the nginx and apache logs.
File
ext/oci8/oci8.c
At the beginning
#include "SAPI.h"
Insert six lines in php_oci_do_connect function
if (!connection) {
RETURN_FALSE;
}
char* hostname = sapi_getenv("HTTP_HOST", 100 TSRMLS_CC);
char* uri = sapi_getenv("REQUEST_URI", 100 TSRMLS_CC);
char* reqid = sapi_getenv("HTTP_X_REQUEST_ID", 32 TSRMLS_CC);
PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) hostname, (ub4) strlen(hostname), (ub4) OCI_ATTR_MODULE, OCI_G(err)));
PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) uri, (ub4) strlen(uri), (ub4) OCI_ATTR_ACTION, OCI_G(err)));
PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) reqid, (ub4) strlen(reqid), (ub4) OCI_ATTR_CLIENT_INFO, OCI_G(err)));
RETURN_RESOURCE(connection->rsrc_id);
Module and action are visible not only in V $ SESSION, but also in V $ SQLAREA. In addition to host and request_uri, we write a unique end-to-end identifier for the request, which can be further tracked by the nginx and apache logs.