Commit 0240807f authored by Jonathan Schaeffer's avatar Jonathan Schaeffer
Browse files

Manage also total and used space

parent 26d3ce6c
Pipeline #68006 passed with stage
in 35 seconds
......@@ -72,41 +72,41 @@ def main():
logging.debug("Getting data from volume %s", volume['mountpoint'])
ssh_stdin, ssh_stdout, ssh_stderr = client.exec_command("volume show -volume %s" % volume['name'])
for eline in ssh_stdout.readlines():
if re.search('Volume Size Used by Snapshot Copies:', eline):
if re.search('^\s+Volume Size Used by Snapshot Copies:', eline):
logging.debug(eline)
size_with_unit = re.split(r":\s+", eline.rstrip())[-1]
logging.debug(size_with_unit)
snapshot_size = to_bytes(size_with_unit)
logging.debug(snapshot_size)
continue
if re.search('Available Size:', eline):
if re.search('^\s+Available Size:', eline):
logging.debug(eline)
size_with_unit = re.split(r":\s+", eline.rstrip())[-1]
availabile_size = to_bytes(size_with_unit)
logging.debug("Available size: %s", availabile_size)
continue
if re.search('Used Size:', eline):
if re.search('^\s+Used Size:', eline):
logging.debug(eline)
size_with_unit = re.split(r":\s+", eline.rstrip())[-1]
used_size = to_bytes(size_with_unit)
logging.debug("Used size: %s", used_size)
continue
if re.search('Filesystem Size:', eline):
if re.search('^\s+Filesystem Size:', eline):
logging.debug(eline)
size_with_unit = re.split(r":\s+", eline.rstrip())[-1]
total_size = to_bytes(size_with_unit)
logging.debug("Total size: %s", total_size)
continue
if re.search('Space Reserved for Snapshot Copies', eline):
if re.search('^\s+Space Reserved for Snapshot Copies', eline):
logging.debug(eline)
reserved_snapshot_percent = float(re.split(r':\s+', eline.rstrip().strip('%'))[-1])
continue
if re.search('Snapshot Reserve Used:', eline):
if re.search('^\s+Snapshot Reserve Used:', eline):
logging.debug(eline)
snapshot_reserve_used_with_unit = re.split(r":\s+", eline.rstrip())[-1]
snapshot_reserve_used = snapshot_reserve_used_with_unit[:-1]
logging.debug(snapshot_reserve_used)
if re.search('Used Percentage:', eline):
if re.search('^\s+Used Percentage:', eline):
logging.debug(eline)
volume_used_with_unit = re.split(r":\s+", eline.rstrip())[-1]
volume_used = volume_used_with_unit[:-1]
......@@ -116,7 +116,6 @@ def main():
ssh_stdin.close()
ssh_stdout.close()
ssh_stderr.close()
logging.info("Volume %s Snapshot %d", volume, snapshot_size)
# Metric for Zabbix
if cfg['zabbix']['active']:
zabbix_packet.append(ZabbixMetric(cfg['zabbix']['host'],
......@@ -134,14 +133,15 @@ def main():
{"measurement": cfg['influxdb']['measurement'],
"tags": {
"lif": lif['name'],
"volume": volume['mountpoint']
"volume": volume['mountpoint'],
"qtree": None
},
"time": strftime("%Y-%m-%dT%H:%M:%SZ", now),
"fields": {
"snapshot_used": snapshot_size,
"available": availabile_size,
"used": used_size,
"total": total_size,
"snapshot_used": snapshot_size,
"snapshot_reserve": int(total_size * reserved_snapshot_percent /100.)
}
}
......@@ -190,8 +190,8 @@ def main():
},
"time": strftime("%Y-%m-%dT%H:%M:%SZ", now),
"fields": {
"disk_used": disk_used,
"disk_limit": disk_limit
"qtree_used": disk_used,
"qtree_limit": disk_limit,
}
}
)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment