Skip to content

Commit

Permalink
Merge tag 'v1.11.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
thorhs committed Dec 18, 2020
2 parents 0d5d9dc + 5b3e35e commit 2336024
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
12 changes: 6 additions & 6 deletions collectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,37 +109,37 @@ void gather_filesystems(std::ostringstream& response, const std::string& static_
response << "# HELP node_filesystem_size_bytes Filesystem size in bytes." << std::endl;
response << "# TYPE node_filesystem_size_bytes gauge" << std::endl;
for(auto it = filesystems.begin(); it < filesystems.end(); it++) {
response << "node_filesystem_size_bytes{device=\"" << (*it).device << "\",fstype=\"jfs2\",mountpoint=\"" << (*it).mountpoint << "\"," << static_labels << "} " << std::fixed << std::setprecision(0) << (*it).size_bytes << std::endl;
response << "node_filesystem_size_bytes{device=\"" << (*it).device << "\",fstype=\"" << (*it).fstype << "\",mountpoint=\"" << (*it).mountpoint << "\"," << static_labels << "} " << std::fixed << std::setprecision(0) << (*it).size_bytes << std::endl;
}

response << "# HELP node_filesystem_free_bytes Filesystem free space in bytes." << std::endl;
response << "# TYPE node_filesystem_free_bytes gauge" << std::endl;
for(auto it = filesystems.begin(); it < filesystems.end(); it++) {
response << "node_filesystem_free_bytes{device=\"" << (*it).device << "\",fstype=\"jfs2\",mountpoint=\"" << (*it).mountpoint << "\"," << static_labels << "} " << std::fixed << std::setprecision(0) << (*it).free_bytes << std::endl;
response << "node_filesystem_free_bytes{device=\"" << (*it).device << "\",fstype=\"" << (*it).fstype << "\",mountpoint=\"" << (*it).mountpoint << "\"," << static_labels << "} " << std::fixed << std::setprecision(0) << (*it).free_bytes << std::endl;
}

response << "# HELP node_filesystem_avail_bytes Filesystem space available to non-root users in bytes." << std::endl;
response << "# TYPE node_filesystem_avail_bytes gauge" << std::endl;
for(auto it = filesystems.begin(); it < filesystems.end(); it++) {
response << "node_filesystem_avail_bytes{device=\"" << (*it).device << "\",fstype=\"jfs2\",mountpoint=\"" << (*it).mountpoint << "\"," << static_labels << "} " << std::fixed << std::setprecision(0) << (*it).avail_bytes << std::endl;
response << "node_filesystem_avail_bytes{device=\"" << (*it).device << "\",fstype=\"" << (*it).fstype << "\",mountpoint=\"" << (*it).mountpoint << "\"," << static_labels << "} " << std::fixed << std::setprecision(0) << (*it).avail_bytes << std::endl;
}

response << "# HELP node_filesystem_files Filesystem total file nodes." << std::endl;
response << "# TYPE node_filesystem_files gauge" << std::endl;
for(auto it = filesystems.begin(); it < filesystems.end(); it++) {
response << "node_filesystem_files{device=\"" << (*it).device << "\",fstype=\"jfs2\",mountpoint=\"" << (*it).mountpoint << "\"," << static_labels << "} " << std::fixed << std::setprecision(0) << (*it).files << std::endl;
response << "node_filesystem_files{device=\"" << (*it).device << "\",fstype=\"" << (*it).fstype << "\",mountpoint=\"" << (*it).mountpoint << "\"," << static_labels << "} " << std::fixed << std::setprecision(0) << (*it).files << std::endl;
}

response << "# HELP node_filesystem_files_free Filesystem total free file nodes." << std::endl;
response << "# TYPE node_filesystem_files_free gauge" << std::endl;
for(auto it = filesystems.begin(); it < filesystems.end(); it++) {
response << "node_filesystem_files_free{device=\"" << (*it).device << "\",fstype=\"jfs2\",mountpoint=\"" << (*it).mountpoint << "\"," << static_labels << "} " << std::fixed << std::setprecision(0) << (*it).files_free << std::endl;
response << "node_filesystem_files_free{device=\"" << (*it).device << "\",fstype=\"" << (*it).fstype << "\",mountpoint=\"" << (*it).mountpoint << "\"," << static_labels << "} " << std::fixed << std::setprecision(0) << (*it).files_free << std::endl;
}

response << "# HELP node_filesystem_files_avail Filesystem available file nodes to non-root users." << std::endl;
response << "# TYPE node_filesystem_files_avail gauge" << std::endl;
for(auto it = filesystems.begin(); it < filesystems.end(); it++) {
response << "node_filesystem_files_avail{device=\"" << (*it).device << "\",fstype=\"jfs2\",mountpoint=\"" << (*it).mountpoint << "\"," << static_labels << "} " << std::fixed << std::setprecision(0) << (*it).files_avail << std::endl;
response << "node_filesystem_files_avail{device=\"" << (*it).device << "\",fstype=\"" << (*it).fstype << "\",mountpoint=\"" << (*it).mountpoint << "\"," << static_labels << "} " << std::fixed << std::setprecision(0) << (*it).files_avail << std::endl;
}
}

Expand Down
12 changes: 11 additions & 1 deletion mounts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ std::vector<mountpoint> list_mounts() {
struct mountpoint mp;
mp.device = vmt2dataptr(mounts, VMT_OBJECT);
mp.mountpoint = vmt2dataptr(mounts, VMT_STUB);

if (mounts->vmt_gfstype == MNT_J2) {
mp.fstype = "jfs2";
} else if (mounts->vmt_gfstype == MNT_JFS) {
mp.fstype = "jfs";
} else {
mp.fstype = "unknown";
}

output.push_back(mp);
}
}
Expand All @@ -63,6 +72,7 @@ std::vector<filesystem> stat_filesystems(std::vector<mountpoint> mounts) {
struct filesystem fs;
fs.mountpoint = (*it).mountpoint;
fs.device = (*it).device;
fs.fstype = (*it).fstype;
fs.avail_bytes = s.f_bavail * s.f_bsize;
fs.size_bytes = s.f_blocks * s.f_bsize;
fs.free_bytes = s.f_bfree * s.f_bsize;
Expand All @@ -81,7 +91,7 @@ int main() {
auto fs = stat_filesystems(list_mounts());

for(auto it = fs.begin(); it != fs.end(); it++) {
std::cout << (*it).mountpoint << " " << (*it).size_bytes/1024 << " " << (*it).free_bytes/1024 << std::endl;
std::cout << (*it).mountpoint << " " << (*it).fstype << " " << (*it).size_bytes/1024 << " " << (*it).free_bytes/1024 << std::endl;
}

return 0;
Expand Down
2 changes: 2 additions & 0 deletions node_exporter_aix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ extern void gather_filesystems(std::ostringstream& response, const std::string&
struct mountpoint {
std::string mountpoint;
std::string device;
std::string fstype;
};

struct filesystem {
std::string mountpoint;
std::string device;
std::string fstype;
u_int64 avail_bytes; // f_bavail
u_int64 size_bytes; // f_bfrsize
u_int64 free_bytes; // f_bfree
Expand Down

0 comments on commit 2336024

Please sign in to comment.