OctoSAM housekeeping scripts¶
The import service provides several hooks to implement custom SQL and/or OctoUtil scripts. Such scripts can help integrate with other systems or to transform custom data within the database.
Support notice
The script and query engines in OctoSAM Inventory and the query definition format may change with future versions of OctoSAM Inventory. At the same time, we try to keep the engines backward compatible with older versions, but that may not always be possible. Be prepared to adjust your own scripts to future versions of OctoSAM Inventory.
Administering scripts¶
The scripts can be modified using the OctoSAM GUI, menu: Setup - Database - Housekeeping - Scripts
<housekeeping>
<!-- Site-specific housekeeping scripts, do not change without consulting Octosoft support first. -->
<scripts>
<script language="SQL" name="MyScript" run="before">
.... SQL Commands ....
</script>
<script language="SQL" name="MyOtherScript" run="after">
.... SQL Commands ....
</script>
<script language="OctoUtil" name="MyExportScript" run="export">
.... OctoUtil Commands ....
</script>
</scripts>
</housekeeping>
Elements¶
script¶
<script name="myscript" language="SQL" run="before" />
The <script>
element defines a script
Attribute | Required | Default Value | Description |
---|---|---|---|
language | Y | either SQL or OctoUtil |
|
run | Y | When to run the script - see table below | |
name | Y | Name of the script. Use the name to identify the script in log and error messages | |
updatehints | N | false |
If set to true causes OctoSAM to update the hints fields before the script is run. Set this to true if your SQL references any hint fields. |
days | N | Specify comma-separated list of days when the script can run one or more out of "Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday" |
Run | Description |
---|---|
before | run this script at the very beginning of a housekeeping cycle - run at the beginning of full and partial housekeeping cycles. |
after | run this script at the end of housekeeping but before Organization mapping - full and partial housekeeping cycles. |
export | run this script at the very end of a full housekeeping cycle. |
beforeImport | run this script at the beginning of an import batch |
afterImport | run this script at the end of an import batch |
SQL scripts¶
Can be used to execute arbitrary Transact SQL commands. Use extreme care not to destroy data. Typical use is to transform site-specific data within the database, often in the context of organization mapping or software installation approval.
OctoUtil script¶
Allows to execute OctoUtil commands - especially the execute
and the query
commands in sync with the import service.
This guarantees that the database is in a consistent state when the commands are executed.
The OcotoUtil query
command is typically executed at export time.
Script user context
Note that the housekeeping scripts execute in the user context of the service account, which might have different permissions from your interactive user.
Consider the OctoUtil run command as an alternative to the Windows Task Scheduler
The octoutil run command can be used to start external programs from housekeeping scripts. This can be used as an alternative to scheduled tasks with the added benefit that actions get logged to the OctoSAM import service log.
Testing Scripts¶
You can use the OctoUtil scripts
command to execute defined scripts.