Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

484 Commits

Repository files navigation

oJob-common

version

A set of base oJobs as common building blocks for custom oJobs.

Check the documentation for some of them:

oJob-commonDescription
oJobBasicsBasic init/done logging, sh command execution, etc.
oJobEmailSend emails.
oJobSSHSSH to execute commands and upload/download files.
oJobSQLQuery or execute SQL to a JDBC database.
oJobESLogging to ElasticSearch
oJobNetTesting network connectivity
oJobHTTPdBuilding a simple HTTP(s) server
oJobRestBuilding a simple REST server
oJobBrowseHTTP file browsing with customizable templates
oJobMCPMCP (Model Context Protocol) server functionality
oJobOPackSimplified OPack creation
oJobRAIDSimplified RAID AF operation execution.
oJobWatchDogHelps build a cron-based process "watchdog".
oJobChChannel operations (buffering, waiting)
oJobIOFile I/O operations (copy, move, append, etc.)
oJobTestTesting functionality with assertions and reports
oJobXLSExcel file operations
oJobGITGIT repository operations
oJobDebugDebug utilities

oJobBasics

oJobBasics jobs
oJob Start and Stop helpers
oJob Sleep utilities
oJob sh
oJob Stringify
oJob Set
oJob Path Set
oJob YAML
oJob Sort Array
oJob Map Array
oJob Map
oJob Split into items
oJob Print list
oJob Print args
oJob Get kept result
oJob Keep result
oJob Switch
oJob Sec Get
oJob background processes
oJob From global
oJob Args from JSON
oJob Args from YAML
oJob Jobs Report

oJob Start and Stop helpers

These utility jobs provide a consistent start/stop lifecycle:

  • oJob Start – emits an init log entry when processing begins.
  • oJob Stop – emits a done log entry when processing is complete.
  • oJob Shutdown – equivalent to oJob Stop but runs on shutdown so it can perform cleanup.
  • oJob Exit – terminates the current script immediately with exit code 0.

oJob Sleep utilities

Two convenience jobs delay execution by a fixed interval:

  • oJob Sleep 1s – sleeps for 1 second (1000 ms).
  • oJob Sleep 5s – sleeps for 5 seconds (5000 ms).

oJob sh

This job runs a local shell command and accepts the following arguments:

ArgumentTypeMandatoryDescription
cmdString/ArrayYesThe command to execute (or an array of commands)
quietBooleanNoDetermines if the stdout should be visible or not (default is false)
directoryStringNoSets the working directory for the command
stdinStringNoProvide any stdin needed
exitcodeNumberNoDetermines what exitcode should be consider success (default is 0)
stdoutStringNoCaptures the command stdout when quiet is true
stderrStringNoCaptures the command stderr when quiet is true
prefixStringNoPrefix to prepend to each output line when quiet is false
prefixLogBooleanNoUses log instead of print when applying the prefix (default is false)

Example:

include:
- oJobBasics.yamljobs:
# Example to show 123#
- name: Example Echo 123to : oJob shargs:
cmd: echo 123# Example to show how you can combine multiple commands#
- name: Example with multiple commandsto : oJob shargs:
cmd:
- echo -- [You are in `pwd`] -------------
- >- echo -- [Previous directory] ----------- && cd .. && ls -1 - >- echo -- [Current directory] ------------ && cd . && ls -1# Example to parse output#
- name: Example to parse outputfrom: oJob shargs:
quiet: truecmd : >- curl -X GET "https://httpbin.org/json" -H "accept: application/json"exec: | print("STDOUT = " + stringify(jsonParse(args.stdout))); print("STDERR = " + args.stderr); print("EXITCODE = " + args.exitcode);# Example to prepare cmd#
- name: Example to prepare cmdto : oJob shexec: | args.cmd = "echo " + new Date();todo:
- Example Echo 123
- Example with multiple commands
- Example to parse output
- Example to prepare cmd

oJob Stringify

Prints the result of a JavaScript expression as JSON.

ArgumentTypeMandatoryDescription
nameStringYesJavaScript expression or object to evaluate and stringify
minBooleanNoIf true, produces a minified JSON string

oJob Set

Assigns a value to a global variable.

ArgumentTypeMandatoryDescription
nameStringYesGlobal variable name to assign
valueAnyNoValue to assign (defaults to undefined)

oJob Path Set

Assigns a value to a nested path of a global variable.

ArgumentTypeMandatoryDescription
nameStringYesGlobal variable name to assign
pathStringNoObject path inside the global variable where the value should be stored
valueAnyNoValue to assign (defaults to undefined)

oJob YAML

Prints the result of a JavaScript expression as YAML.

ArgumentTypeMandatoryDescription
nameStringYesJavaScript expression or object to evaluate and dump as YAML

oJob Sort Array

Sorts an array and stores the result in a global variable.

ArgumentTypeMandatoryDescription
nameStringYesDestination global variable name
srcNameStringNoSource variable or expression to evaluate (defaults to name)
reverseBooleanNoIf true, reverses the sorted array

oJob Map Array

Maps an array of objects into a new array using selectors.

