This commit is contained in:
Andreas Grimm 2019-02-25 13:23:27 +01:00
parent 9023954f3f
commit 0533eb0ac8
1 changed files with 4 additions and 4 deletions

View File

@ -95,7 +95,7 @@ $ DISK_USAGE_MOUNTPOINT=/dev/vdb ./metrics.sh -m disk_usage
### Configuration files ### Configuration files
Maintaing all these options can become a cumbersome job, but metrics.sh provides functionality for creating and reading configuration files. Maintaining all these options can become a cumbersome job, but metrics.sh provides functionality for creating and reading configuration files.
```sh ```sh
$ ./metrics.sh -C > metrics.ini # write configuration to metrics.ini $ ./metrics.sh -C > metrics.ini # write configuration to metrics.ini
@ -152,7 +152,7 @@ defaults () {} # setting default variables
start () {} # called at the beginning start () {} # called at the beginning
collect () {} # collect the actual metric collect () {} # collect the actual metric
stop () {} # called before exiting stop () {} # called before exiting
docs () {} # used for priting docs and creating output for configuration docs () {} # used for printing docs and creating output for configuration
``` ```
Metrics run within an isolated scope. It's generally safe to create variables and helper functions within metrics. Metrics run within an isolated scope. It's generally safe to create variables and helper functions within metrics.
@ -215,7 +215,7 @@ defaults () {} # setting default variables
start () {} # called at the beginning start () {} # called at the beginning
report () {} # report the actual metric report () {} # report the actual metric
stop () {} # called before exiting stop () {} # called before exiting
docs () {} # used for priting docs and creating output for configuration docs () {} # used for printing docs and creating output for configuration
``` ```
Below is an example script for sending metrics as JSON data to an API endpoint. Assuming this script is located at `./reporters/custom/json_api.sh`, it can be invoked by calling `./metrics.sh -r json_api`. Below is an example script for sending metrics as JSON data to an API endpoint. Assuming this script is located at `./reporters/custom/json_api.sh`, it can be invoked by calling `./metrics.sh -r json_api`.
@ -231,7 +231,7 @@ defaults () {
} }
# Prepare the reporter. Create helper functions to be used during collection # Prepare the reporter. Create helper functions to be used during collection
# if needed. Returning 1 will result in an error and exection will be stopped. # if needed. Returning 1 will result in an error and execution will be stopped.
start () { start () {
if [ -z $JSON_API_ENDPOINT ]; then if [ -z $JSON_API_ENDPOINT ]; then
echo "Error: json_api requires \$JSON_API_ENDPOINT to be specified" echo "Error: json_api requires \$JSON_API_ENDPOINT to be specified"