Fix various issues with PVC Munin plugin
This commit is contained in:
		| @@ -28,6 +28,8 @@ GPLv3 | |||||||
|  |  | ||||||
| . "$MUNIN_LIBDIR/plugins/plugin.sh" | . "$MUNIN_LIBDIR/plugins/plugin.sh" | ||||||
|  |  | ||||||
|  | is_multigraph | ||||||
|  |  | ||||||
| warning=1 | warning=1 | ||||||
| critical=2 | critical=2 | ||||||
|  |  | ||||||
| @@ -36,6 +38,7 @@ PVC_CMD="/usr/bin/pvc --quiet --cluster local status --format json-pretty" | |||||||
| JQ_CMD="/usr/bin/jq" | JQ_CMD="/usr/bin/jq" | ||||||
|  |  | ||||||
| output_usage() { | output_usage() { | ||||||
|  |     echo "This plugin outputs information about a PVC cluster and node" | ||||||
|     exit 0 |     exit 0 | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -57,33 +60,58 @@ output_autoconf() { | |||||||
| } | } | ||||||
|  |  | ||||||
| output_config() { | output_config() { | ||||||
|     echo 'graph_title PVC CHealth' |     echo 'multigraph pvc_cluster_health' | ||||||
|     echo 'graph_args --base 100' |     echo 'graph_title PVC Cluster Health' | ||||||
|     echo 'graph_vlabel Count' |     echo 'graph_args --base 1000' | ||||||
|  |     echo 'graph_vlabel Health%' | ||||||
|     echo 'graph_category pvc' |     echo 'graph_category pvc' | ||||||
|     echo 'graph_period second' |     echo 'graph_info Health of the PVC cluster' | ||||||
|     echo 'graph_info These graphs show the health of the PVC cluster and specific node.' |  | ||||||
|  |  | ||||||
|     echo 'pvc_cluster.label Cluster Health' |     echo 'pvc_cluster_health.label Cluster Health' | ||||||
|     echo 'pvc_cluster.type GAUGE' |     echo 'pvc_cluster_health.type GAUGE' | ||||||
|     echo 'pvc_cluster.max 100' |     echo 'pvc_cluster_health.max 100' | ||||||
|     echo 'pvc_cluster.info Health of the PVC cluster in %.' |     echo 'pvc_cluster_health.min 0' | ||||||
|  |     echo 'pvc_cluster_health.info Health of the PVC cluster in %' | ||||||
|  |  | ||||||
|  |     echo 'multigraph pvc_cluster_alert' | ||||||
|  |     echo 'graph_title PVC Cluster Alerting' | ||||||
|  |     echo 'graph_args --base 1000' | ||||||
|  |     echo 'graph_vlabel State' | ||||||
|  |     echo 'graph_category pvc' | ||||||
|  |     echo 'graph_info Alerting state of the PVC cluster health' | ||||||
|  |  | ||||||
|     echo 'pvc_cluster_alert.label Cluster Health State' |     echo 'pvc_cluster_alert.label Cluster Health State' | ||||||
|     echo 'pvc_cluster_alert.type GAUGE' |     echo 'pvc_cluster_alert.type GAUGE' | ||||||
|     echo 'pvc_cluster_alert.max 2', |     echo 'pvc_cluster_alert.max 2' | ||||||
|  |     echo 'pvc_cluster_alert.min 0' | ||||||
|     echo 'pvc_cluster_alert.info Alerting state of the PVC cluster health' |     echo 'pvc_cluster_alert.info Alerting state of the PVC cluster health' | ||||||
|     print_warning pvc_cluster_alert |     print_warning pvc_cluster_alert | ||||||
|     print_critical pvc_cluster_alert |     print_critical pvc_cluster_alert | ||||||
|  |  | ||||||
|     echo 'pvc_node.label Node Health' |     echo 'multigraph pvc_node_health' | ||||||
|     echo 'pvc_node.type GAUGE' |     echo 'graph_title PVC Node Health' | ||||||
|     echo 'pvc_node.max 100' |     echo 'graph_args --base 1000' | ||||||
|     echo 'pvc_node.info Health of the PVC node in %.' |     echo 'graph_vlabel Health%' | ||||||
|  |     echo 'graph_category pvc' | ||||||
|  |     echo 'graph_info Health of the PVC node' | ||||||
|  |  | ||||||
|  |     echo 'pvc_node_health.label Node Health' | ||||||
|  |     echo 'pvc_node_health.type GAUGE' | ||||||
|  |     echo 'pvc_node_health.max 100' | ||||||
|  |     echo 'pvc_node_health.min 0' | ||||||
|  |     echo 'pvc_node_health.info Health of the PVC node in %' | ||||||
|  |  | ||||||
|  |     echo 'multigraph pvc_node_alert' | ||||||
|  |     echo 'graph_title PVC Node Alerting' | ||||||
|  |     echo 'graph_args --base 1000' | ||||||
|  |     echo 'graph_vlabel State' | ||||||
|  |     echo 'graph_category pvc' | ||||||
|  |     echo 'graph_info Alerting state of the PVC node health' | ||||||
|  |  | ||||||
|     echo 'pvc_node_alert.label Node Health State' |     echo 'pvc_node_alert.label Node Health State' | ||||||
|     echo 'pvc_node_alert.type GAUGE' |     echo 'pvc_node_alert.type GAUGE' | ||||||
|     echo 'pvc_node_alert.max 2', |     echo 'pvc_node_alert.max 2' | ||||||
|  |     echo 'pvc_node_alert.min 0' | ||||||
|     echo 'pvc_node_alert.info Alerting state of the PVC node health' |     echo 'pvc_node_alert.info Alerting state of the PVC node health' | ||||||
|     print_warning pvc_node_alert |     print_warning pvc_node_alert | ||||||
|     print_critical pvc_node_alert |     print_critical pvc_node_alert | ||||||
| @@ -99,8 +127,9 @@ output_values() { | |||||||
|  |  | ||||||
|     cluster_health="$( $JQ_CMD ".cluster_health.health" <<<"${PVC_OUTPUT}" | tr -d '"' )" |     cluster_health="$( $JQ_CMD ".cluster_health.health" <<<"${PVC_OUTPUT}" | tr -d '"' )" | ||||||
|     cluster_health_messages="$( $JQ_CMD -r ".cluster_health.messages | @csv" <<<"${PVC_OUTPUT}" | tr -d '"' | sed 's/,/, /g' )" |     cluster_health_messages="$( $JQ_CMD -r ".cluster_health.messages | @csv" <<<"${PVC_OUTPUT}" | tr -d '"' | sed 's/,/, /g' )" | ||||||
|     echo "pvc_cluster.value ${cluster_health}" |     echo 'multigraph pvc_cluster_health' | ||||||
|     echo "pvc_cluster.extinfo ${cluster_health_messages}" |     echo "pvc_cluster_health.value ${cluster_health}" | ||||||
|  |     echo "pvc_cluster_health.extinfo ${cluster_health_messages}" | ||||||
|  |  | ||||||
|     if [[ ${cluster_health} -le 50 && ${is_maintenance} == "false" ]]; then |     if [[ ${cluster_health} -le 50 && ${is_maintenance} == "false" ]]; then | ||||||
|         cluster_health_alert=2 |         cluster_health_alert=2 | ||||||
| @@ -109,12 +138,14 @@ output_values() { | |||||||
|     else |     else | ||||||
|         cluster_health_alert=0 |         cluster_health_alert=0 | ||||||
|     fi |     fi | ||||||
|  |     echo 'multigraph pvc_cluster_alert' | ||||||
|     echo "pvc_cluster_alert.value ${cluster_health_alert}" |     echo "pvc_cluster_alert.value ${cluster_health_alert}" | ||||||
|  |  | ||||||
|     node_health="$( $JQ_CMD ".node_health.${HOST}.health" <<<"${PVC_OUTPUT}" | tr -d '"' )" |     node_health="$( $JQ_CMD ".node_health.${HOST}.health" <<<"${PVC_OUTPUT}" | tr -d '"' )" | ||||||
|     node_health_messages="$( $JQ_CMD -r ".node_health.${HOST}.messages | @csv" <<<"${PVC_OUTPUT}" | tr -d '"' | sed 's/,/, /g' )" |     node_health_messages="$( $JQ_CMD -r ".node_health.${HOST}.messages | @csv" <<<"${PVC_OUTPUT}" | tr -d '"' | sed 's/,/, /g' )" | ||||||
|     echo "pvc_node.value ${node_health}" |     echo 'multigraph pvc_node_health' | ||||||
|     echo "pvc_node.extinfo ${node_health_messages}" |     echo "pvc_node_health.value ${node_health}" | ||||||
|  |     echo "pvc_node_health.extinfo ${node_health_messages}" | ||||||
|  |  | ||||||
|     if [[ ${node_health} -le 50 && ${is_maintenance} == "false" ]]; then |     if [[ ${node_health} -le 50 && ${is_maintenance} == "false" ]]; then | ||||||
|         node_health_alert=2 |         node_health_alert=2 | ||||||
| @@ -123,6 +154,7 @@ output_values() { | |||||||
|     else |     else | ||||||
|         node_health_alert=0 |         node_health_alert=0 | ||||||
|     fi |     fi | ||||||
|  |     echo 'multigraph pvc_node_alert' | ||||||
|     echo "pvc_node_alert.value ${node_health_alert}" |     echo "pvc_node_alert.value ${node_health_alert}" | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user