Skip to content

Commit

Permalink
Get hostname in a cross-platform way (#117)
Browse files Browse the repository at this point in the history
os.uname()[1] only works on Unix-like operating systems, socket.gethostname() gets the same data in a cross-platform way.

Co-authored-by: Ricardo <[email protected]>
  • Loading branch information
pv2b and bb-Ricardo authored Jul 20, 2023
1 parent e2afaa4 commit f60938e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cr_module/classes/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

from cr_module.classes import plugin_status_types

from cr_module.common import grab
from socket import gethostname


# inventory definition
inventory_layout_version_string = "1.4.0"

Expand Down Expand Up @@ -618,7 +622,7 @@ def to_json(self):
"duration_of_data_collection_in_seconds": (datetime.datetime.utcnow()-self.inventory_start).total_seconds(),
"inventory_layout_version": inventory_layout_version_string,
"data_retrieval_issues": self.data_retrieval_issues,
"host_that_collected_inventory": os.uname()[1],
"host_that_collected_inventory": gethostname(),
"script_version": self.plugin_version,
"inventory_id": self.inventory_id,
"inventory_name": self.inventory_name,
Expand Down

0 comments on commit f60938e

Please sign in to comment.