ArgumentTypeMandatoryDescription
nameStringYesDestination global variable name
srcNameStringYesSource variable or expression that resolves to an array
selectorsArrayNoArray of object path selectors to map (defaults to empty array)
limitNumberNoOptional limit for the number of entries to process

oJob Map

Applies a $path/JMESPath expression to derive a new value.

ArgumentTypeMandatoryDescription
nameStringYesDestination global variable name
srcNameStringYesSource variable or expression to evaluate
pathStringNo$path/JMESPath expression (defaults to empty string)

oJob Split into items

Splits a string from args into a list of maps stored in args._list.

ArgumentTypeMandatoryDescription
sourceStringYesObject path to the string source within args
separatorStringNoSeparator used to split the string (defaults to newline)

oJob Print list

Prints the current list stored in args._list as YAML.

oJob Print args

Prints the current args map or a specific sub-path as YAML.

ArgumentTypeMandatoryDescription
_pathStringNoOptional object path to print within args

oJob Get kept result

Retrieves a previously stored result created by oJob Keep result.

ArgumentTypeMandatoryDescription
ojobkeep.nameStringNoName of the stored result (defaults to default)
ojobkeep.keepStringNoOptional object path to merge or assign from the kept result

Depending on the stored data type, the job will either merge maps into args or set args._list with the saved list.

oJob Keep result

Stores the current job output so it can be reused later with oJob Get kept result or oafGetResult.

ArgumentTypeMandatoryDescription
ojobkeep.nameStringNoName to associate with the stored result (defaults to default)
ojobkeep.keepStringNoOptional object path inside args to store instead of the whole result

If args._list exists it will be persisted; otherwise the whole args map (or the provided path) is kept.

oJob Switch

Adds additional todo entries depending on the value of an argument.

ArgumentTypeMandatoryDescription
switchOnStringYesArgument name whose value determines the todo list
lowerCaseBooleanNoIf true, compares the value in lower case
todosMapYesMap of todo arrays keyed by possible argument values
defaultArrayNoTodo array used when no matching key is found

oJob Sec Get

Retrieves secrets from an SBucket and maps them into args.

ArgumentTypeMandatoryDescription
secOutStringNoDestination path within args for the loaded secret
secKeyStringNoKey to retrieve from the SBucket (required unless secIgnore is true)
secRepoStringNoRepository containing the SBucket
secBucketStringNoSBucket name
secPassStringNoPassword for the SBucket
secMainPassStringNoRepository password
secFileStringNoSpecific SBucket file to load
secDontAskBooleanNoIf true, avoids prompting for missing passwords
secIgnoreBooleanNoIf true, ignore missing secret parameters

oJob background processes

These jobs will run a command in background and wait for all to finish if needed. oJob Process Launch expects:

ArgumentTypeMandatoryDescription
cmdString/ArrayYesThe command to execute (or an array of commands) in background.
consoleBooleanNoDefines if stdout/stderr should be printed or not (defaults to true)
successStringNoCode to execute as a function in case of success. Receives a "res" map from executing a sh function.
errorStringNoCode to execute as a function in case of error. Receives a "e" exception and a "cmd" with the original cmd argument.

Example:

include:
- oJobBasics.yamltodo:
- Launch proc 1
- Launch proc 2
- oJob Process Waitjobs:
- name: Launch proc 1to :
- oJob Process Launchargs:
cmd : "myProc1.sh"success: "log(stringify(res, void 0, ''));"
- name: Launch proc 2to :
- oJob Process Launchargs:
cmd : "myProc2.sh"

oJob From global

This job will reset or merge a global variable map. Expects:

ArgumentTypeMandatoryDescription
globalStringYesLoad arguments from the global variable specified.

oJob Args from JSON

This job will load the args map from a JSON file. Expects:

ArgumentTypeMandatoryDescription
fileStringYesThe filepath to read the JSON file from.
globalStringNoAlternatively load to the global variable specified.

oJob Args from YAML

This job will load the args map from a YAML file. Expects:

ArgumentTypeMandatoryDescription
fileStringYesThe filepath to read the YAML file from.
globalStringNoAlternatively load to the global variable specified.

oJob Jobs Report

This job prints a job execution report on shutdown.

ArgumentTypeMandatoryDescription
formatStringNoOutput in json, yaml or table format (defaults to table)

Note: you can also use the job "oJob Jobs Final Report" to output the report on shutdown.

include:
- oJobBasics.yamljobs:
# some jobstodo:
- oJob Jobs Final Report# some todos

oJobEmail

oJobEmail jobs
oJob Send email

oJob Send email

This job tries to send an email. Expects:

ArgumentTypeMandatoryDescription
serverStringYesThe email server to use.
portNumberNoThe email server port to use.
fromStringYesThe email from address.
toArrayYesThe email to addresses.
ccArrayNoThe email cc addresses.
bccArrayNoThe email bcc addresses.
isHTMLBooleanNoSpecifies if the email is in HTML format.
subjectStringYesThe email subject (a hbs template using args as data).
outputStringYesThe email body message (a hbs template using args as data).
altOutputStringNoThe email body alternative message (defaults to message).
credentialsMapNoThe email server credentials (user and pass).
useSSLBooleanNoIf the email server uses SSL.
useTLSBooleanNoIf the email server uses TLS.
embedFilesArrayNoArray of maps (with file and name) to embeded on the email.
addAttachmentsArrayNoArray of maps (with file, isInLine, name) to attach on the email.
addImagesArrayNoArray of urls to images (only available if isHTML = true)-
embedURLsArrayNoArray of maps (with url and name) to embeded on the email.
debugBooleanNoDetermines if it should debug the process.

