diff --git a/examples/Kafka/README.md b/examples/Kafka/README.md index ee3a560..7facd67 100644 --- a/examples/Kafka/README.md +++ b/examples/Kafka/README.md @@ -1,5 +1,5 @@ # Kafka Consumer/Producer # -To run `./comsume.ch` +To run `./comsume.sh` To run `./producer.sh` \ No newline at end of file diff --git a/examples/OECC/README.md b/examples/OECC/README.md new file mode 100644 index 0000000..7548212 --- /dev/null +++ b/examples/OECC/README.md @@ -0,0 +1,149 @@ +# OpenEdge Command Center # + +Demo scripts to setup an OpenEdge Command Center environment with support for OpenTelemetry metrics. + +The scripts are an updated version of the scripts used for the following blog post: +* https://www.progress.com/blogs/using-opentelemetry-metrics-support-openedge-azure + +In the new version, the scripts can be used on an Ubuntu VM running on various virtualization options such as AWS, Azure, VirtualBox or VMWare Fusion. + +Scripts run commands to detect the IP address of the machine. + +### Requirements +* Ubuntu Linux 22.04 + * user with sudo access +* OpenEdge media: + * PROGRESS_OE_12.8.3_LNX_64.tar.gz + * PROGRESS_OECC_SERVER_1.3.0_LNX_64.tar.gz + * PROGRESS_OECC_AGENT_1.3.0_LNX_64.bin +* Reponse file for OpenEdge installation: + * response_12.8.3.ini + * Products: + * OE Adv. Ent. RDBMS + * 4GL Development System + * Progress ProdAS for OE + +**Notes:** +* The OpenEdge media for both OpenEdge and OpenEdge Command Center can be downloaded from the Progress OpenEdge 12.8.x section in the ESD site. +* You can use the `OpenEdge-Samples/examples/OECC/config/response_12.8.3.ini` file as a template and specify the control codes in the file. +* The demo scripts install the components using the media and the response .ini file. +* The demo scripts install OpenJDK to `/usr/lib/jvm/jdk` and OpenEdge to `/psc/dlc`. +* The demo scripts install Docker Engine on Ubuntu using the instructions at https://docs.docker.com/engine/install/ubuntu/. + +### Components +The infrastructure uses multiple components. To simplify the deployment, it uses a single virtual machine with some components running at the OS level and others running as a container using Docker. + +* Ubuntu Virtual Machine latest 22.04 (tested 22.04.4) + * OpenEdge Database 12.8.3 + * PAS for OpenEdge 12.8.3 + * OpenEdge Command Center agent 1.3.0 + * Docker (latest, version tested: 26.1.4) + * OpenTelemetry Collector 0.53.0 + * Prometheus (latest, version tested: v2.53.0) + * Grafana (latest, version tested: 9.5.20) + * MongoDB 4.4-rc-focal + * OpenEdge Command Center server 1.3.0 + +The OpenEdge Database, PAS for OpenEdge and the OpenEdge Command Center agent are installed at the OS level. +The OpenTelemetry Collector, Prometheus, Grafana, MongoDB, and the OpenEdge Command Center server are deployed using Docker. + +The following diagram shows the components use for OpenTelemetry support. +![Components](./images/diagram.png) + +See related diagram at +https://www.progress.com/openedge/features/command-center + +### Steps + +#### Preparing the installation with the prerequisites +1. Create `/install` directory used for the installation files. +~~~ +sudo mkdir -p /install +sudo chown $USER /install +~~~ + +2. Copy the OpenEdge media files and the response file to `/install`. + +#### Setting up the environment + +1. Clone the OpenEdge-Samples repo: +~~~ +cd +git clone https://github.com/progress/OpenEdge-Samples.git +~~~ + +2. Run `setup.sh` in the `OECC/scripts` directory. Script uses `sudo` to perform administrator tasks. +~~~ +cd ~/OpenEdge-Samples/examples/OECC +./scripts/setup.sh +~~~ + +#### Testing the environment + +1. Test the configuration. +~~~ +./scripts/test.sh +~~~ + +2. Access OpenEdge Command Center via a web browser: + * http://<host-machine>:8000 + * Use admin/admin to login + +3. Access the PAS for OpenEdge instance via a web browser: + * http://<host-machine>:8810 + * http://<host-machine>:8810/web/customer.p + +4. Access Prometheus via a web browser: + * http://<host-machine>:9090 + * Use DB_ in the Expression field to query for metrics for the OpenEdge database + * Use PASOE_ in the Expression field to query for metrics for PAS for OpenEdge + +5. Access Grafana via a web browser: + * http://<host-machine>:3000 + * Use admin/admin to login + +**Notes:** +* The setup script, adds `/etc/rc.local` to start the configuration on startup of the machine. You can also use `./scripts/start.sh` and `./scripts/stop.sh` to manually start and stop the configuration. + +### Creating a Dashboard in Grafana + +**Steps** + +1. Click on DATA SOURCES then on Prometheus to create a data source with the following values: + * Prometheus server URL: http://prometheus:9090 + * Prometheus is a reference to a service in the `docker-compose.yaml` file and can be used as a hostname. + * Scroll down and click on Save & Test + +2. Click on Home then on DASHBOARDS to create a dashboard. +3. Click on Add visualization to add a visualization for an OpenEdge database metric. + * Select Prometheus as the data source. + * Click on "Select metric" and click on Open. + +![Selecting a Metric #1](./images/selecting_a_metric1.png) + + * Search for "DB_" and select the BufferHits metric from the list. + +![Selecting a Metric #2](./images/selecting_a_metric2.png) + + * Click on Run queries. + * Click on Time series to change the visualization to use a Gauge. + * Change the Panel Title to "Buffer Hits" + * Scroll down and change the Unit in "Standard options" to Misc / Pecent (0-100). + * Scroll down and click on the Red dot for the Threshold to use Green. + * Click on the Green dot for Base to use Orange. + * Click on Apply. + +![Visualization](./images/bufferhits_visualization.png) + +4. Click on Add / Visualization (on toolbar) to add a visualization for a PASOE metric. + * Click on "Select metric" and click on Open. + * Search for "getrequests" and select the getRequests metric from the list. + * Click on Run queries. + * Change the Panel Title to "Get Requests". + * Click on Apply. +5. Click on the "Save dashboard" button (floppy disk icon on toolbar) to save the dashboard. + +![Dashboard](./images/openedge_dashboard.png) + +Notes: +* Examples of Grafana dashboards can be found at https://grafana.com/grafana/dashboards/ diff --git a/examples/OECC/config/customer.p b/examples/OECC/config/customer.p new file mode 100644 index 0000000..2a7b655 --- /dev/null +++ b/examples/OECC/config/customer.p @@ -0,0 +1,45 @@ +/** ------------------------------------------------------------------------ + File : customer.p + Purpose : Return records from the Customer table as JSON. + Syntax : + Description : + @author egarcia + Modified : Thu Jun 27 15:32:00 EST 2024 + Notes : + * Deploy to openedge/ directory in PAS instance + using OpenEdge.Web.CompatibilityHandler + * Access using http://:8810/web/customer.p + ---------------------------------------------------------------------- */ +USING Progress.Json.ObjectModel.JsonObject. + +CREATE WIDGET-POOL. + +{src/web2/wrap-cgi.i} + +DEFINE TEMP-TABLE ttCustomer LIKE Customer. +DEFINE DATASET dsCustomer FOR ttCustomer. + +RUN process-web-request. + +PROCEDURE outputHeader : + output-content-type ("application/json":U). +END PROCEDURE. + +PROCEDURE process-web-request : + DEFINE VARIABLE oJsonObject AS Progress.Json.ObjectModel.JsonObject NO-UNDO. + DEFINE VARIABLE lChar AS LONGCHAR NO-UNDO. + RUN outputHeader. + + EMPTY TEMP-TABLE ttCustomer. + FOR EACH Customer WHERE Customer.CustNum < 3110 NO-LOCK: + CREATE ttCustomer. + BUFFER-COPY Customer TO ttCustomer. + END. + + oJsonObject = NEW JsonObject(). + oJsonObject:READ(DATASET dsCustomer:HANDLE). + + lChar = oJsonObject:GetJsonText(). + {&OUT-LONG} lChar. + +END PROCEDURE. diff --git a/examples/OECC/config/oepas1.properties b/examples/OECC/config/oepas1.properties new file mode 100644 index 0000000..ff0b285 --- /dev/null +++ b/examples/OECC/config/oepas1.properties @@ -0,0 +1,9 @@ +[AppServer.SessMgr] +agentStartupParam=-T "${catalina.base}/temp" -db sports2020 -S 20000 + +[AppServer.Agent] + numInitialSessions=2 + +[oepas1.ROOT.WEB] +adapterEnabled=1 +defaultHandler=OpenEdge.Web.CompatibilityHandler diff --git a/examples/OECC/config/otagentoedb.yaml b/examples/OECC/config/otagentoedb.yaml new file mode 100644 index 0000000..1ce64dc --- /dev/null +++ b/examples/OECC/config/otagentoedb.yaml @@ -0,0 +1,19 @@ +exporter: + name: "otlp" + endpoint: "http://192.168.56.215:4317" + protocol: "grpc" + connectionretry: 20 + timeout: 10 + + +oedbInstances: +- dbname: sports2020 + host: localhost + port: 20000 + user: dba + password: dba + metricsregex: + otherdbconnparams: + dbconnectionretry: 5 + dbschedule: 30 + dbduration: seconds diff --git a/examples/OECC/config/otagentpasoe.yaml b/examples/OECC/config/otagentpasoe.yaml new file mode 100644 index 0000000..980f9f8 --- /dev/null +++ b/examples/OECC/config/otagentpasoe.yaml @@ -0,0 +1,13 @@ +exporter: + name: "otlp" + endpoint: "http://192.168.56.215:4317" + protocol: "grpc" + connectionretry: 20 + timeout: 10 + +pasInstances: +- pasdir: "/psc/wrk/oepas1" + passchedule: 30 + pasconnectionretry: 5 + pasduration: seconds + metricsregex: diff --git a/examples/OECC/config/rc.local b/examples/OECC/config/rc.local new file mode 100644 index 0000000..1e96e09 --- /dev/null +++ b/examples/OECC/config/rc.local @@ -0,0 +1,11 @@ +#!/bin/sh -e +# + +export DLC=/psc/dlc +export PATH=$DLC/bin:$PATH + +cd /psc/wrk +proserve sports2020 -S 20000 -n 30 +/psc/wrk/oepas1/bin/tcman.sh start + +exit 0 diff --git a/examples/OECC/config/response_12.8.3.ini b/examples/OECC/config/response_12.8.3.ini new file mode 100644 index 0000000..3313591 --- /dev/null +++ b/examples/OECC/config/response_12.8.3.ini @@ -0,0 +1,171 @@ +; +; DESCRIPTION of Configuration Count +; +; NumberofConfigurations - the number of products being installed. +; + +[Install Method] +ApplyAsServicePack=0 + +[Configuration Count] +NumberofConfigurations=3 + +[Product Configuration 1] +name=DEMO +serial= +version=12.8 +control= +prodname=OE Adv. Ent. RDBMS + +[Product Configuration 2] +name=DEMO +serial=<4GL_DEV_SERIAL_NUMBER> +version=12.8 +control=<4GL_DEV_CONTROL_CODES> +prodname=4GL Development System + +[Product Configuration 3] +name=DEMO +serial= +version=12.8 +control= +prodname=Progress ProdAS for OE + +; +; DESCRIPTION of OpenEdge Explorer +; +; enable - indicates whether or not you want to enable the OpenEdge Explorer functionality. +; - a value of false indicates you do NOT want to enable the OpenEdge Explorer functionality. +; - a value of true indicates you want to enable the OpenEdge Explorer functionality. +; + +[OpenEdge Explorer] +enable=true + +; +; DESCRIPTION of Java +; +; JavaHome - the root directory where the JRE is installed +; + +[Java] +JavaHome=/usr/lib/jvm/jdk + +; +; DESCRIPTION of Type and Destination +; +; type - identifies the type of installation. Valid values are COMPLETE and CUSTOM. +; path - identifies the directory in which you install your OpenEdge product software. +; workpath - identifies the directory in which your applications, databases, and log files will reside. +; oem_path - identifies the directory in which you install your Management product software. +; oem_workpath - identifies the directory in which your Management applications, databases, and log files will reside. +; + +[Type and Destination] +type=COMPLETE +path=/psc/dlc +workpath=/psc/wrk +oem_path=/psc/oemgmt +oem_workpath=/psc/wrk_oemgmt + +; +; DESCRIPTION of Server Engine +; +; UseSqlServerEngine - valid values are 0 and 1. +; 0 - indicates that the SQL Database Engine is to not be installed. +; 1 - indicates that the SQL Database Engine is to be installed. +; + +[Server Engine] +UseSqlServerEngine=1 + +; +; DESCRIPTION of Language Default +; +; DefaultLanguage - identifies the language in which PROMSGS appears by default. +; -Valid values are: +; Czech +; Dutch +; English - American +; English - International +; French +; German +; Italian +; Polish +; Portuguese +; Portuguese - Brazilian +; Spanish +; Spanish - Latin +; Swedish +; + +[Language Default] +DefaultLanguage=English - American + +; +; DESCRIPTION of Language Choice +; +; lang1, lang2, lang3 ... - Identifies all the PROMSGS languages installed during installation including the default language. +; + +[Language Choice] +lang1=English - American + +; +; DESCRIPTION of International Settings +; +; NOTE: For specific information please refer to the intlsets.txt file located at the root level of the cdrom from which this information is derived. +; cpinternal - identifies the -cpinternal and -cpstream values included in the startup.pf file. +; cpcollation - identifies the -cpcoll value included in the startup.pf file. +; cpcase - identifies the -cpcase value included in the startup.pf file. +; dateformat - identifies the -d value included in the startup.pf file. +; numsep - identifies the -numsep value included in the startup.pf file. +; numdec - identifies the -numdec value included in the startup.pf file. +; +; The following is a table of the numbers and the separators they represent: +; 32 - space +; 36 - dollar +; 39 - apostrophe +; 44 - comma +; 46 - period +; + +[International Settings] +cpinternal=ISO8859-1 +cpcollation=Basic +cpcase=Basic +dateformat=mdy +numsep=44 +numdec=46 +; +; DESCRIPTION of PacificAppServerPortDetails +; +; nPortHttp - A port for HTTP connections. +; nPortHttps - A port for HTTPS connections. +; nPortShutdown - Port on which the shutdown process will run. +; + +[PacificAppServerPortDetails] +nPortHttp=8810 +nPortHttps=8811 +nPortShutdown=8812 +; +; DESCRIPTION of STS Key Plugin Dialog +; +; EnableAuthGatewaySTSClient - Enable Authentication Gateway. Enable = 1, Disable = 0 +; OEAuthGatewayURL - Gateway URL. +; ServerKeyPassword - Password +; STSKeystorePath- Path for storing keys. +; NoHostVerify - Enable = 1, Disable = 0 +; EnableAdminSrvSTSKeyPlugin - Enable = 1, Disable = 0 +; PollingInterVal - Polling interval (in minutes). +; + +[STS Key Plugin Dialog] +EnableAuthGatewaySTSClient=0 +OEAuthGatewayURL= +ServerKeyPassword= +STSKeystorePath= +NoHostVerify=0 +EnableAdminSrvSTSKeyPlugin=0 +PollingInterVal= diff --git a/examples/OECC/config/response_agent_1.3.0.properties b/examples/OECC/config/response_agent_1.3.0.properties new file mode 100644 index 0000000..d1754f4 --- /dev/null +++ b/examples/OECC/config/response_agent_1.3.0.properties @@ -0,0 +1,14 @@ +#Install Configurations +#---------------------- +USER_INSTALL_DIR=/usr/oecc_agent +OECC_AGENT_AS_SERVICE=1 +OECC_JAVA_HOME=/usr/lib/jvm/jdk + +#Server Connection +#----------------- +AGENT_KEY_FILE=/install/serverInfo.json +SERVER_SEC_CONNECTION=0 + +#OpenEdge Installations +#---------------------- +OE_INSTALL_DIR_1=/psc/dlc diff --git a/examples/OECC/config/serverInfo.json b/examples/OECC/config/serverInfo.json new file mode 100644 index 0000000..41c279d --- /dev/null +++ b/examples/OECC/config/serverInfo.json @@ -0,0 +1,7 @@ +{ + "host": "192.168.56.215", + "port": "8000", + "agentKey": "4e2b66cd-948b-4618-acd5-8d71a3ca5195", + "agentKeyName": "DEMO_AGENT_KEY", + "isServerSecured": false +} diff --git a/examples/OECC/diagram.txt b/examples/OECC/diagram.txt new file mode 100644 index 0000000..75567e5 --- /dev/null +++ b/examples/OECC/diagram.txt @@ -0,0 +1,21 @@ +title Using OpenTelemetry in OpenEdge + +participantgroup Virtual Machine +participant Sports2020#lightblue +participant oepas1#lightblue +participant "OECC Agent" as OECCAgent#lightgreen +end +participantgroup Docker +participant "OpenTelemetry Collector" as Collector#lightgreen +participant Prometheus#lightblue +participant Grafana#orange +end +actor User + +Sports2020<-OECCAgent: "" +oepas1<-OECCAgent: "" +OECCAgent->Collector: "" +note over OECCAgent#yellow:Agent post metrics to collector +Prometheus->Collector: "" +Grafana->Prometheus: "" +User->Grafana: "" diff --git a/examples/OECC/docker/collector-config.yaml b/examples/OECC/docker/collector-config.yaml new file mode 100644 index 0000000..c57aeca --- /dev/null +++ b/examples/OECC/docker/collector-config.yaml @@ -0,0 +1,29 @@ +receivers: + otlp: + protocols: + grpc: + http: + cors: + allowed_origins: + - http://* + - https://* + +exporters: + logging: + logLevel: debug + prometheus: + endpoint: "0.0.0.0:9464" + +processors: + batch: + +service: + telemetry: + logs: + level: "debug" + pipelines: + metrics: + receivers: [otlp] + exporters: [logging, prometheus] + processors: [batch] + diff --git a/examples/OECC/docker/docker-compose.yaml b/examples/OECC/docker/docker-compose.yaml new file mode 100644 index 0000000..21606a9 --- /dev/null +++ b/examples/OECC/docker/docker-compose.yaml @@ -0,0 +1,61 @@ +volumes: + mongodb-data: + oecc-data: + prometheus-data: + grafana-data: + +services: + # MongoDB + mongodb: + restart: always + image: mongo:4.4-rc-focal + ports: + - 27017:27017 + volumes: + - mongodb-data:/data/db + environment: + MONGO_INITDB_ROOT_USERNAME: admin + MONGO_INITDB_ROOT_PASSWORD: admin + + # OpenEdge Command Center Server + oecc: + restart: always + image: oecc + build: ./oecc + ports: + - 8000:8000 + volumes: + - oecc-data:/oecc/data + depends_on: + - "mongodb" + + # Collector + collector: + restart: always + image: otel/opentelemetry-collector-contrib:0.53.0 + command: ["--config=/conf/collector-config.yaml"] + volumes: + - ./collector-config.yaml:/conf/collector-config.yaml + ports: + - "9464:9464" + - "4317:4317" + - "4318:4318" + + # Prometheus + prometheus: + restart: always + image: prom/prometheus:latest + volumes: + - ./prometheus.yaml:/etc/prometheus/prometheus.yml + - prometheus-data:/prometheus + ports: + - "9090:9090" + + # Grafana + grafana: + restart: always + image: grafana/grafana:latest + ports: + - 3000:3000 + volumes: + - grafana-data:/var/lib/grafana diff --git a/examples/OECC/docker/oecc/Dockerfile b/examples/OECC/docker/oecc/Dockerfile new file mode 100644 index 0000000..ae4be01 --- /dev/null +++ b/examples/OECC/docker/oecc/Dockerfile @@ -0,0 +1,14 @@ +FROM ubuntu:focal +# FROM centos:7 + +RUN mkdir -p /usr/oecc /oecc/data/conf +ADD ./PROGRESS_OECC_SERVER_1.3.0_LNX_64.tar.gz /usr/oecc +COPY ./start.sh /usr/oecc +COPY db-config.json firstuser-config.json /oecc/data/conf/ +COPY server-config.json /usr/oecc/conf/ +RUN cp /usr/oecc/orig/system-config.json.orig /oecc/data/conf/system-config.json +RUN chmod +x /usr/oecc/oeccserver +RUN chmod +x /usr/oecc/start.sh + +CMD [ "/usr/oecc/start.sh" ] + diff --git a/examples/OECC/docker/oecc/db-config.json b/examples/OECC/docker/oecc/db-config.json new file mode 100644 index 0000000..deb2f8f --- /dev/null +++ b/examples/OECC/docker/oecc/db-config.json @@ -0,0 +1,15 @@ +{ + "dbHostNameAndPort": "mongodb:27017", + "srvRecord": false, + "connectOptions": { + "autoIndex": true, + "connectTimeoutMS": 10000, + "socketTimeoutMS": 45000, + "auth": { + "user": "admin", + "password": "admin" + }, + "authSource": "admin" + }, + "tls": false +} diff --git a/examples/OECC/docker/oecc/firstuser-config.json b/examples/OECC/docker/oecc/firstuser-config.json new file mode 100644 index 0000000..c53e8bc --- /dev/null +++ b/examples/OECC/docker/oecc/firstuser-config.json @@ -0,0 +1,8 @@ +{ + "firstName": "admin", + "lastName": "admin", + "userName": "admin", + "email": "EMAIL_ADDRESS", + "password": "admin", + "description": "" +} diff --git a/examples/OECC/docker/oecc/server-config.json b/examples/OECC/docker/oecc/server-config.json new file mode 100644 index 0000000..8fc13c7 --- /dev/null +++ b/examples/OECC/docker/oecc/server-config.json @@ -0,0 +1,13 @@ +{ + "_comment": "Provide complete path for key and certificate files if 'isServerSecured' is set to true", + "nodeId": "", + "hostName": "", + "port": 8000, + "dataDir": "/oecc/data", + "security": { + "isServerSecured": false, + "key": "", + "certificate": "", + "intermediateCerts": [] + } +} diff --git a/examples/OECC/docker/oecc/start.sh b/examples/OECC/docker/oecc/start.sh new file mode 100644 index 0000000..1a264a9 --- /dev/null +++ b/examples/OECC/docker/oecc/start.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +cd /usr/oecc + +trap 'exit 0' SIGTERM + +export PATH=/usr/oecc/node/bin:$PATH +export NODE_PATH=/usr/oecc/console/node_modules +export NODE_ENV=production +exec node ./console/dist/server.js + +# ./oeccserver start +# sleep 30 +# ls -l +# tail --pid=`cat ./oeccserver.pid` -f `ls -ltr | awk '{ print $9 }' | tail -1` diff --git a/examples/OECC/docker/prometheus.yaml b/examples/OECC/docker/prometheus.yaml new file mode 100644 index 0000000..6037680 --- /dev/null +++ b/examples/OECC/docker/prometheus.yaml @@ -0,0 +1,10 @@ +global: + scrape_interval: 30s # Default is every 1 minute. + +scrape_configs: + - job_name: 'collector' + # metrics_path defaults to '/metrics' + # scheme defaults to 'http'. + static_configs: + - targets: ['collector:9464'] + diff --git a/examples/OECC/images/bufferhits_visualization.png b/examples/OECC/images/bufferhits_visualization.png new file mode 100755 index 0000000..4fbebfc Binary files /dev/null and b/examples/OECC/images/bufferhits_visualization.png differ diff --git a/examples/OECC/images/diagram.png b/examples/OECC/images/diagram.png new file mode 100644 index 0000000..5def0a8 Binary files /dev/null and b/examples/OECC/images/diagram.png differ diff --git a/examples/OECC/images/openedge_dashboard.png b/examples/OECC/images/openedge_dashboard.png new file mode 100755 index 0000000..146e276 Binary files /dev/null and b/examples/OECC/images/openedge_dashboard.png differ diff --git a/examples/OECC/images/selecting_a_metric1.png b/examples/OECC/images/selecting_a_metric1.png new file mode 100755 index 0000000..71440d4 Binary files /dev/null and b/examples/OECC/images/selecting_a_metric1.png differ diff --git a/examples/OECC/images/selecting_a_metric2.png b/examples/OECC/images/selecting_a_metric2.png new file mode 100755 index 0000000..c449990 Binary files /dev/null and b/examples/OECC/images/selecting_a_metric2.png differ diff --git a/examples/OECC/scripts/setup.sh b/examples/OECC/scripts/setup.sh new file mode 100755 index 0000000..6afda1d --- /dev/null +++ b/examples/OECC/scripts/setup.sh @@ -0,0 +1,117 @@ +#!/bin/bash + +if [ "$EUID" -eq "0" ] +then + echo "Usage: setup.sh" + echo "Program must be run as a non-root user with sudo access" + exit 1 +fi + +export OPENEDGE_VERSION=12.8.3 +export OECC_VERSION=1.3.0 + +export DEMO=`pwd` + +FILE=PROGRESS_OE_${OPENEDGE_VERSION}_LNX_64.tar.gz +if [ ! -f /install/$FILE ] +then + echo "Prerequisite: OpenEdge ${OPENEDGE_VERSION} media ($FILE) must be found in /install folder." + exit +fi + +FILE=response_${OPENEDGE_VERSION}.ini +if [ ! -f /install/$FILE ] +then + echo "Prerequisite: OpenEdge ${OPENEDGE_VERSION} response.ini file ($FILE) must be found in /install folder." + exit +fi + +FILE=PROGRESS_OECC_SERVER_${OECC_VERSION}_LNX_64.tar.gz +if [ ! -f /install/$FILE ] +then + echo "Prerequisite: OpenEdge Command Center server ${OECC_VERSION} .tar.gz file ($FILE) must be found in /install folder." + exit +fi + +if [ ! -f docker/oecc/$FILE ] +then + cp -vi /install/$FILE docker/oecc/ +fi + +FILE=PROGRESS_OECC_AGENT_${OECC_VERSION}_LNX_64.bin +if [ ! -f /install/$FILE ] +then + echo "Prerequisite: OpenEdge Command Center agent ${OECC_VERSION} .bin file ($FILE) must be found in /install folder." + exit +fi + +if [ ! -f /usr/bin/file ] +then + sudo apt-get update + sudo apt-get install -y file +fi + +if [ ! -f /usr/bin/jq ] +then + sudo apt-get update + sudo apt-get install -y jq +fi + +if [ -d /usr/sbin/dmidecode ] +then + if sudo dmidecode -s bios-version | fgrep -qi amazon + then + PRIVATE_IP_ADDRESS=`curl -s http://169.254.169.254/latest/meta-data/local-ipv4` + else + if sudo dmidecode -s system-manufacturer | fgrep -q "Microsoft Corporation" + then + PRIVATE_IP_ADDRESS=`curl -s -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance?api-version=2021-02-01" | jq -r '.network.interface[0].ipv4.ipAddress[0].privateIpAddress'` + fi + fi +fi + +if [ "$PRIVATE_IP_ADDRESS" == "" ] +then + PRIVATE_IP_ADDRESS=`ip -4 -j a | jq -r '.[1].addr_info[0].local'` +fi + +# echo PRIVATE_IP_ADDRESS: $PRIVATE_IP_ADDRESS + +# Copy config files that need tailoring to the /files +for file in otagentoedb.yaml otagentpasoe.yaml serverInfo.json +do + cp config/$file /install + if [ "${PRIVATE_IP_ADDRESS}" != "" ] + then + sed -i "s/192.168.56.215/${PRIVATE_IP_ADDRESS}/g" /install/$file + fi +done + +if [ ! -f /etc/rc.local ] +then + sudo cp config/rc.local /etc/rc.local + sudo chmod +x /etc/rc.local +fi + +chmod +x ../common/scripts/*.sh + +echo Running install_docker.sh... +../common/scripts/install_docker.sh +echo Running install_openjdk.sh... +../common/scripts/install_openjdk.sh 17 +echo Running install_openedge.sh... +../common/scripts/install_openedge.sh ${OPENEDGE_VERSION} +echo Running create_sports2020.sh... +sudo ../common/scripts/create_sports2020.sh +echo Running create_oepas1.sh... +../common/scripts/create_oepas1.sh + +echo Running docker compose up -d... +cd docker +echo "docker compose up -d" | newgrp docker +cd .. + +echo Running upload_agentkey.sh... +../common/scripts/upload_agentkey.sh +echo Running install_oecc_agent.sh... +../common/scripts/install_oecc_agent.sh diff --git a/examples/OECC/scripts/start.sh b/examples/OECC/scripts/start.sh new file mode 100755 index 0000000..0ab6951 --- /dev/null +++ b/examples/OECC/scripts/start.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# +# Start the OpenEdge Command Center environment. +# + +export DLC=${DLC-/psc/dlc} +export WRKDIR=${WRKDIR-/psc/wrk} + +if [ ! -d "$DLC" ] +then + echo OpenEdge installation was not found. + exit 1 +fi + +if [ ! -d "$WRKDIR" ] +then + echo OpenEdge working directory was not found. + exit 1 +fi + +if ! $DLC/bin/proutil $WRKDIR/sports2020 -C probe liveness +then + echo Starting database broker for Sports2020... + sudo $DLC/bin/proserve $WRKDIR/sports2020 -S 20000 -n 30 +fi + +echo Starting PASOE instance oepas1... +sudo $WRKDIR/oepas1/bin/tcman.sh pasoestart -restart + +echo Running docker compose up -d... +cd docker +echo "docker compose up -d" | newgrp docker +cd .. + +echo Restarting OpenEdge Command Center Agent... +sudo systemctl restart Progress-OpenEdge-Command-Center-Agent.service diff --git a/examples/OECC/scripts/stop.sh b/examples/OECC/scripts/stop.sh new file mode 100755 index 0000000..8dd3177 --- /dev/null +++ b/examples/OECC/scripts/stop.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# +# Stop the OpenEdge Command Center environment. +# + +export DLC=${DLC-/psc/dlc} +export WRKDIR=${WRKDIR-/psc/wrk} + +if [ ! -d "$DLC" ] +then + echo OpenEdge installation was not found. + exit 1 +fi + +if [ ! -d "$WRKDIR" ] +then + echo OpenEdge working directory was not found. + exit 1 +fi + +echo Stopping PASOE instance oepas1... +sudo $WRKDIR/oepas1/bin/tcman.sh stop + +echo Stopping database broker... +sudo $DLC/bin/proshut $WRKDIR/sports2020 -by + +echo Stopping containers ... +cd ~/OpenEdge-Samples/examples/OECC/docker +echo "docker compose down" | newgrp docker diff --git a/examples/OECC/scripts/test.sh b/examples/OECC/scripts/test.sh new file mode 100755 index 0000000..2d1c704 --- /dev/null +++ b/examples/OECC/scripts/test.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# +# Test the demo environment. +# + +echo -n "Testing OEPAS1 instance... " +RECORDS=`curl -s http://localhost:8810/web/customer.p | jq '.dsCustomer.ttCustomer | length'` +if [ "$RECORDS" == "22" ] +then + echo PASSED +else + echo FAILED +fi + +echo "Waiting 30 seconds to ensure data collection from Prometheus... " +sleep 30 + +echo -n "Testing Prometheus endpoint at OTLP Collector... " +if curl -s http://localhost:9464/metrics > /tmp/$$.tmp +then + echo PASSED +else + echo FAILED +fi + +echo -n "Testing response from Prometheus endpoint at OTLP Collector... " +LINES=`wc -l /tmp/$$.tmp | awk '{ print $1 }'` +if [ "$LINES" -gt 0 ] +then + echo PASSED +else + echo FAILED +fi + +echo -n "Check for DB_ entries... " +LINES=`fgrep DB_ /tmp/$$.tmp | wc -l | awk '{ print $1 }'` +if [ "$LINES" -gt 0 ] +then + echo PASSED +else + echo FAILED +fi + +echo -n "Check for PASOE_ entries... " +LINES=`fgrep PASOE_ /tmp/$$.tmp | wc -l | awk '{ print $1 }'` +if [ "$LINES" -gt 0 ] +then + echo PASSED +else + echo FAILED +fi + +echo -n "Testing Prometheus metrics... " +LINES=`curl -s http://localhost:9090/metrics | wc -l | awk '{ print $1 }'` +if [ "$LINES" -gt 0 ] +then + echo PASSED +else + echo FAILED +fi + +echo -n "Testing Grafana metrics... " +LINES=`curl -s http://localhost:3000/metrics | wc -l | awk '{ print $1 }'` +if [ "$LINES" -gt 0 ] +then + echo PASSED +else + echo FAILED +fi + +rm /tmp/$$.tmp diff --git a/examples/README.md b/examples/README.md index 2ad48a1..1be9bd2 100644 --- a/examples/README.md +++ b/examples/README.md @@ -8,6 +8,10 @@ One or more pieces of ABL code which are self-contained and demonstrate a key fe - Concepts and features available in the ABL, from procedural to Object-Oriented examples. +### OpenEdge Command Center + +- Demo scripts to setup an OpenEdge Command Center environment with support for OpenTelemetry metrics. + ### Kafka Consumer/Producer - Highlights the Kafka consumer and producer code available in OpenEdge 12.5 and later. diff --git a/examples/common/scripts/README.md b/examples/common/scripts/README.md new file mode 100644 index 0000000..0922a3a --- /dev/null +++ b/examples/common/scripts/README.md @@ -0,0 +1,3 @@ +# common/scripts # + +Bash shell scripts common to multiple OpenEdge examples in the repo. diff --git a/examples/common/scripts/create_oepas1.sh b/examples/common/scripts/create_oepas1.sh new file mode 100755 index 0000000..59892ad --- /dev/null +++ b/examples/common/scripts/create_oepas1.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# +# Script to create PASOE instance oepas1 for the corresponding demo. +# + +# Environment Variables +# DEMO: Location of demo files + +# set -x +if [ "$DEMO" == "" ] +then + echo "Environment variable 'DEMO' is not defined" + exit 1 +fi + +if [ ! -d /psc/wrk/oepas1 ] +then + echo "Creating PASOE instance (oepas1)..." + cd /psc/wrk + time sudo DLC=/psc/dlc /psc/dlc/bin/pasman create -v oepas1 + + sudo ./oepas1/bin/oeprop.sh -f $DEMO/config/oepas1.properties + sudo cp $DEMO/config/customer.p /psc/wrk/oepas1/openedge + + sudo ./oepas1/bin/tcman.sh pasoestart -restart +fi diff --git a/examples/common/scripts/create_sports2020.sh b/examples/common/scripts/create_sports2020.sh new file mode 100755 index 0000000..8fb2b55 --- /dev/null +++ b/examples/common/scripts/create_sports2020.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# +# Script to create instance of the sports2020 database with DBA user. +# + +# set -x + +if [ ! -f /psc/wrk/sports2020.db ] +then + echo "Creating OpenEdge database instance (sports2020)..." + export DLC=/psc/dlc + export PATH=$DLC/bin:$PATH + cd /psc/wrk + cat > create_dba.sql < /dev/null + sudo apt-get update + sudo apt-get -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin + sudo usermod -aG docker $USER +fi diff --git a/examples/common/scripts/install_oecc_agent.sh b/examples/common/scripts/install_oecc_agent.sh new file mode 100755 index 0000000..8b7c17a --- /dev/null +++ b/examples/common/scripts/install_oecc_agent.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# +# Script to install OpenEdge Command Center Agent. +# + +# Environment Variables +# DEMO: Location of demo files +# OECC_VERSION: Version of OpenEdge Command Center + +# set -x +if [ "$DEMO" == "" ] +then + echo "Environment variable 'DEMO' is not defined" + exit 1 +fi +if [ "$OECC_VERSION" == "" ] +then + echo "Environment variable 'OECC_VERSION' is not defined" + exit 1 +fi + +VERSION=${OECC_VERSION} + +if [ ! -d /usr/oecc_agent ] +then + echo "Installing OpenEdge Command Center Agent..." + sudo chmod +rx /install/PROGRESS_OECC_AGENT_${VERSION}_LNX_64.bin + sudo /install/PROGRESS_OECC_AGENT_${VERSION}_LNX_64.bin \ + -i silent \ + -f $DEMO/config/response_agent_${VERSION}.properties + + sudo cp /install/otagentoedb.yaml /usr/oecc_agent/conf + sudo cp /install/otagentpasoe.yaml /usr/oecc_agent/conf + + sudo systemctl restart Progress-OpenEdge-Command-Center-Agent.service +fi diff --git a/examples/common/scripts/install_openedge.sh b/examples/common/scripts/install_openedge.sh new file mode 100755 index 0000000..bb4a7c9 --- /dev/null +++ b/examples/common/scripts/install_openedge.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# +# Script to install OpenEdge on Linux using silent install. +# + +# set -x +if [ "$1" == "" ] +then + echo "Usage: $0 " + echo "Example: $0 12.6" + exit +fi + +function show_version() { + cat /psc/dlc/version +} + +if [ -d /psc/dlc ] +then +# show_version + exit +fi + +echo "Installing OpenEdge..." + +FILES=/install +VERSION=$1 + +cd $FILES + +OPENEDGE_PACKAGE=`ls PROGRESS_OE_${VERSION}*.tar.gz 2> /dev/null | sort | tail -1` + +if [ "$OPENEDGE_PACKAGE" == "" ] +then + echo "OpenEdge media was not found at $FILES." + echo "Exiting." + exit 1 +fi + +mkdir -p /tmp/openedge +tar xzf $FILES/$OPENEDGE_PACKAGE -C /tmp/openedge +cd /tmp +time sudo ./openedge/proinst -b /install/response_${VERSION}.ini -l /tmp/install.log +rm -rf /tmp/openedge +cd / + +# show_version diff --git a/examples/common/scripts/install_openjdk.sh b/examples/common/scripts/install_openjdk.sh new file mode 100755 index 0000000..d6934fc --- /dev/null +++ b/examples/common/scripts/install_openjdk.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# +# Script to install OpenJDK by downloading the latest version from GitHub. +# + +# set -x + +if [ "$1" == "" ] +then + echo "Usage: $0 " + echo "Example: $0 17" + exit +fi + +function show_version() { + /usr/lib/jvm/jdk/bin/java -version 2>&1 | fgrep "OpenJDK Runtime" +} + +if [ -d /usr/lib/jvm/jdk ] +then + # show_version + exit +fi + +echo "Installing OpenJDK..." + +FILES=/install +VERSION=$1 +OWNER=adoptium +REPO=temurin${VERSION}-binaries +API_URL=https://api.github.com/repos/${OWNER}/${REPO}/releases + +cd $FILES + +LATEST_JDK=`curl -s ${API_URL}/latest | jq -r ".name"` +JDK_NAME=`cat JDK_NAME 2> /dev/null` +PACKAGE_NAME=`cat JDK_PACKAGE_NAME 2> /dev/null` + +if [ "$JDK_NAME" != "$LATEST_JDK" ] +then + URL=`curl -s ${API_URL}/tags/${LATEST_JDK} | jq -r '.assets[] | select(.content_type == "application/gzip") | select(.name | contains("jdk_x64_linux_hotspot")) | .browser_download_url'` + PACKAGE_NAME=`basename $URL` + wget -q $URL + echo $LATEST_JDK > JDK_NAME + echo $PACKAGE_NAME > JDK_PACKAGE_NAME +fi + +# echo "DEBUG: " $PACKAGE_NAME +if [ ! -d /usr/lib/jvm/jdk ] +then + sudo mkdir -p /usr/lib/jvm/jdk/ + sudo tar xzf $PACKAGE_NAME -C /usr/lib/jvm/jdk/ --strip-components=1 +fi + +# show_version diff --git a/examples/common/scripts/upload_agentkey.sh b/examples/common/scripts/upload_agentkey.sh new file mode 100755 index 0000000..0a98616 --- /dev/null +++ b/examples/common/scripts/upload_agentkey.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# +# Script to upload a known agent key to OpenEdge Command Center. +# + +# set -x + +OECC_USER_NAME=admin +OECC_USER_PASSWORD=admin + +sleep 5 + +ID_TOKEN=`curl http://localhost:8000/api/auth/login \ + -s \ + -X POST \ + -H "Content-type: application/json" \ + -d "{ \"userName\": \"$OECC_USER_NAME\", \"password\": \"$OECC_USER_PASSWORD\" }" | jq -r '.idToken'` + +jq '{ agentKey: .agentKey, agentKeyName: .agentKeyName }' /install/serverInfo.json > /tmp/payload.json + +curl http://localhost:8000/api/admin/agentKeys \ + -s \ + -X POST \ + -H "Content-type: application/json" \ + -H "Authorization: Bearer $ID_TOKEN" \ + -d "`jq '{ agentKey: .agentKey, agentKeyName: .agentKeyName }' /install/serverInfo.json`"