Skip to content

Instantly share code, notes, and snippets.

root@node1:~# linstor resource toggle-disk node1 my_ssd_res --diskless
SUCCESS:
...
root@node1:~# linstor resource list
╭─────────────────────────────────────────────────────────────────────────────────────────╮
┊ ResourceName ┊ Node ┊ Port ┊ Usage ┊ Conns ┊ State ┊ CreatedOn ┊
╞═════════════════════════════════════════════════════════════════════════════════════════╡
┊ my_ssd_res ┊ node1 ┊ 7000 ┊ Unused ┊ Ok ┊ Diskless ┊ 2020-11-04 12:26:50 ┊
┊ my_ssd_res ┊ node2 ┊ 7000 ┊ Unused ┊ Ok ┊ UpToDate ┊ 2020-11-04 12:26:50 ┊
┊ my_ssd_res ┊ node3 ┊ 7000 ┊ Unused ┊ Ok ┊ SyncTarget(43.95%) ┊ 2020-11-04 12:26:50 ┊
@candlerb
candlerb / gist:891e0fc3702b59bc2c63e45ed6a55835
Created January 26, 2021 14:26
linstor promote node to replica
root@node1:~# linstor resource list
╭───────────────────────────────────────────────────────────────────────────────╮
┊ ResourceName ┊ Node ┊ Port ┊ Usage ┊ Conns ┊ State ┊ CreatedOn ┊
╞═══════════════════════════════════════════════════════════════════════════════╡
┊ my_ssd_res ┊ node1 ┊ 7000 ┊ Unused ┊ Ok ┊ UpToDate ┊ 2020-11-04 12:26:50 ┊
┊ my_ssd_res ┊ node2 ┊ 7000 ┊ Unused ┊ Ok ┊ UpToDate ┊ 2020-11-04 12:26:50 ┊
┊ my_ssd_res ┊ node3 ┊ 7000 ┊ Unused ┊ Ok ┊ Diskless ┊ 2020-11-04 12:26:50 ┊
┊ my_ssd_res ┊ node4 ┊ 7000 ┊ Unused ┊ Ok ┊ Diskless ┊ 2020-11-04 12:46:37 ┊
╰───────────────────────────────────────────────────────────────────────────────╯
root@node1:~# linstor resource toggle-disk node3 my_ssd_res --storage-pool pool_ssd
@candlerb
candlerb / gist:a8323123262f3466830c37ee75b339b5
Created January 26, 2021 14:20
linstor adding diskless node to resource
root@node1:~# linstor resource list
╭───────────────────────────────────────────────────────────────────────────────╮
┊ ResourceName ┊ Node ┊ Port ┊ Usage ┊ Conns ┊ State ┊ CreatedOn ┊
╞═══════════════════════════════════════════════════════════════════════════════╡
┊ my_ssd_res ┊ node1 ┊ 7000 ┊ Unused ┊ Ok ┊ UpToDate ┊ 2020-11-04 12:26:50 ┊
┊ my_ssd_res ┊ node2 ┊ 7000 ┊ Unused ┊ Ok ┊ UpToDate ┊ 2020-11-04 12:26:50 ┊
┊ my_ssd_res ┊ node3 ┊ 7000 ┊ Unused ┊ Ok ┊ Diskless ┊ 2020-11-04 12:26:50 ┊
╰───────────────────────────────────────────────────────────────────────────────╯
root@node1:~# linstor resource create node4 my_ssd_res --drbd-diskless
SUCCESS:
root@node1:~# ls -l /dev/drbd*
brw-rw---- 1 root disk 147, 1000 Nov 4 12:26 /dev/drbd1000
/dev/drbd:
total 0
drwxr-xr-x 3 root root 60 Nov 4 12:26 by-disk
drwxr-xr-x 3 root root 60 Nov 4 12:26 by-res
root@node1:~# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root@node1:~# linstor resource list
╭────────────────────────────────────────────────────────────────────────────────────────╮
┊ ResourceName ┊ Node ┊ Port ┊ Usage ┊ Conns ┊ State ┊ CreatedOn ┊
╞════════════════════════════════════════════════════════════════════════════════════════╡
┊ my_ssd_res ┊ node1 ┊ 7000 ┊ Unused ┊ Ok ┊ SyncTarget(1.81%) ┊ 2020-11-04 12:26:50 ┊
┊ my_ssd_res ┊ node2 ┊ 7000 ┊ Unused ┊ Ok ┊ UpToDate ┊ 2020-11-04 12:26:50 ┊
╰────────────────────────────────────────────────────────────────────────────────────────╯
@candlerb
candlerb / nfacctd.conf
Last active November 1, 2020 09:25
nfacctd configuration for tracking most active local IP addresses (inbound and outbound)
nfacctd_port: 2055
plugins: memory[inbound], memory[outbound]
imt_path[inbound]: /tmp/inbound.pipe
aggregate_filter[inbound]: dst net 10.0.0.0/8 or dst net 192.0.2.0/24 or dst net 2001:db8::/32
aggregate[inbound]: dst_host, src_net
imt_mem_pools_number[inbound]: 64
imt_mem_pools_size[inbound]: 65536
imt_path[outbound]: /tmp/outbound.pipe
@candlerb
candlerb / pmacct.py
Created November 1, 2020 09:10
Prometheus exporter for pmacct
#!/usr/bin/python3
import json
import subprocess
LABELS={} # add any static labels here, eg hostname
def export(metric, labels, value):
lstr = ",".join(("%s=\"%s\"" % (k,v) for k,v in labels.items()))
print("%s{%s} %d" % (metric, lstr, value))
@candlerb
candlerb / assign5.py
Last active October 27, 2020 11:01
Mixing 'let' and '<-'
class ValueAndLog:
def __init__(self, value, log):
self.value = value
self.log = log
def __rshift__(self, func):
result = func(self.value)
return ValueAndLog(result.value, self.log + result.log)
@staticmethod
@candlerb
candlerb / assign4.py
Last active October 27, 2020 11:03
Nested binds
class ValueAndLog:
def __init__(self, value, log):
self.value = value
self.log = log
def __rshift__(self, func):
result = func(self.value)
return ValueAndLog(result.value, self.log + result.log)
@staticmethod
@candlerb
candlerb / assign3.py
Last active October 27, 2020 10:38
A chain of assignments with wrapped values
class ValueAndLog:
def __init__(self, value, log):
self.value = value
self.log = log
def __rshift__(self, func):
result = func(self.value)
return ValueAndLog(result.value, self.log + result.log)
@staticmethod