Skip to content

Commit

Permalink
Slightly upgrade snmphost to use better device names. (#46)
Browse files Browse the repository at this point in the history
* Update device name of file systems

* Update device name of file systems
  • Loading branch information
Rui Liu authored Jul 2, 2024
1 parent 3b699c8 commit c367387
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ private void queryFileSystemUsage() throws IOException {
Oid.FILESYSTEM_USAGE__ALL, Oid.FILESYSTEM_USAGE__UNIT);
List<SimpleQueryResult> output = new ArrayList<SimpleQueryResult>();

int no = 0;
for (Map<OID, SnmpValue> result1 : result) {
String device = SnmpValue.getString(result1, Oid.FILESYSTEMDEVICE, null);
long unit = SnmpValue.getLong(result1, Oid.FILESYSTEM_USAGE__UNIT, 0L);
Expand All @@ -149,13 +150,14 @@ private void queryFileSystemUsage() throws IOException {
long all = SnmpValue.getLong(result1, Oid.FILESYSTEM_USAGE__ALL, 0L);
long free = all - used;
output.add(new SimpleQueryResult(used * unit).setKey(device + ":u")
.setAttribute("device", device).setAttribute("mountpoint", device).setAttribute("state", "used")
.setAttribute("mode", "-").setAttribute("type", "ext4")
.setAttribute("device", "dev" + no).setAttribute("mountpoint", device).setAttribute("state", "used")
.setAttribute("mode", "-").setAttribute("type", "xfs")
);
output.add(new SimpleQueryResult(free * unit).setKey(device + ":f")
.setAttribute("device", device).setAttribute("mountpoint", device).setAttribute("state", "free")
.setAttribute("mode", "-").setAttribute("type", "ext4")
.setAttribute("device", "dev" + no).setAttribute("mountpoint", device).setAttribute("state", "free")
.setAttribute("mode", "-").setAttribute("type", "xfs")
);
no++;
}
}

Expand Down

0 comments on commit c367387

Please sign in to comment.