From bb294cb1ca5ced75a77fa53b07c1291648a5616e Mon Sep 17 00:00:00 2001
From: Mike Hanby <mhanby@uab.edu>
Date: Tue, 15 Aug 2023 11:51:01 -0400
Subject: [PATCH] Rem Redundant Hostname Code in Script

NHC function [nhcmain_init_env()](https://github.com/mej/nhc/blob/master/nhc#L210) already initiallizes a variable containing the short hostname `HOSTNAME_S`.

The merge removes `NODENAME` and related code in favor of `$HOSTNAME_S`
---
 uabrc_hw.nhc | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/uabrc_hw.nhc b/uabrc_hw.nhc
index c5663cc..96740f6 100644
--- a/uabrc_hw.nhc
+++ b/uabrc_hw.nhc
@@ -10,14 +10,11 @@
 
 declare HW_CONTEXT_SWITCH_RATE=0
 declare HW_CONTEXT_SWITCH_INTERVAL=0
-declare NODENAME=""
 
 # Gather the metrics
 function uabrc_hw_gather_data() {
-    NODENAME="$(hostname -s)"
-
     # Gather the nodes context switching rate from Prometheus
-    HW_CONTEXT_SWITCH_RATE=$(curl -fs --data-urlencode "query=irate(node_context_switches_total{job=\"compute-node\",name=\"$NODENAME\"}[$HW_CONTEXT_SWITCH_INTERVAL])" http://nagios.rc.uab.edu:9090/api/v1/query | jq -r '.data.result[] | .value[1]')
+    HW_CONTEXT_SWITCH_RATE=$(curl -fs --data-urlencode "query=irate(node_context_switches_total{job=\"compute-node\",name=\"$HOSTNAME_S\"}[$HW_CONTEXT_SWITCH_INTERVAL])" http://nagios.rc.uab.edu:9090/api/v1/query | jq -r '.data.result[] | .value[1]')
     # Convert to an integer (hacky as it doesn't round, but insignificant)
     HW_CONTEXT_SWITCH_RATE=${HW_CONTEXT_SWITCH_RATE%.*}
 }
-- 
GitLab