I have a DAG of three tasks. The first one checks if csv file exists, the second creates MySQL table and the third one inserts the data from csv file into MySQL table. First two tasks succeed but the last one not saying that due to secure-file-priv option I have no rigts to insert data from file to database.
default_args = {
"owner": "airflow",
"start_date": airflow.utils.dates.days_ago(1),
"retries": 1,
"retry_delay": timedelta(seconds=5)
}
with DAG('sql_operator_from_csv_to_mysql',default_args=default_args,schedule_interval='#daily', template_searchpath=['/opt/airflow/sql_files_mysql'], catchup=True) as dag:
t1 = BashOperator(task_id='check_file_exists', bash_command='ls /opt/airflow/store_files/students_data.csv | sha1sum', retries=2, retry_delay=timedelta(seconds=15))
t2 = MySqlOperator(task_id='create_mysql_table', mysql_conn_id="mysql_conn", sql="create_table.sql")
t3 = MySqlOperator(task_id='insert_into_table', mysql_conn_id="mysql_conn", sql="insert_into_table.sql")
SQL statement:
LOAD DATA INFILE '/store_files/students_data.csv' INTO TABLE students_db FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' IGNORE 1 ROWS;
mysql.cnf file is as following.
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
secure-file-priv= ""
I have tried to mark 'secure-file-priv' option as an empty string and showing the location of a csv file but none of them are working.
secure-file-priv= ""
secure-file-priv= "/opt/airflow/store_files"
Error message saying:
[2022-06-12, 09:44:24 UTC] {taskinstance.py:1774} ERROR - Task failed with exception
Traceback (most recent call last):
File "/home/airflow/.local/lib/python3.7/site-packages/airflow/providers/mysql/operators/mysql.py", line 84, in execute
hook.run(self.sql, autocommit=self.autocommit, parameters=self.parameters)
File "/home/airflow/.local/lib/python3.7/site-packages/airflow/hooks/dbapi.py", line 205, in run
self._run_command(cur, sql_statement, parameters)
File "/home/airflow/.local/lib/python3.7/site-packages/airflow/hooks/dbapi.py", line 229, in _run_command
cur.execute(sql_statement)
File "/home/airflow/.local/lib/python3.7/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/home/airflow/.local/lib/python3.7/site-packages/MySQLdb/cursors.py", line 319, in _query
db.query(q)
File "/home/airflow/.local/lib/python3.7/site-packages/MySQLdb/connections.py", line 254, in query
_mysql.connection.query(self, query)
MySQLdb._exceptions.OperationalError: (1290, 'The MySQL server is running with the --secure-file-priv option so it cannot execute this statement')
[2022-06-12, 09:44:24 UTC] {taskinstance.py:1288} INFO - Marking task as FAILED. dag_id=sql_operator_from_csv_to_mysql, task_id=insert_into_table, execution_date=20220612T094413, start_date=20220612T094424, end_date=20220612T094424
[2022-06-12, 09:44:24 UTC] {standard_task_runner.py:98} ERROR - Failed to execute job 10 for task insert_into_table ((1290, 'The MySQL server is running with the --secure-file-priv option so it cannot execute this statement'); 1190)
[2022-06-12, 09:44:24 UTC] {local_task_job.py:154} INFO - Task exited with return code 1
[2022-06-12, 09:44:24 UTC] {local_task_job.py:264} INFO - 0 downstream tasks scheduled from follow-on schedule check
Any ideas to solve this problem?
I have tried to make some minor modifications in the docker-compose.yaml file.
My docker-compose.yaml file is as below
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# Basic Airflow cluster configuration for CeleryExecutor with Redis and PostgreSQL.
#
# WARNING: This configuration is for local development. Do not use it in a production deployment.
#
# This configuration supports basic configuration using environment variables or an .env file
# The following variables are supported:
#
# AIRFLOW_IMAGE_NAME - Docker image name used to run Airflow.
# Default: apache/airflow:2.3.2
# AIRFLOW_UID - User ID in Airflow containers
# Default: 50000
# Those configurations are useful mostly in case of standalone testing/running Airflow in test/try-out mode
#
# _AIRFLOW_WWW_USER_USERNAME - Username for the administrator account (if requested).
# Default: airflow
# _AIRFLOW_WWW_USER_PASSWORD - Password for the administrator account (if requested).
# Default: airflow
# _PIP_ADDITIONAL_REQUIREMENTS - Additional PIP requirements to add when starting all containers.
# Default: ''
#
# Feel free to modify this file to suit your needs.
---
version: '3'
x-airflow-common:
&airflow-common
# In order to add custom dependencies or upgrade provider packages you can use your extended image.
# Comment the image line, place your Dockerfile in the directory where you placed the docker-compose.yaml
# and uncomment the "build" line below, Then run `docker-compose build` to build the images.
image: ${AIRFLOW_IMAGE_NAME:-apache/airflow:2.3.2}
# build: .
environment:
&airflow-common-env
AIRFLOW__CORE__EXECUTOR: CeleryExecutor
AIRFLOW__DATABASE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow#postgres/airflow
# For backward compatibility, with Airflow <2.3
AIRFLOW__CORE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow#postgres/airflow
AIRFLOW__CELERY__RESULT_BACKEND: db+postgresql://airflow:airflow#postgres/airflow
AIRFLOW__CELERY__BROKER_URL: redis://:#redis:6379/0
AIRFLOW__CORE__FERNET_KEY: ''
AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION: 'true'
AIRFLOW__CORE__LOAD_EXAMPLES: 'true'
AIRFLOW__API__AUTH_BACKENDS: 'airflow.api.auth.backend.basic_auth'
_PIP_ADDITIONAL_REQUIREMENTS: ${_PIP_ADDITIONAL_REQUIREMENTS:-}
volumes:
- ./dags:/usr/local/airflow/dags
- ./store_files:/usr/local/airflow/store_files_airflow
- ./sql_files_mysql:/usr/local/airflow/sql_files
user: "${AIRFLOW_UID:-50000}:0"
depends_on:
&airflow-common-depends-on
redis:
condition: service_healthy
postgres:
condition: service_healthy
services:
postgres:
image: postgres:13
environment:
POSTGRES_USER: airflow
POSTGRES_PASSWORD: airflow
POSTGRES_DB: airflow
volumes:
- postgres-db-volume:/var/lib/postgresql/data
healthcheck:
test: ["CMD", "pg_isready", "-U", "airflow"]
interval: 5s
retries: 5
restart: always
redis:
image: redis:latest
expose:
- 6379
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 30s
retries: 50
restart: always
mysql:
image: mysql:latest
environment:
- MYSQL_ROOT_PASSWORD=airflow
volumes:
- ./store_files:/var/lib/mysql-files
- ./mysql.cnf:/etc/mysql/mysql.cnf
restart: always
airflow-webserver:
<<: *airflow-common
command: webserver
ports:
- 8080:8080
healthcheck:
test: ["CMD", "curl", "--fail", "http://localhost:8080/health"]
interval: 10s
timeout: 10s
retries: 5
restart: always
depends_on:
<<: *airflow-common-depends-on
airflow-init:
condition: service_completed_successfully
airflow-scheduler:
<<: *airflow-common
command: scheduler
healthcheck:
test: ["CMD-SHELL", 'airflow jobs check --job-type SchedulerJob --hostname "$${HOSTNAME}"']
interval: 10s
timeout: 10s
retries: 5
restart: always
depends_on:
<<: *airflow-common-depends-on
airflow-init:
condition: service_completed_successfully
airflow-worker:
<<: *airflow-common
command: celery worker
healthcheck:
test:
- "CMD-SHELL"
- 'celery --app airflow.executors.celery_executor.app inspect ping -d "celery#$${HOSTNAME}"'
interval: 10s
timeout: 10s
retries: 5
environment:
<<: *airflow-common-env
# Required to handle warm shutdown of the celery workers properly
# See https://airflow.apache.org/docs/docker-stack/entrypoint.html#signal-propagation
DUMB_INIT_SETSID: "0"
restart: always
depends_on:
<<: *airflow-common-depends-on
airflow-init:
condition: service_completed_successfully
airflow-triggerer:
<<: *airflow-common
command: triggerer
healthcheck:
test: ["CMD-SHELL", 'airflow jobs check --job-type TriggererJob --hostname "$${HOSTNAME}"']
interval: 10s
timeout: 10s
retries: 5
restart: always
depends_on:
<<: *airflow-common-depends-on
airflow-init:
condition: service_completed_successfully
airflow-init:
<<: *airflow-common
entrypoint: /bin/bash
# yamllint disable rule:line-length
command:
- -c
- |
function ver() {
printf "%04d%04d%04d%04d" $${1//./ }
}
airflow_version=$$(gosu airflow airflow version)
airflow_version_comparable=$$(ver $${airflow_version})
min_airflow_version=2.2.0
min_airflow_version_comparable=$$(ver $${min_airflow_version})
if (( airflow_version_comparable < min_airflow_version_comparable )); then
echo
echo -e "\033[1;31mERROR!!!: Too old Airflow version $${airflow_version}!\e[0m"
echo "The minimum Airflow version supported: $${min_airflow_version}. Only use this or higher!"
echo
exit 1
fi
if [[ -z "${AIRFLOW_UID}" ]]; then
echo
echo -e "\033[1;33mWARNING!!!: AIRFLOW_UID not set!\e[0m"
echo "If you are on Linux, you SHOULD follow the instructions below to set "
echo "AIRFLOW_UID environment variable, otherwise files will be owned by root."
echo "For other operating systems you can get rid of the warning with manually created .env file:"
echo " See: https://airflow.apache.org/docs/apache-airflow/stable/start/docker.html#setting-the-right-airflow-user"
echo
fi
one_meg=1048576
mem_available=$$(($$(getconf _PHYS_PAGES) * $$(getconf PAGE_SIZE) / one_meg))
cpus_available=$$(grep -cE 'cpu[0-9]+' /proc/stat)
disk_available=$$(df / | tail -1 | awk '{print $$4}')
warning_resources="false"
if (( mem_available < 4000 )) ; then
echo
echo -e "\033[1;33mWARNING!!!: Not enough memory available for Docker.\e[0m"
echo "At least 4GB of memory required. You have $$(numfmt --to iec $$((mem_available * one_meg)))"
echo
warning_resources="true"
fi
if (( cpus_available < 2 )); then
echo
echo -e "\033[1;33mWARNING!!!: Not enough CPUS available for Docker.\e[0m"
echo "At least 2 CPUs recommended. You have $${cpus_available}"
echo
warning_resources="true"
fi
if (( disk_available < one_meg * 10 )); then
echo
echo -e "\033[1;33mWARNING!!!: Not enough Disk space available for Docker.\e[0m"
echo "At least 10 GBs recommended. You have $$(numfmt --to iec $$((disk_available * 1024 )))"
echo
warning_resources="true"
fi
if [[ $${warning_resources} == "true" ]]; then
echo
echo -e "\033[1;33mWARNING!!!: You have not enough resources to run Airflow (see above)!\e[0m"
echo "Please follow the instructions to increase amount of resources available:"
echo " https://airflow.apache.org/docs/apache-airflow/stable/start/docker.html#before-you-begin"
echo
fi
mkdir -p /sources/logs /sources/dags /sources/plugins
chown -R "${AIRFLOW_UID}:0" /sources/{logs,dags,plugins}
exec /entrypoint airflow version
# yamllint enable rule:line-length
environment:
<<: *airflow-common-env
_AIRFLOW_DB_UPGRADE: 'true'
_AIRFLOW_WWW_USER_CREATE: 'true'
_AIRFLOW_WWW_USER_USERNAME: ${_AIRFLOW_WWW_USER_USERNAME:-airflow}
_AIRFLOW_WWW_USER_PASSWORD: ${_AIRFLOW_WWW_USER_PASSWORD:-airflow}
_PIP_ADDITIONAL_REQUIREMENTS: ''
user: "0:0"
volumes:
- .:/sources
airflow-cli:
<<: *airflow-common
profiles:
- debug
environment:
<<: *airflow-common-env
CONNECTION_CHECK_MAX_COUNT: "0"
# Workaround for entrypoint issue. See: https://github.com/apache/airflow/issues/16252
command:
- bash
- -c
- airflow
# You can enable flower by adding "--profile flower" option e.g. docker-compose --profile flower up
# or by explicitly targeted on the command line e.g. docker-compose up flower.
# See: https://docs.docker.com/compose/profiles/
flower:
<<: *airflow-common
command: celery flower
profiles:
- flower
ports:
- 5555:5555
healthcheck:
test: ["CMD", "curl", "--fail", "http://localhost:5555/"]
interval: 10s
timeout: 10s
retries: 5
restart: always
depends_on:
<<: *airflow-common-depends-on
airflow-init:
condition: service_completed_successfully
volumes:
postgres-db-volume:
And the sql.conf file is as below
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
secure-file-priv= ""
I am a new to terraform and struggling with using templatefile to pass a list to my script.yml.
I can pass the list devnames to a bash script without issues but I cannot figure it out with script.yml. With the belw configuration, when I run terraform plan, the list just shows as $devnames and does not unpack the content of the list devnames.
Can you please assist?
resource "aws_imagebuilder_component" "devmappings" {
name = "devmappings"
platform = "Linux"
data = templatefile("${path.module}/script.yml", {
device_names = join(" ", local.devnames)
})
version = "1.0.0"
}
I need to execute script.yml against the content of the list devnames
name: 'myName'
description: 'myDescrip'
schemaVersion: 1.0
phases:
- name: build
steps:
- name: Install-prereqs
action: ExecuteBash
inputs:
commands: ["echo $devnames; for i in `seq 0 26`; do; nvme_blkd='/dev/nvme$${i}n1'; if [ -e $nvme_blkd ]; then; mapdevs='$${devnames[i]}'; if [[ -z '$mapdevs' ]]; then; mapdevs='$${devnames[i]}'; fi; if [[ '$mapdevs' != /dev/* ]]; then; mapdevs='/dev/$${mapdevs}'; fi; if [ -e $mapdevs ]; then; echo 'path exists: $${mapdevs}'; else; ln -s $nvme_blkd $mapdevs; echo 'symlink created: $${nvme_blkd} to $${mapdevs}'; fi; fi; done"]
I have my WordPress instance setup, connected to the database and functioning perfectly when accessed via the docker host IP and port 2142 (mapped to 80.) I have this in my Nginx Proxy Manager the same way I do for all of my other proxy hosts and get 502 bad gateway (openresty) SSL enabled or Disabled makes no difference.
Compose file:
services:
wordpress:
image: wordpress:latest
volumes:
- wordpress_data:/var/www/html
ports:
- "2142:80"
restart: unless-stopped
environment:
- WORDPRESS_DB_HOST=REDACTED
- WORDPRESS_DB_PASSWORD=REDACTED
- WORDPRESS_DB_USER=REDACTED
- WORDPRESS_DB_NAME=REDACTED
- WORDPRESS_TABLE_PREFIX=REDACTED
volumes:
wordpress_data: {}
I have recently fixed this. This is the code:
version: '3'
services:
landing-db:
container_name: ${CONTAINER_DB_NAME}
image: ${DB-IMAGE:-mariadb}:${DB_VERSION:-latest}
restart: unless-stopped
volumes:
- ${DB_FILES}:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
landing-wordpress:
depends_on:
- landing-db
container_name: ${CONTAINER_SITE_NAME}
#image: ${SITE_IMAGE:-wordpress}:${SITE_VERSION:-latest}
build:
context: ${DOCKERFILE_CONTEXT}
dockerfile: ${DOCKERFILE_NAME}
restart: unless-stopped
volumes:
- ${SITE_FILES}:/var/www/html
- ${PHP_INI}:/usr/local/etc/php/conf.d/php.ini
environment:
WORDPRESS_DB_HOST: ${CONTAINER_DB_NAME}
WORDPRESS_DB_NAME: ${MYSQL_DATABASE}
WORDPRESS_DB_USER: ${MYSQL_USER}
WORDPRESS_DB_PASSWORD: ${MYSQL_PASSWORD}
WORDPRESS_TABLE_PREFIX: ${WORDPRESS_TABLE_PREFIX}
logging:
options:
max-size: ${LOGGING_OPTIONS_MAX_SIZE:-200k}
links:
- landing-db
landing-nginx:
image: nginx:alpine
container_name: landing-nginx
restart: unless-stopped
volumes:
- ${NGINX_CONFIG}:/etc/nginx/conf.d
#- ${NGINX_MY_INCLUDE_FILES}:/etc/nginx/my_include_files
- ${SITE_FILES}:/var/www/html
expose:
- "80"
#ports:
# - "8080:80"
links:
- landing-wordpress
environment:
- VIRTUAL_HOST=${DOMAIN},www.${DOMAIN}
#- LETSENCRYPT_HOST=${DOMAIN},www.${DOMAIN}
#- LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
networks:
default:
name: ${NETWORK}
I also have a .env file where everything with ${variable_name} is specified.
I built this with dockerfile:
#
# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh"
#
# PLEASE DO NOT EDIT IT DIRECTLY.
#
FROM php:8.1-fpm-alpine
# persistent dependencies
RUN set -eux; \
apk add --no-cache \
# in theory, docker-entrypoint.sh is POSIX-compliant, but priority is a working, consistent image
bash \
# Ghostscript is required for rendering PDF previews
ghostscript \
# Alpine package for "imagemagick" contains ~120 .so files, see: https://github.com/docker-library/wordpress/pull/497
imagemagick \
;
# install the PHP extensions we need (https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions)
RUN set -ex; \
\
apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
freetype-dev \
icu-dev \
imagemagick-dev \
libjpeg-turbo-dev \
libpng-dev \
libwebp-dev \
libzip-dev \
; \
\
docker-php-ext-configure gd \
--with-freetype \
--with-jpeg \
--with-webp \
; \
docker-php-ext-install -j "$(nproc)" \
bcmath \
exif \
gd \
intl \
mysqli \
zip \
pdo_mysql \
; \
# WARNING: imagick is likely not supported on Alpine: https://github.com/Imagick/imagick/issues/328
# https://pecl.php.net/package/imagick
pecl install imagick-3.6.0; \
docker-php-ext-enable imagick; \
rm -r /tmp/pear; \
\
# some misbehaving extensions end up outputting to stdout 🙈 (https://github.com/docker-library/wordpress/issues/669#issuecomment-993945967)
out="$(php -r 'exit(0);')"; \
[ -z "$out" ]; \
err="$(php -r 'exit(0);' 3>&1 1>&2 2>&3)"; \
[ -z "$err" ]; \
\
extDir="$(php -r 'echo ini_get("extension_dir");')"; \
[ -d "$extDir" ]; \
runDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive "$extDir" \
| tr ',' '\n' \
| sort -u \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
)"; \
apk add --no-network --virtual .wordpress-phpexts-rundeps $runDeps; \
apk del --no-network .build-deps; \
\
! { ldd "$extDir"/*.so | grep 'not found'; }; \
# check for output like "PHP Warning: PHP Startup: Unable to load dynamic library 'foo' (tried: ...)
err="$(php --version 3>&1 1>&2 2>&3)"; \
[ -z "$err" ]
# set recommended PHP.ini settings
# see https://secure.php.net/manual/en/opcache.installation.php
RUN set -eux; \
docker-php-ext-enable opcache; \
{ \
echo 'opcache.memory_consumption=128'; \
echo 'opcache.interned_strings_buffer=8'; \
echo 'opcache.max_accelerated_files=4000'; \
echo 'opcache.revalidate_freq=2'; \
echo 'opcache.fast_shutdown=1'; \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini
# https://wordpress.org/support/article/editing-wp-config-php/#configure-error-logging
RUN { \
# https://www.php.net/manual/en/errorfunc.constants.php
# https://github.com/docker-library/wordpress/issues/420#issuecomment-517839670
echo 'error_reporting = E_ERROR | E_WARNING | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_RECOVERABLE_ERROR'; \
echo 'display_errors = Off'; \
echo 'display_startup_errors = Off'; \
echo 'log_errors = On'; \
echo 'error_log = /dev/stderr'; \
echo 'log_errors_max_len = 1024'; \
echo 'ignore_repeated_errors = On'; \
echo 'ignore_repeated_source = Off'; \
echo 'html_errors = Off'; \
} > /usr/local/etc/php/conf.d/error-logging.ini
RUN set -eux; \
version='5.9.3'; \
sha1='cab576e112c45806c474b3cbe0d1263a2a879adf'; \
\
curl -o wordpress.tar.gz -fL "https://wordpress.org/wordpress-$version.tar.gz"; \
echo "$sha1 *wordpress.tar.gz" | sha1sum -c -; \
\
# upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
tar -xzf wordpress.tar.gz -C /usr/src/; \
rm wordpress.tar.gz; \
\
# https://wordpress.org/support/article/htaccess/
[ ! -e /usr/src/wordpress/.htaccess ]; \
{ \
echo '# BEGIN WordPress'; \
echo ''; \
echo 'RewriteEngine On'; \
echo 'RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]'; \
echo 'RewriteBase /'; \
echo 'RewriteRule ^index\.php$ - [L]'; \
echo 'RewriteCond %{REQUEST_FILENAME} !-f'; \
echo 'RewriteCond %{REQUEST_FILENAME} !-d'; \
echo 'RewriteRule . /index.php [L]'; \
echo ''; \
echo '# END WordPress'; \
} > /usr/src/wordpress/.htaccess; \
\
chown -R www-data:www-data /usr/src/wordpress; \
# pre-create wp-content (and single-level children) for folks who want to bind-mount themes, etc so permissions are pre-created properly instead of root:root
# wp-content/cache: https://github.com/docker-library/wordpress/issues/534#issuecomment-705733507
mkdir wp-content; \
for dir in /usr/src/wordpress/wp-content/*/ cache; do \
dir="$(basename "${dir%/}")"; \
mkdir "wp-content/$dir"; \
done; \
chown -R www-data:www-data wp-content; \
chmod -R 755 wp-content
VOLUME /var/www/html
COPY --chown=www-data:www-data wp-config-docker.php /usr/src/wordpress/
COPY ./docker-entrypoint.sh /usr/local/bin/
RUN ["chmod", "+x", "/usr/local/bin/docker-entrypoint.sh"]
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["php-fpm"]
The docker file is takes from docker-library. You can search it with name "wordpress".
The secret in this case is "expose: 80". It is the port exposed between containers. This will be added on Nginx proxy manager with: {service-name}:{exposed port of nginx service}.
Do not forget to be on the same network.
#!/bin/bash
echo """"""""
now=`date "+%m/%d/%y:%H:%M:%S"`
echo -e "\n\n $now ---CPU/MEM output--- \n\n"
cat /proc/cpuinfo
echo -e "\n\n"
cat /proc/meminfo
echo -e "\n\n"
echo `ulimit -a`
now=`date "+%m/%d/%y:%H:%M:%S"`
echo -e "\n\n $now ---top output--- \n\n"
export TERM=xterm
top -n 1 -U username
top -H -n 1 -U username
echo -e "\n END OF Script"
Tried using
export Term
still getting error as failed to get TTY.
Please advice.
I try to get the list of all the jobs running on a specific client.
When running autorep -J ALL -q I get the following output:
/* ----------------- ### ----------------- */
insert_job: ### job_type: CMD
box_name: ###
command: ###
machine: MACHINE X
owner: autosys
permission:
date_conditions: ###
condition: ###
description: ###
box_terminator: 1
alarm_if_fail: 0
application: ###
/* ----------------- ### ----------------- */
insert_job: ### job_type: CMD
box_name: ###
command: ###
machine: MACHINE Y
owner: autosys
permission:
date_conditions: ###
condition: ###
description: ###
box_terminator: 1
alarm_if_fail: 0
application: ###
...
As you can see, is displayed here the list of ALL the jobs for ALL the clients
What I expect to get is an output as following :
/* ----------------- ### ----------------- */
insert_job: ### job_type: CMD
box_name: ###
command: ###
machine: MACHINE X
owner: autosys
permission:
date_conditions: ###
condition: ###
description: ###
box_terminator: 1
alarm_if_fail: 0
application: ###
/* ----------------- ### ----------------- */
insert_job: ### job_type: CMD
box_name: ###
command: ###
machine: MACHINE X
owner: autosys
permission:
date_conditions: ###
condition: ###
description: ###
box_terminator: 1
alarm_if_fail: 0
application: ###
...
Unfortunately the commands autorep -J ALL -q -m MACHINE X doesn't work but give me the following output :
/* ----------------- MACHINE X ----------------- */
insert_machine: MACHINE X
type: a
factor: 1.00
port: 7520
node_name: MACHINE X
agent_name: WA_AGENT
encryption_type: DEFAULT
opsys: windows
character_code: ASCII
I guess that this is the JIL format to add a machine, so what no I expect to get.
Do you know if what I try to do is possible using autosys commands only or if I have to parse the first output trough some regex to finally obtain what I would like to ?
I have created a Autosys Jill parser , using that you can have required info in csv file .After that you can filter required information
first you must have a file which contains required columns to be extracted from jill like
$]cat Jill_Columns
insert_job
job_type
box_name
watch_file
watch_interval
command
date_conditions
machine
owner
permission
condition
days_of_week
exclude_calendar
start_times
description
std_out_file
std_err_file
alarm_if_fail
profile
application
and Jill file which needs to be parsed to csv
Here is the script
Command to run in unix box
sh JillToCsv.sh Your_Jill_Columns Yours_Jill_file
#!/bin/bash
Usage()
{
echo "----------------------------------------------------------------------------"
echo " "
echo " "
echo " "
echo "This script takes two parameter "
echo "First is the file which conatins column names like below for Jill information "
echo "cat Jill_ColumnOrder.txt"
echo "insert_job
job_type
box_name
command
date_conditions
machine
owner
permission
condition
days_of_week
exclude_calendar
start_times
description
std_out_file
std_err_file
alarm_if_fail
profile
application"
echo " "
echo " "
echo " "
echo "Second is the Jill File which needs to be parsed as csv "
echo " "
echo " "
echo " "
echo "----------------------------------------------------------------------------"
}
if [ $# -eq 2 ]
then
echo "File which contains column names : $1"
echo "Input Jill File : $2"
else
echo "Please pass manadatory parameters"
Usage
exit 1
fi
Jill_ColumnOrder=$1
tfile=$2
dos2unix $tfile
final=${tfile}_Parse.csv
rm -f $final
heading=`cat $Jill_ColumnOrder|sed 's/$/#Akhilesh#/g'|sed '$ s/#Akhilesh#$//g'|tr -d '\n'`
line=
filler=1
no_columns=`cat $Jill_ColumnOrder|wc -l`
while [ $filler -lt $no_columns ]
do
filler=`expr $filler + 1`
line=$line`echo -n "#Akhilesh#"`
#echo $line
done
#echo "$heading"
#echo " "
#echo "$line"
echo "$heading">$final
count=1
cat $tfile|sed -r 's/job_type/\njob_type/g'|sed '/^$/d'|sed -r 's/\s+/ /g'|while read kk
do
echo "$kk"|sed -r 's/^[ ]+//g'|grep '\/\* -----------------' # >/dev/null
if [ $? -eq 0 ]
then
count=`expr $count + 1`
echo "$line">>$final
else
PP=`echo $kk|cut -d ':' -f1|tr -d ' '`
#echo "PP : $PP"
val=`echo $kk|cut -d ':' -f2-|sed -r 's/^[ ]+//g'|tr -d '"'|tr -d '\n'`
#echo $val
val=\"$val\"
field=`grep -nw $PP $Jill_ColumnOrder|cut -d':' -f1|tr -d '\n'`
#echo "field : $field"
if [ -z $field ]
then
echo "$PP not there in column list"
else
awk -F'#Akhilesh#' -v OFS=#Akhilesh# -v var="$val" -v var1=$count '{if(NR== var1) $'$field' = var;print}' $final > tmp.parse && mv tmp.parse $final
fi
fi
done
cat $final|sed 's/#Akhilesh#/,/g' > tmp.parse && mv tmp.parse $final
autorep does not support that sorting as of yet. You will need to parse out the output.
Dave
I have finally created a script that does it for me :
#!/bin/ksh
autorep -j ALL -q > alljobs.jil
mkdir /tmp/autosystemp
i=0
while IFS=\| read -r "line"; do
if [ `echo $line | grep '/* ------' | wc -l` -eq 1 ]; then
i=$((i+1))
fi
echo "$line" >> "/tmp/autosystemp/f$i"
done < alljobs.jil
rm tempo/f0
for file in /tmp/autosystemp/*; do
while read line; do
if [ `echo $line | grep "machine: $1" | wc -l` -eq 1 ]; then
cat $file >> "jobs-on-$1.jil"
fi
done < $file
done
rm -rf /tmp/autosystemp
To use it just pass the machine name as an argument to the script