Skip to content

Commit 67e043f

Browse files
committed
Made it even more better.
This refactor brought my text execution time from ~20s to ~1.3s
1 parent 3faeb73 commit 67e043f

1 file changed

Lines changed: 12 additions & 17 deletions

File tree

inventory/linux.cf

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,18 @@ bundle common inventory_linux
4141
if => strcmp("$(proc_routes[$(routeidx)][1])", "00000000");
4242

4343
linux::
44-
"nfs_servers" -> { "CFE-3259" }
45-
comment => "NFS servers (to list hosts impacted by NFS outages)",
46-
slist => maplist( regex_replace( $(this) , ":.*", "", "g"),
47-
# NFS server is before the colon (:), that's all we want
48-
# e.g., nfs.example.com:/vol/homedir/user1 /home/user1 ...
49-
# ^^^^^^^^^^^^^^^
50-
grep( ".* nfs .*",
51-
readstringlist("/proc/$(this.promiser_pid)/mounts", "", "\n", inf, inf)
52-
)
53-
),
54-
if => and( fileexists( "/proc/$(this.promiser_pid)/mounts" ),
55-
not( isvariable( "$(this.promiser)" ) ) );
56-
57-
58-
"nfs_server[$(nfs_servers)]"
59-
string => "$(nfs_servers)",
60-
meta => { "inventory", "attribute_name=NFS Server" };
44+
45+
"mounts" string => "/proc/$(this.promiser_pid)/mounts";
46+
47+
"nfs_mounts"
48+
slist => grep( ".* nfs .*",
49+
readstringlist("$(mounts)", "", "\n", inf, inf) ),
50+
if => not( isvariable( "$(this.promiser)" ) );
51+
52+
"nfs_server[$(nfs_mounts)]" -> { "CFE-3259", "ENT-13210" }
53+
string => regex_replace( "$(nfs_mounts)", ":.*", "", "g" ),
54+
meta => { "inventory", "attribute_name=NFS Server" },
55+
if => not( isvariable( "$(this.promiser)" ) );
6156

6257

6358
classes:

0 commit comments

Comments
 (0)