Split Ind Summary
Instead of working with one long unformatted script, we changed the ind scripts to one folder with formatted files.
Ind file:
Extension: yaml for example (free.ind.yaml)
Purpose: define the metadata of the scripts (name/interval/steps)
for example:
name: linux-free description: Record memory usage type: monitoring monitoring_interval: 1 minute includes_resource_data: true requires: linux-based: 'true' comments: memory-usage: why: | If memory is low, this could have impact on services and performance. without-indeni: | An administrator could login and manually check the memory allocation, or via SNMP. steps: - run: type: SSH command: ${nice-path} -n 15 free parse: type: AWK file: free.parser.1.awk
Run section:
Type (Mandatory): supports SSH/HTTP/COPY
Command (Optional): good for one line commands
File: (Optional): good for multi-line commands
for example:
echo -n "curdate: " ; ${nice-path} -n 15 date +%s echo -n "boottime: " ; ${nice-path} -n 15 sysctl kern.boottime | sed 's/.* sec = //' | sed 's/,.*//'
Parser section:
Type: Mandatory - supports AWK/JSON/XML
File: Mandatory
for example:
#curdate: 1503135122 /^curdate:\s/ { curDate = $NF } #boottime: 1503077738 /^boottime:\s/ { bootTime = $NF } END { if (curDate && bootTime) { uptime = (curDate - bootTime) * 1000 writeDoubleMetricWithLiveConfig("uptime-milliseconds", null, "gauge", 300, uptime, "Uptime", "duration", "") } }
Benefits for the changes:
- You can edit the files in Visual Studio Code or any other YAML/AWK supported IDE and get syntax and compilation error in real time
- You can reuse parsers for multiple ind scripts
- multi-steps commands are much clearer to read