flatironinstitute / slurm-prometheus-exporter

Prometheus exporter for slurm job/node data
31 stars 7 forks source link

Compilation issues. Does precompiled version of exporter exist? #2

Open rd178639 opened 3 years ago

rd178639 commented 3 years ago

Hi there,

I was trying to compile your exporter under Slurm 21.08.1, but I encountered many issues on my way, starting from missing library (libslurmdb.so), through issues related to permissions and finally this appeared:

error: In file included from .stack-work/dist/x86_64-linux/Cabal-3.0.1.0/build/slurm-exporter/slurm-exporter-tmp/Slurm/Node_hsc_make.c:1:0: Node.hsc: In function ‘main’: Node.hsc:48:76: error: ‘NODE_STATE_REBOOT’ undeclared (first use in this function) /root/.stack/programs/x86_64-linux/ghc-8.8.4/lib/ghc-8.8.4/template-hsc.h:112:10: note: in definition of macro ‘hsc_enum’ if ((x) < 0) \ ^ Node.hsc:48:76: note: each undeclared identifier is reported only once for each function it appears in /root/.stack/programs/x86_64-linux/ghc-8.8.4/lib/ghc-8.8.4/template-hsc.h:112:10: note: in definition of macro ‘hsc_enum’ if ((x) < 0) \ ^ I decided to stop doing this as it consumes lots plenty of time and there is no guarantee it will work. However, would be great if you could share pre-compiled version (if you have).

Thanks, Radek

sjpribyl commented 2 years ago

I am guessing you are using slurm 21 which does require some changes. Here's a patch that might work.

diff --git a/Node.hs b/Node.hs
index 8875326..82f0408 100644
--- a/Node.hs
+++ b/Node.hs
@@ -79,7 +79,7 @@ addNode :: Bool -> Node -> ResMap -> ResMap
 addNode withreason Node{..} = ar ResAlloc nodeAlloc
     { allocTime = if alloc then allocTime nodeAlloc else 0 }
   . ar (case nodeInfoState nodeInfo of
-    s | s == nodeStateDrain && s /= nodeStateReboot -> ResDrain
+    s | s == nodeStateDrain && s /= nodeStateRebootRequest -> ResDrain
       | s == nodeStateDown -> ResDown
       | s == nodeStateRes -> ResResv
       | otherwise -> ResFree)
diff --git a/Slurm/Node.hsc b/Slurm/Node.hsc
index 0bf7e9e..44e31b9 100644
--- a/Slurm/Node.hsc
+++ b/Slurm/Node.hsc
@@ -9,7 +9,7 @@ module Slurm.Node
   , nodeStateMixed
   , nodeStateDrain
   , nodeStateMaint
-  , nodeStateReboot
+  , nodeStateRebootRequest
   , nodeStateRes
   , NodeInfo(..)
   , unknownNodeInfo
@@ -46,7 +46,7 @@ newtype NodeState = NodeState Word32
   NODE_STATE_RES,       \
   NODE_STATE_DRAIN,     \
   NODE_STATE_MAINT,     \
-  NODE_STATE_REBOOT
+  NODE_STATE_REBOOT_REQUEST

 -- sort of a hacky, assymetric, broken "equals"
 instance Eq NodeState where
diff --git a/slurm-prometheus-exporter.cabal b/slurm-prometheus-exporter.cabal
index 0fb845e..da86c2b 100644
--- a/slurm-prometheus-exporter.cabal
+++ b/slurm-prometheus-exporter.cabal
@@ -52,4 +52,4 @@ executable slurm-exporter
   if flag(pkgconfig)
     pkgconfig-depends: slurm
   else
-    extra-libraries: slurmfull slurmdb
+    extra-libraries: slurmfull