- #!/bin/bash
- bjobs -u all -a \
- | tail -n+2 \
- | awk '
- {
- # node
- split($6, z, "*");
- # No "*" means 1 core
- if ("" ~ z[2]) {
- node=z[1];
- x[$2, $3, $4, node] += 1
- } else {
- # Number of cpus given
- node=z[2];
- x[$2, $3, $4, node] += z[1]
- }
- }
- END {
- for (i in x) {
- split(i, y, SUBSEP);
- 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]]
- }
- }' \
- | while read i ; do
- echo "$i `date +%s"000000000"`"
- done | while read i ; do
- echo "curl -X POST 'http://influxdb/write?db=lsf' --data-binary '$i'" | sh
- done
- squeue -l -o "%.18i %.9P %.8j %.8u %.8T %5c %10C %10m %.10M %.9l %.6D %R" \
- | tail -n+3 \
- | awk '
- {
- # user, status, queue, node = cpu
- x[$4, $5, $2, $12] += $7
- }
- END {
- for (i in x) {
- split(i, y, SUBSEP);
- print "slurm,username="y[1]",status="y[2]",queue="y[3]",node="y[4]" value="x[y[1], y[2], y[3], y[4]]
- }
- }' \
- | while read i ; do
- echo "$i `date +%s"000000000"`"
- done | while read i ; do
- echo "curl -X POST 'http://influxdb/write?db=slurm' --data-binary '$i'" | sh
- done