Module: check_mk
Branch: master
Commit: 2721a7f6db69452eb37f1a964b76df154c2dc41e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2721a7f6db6945…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Oct 30 18:37:33 2014 +0100
HW/SW-Inventory: always create also gzipped version of file
---
modules/inventory.py | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/modules/inventory.py b/modules/inventory.py
index 5c274c1..78c33ea 100644
--- a/modules/inventory.py
+++ b/modules/inventory.py
@@ -24,8 +24,9 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-inventory_output_dir = var_dir + "/inventory"
+import gzip
+inventory_output_dir = var_dir + "/inventory"
inventory_pprint_output = True
# .--Plugins-------------------------------------------------------------.
@@ -251,8 +252,16 @@ def do_inv_for(hostname, ipaddress):
path = inventory_output_dir + "/" + hostname
if g_inv_tree:
file(path, "w").write(r + "\n")
- elif os.path.exists(path): # Remove emtpy inventory files. Important for host
inventory icon
- os.remove(path)
+ gzip.open(path + ".gz", "w").write(r + "\n")
+
+ else:
+ if os.path.exists(path): # Remove empty inventory files. Important for host
inventory icon
+ os.remove(path)
+ if os.path.exists(path + ".gz"):
+ os.remove(path + ".gz")
+
+ # Inform Livestatus about the latest inventory update
+ file(inventory_output_dir + "/.last", "w")
if opt_verbose:
sys.stdout.write("..%s%s%d%s entries" % (tty_bold, tty_yellow,
count_nodes(g_inv_tree), tty_normal))