Skip to content

Commit

Permalink
Revert "CP-47869: Removed rrdd-example.py ocaml/xcp-rrdd/scripts/rrdd/"
Browse files Browse the repository at this point in the history
Signed-off-by: Ashwinh <[email protected]>

This reverts commit a1b06ec.
  • Loading branch information
ashwin9390 committed Jun 12, 2024
1 parent 1afc908 commit 05b6741
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions ocaml/xcp-rrdd/scripts/rrdd/rrdd-example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env python

import rrdd, os

if __name__ == "__main__":
# Create a proxy for communicating with xcp-rrdd.
api = rrdd.API(plugin_id="host_mem")
while True:
# Wait until 0.5 seconds before xcp-rrdd is going to read the output file.
api.wait_until_next_reading(neg_shift=.5)
# Collect measurements.
cmd = "free -k | grep Mem | awk '{print $2, $3, $4}'"
vs = os.popen(cmd).read().strip().split()
# Tell the proxy which datasources should be exposed in this iteration.
api.set_datasource("used_mem", vs[1], min_val=0, max_val=vs[0], units="KB")
api.set_datasource("free_mem", vs[2], min_val=0, max_val=vs[0], units="KB")
# Write all required information into a file about to be read by xcp-rrdd.
api.update()

0 comments on commit 05b6741

Please sign in to comment.