Example:

smtp-config.yaml

from : my.email@some.domainserver : my.smtp.servercredentials:
user: user1pass: pass1useSSL : true

sendEmail.yaml

include:
- oJobEmail.yamljobs:
- name: Send email testfrom: oJob Args from YAMLto : oJob Send emailargs:
file : smtp-config.yamlto :
- email1@some.domainsubject: Test emailoutput : My test emailtodo:
- Send email test

oJobSSH

SSH Exec

Executes commands on a SSH connection. The expected arguments are:

ArgumentTypeMandatoryDescription
cmdString/ArrayYesA SSH command-line to execute or and array of it (keep in mind that this isn't bash)
stdinStringNoAn optional SSH stdin for the command-line to execute
chHostsStringNoA channel with hosts configurations to use instead of individual config
hostStringNoThe SSH host
portNumberNoThe SSH port (defaults to 22)
loginStringNoThe SSH login
passStringNoThe SSH pass
keyStringNoThe path to a SSH key file (optional)
exitcodeNumberNoDetermines what exitcode should be consider success (default is 0)
sudoStringNoSudo's to the corresponding user to executing the command-line
quietBooleanNoDetermines if no output of the command(s) execution should be provided (default to false)

Example:

hosts.yaml

- name : my host 1host : host1.locallogin: user1pass : pass1234key : key.rsa
- name : my host 2host : host2.locallogin: user1pass : pass1234key : key.rsa

example.yaml

include:
- oJobSSH.yamlojob:
sequential: truejobs:
# Example to show 123#
- name: Example Echo 123deps:
- SSH Load hoststo : SSH Execargs:
cmd: echo 123# Example to show how you can combine multiple commands#
- name: Example with multiple commandsdeps:
- SSH Load hoststo : SSH Execargs:
cmd:
- echo -- [You are in `pwd`] -------------
- >- echo -- [Previous directory] ----------- && cd .. && ls -1 - >- echo -- [Current directory] ------------ && cd . && ls -1# Example to parse output#
- name: Example to parse outputdeps:
- SSH Load hostsfrom: SSH Execargs:
quiet: truecmd : >- curl -X GET "https://httpbin.org/json" -H "accept: application/json"exec: | print("STDOUT = " + stringify(jsonParse(args.stdout))); print("STDERR = " + args.stderr); print("EXITCODE = " + args.exitcode);todo:
- name: SSH Load hostsargs:
chHosts: myhostsfile : hosts.yaml
- name: Example Echo 123args:
chHosts: myhosts
- name: Example with multiple commandsargs:
chHosts: myhosts
- name: Example to parse outputargs:
chHosts: myhosts

oJobSQL

Allows for easy SQL query or executiong in any JDBC database.

Basic example:

consts:
dbJDBC: &jdbcurl jdbc:oracle:thin:@1.2.3.4:1521:ORCLdbUser: &jdbcuser scottdbPass: &jdbcpass tigerinclude:
- ojobSQL.yamljobs:
########################
- name: Get current datefrom: SQLargs:
DBURL : *jdbcurlDBUser: *jdbcuserDBPass: *jdbcpasssql : select current_date cd, sysdate sd from dualexec: | tprint("Current date = {{CD}}", args.output[0]); tprint("System date = {{SD}}", args.output[0]);##########################
- name: Get generated datafrom: SQL RAIDargs:
DBURL : *jdbcurlDBUser: *jdbcuserDBPass: *jdbcpassformat : tablesql : | SELECT level, current_date, sysdate FROM dual CONNECT BY level <= 10todo:
- Get current date
- Get generated data

Example using RAID:

consts:
raidURL: &raidurl http://user:pass@1.2.3.4:1234/xdtraidDB : &raiddb Datinclude:
- ojobSQL.yamljobs:
########################
- name: Get current datefrom: SQL RAIDargs:
raidURL: *raidurlraidDB : *raiddbsql : select current_date cd, sysdate sd from dualexec: | tprint("Current date = {{CD}}", args.output[0]); tprint("System date = {{SD}}", args.output[0]);##########################
- name: Get generated datafrom: SQL RAIDargs:
raidURL: *raidurlraidDB : *raiddbformat : tablesql : | SELECT level, current_date, sysdate FROM dual CONNECT BY level <= 10todo:
- Get current date
- Get generated data

oJobES

Start Log to ES

Starts logging to ElasticSearch. Expects:

ArgumentTypeDescription
urlStringThe ElasticSearch cluster URL
indexStringAn ElasticSearch index name (it will be suffixed automatically with the current date)
formatStringThe format of the date if different from day
hostStringA LogStash like host to identify in each entry
userStringA user name
passStringA password (encrypted or not)

Example:

include:
- oJobES.yaml# [...]# Log to ElasticSearchtodo:
- name: Start Log to ESargs:
url : http://my.es.clusterindex: mylogshost : myjob

Example by week:

include:
- oJobES.yaml# [...]# Log to ElasticSearchtodo:
- name: Start Log to ESargs:
url : http://my.es.clusterindex : mylogsformat: yyyy.wwhost : myjob

Stop ES Logging

Stops logging to ElasticSearch.

Example:

# Stop logging to ElasticSearchtodo:
- Stop ES logging

oJobNet

tbc

oJobHTTPd

Simplifies the creation of one or more HTTP(s) server where you just provide which functions to run for each URI on a http(s) server. The function will receive all the requests parameters and return the content for the browser. If you wish to return JSON please check oJobRest.

It's composed of 3 jobs:

  • HTTP Start Server
  • HTTP Stop Server
  • HTTP Service
  • HTTP File Browse

The job "HTTP Start Server" expects:

ArgumentTypeMandatoryDescription
portNumberNoThe port number where to assign the HTTP(s) server (defaults to 8091)
keystoreStringNoThe keystore for the SSL certificates to create a HTTPS server
passStringNoThe password for the keystore to create a HTTPS server
hostStringNoThe ip address of the local network interface to which to bind this HTTP server (defaults to 0.0.0.0)
uriPrefixStringNoOptionally a URI prefix to be applied to all routes
cpStringNoProvide a folder where the keystore file is to include it on the current classpath (Java requires for keystores to be on the execution classpath)
hsHTTPServer objectNoAn already created HTTPServer to which to bind the HTTP services
mapLibsBooleanNoMap internal OpenAF libs like JQuery, highlight css, etc.

The job "HTTP Stop Server" expects:

ArgumentTypeMandatoryDescription
portNumberNoThe port number where to assign the HTTP(s) server (defaults to 8091)

The job "HTTP service" expects:

ArgumentTypeMandatoryDescription
portNumberNoThe port number where to assign the HTTP(s) server (defaults to 8091)
uriStringNoThe URI where the HTTP(s) service will be available.
execURIStringYesThe code to execute whenever the uri is requested. The code is included into a function that receives the arguments: request and server. "request" is a map containing all the request properties. "server" is the HTTPServer object for which you should use replyOKText, replyOKJSON, etc.

The job "HTTP File Browse" expects:

ArgumentTypeMandatoryDescription
portNumberNoThe port number where to assign the HTTP(s) server (defaults to 8091)
uriStringNoThe URI where the HTTP(s) service will be available.
pathStringYesThe canonical path to the file path that will be made available for browsing.
browseStringNoIf "false" no browsing interface will be included.

Example:

include:
- oJobHTTPd.yamlojob:
daemon: truejobs:
- name: Hello worldto : HTTP Serviceargs:
port : 8080uri : /execURI: return server.replyOKText("Hello world!");
- name: Echoto : HTTP Serviceargs:
port : 8080uri : /echoexecURI: return server.replyOKJSON(stringify(request));
- name: Browserto : HTTP File Browseargs:
port: 8080uri : /browserpath: .
- name: READMEto : HTTP Serviceargs:
port : 8080uri : /READMEexecURI: return ow.server.httpd.replyFileMD(server, ".", "/README", request.uri, void 0, [ "README.md" ]); todo: # Starts the server
- name: HTTP Start Serverargs:
port : 8080mapLibs: true# Sets a shutdown job once the everything is stopped.
- name: HTTP Stop Server args:
port: 8080# Sets for every URI to return Hello world
- Hello world# Sets that /echo will return the actual request map
- Echo# Sets that /README shows this README.md file
- README# Sets that /browser shows a simple browse interface for the current directory.
- Browser

oJobREST

In the same line as oJobHTTPd simplifies the specific creation of REST HTTP(s) servers.

It's composed of 3 jobs:

  • REST Start Server
  • REST Stop Server
  • REST Service

The job "REST Start Server" expects:

ArgumentTypeMandatoryDescription
portNumberNoThe port number where to assign the HTTP(s) server (defaults to 8091)
keystoreStringNoThe keystore for the SSL certificates to create a HTTPS server
passStringNoThe password for the keystore to create a HTTPS server
hostStringNoThe ip address of the local network interface to which to bind this HTTP server (defaults to 0.0.0.0)
cpStringNoProvide a folder where the keystore file is to include it on the current classpath (Java requires for keystores to be on the execution classpath)
hsHTTPServer objectNoAn already created HTTPServer to which to bind the HTTP services
mapLibsBooleanNoMap internal OpenAF libs like JQuery, highlight css, etc.

The job "REST Stop Server" expects:

ArgumentTypeMandatoryDescription
portNumberNoThe port number where to assign the HTTP(s) server (defaults to 8091)

The job "REST service" expects:

ArgumentTypeMandatoryDescription
portNumberNoThe port number where to assign the HTTP(s) server (defaults to 8091)
uriStringNoThe URI where the HTTP(s) service will be available.
execGETStringYesThe code to execute whenever the uri is requested with a GET verb. The code is included into a function that receives the argument: idxs. "idxs" is a map containing all the parameters from the URL.
execPOSTStringYesThe code to execute whenever the uri is requested with a POST verb. The code is included into a function that receives the arguments: idxs and data. "idxs" is a map containing all the parameters from the URL. "data" is a map containing all the parameters passed on the request body.
execPUTStringYesThe code to execute whenever the uri is requested with a PUT verb. The code is included into a function that receives the arguments: idxs and data. "idxs" is a map containing all the parameters from the URL. "data" is a map containing all the parameters passed on the request body.
execDELETEStringYesThe code to execute whenever the uri is requested with a DELETE verb. The code is included into a function that receives the argument: idxs. "idxs" is a map containing all the parameters from the URL.
returnWithParamsBooleanNoChanges the behaviour of the return of each exec* function to use a map to force mimetype, http code, etc. (see help ow.server.rest.reply for more details)
errorBooleanNoIf true and an error occurs in execGET, execPOST, execPUT or execDELETE will return a map with the exception in a map with a key __error (defaults to true)

oJobOPack

Simplifies the creation of oPack files based on an url or oPack name.

The job "oPack Pack external" expects:

ArgumentTypeMandatoryDescription
nameStringYesThe name or URL to an oPack
tmpDirStringNoThe temporary folder to use during the process (defaults to ./tmp)
outputDirStringNoOutput folder where the oPack will be placed (defaults to .)

Example:

include:
- oJobOPack.yamltodo:
- name: oPack Pack externalargs:
- name : https://raw.githubusercontent.com/OpenAF/nAttrMon/mastertmpDir: nAttrMon
- name : APIstmpDir: APIs
- name : GoogleCompilertmpDir: GoogleCompiler
- name : GooglePhoneNumbertmpDir: GooglePhoneNumber

oJobRAID

Simplified RAID AF operation execution.

Expects:

ArgumentTypeMandatoryDescription
raidURLStringYesA RAID AF connection URL.
operationStringYesThe RAID AF operation to execute.
inputMapNoThe RAID AF operation input map.
formatStringNoIf not quiet it displays the result on a format you can choose between "prettyprint" (default), "pmap", "parametermap", "yaml" or "json"
quietBooleanNoIf true no output will be displayed.
include:
- oJobRAID.yamltodo:
- name: RAID AFargs:
raidURL : http://user:pass@127.0.0.1:8090/#/web/guest/homeoperation: Pinginput :
test: 123format : prettyprint

oJobWatchDog

Helps build a cron-based process "watchdog" for checking if a daemon process isn't running, has a "fatal" error on the log or any custom way to check the responsive of the daemon process.

Expects:

ArgumentTypeMandatoryDescription
checksMapNoMap of checks to determine if the daemon process should be restarted or not.
checks.pid.fileStringNoIf a pid file location is provided it will check if the corresponding pid is running. If not it sets to trigger a stop and start operation.
checks.log.folderStringNoFolder where the log files to check are located.
checks.log.fileREStringNoChecks for files matching fileRE choosing the latest by modified date.
checks.log.stringREStringNoArray of regular expressions strings to look for. If found assumes a restart is needed.
checks.log.histFileStringNoThe file where to store the history of findings on the file to avoid duplicate findings.
checks.log.olderMinNumberNoChecks if the latest log file (fileRE) by modified date is older than x minutes and if yes assumes it needs to be restarted.
checks.custom.execStringNoExecutes the corresponding code in a function and passes if returns true or fails assuming a restart is needed if returns false.
quietBooleanNoIf true will only produce logging if something is not right (default is true)
cmdToStopStringNoIf defined will execute the command on the stop event.
execToStopStringNoIf defined will execute the code on the stop event.
jobToStopStringNoIf defined will execute the job on the stop event.
waitAfterStopNumberNoNumber of ms to wait after stopping.
workDirStopStringNoThe working directory to use for the stop command.
timeoutStopNumberNoTimeout waiting for cmdToStop to exit.
exitCodeStopNumberNoIf defined the cmdToStop exitcode must be this value.
cmdToStartStringNoCommand to startup on the start event (make sure it exits after starting).
execToStartStringNoIf defined will execute the code on the start event.
jobToStartStringNoIf defined will execute the job on the start event.
waitAfterStartNumberNoNumber of ms to wait after starting.
workDirStartStringNoThe working directory to use for startup command.
timeoutStartNumberNoTimeout waiting for cmdToStart to exit.
exitCodeStartNumberNoIf defined the cmdToStart exitcode must be this value.

Example:

include:
- oJobWatchDog.yamlojob:
logToFile :
logToFolder : /some/path/watchdog.logsHKhowLongAgoInMinutes: 11152setLogOff : falselogToConsole: falselogJobs : falseunique :
pidFile : /some/path/watchdog.pidkillPrevious: falsecheckStall :
everySeconds : 1killAfterSeconds: 60jobs:
- name: Watch my logya daemonto : oJob WatchDogargs:
checks :
pid:
file: /some/path/a.pidlog :
folder : /some/path/logyafileRE : log-\d+-\d+-\d+.log histFile: /some/path/logya/logya.jsonstringRE: OutOfMemorycustom:
exec: | print(123); return false;cmdToStart : start ojob /some/path/a.yamlworkDirStart : /some/path/waitAfterStart: 5000execToStop : | pidKill(io.readFileString("/some/path/a.pid"), true);quiet : falsetodo:
- nAttrMon watchdog

oJobMCP

Provides MCP (Model Context Protocol) server functionality for handling requests and executing jobs via HTTP or STDIO transport.

HTTP MCP Server

Starts a MCP server that listens for HTTP requests and executes jobs based on the requests.

ArgumentTypeMandatoryDescription
portNumberYesThe port to listen on
uriStringNoThe URI to handle requests (defaults to "/mcp")
usestreamBooleanNoIf true, returns MCP responses as HTTP SSE stream events (defaults to false)
debugBooleanNoIf true, debug messages will be logged (defaults to false)
descriptionMapNoMetadata for the MCP server (protocol version, server info, capabilities)
toolPrefixStringNoPrefix for exposed wire tool names; does not change the source fns keys (defaults to empty)
fnsMetaMapNoMetadata for the functions available in the MCP server (defaults to {})
fnsMapYesFunctions/jobs to be executed when called from the MCP server
authtokenStringNoIf defined (or env OJOB_MCP_AUTH_TOKEN), requires this bearer token on every request. If not defined, no authentication is enforced
authheaderStringNoThe request header to read the credential from (default "authorization", or env OJOB_MCP_AUTH_HEADER)
authschemeStringNoThe authorization scheme prefix expected before the token (default "Bearer", or env OJOB_MCP_AUTH_SCHEME)
authrealmStringNoThe realm reported in the WWW-Authenticate challenge (default is the MCP server's name, or env OJOB_MCP_AUTH_REALM)
authchallengeBooleanNoIf true (default), unauthenticated/unauthorized requests receive a WWW-Authenticate header (or env OJOB_MCP_AUTH_CHALLENGE)
authapiurlStringNoIf defined (or env OJOB_MCP_AUTH_API_URL), validates the bearer credential by calling this URL instead of comparing it against authtoken. The incoming auth header is forwarded verbatim, along with the MCP context headers X-OJob-MCP-URI, X-OJob-MCP-Port, X-OJob-MCP-Name, X-OJob-MCP-Title, X-OJob-MCP-Version, X-OJob-MCP-Protocol-Version, X-OJob-MCP-Tool-Prefix, and X-OJob-MCP-Stream. A 2xx response means valid; any other response, or a request error/timeout, means invalid (fails closed). Mutually exclusive with authtokenauthapiurl takes precedence if both are set
authapimethodStringNoHTTP method used for the authapiurl validation call (default "GET", or env OJOB_MCP_AUTH_API_METHOD)
authapitimeoutNumberNoTimeout in milliseconds for the authapiurl validation call (default 5000, or env OJOB_MCP_AUTH_API_TIMEOUT)
authapicachettlNumberNoIf greater than 0, caches a token's authapiurl validation result in memory for this many milliseconds (default 0, disabled; or env OJOB_MCP_AUTH_API_CACHE_TTL)
auditBooleanNoIf true (or env OJOB_MCP_AUDIT), logs every tool call (tool name, arguments, User-Agent and, when available, client IP) via OpenAF's log() function (defaults to false). The IP is best-effort, read from the X-Forwarded-For/X-Real-IP request headers, since OpenAF's HTTP server does not expose the raw socket address — it is only populated behind a reverse proxy that sets one of those headers

Error Handling: Jobs can signal errors by returning a map with an _err property. When _err is present in the job result, the MCP server will treat it as an error response with isError: true and return the error message to the client.

Example:

include:
- oJobMCP.yamlojob:
daemon: truejobs:
- name: pingexec: | args.text = "PONG!" - name: echoexec: | args.text = args.texttodo:
- (httpdStart): 17878
- (httpdMCP): 17878((debug)): true((uri)): "/mcp"((usestream)): false((fnsMeta)):
ping:
name: pingdescription: Pings the serverinputSchema:
type: objectproperties:
text:
type: stringdescription: Text to returnrequired: ["text"]echo:
name: echodescription: Echoes the inputinputSchema:
type: objectproperties:
text:
type: stringdescription: Text to echorequired: ["text"]((fns)):
ping: pingecho: echo

STDIO MCP Server

Starts a MCP stdio server to handle requests with execution of jobs.

ArgumentTypeMandatoryDescription
debugStringNoIf defined, creates an ndjson file with the provided name for debugging
descriptionMapNoMetadata for the MCP server (protocol version, server info, capabilities)
toolPrefixStringNoPrefix for exposed wire tool names; does not change the source fns keys (defaults to empty)
fnsMetaMapNoMetadata for the functions available in the MCP server (defaults to {})
fnsMapYesFunctions/jobs to be executed when called from the MCP server

Error Handling: Jobs can signal errors by returning a map with an _err property. When _err is present in the job result, the STDIO MCP server will throw the error message as an exception, which will be returned to the client as an error response.

For both transports, OJOB_MCP_TOOLS_INCLUDE and OJOB_MCP_TOOLS_EXCLUDE are optional environment variables parsed as JSON/SLON arrays of exact, unprefixed fns keys. An unset or empty include list allows all tools; exclusions take precedence. For example, OJOB_MCP_TOOLS_INCLUDE='["ping", "echo"]' OJOB_MCP_TOOLS_EXCLUDE='["echo"]' ojob my-mcp.yaml exposes only ping. Tool prefixes affect only the MCP wire name, not filtering.

oJobBrowse

Provides HTTP file browsing functionality with customizable templates and multiple rendering options.

HTTP Browse generic

Generic HTTP browse service with customizable templates and functions.

ArgumentTypeMandatoryDescription
portNumberNoThe port where the server was made available (defaults to 8091)
uriStringNoThe URI where the HTTP Browse will be available (defaults to "/")
pathStringNoThe base path for browsing (defaults to "")
templatesMapNoMap with templates to be used
fnsMapNoMap with functions for template rendering (getList, getObj, renderList, renderObj, renderEmpty, init)
optionsMapNoMap with options to be passed (browse, default, logo, showURI, sortTab, footer)

Pagination:

  • renderList will render pager controls when the list metadata includes pageInfo with page, pageSize, and total.
  • If pageInfo is not present, it falls back to query parameters page and pageSize.

HTTP Browser API

HTTP API to access getList/getObj for any HTTP Browse generic instance.

ArgumentTypeMandatoryDescription
portNumberNoThe port where the server was made available (defaults to 8091)
uriStringNoThe URI where the HTTP Browser API will be available (defaults to "/api/browse")
browseUriStringNoThe HTTP Browse generic URI to target (can be overridden by request param browseUri)

Query parameters:

  • action: list (default) or obj.
  • path: Optional relative path appended to the target browse URI.
  • raw: When true, streams the object response if possible.

HTTP Browser

HTTP browser service based on existing types (e.g., ow.server.httpd.browse.files).

ArgumentTypeMandatoryDescription
portNumberNoThe port where the server was made available (defaults to 8091)
uriStringNoThe URI where the HTTP Browser will be available (defaults to "/")
typeStringNoThe type of HTTP Browser services (defaults to "files")
optionsMapNoMap with options to be passed to the browser type

oJobCh

Channel operations for buffering and managing data flow between channels.

oJob Ch Start Buffering

Creates a buffering channel between a source and a target channel.

ArgumentTypeMandatoryDescription
sourceStringYesThe source channel name
targetStringYesThe target channel name
idString/ArrayYesA string or array of fields that uniquely identify records
byNumberNumberNoLimit number of records to buffer
byTimeInMsNumberNoLimit time in ms to hold records in buffer
filterFuncStringNoFunction to filter what gets buffered
bufferFuncStringNoFunction to determine when to flush the buffer

Note: Use oJob Ch Stop Buffering to ensure proper release of resources.

oJob Ch Stop Buffering

Stops buffering between a source and a target channel.

ArgumentTypeMandatoryDescription
sourceStringYesThe source channel name
targetStringYesThe target channel name

oJob Ch Wait For Jobs

Waits for the jobs associated with a channel.

ArgumentTypeMandatoryDescription
nameStringYesThe channel name
timeoutNumberNoOptionally provide a timeout for the wait in ms

oJobIO

File I/O operations for manipulating files and directories.

IO Append File

Appends a line or lines to a file.

ArgumentTypeMandatoryDescription
targetStringYesThe text file to which the line will be appended
lineString/ArrayYesThe line(s) to be appended
separatorStringNoSeparator (defaults to '\n')

IO Find & Replace

Finds and replaces text in a file using regular expressions.

ArgumentTypeMandatoryDescription
targetStringYesThe text file to be changed
searchStringYesThe regular expression used for replacing
flagsStringNoOptional regular expression flags for search
replaceStringYesThe replace text
separatorStringNoSeparator (defaults to '\n')
bylineBooleanNoLoad entire file vs. line by line (defaults to true)

IO MV File

Moves a source to a target.

ArgumentTypeMandatoryDescription
sourceStringYesSource to move from
targetStringYesTarget to move to

IO RM File

Removes a file or directory recursively.

ArgumentTypeMandatoryDescription
filepathStringYesThe filepath (file or directory) to remove

IO CP File

Copies a source to a target.

ArgumentTypeMandatoryDescription
sourceStringYesSource to copy from
targetStringYesTarget to copy to

IO List files

List files from a local filepath to args.files array.

ArgumentTypeMandatoryDescription
pathStringYesThe filepath to list files from
recursiveBooleanNoRecursive file list (defaults to false)

IO List filenames

List filenames from a local filepath to args.files array.

ArgumentTypeMandatoryDescription
pathStringYesThe filepath to list files from
fullpathBooleanNoInclude the fullpath with each file (defaults to true)

IO Modify text file

Finds and replaces text in a configuration file (exact match, not regex).

ArgumentTypeMandatoryDescription
fileStringYesThe file for find/replace
findStringYesThe string to find
replaceStringYesThe string to replace

oJobTest

Testing functionality with assertions, test execution, and result reporting.

oJob Assert

Asserts that two values are equal.

ArgumentTypeMandatoryDescription
aAnyYesThe 'a' value
bAnyYesThe 'b' value
msgStringYesThe message to display if the assert fails

oJob Test

Tests a function or job with optional asserts.

ArgumentTypeMandatoryDescription
nameStringNoTest name (defaults to job name)
funcFunction/StringNoThe function to execute and test
jobStringNoThe ojob to execute and test
countNumberNoNumber of test repeats (defaults to 1)
assertsArrayNoArray of assert maps with 'path', 'value', and 'msg'
debugBooleanNoIf true, outputs debug information

oJob Test sh

Tests a shell command.

ArgumentTypeMandatoryDescription
nameStringNoTest name (defaults to job name)
cmdStringYesThe shell command to test

oJob Test Results

Prints or outputs test results with profile information.

ArgumentTypeMandatoryDescription
quietBooleanNoIf true, won't output results to stdout (defaults to false)
noprofileBooleanNoIf true, won't include profile results (defaults to false)
keyStringNoIf defined, outputs results to the provided key

oJob Generate Markdown

Generates a Markdown document with test results.

ArgumentTypeMandatoryDescription
keyStringNoIf 'file' not defined, output to key and path
pathStringNoPath within key to store markdown output
fileStringNoIf defined, outputs markdown to the provided file
includeLogsBooleanNoIf true, includes logs in markdown (defaults to false)

oJob Generate JSON results

Generates JSON output with test results.

ArgumentTypeMandatoryDescription
fileStringNoIf defined, outputs JSON to file; "-" outputs to stdout
noprofileBooleanNoIf true, won't include profile results (defaults to false)
includeLogsBooleanNoIf true, includes logs (defaults to false)

oJob Generate JUnit XML

Generates JUnit XML format test results.

ArgumentTypeMandatoryDescription
suitesIdStringYesThe JUnit suites id
suitesNameStringYesThe JUnit suites name
resultsFileStringYesThe filename and path where to store the JUnit results

oJobXLS

Excel file operations for creating and manipulating XLS/XLSX files.

oJob XLS Open File

Opens an XLSx file for use with other oJob XLS jobs.

ArgumentTypeMandatoryDescription
fileStringYesThe XLSx file to write to
templateStringNoThe XLSx file to use as a template

oJob XLS Table

Adds an array of objects as a table on an XLS file sheet.

ArgumentTypeMandatoryDescription
fileStringYesThe XLSx file to write to
sheetStringNoThe sheet name or number (defaults to "table")
dataArrayYesThe array of objects to add
positionMapNoXLSx position with column and row (defaults to A1)
headerStyleObjectNoMap of table header style options
lineStyleObjectNoMap of table line style options
autoResizeBooleanNoAuto-size columns (defaults to true)
autoFilterBooleanNoEnable auto filter (defaults to true)

oJob XLS Close File

Closes an XLSx file, writing it to the filesystem.

ArgumentTypeMandatoryDescription
fileStringYesThe XLSx file to write to

oJobGIT

GIT repository operations.

GIT Copy Repository

Copies a GIT repository files to a local folder.

ArgumentTypeMandatoryDescription
gittargetStringYesThe target folder for repository files
giturlStringYesThe GIT repository URL
gittempStringNoTemporary folder to clone repository (defaults to gittarget + ".tmp")
gitbranchStringNoSpecific branch to checkout (defaults to master)
gituserStringNoGIT remote repository user (can be encrypted)
gitpassStringNoGIT remote repository pass (can be encrypted)

oJobDebug

Debug utilities for troubleshooting oJob execution.

oJob Debug Args

Logs the current args map for debugging purposes.


Shortcuts examples:

oJobTest.yaml

include:
- oJobTest.yamltodo:
- (test ): oJob::a((job )): a
- (test ): oJob::b((job )): b
- (test ): Script::Test((func )): | sleep(1500, true) ow.test.assert(1, 1, "Problem with assert in script test")- (testAssert): Problem with a and b((a )): 123((b )): 124
- (testGenMD ): __((file )): results.mdjobs:
- name: aexec: | sleep(1500, true)- name: bexec: | throw "MY error!"

oJobHTTPd.yaml

todo:
# Starts the server
- (httpdStart ): &PORT 12345# Setups the default answer, /healthz, /livez and /metrics
- (httpdDefault): *PORT((uri )): /
- (httpdHealthz): *PORT 
- (httpdMetrics): *PORT((prefix )): mytest# Allows browsing of files
- (httpdFileBrowse): *PORT((uri )): /browse((path )): .# Allows for the upload of files
- (httpdUpload): *PORT((uri )): /upload((path )): .# Adds a custom metric
- (httpdAddMetric): global-counter((fn )): |  // Sets an atomic counter if one does not exist and returns a counter increment if (isUnDef(global.counter)) global.counter = $atomic() return global.counter.inc()# /test calls the 'test' job
- (httpdService): *PORT((uri )): /test((execURI )): | // Shows all request components for debug cprint(request) // Returns the result of calling the job 'test' passing the request and expecting an ANSWER to be returned return ow.server.httpd.reply($job("test", request).ANSWER)jobs:
# ---------------------------------# Job test is written in shell code
- name: testlang: shellexec: | # Sets ANSWER in shell script ANSWER="Echo from the shell (a: {{params.a}})" # return ANSWER# Includes the http server functionalityinclude:
- oJobHTTPd.yaml# Makes sures it runs forever and oJob-common is includedojob:
daemon: trueopacks:
oJob-common

About

A set common building blocks for custom OpenAF's oJobs.

Topics

Resources

Stars

2 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors