<< Click to Display Table of Contents >> Raynet One > 1.1 > User Guide > Technical overview > Custom inventory scripting > Python inventory scripting Use case: fetching Linux users |
View the user list of your IT landscape devices powered by Linux distributions. Get more out of your devices by assigning multiple users to single devices. Detect devices overloaded by too many users to balance device use across the entire network.
Supported OS types: Linux
osf = PythonConnector.os_family()
if osf == "Linux":
lines = PythonConnector.run("cat /etc/passwd")
if lines:
for L in lines:
TKS = L.split(":")
if len(TKS) == 7:
U = PythonConnector.create_item("UnixUser", TKS[0])
PythonConnector.add_property("UID", TKS[2], U)
PythonConnector.add_property("GID", TKS[3], U)
PythonConnector.add_property("GECOS", TKS[4], U)
PythonConnector.add_property("HomeDir", TKS[5], U)
PythonConnector.add_property("Shell", TKS[6], U)
PythonConnector.add_item(U)
print("Collected Linux user inventory")
else:
print("Unsupported platform for user collection")