| 
									
										
										
										
											2018-08-27 10:23:22 -07:00
										 |  |  | # |source| this file | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # The SOLANA_METRICS_CONFIG environment variable is formatted as a | 
					
						
							|  |  |  | # comma-delimited list of parameters. All parameters are optional. | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # Example: | 
					
						
							|  |  |  | #   export SOLANA_METRICS_CONFIG="host=<metrics host>,db=<database name>,u=<username>,p=<password>" | 
					
						
							|  |  |  | # | 
					
						
							| 
									
										
										
										
											2018-09-03 18:15:55 -10:00
										 |  |  | # The following directive disable complaints about unused variables in this | 
					
						
							|  |  |  | # file: | 
					
						
							|  |  |  | # shellcheck disable=2034 | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | configureMetrics() { | 
					
						
							| 
									
										
										
										
											2018-08-27 10:23:22 -07:00
										 |  |  |   [[ -n $SOLANA_METRICS_CONFIG ]] || return 0 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-03 18:15:55 -10:00
										 |  |  |   declare metricsParams | 
					
						
							|  |  |  |   IFS=',' read -r -a metricsParams <<< "$SOLANA_METRICS_CONFIG" | 
					
						
							|  |  |  |   for param in "${metricsParams[@]}"; do | 
					
						
							| 
									
										
										
										
											2018-08-27 10:23:22 -07:00
										 |  |  |     IFS='=' read -r -a pair <<< "$param" | 
					
						
							|  |  |  |     if [[ ${#pair[@]} != 2 ]]; then | 
					
						
							|  |  |  |       echo Error: invalid metrics parameter: "$param" >&2 | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |       declare name="${pair[0]}" | 
					
						
							|  |  |  |       declare value="${pair[1]}" | 
					
						
							|  |  |  |       case "$name" in | 
					
						
							|  |  |  |       host) | 
					
						
							|  |  |  |         export INFLUX_HOST="$value" | 
					
						
							|  |  |  |         echo INFLUX_HOST="$INFLUX_HOST" >&2 | 
					
						
							|  |  |  |         ;; | 
					
						
							|  |  |  |       db) | 
					
						
							|  |  |  |         export INFLUX_DATABASE="$value" | 
					
						
							|  |  |  |         echo INFLUX_DATABASE="$INFLUX_DATABASE" >&2 | 
					
						
							|  |  |  |         ;; | 
					
						
							|  |  |  |       u) | 
					
						
							|  |  |  |         export INFLUX_USERNAME="$value" | 
					
						
							|  |  |  |         echo INFLUX_USERNAME="$INFLUX_USERNAME" >&2 | 
					
						
							|  |  |  |         ;; | 
					
						
							|  |  |  |       p) | 
					
						
							|  |  |  |         export INFLUX_PASSWORD="$value" | 
					
						
							|  |  |  |         echo INFLUX_PASSWORD="********" >&2 | 
					
						
							|  |  |  |         ;; | 
					
						
							|  |  |  |       *) | 
					
						
							|  |  |  |         echo Error: Unknown metrics parameter name: "$name" >&2 | 
					
						
							|  |  |  |         ;; | 
					
						
							|  |  |  |       esac | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  |   done | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-09-03 18:15:55 -10:00
										 |  |  | configureMetrics | 
					
						
							| 
									
										
										
										
											2019-05-06 16:44:06 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | metricsWriteDatapoint="$(dirname "${BASH_SOURCE[0]}")"/metrics-write-datapoint.sh |