Skip to content

Commit

Permalink
Add text file, nfs-client-counts.txt, collecting the number of NFS cl…
Browse files Browse the repository at this point in the history
…ients by type
  • Loading branch information
mgrimesix committed Sep 30, 2023
1 parent ab54dac commit 2298426
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions ixdiagnose/plugins/nfs.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
from ixdiagnose.utils.command import Command
from ixdiagnose.utils.middleware import MiddlewareCommand
from ixdiagnose.utils.middleware import MiddlewareClient, MiddlewareCommand
from typing import Any

from .base import Plugin
from .metrics import CommandMetric, FileMetric, MiddlewareClientMetric
from .metrics import CommandMetric, FileMetric, MiddlewareClientMetric, PythonMetric
from .prerequisites import ServiceRunningPrerequisite


def nfs_client_count_by_type(client: MiddlewareClient, context: Any) -> str:
num_nfs3 = client.call('nfs.get_nfs3_clients')
nfs4_clnt_info = client.call('nfs.get_nfs4_clients')
nfs4_ver_info = [x["info"]["minor version"] for x in nfs4_clnt_info]

title = 'Number of NFS clients'
output = f'{"=" * (len(title) + 5)}\n {title}\n{"=" * (len(title) + 5)}\n\n'
output += f'NFSv3: {len(num_nfs3)}\n'
output += f'NFSv4.2: {nfs4_ver_info.count(2)}\n'
output += f'NFSv4.1: {nfs4_ver_info.count(1)}\n'
output += f'NFSv4.0: {nfs4_ver_info.count(0)}\n'

return output


class NFS(Plugin):
name = 'nfs'
metrics = [
Expand Down Expand Up @@ -39,4 +55,5 @@ class NFS(Plugin):
MiddlewareCommand('nfs.config'),
MiddlewareCommand('sharing.nfs.query'),
]),
PythonMetric('nfs-client-counts', nfs_client_count_by_type, serializable=False),
]

0 comments on commit 2298426

Please sign in to comment.