cluster monitor to influxdb

From Hot Armadillo, 4 Years ago, written in Plain Text, viewed 222 times. This paste is a reply to Untitled from Crippled Gibbon - view diff
URL https://paste.steamr.com/view/15231e4c Embed
Download Paste or View Raw
  1.  
  2. #!/bin/bash
  3.  
  4. bjobs -u all -a \
  5.         | tail -n+2 \
  6.         | awk '
  7. {
  8.         # node
  9.         split($6, z, "*");
  10.  
  11.         # No "*" means 1 core
  12.         if ("" ~ z[2]) {
  13.                 node=z[1];
  14.                 x[$2, $3, $4, node] += 1
  15.         } else {
  16.                 # Number of cpus given
  17.                 node=z[2];
  18.                 x[$2, $3, $4, node] += z[1]
  19.         }
  20. }
  21. END {
  22.         for (i in x) {
  23.                 split(i, y, SUBSEP);
  24.                 print "lsf,username="y[1]",status="y[2]",queue="y[3]",node="y[4]" cpu_alloc="x[y[1], y[2], y[3], y[4]]
  25.         }
  26. }' \
  27.         |  while read i ; do
  28.                 echo "$i `date +%s"000000000"`"
  29.         done | while read i ; do
  30.                 echo "curl -X POST 'http://influxdb/write?db=lsf' --data-binary '$i'" | sh
  31.         done
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. squeue -l -o "%.18i %.9P %.8j %.8u %.8T  %5c %10C  %10m  %.10M %.9l %.6D %R" \
  40.         | tail -n+3 \
  41.         | awk '
  42. {
  43.         # user, status, queue, node  = cpu
  44.         x[$4, $5, $2, $12] += $7
  45. }
  46. END {
  47.         for (i in x) {
  48.                 split(i, y, SUBSEP);
  49.                 print "slurm,username="y[1]",status="y[2]",queue="y[3]",node="y[4]" value="x[y[1], y[2], y[3], y[4]]
  50.         }
  51. }' \
  52.         |  while read i ; do
  53.                 echo "$i `date +%s"000000000"`"
  54.         done | while read i ; do
  55.                 echo "curl -X POST 'http://influxdb/write?db=slurm' --data-binary '$i'" | sh
  56.         done
  57.  
  58.  
  59.  
  60.  

Reply to "cluster monitor to influxdb"

Here you can reply to the paste above