Skip to content

Commit

Permalink
Merge pull request #30 from jefw/issue-3
Browse files Browse the repository at this point in the history
Closes #3
  • Loading branch information
tomschenkjr committed Dec 9, 2015
2 parents 71b309a + 1ab7c3c commit d9060e5
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Log/A_DatasetLogs.bat
@@ -0,0 +1,7 @@
@echo off
IF [%1] == [] GOTO USAGE
dir /b | find "%1"
exit /B

:USAGE
echo Usage: A_DatasetLogs.bat StringToFindInLogName
8 changes: 8 additions & 0 deletions Log/A_ETLRuntimes.bat
@@ -0,0 +1,8 @@
@echo off
IF [%1] == [] GOTO USAGE
type *%1* 2>nul | find "Processing ended after"
exit /B

:USAGE
echo Usage: A_ETLRuntimes.bat StringToFindInLogName
exit /B 1
16 changes: 16 additions & 0 deletions Log/A_RunETL.bat
@@ -0,0 +1,16 @@
@echo off
IF [%1] == [] GOTO USAGE

REM Sanity check
echo %1 | findstr /r "\<[a-Z0123456789][a-Z0123456789][a-Z0123456789][a-Z0123456789]-[a-Z0123456789][a-Z0123456789][a-Z0123456789][a-Z0123456789]\>"
IF %ERRORLEVEL% NEQ 0 (
echo Invalid Dataset4x4
exit /B 1
)

schtasks /Query /FO list /V | FOR /F "tokens=2 DELIMS=:" %%f in ('findstr /RC:"^Task To Run"') do @FOR /F "tokens=* delims= " %%a in ('@echo %%f') do @echo %%a | FOR /F "tokens=*" %%b in ('find "%1"') do @call %%b
exit /B

:USAGE
echo Usage: A_RunETL.bat Dataset4x4
exit /B 1
5 changes: 5 additions & 0 deletions Log/A_RunETL.sh
Expand Up @@ -3,6 +3,11 @@ then
echo "Usage: A_RunETL.sh Dataset4x4"
exit 1
else
# Sanity check
if [ -z $(echo "$1" | grep "^[a-zA-Z0-9]\{4\}-[a-zA-Z0-9]\{4\}$") ]; then
echo "Invalid Dataset4x4"
exit 1
fi
CRONTAB_LINE="crontab -l | grep $1 | cut -d ' ' -f 6-" #Returns the 6th and subsequent "fields" from the crontab line containing the 4x4, with the field delimiter being a space. Result: Skips the scheduling part and returns the actual command.
COMMAND_TO_RUN=$(eval $CRONTAB_LINE)
eval $COMMAND_TO_RUN
Expand Down
18 changes: 18 additions & 0 deletions Log/A_TodayLogs.bat
@@ -0,0 +1,18 @@
@echo off
REM Specify the 4x4 values to exclude, separated by space characters
set DATASETS_TO_EXCLUDE="n4j6-wkkf t2qx-9pjd qmqz-2xku 97wa-y6ff"
set TODAY=%date:~10,4%%date:~4,2%%date:~7,2%

IF [%1] == [] GOTO DEFAULT
IF [%1] == [-e] GOTO EXCLUDE

echo Usage: A_Today.bat [-e]
echo -e Exclude a pre-specified set of datasets by 4x4. generally those that run frequently and would clutter the output.
exit /B 1

:DEFAULT
dir /b | find "%TODAY%"
exit /B

:EXCLUDE
dir /b | find "%TODAY%" | findstr /V %DATASETS_TO_EXCLUDE%
46 changes: 45 additions & 1 deletion docs/utilities-for-administering-etls.rst
Expand Up @@ -49,10 +49,21 @@ Show all log files

**Returns:** Will list the log files associated for a user-specified ETL job. The output is displayed in the terminal.

**File:** Log/A_DatasetLogs.bat (Windows only)

**Description:** Shows all of the log files associated with a dataset.

**Usage:** Open the command prompt window and type the name of a dataset::
> cd \path\to\directory\open-data-etl-utility-kit\
> \Log\A_DatasetLogs.bat Name_of_dataset
**Returns:** Will list the log files associated for a user-specified ETL job. The output is displayed in the command prompt window.

Summarize ETL run times
-----------------------

**File:** Log/A_DatasetLogs.sh (MacOS X/Linux/Unix only)
**File:** Log/A_ETLRuntimes.sh (MacOS X/Linux/Unix only)

**Description:** Shows the runtime for ETLs with a dataset.

Expand All @@ -63,6 +74,17 @@ Summarize ETL run times

**Returns:** The output will show the total run-times recorded in log files for the user-specified ETL. The output is displayed in the terminal.

**File:** Log/A_ETLRuntimes.bat (Windows only)

**Description:** Shows the runtime for ETLs with a dataset.

**Usage:** Open the command prompt window and type the name of a dataset::

> cd \path\to\directory\open-data-etl-utility-kit\
> Log\A_ETLRuntimes.bat Name_of_dataset

**Returns:** The output will show the total run-times recorded in log files for the user-specified ETL. The output is displayed in the command prompt window.

Show today's ETL logs
---------------------

Expand All @@ -76,6 +98,16 @@ Show today's ETL logs

**Returns:** The output will show the list of log files which were generated today. With the *-e* parameter, a group of datasets specified in a parameter at the beginning of the script will be excluded (generally, those that run frequently and would clutter the output). The output is displayed in the terminal.

**File:** Log/A_TodayLogs.bat (Windows only)

**Description:** Shows log files which were created today

**Usage:** Open the command prompt window and run the command::

> sh \path\to\directory\open-data-etl-utility-kit\Log\A_TodayLogs.bat [-e]

**Returns:** The output will show the list of log files which were generated today. With the *-e* parameter, a group of datasets specified in a parameter at the beginning of the script will be excluded (generally, those that run frequently and would clutter the output). The output is displayed in the command prompt window.

Run a specific ETL
---------------------

Expand All @@ -89,3 +121,15 @@ Run a specific ETL
$ sh Log/A_RunETL.sh Name_of_dataset

**Returns:** The script will find and run the ETL command for the specified dataset. The output will show the command run so the user can confirm it was the intended dataset ETL.


**File:** Log/A_RunETL.bat (Windows only)

**Description:** Performs a one-time run of an ETL normally run on a scheduled basis through by the Windows task scheduler. This file need not be in the Log directory to run correctly. It does not use the log files and is in the Log directory only to keep it with other scripts.

**Usage:** Open the terminal and type the name of a dataset::

$ cd \path\to\directory\open-data-etl-utility-kit\
$ Log\A_RunETL.bat Name_of_dataset

**Returns:** The script will find and run the ETL command for the specified dataset. The output will show the command run so the user can confirm it was the intended dataset ETL.

0 comments on commit d9060e5

Please sign in to comment.