text: #!/usr/bin/env python3
  #
  ## custom_worker_monitor for TFE
  #
  ##########################################################################################
  
  from prometheus_client import CollectorRegistry, Gauge, push_to_gateway
  from subprocess import check_output
  import time
  import sys
  
  if __name__ == '__main__':
    ## setup
    #
    if len(sys.argv) != 3:
      print('ERROR: incorrect arguments supplied')
      exit(1)
  
    ## start the collector registry
    ## https://github.com/prometheus/client_python#exporting-to-a-pushgateway
    #
    registry = CollectorRegistry()
  
    ## Create gauge for RAM consumption and iteratively
    #
    g = Gauge(
      'tfe_worker_usage_in_bytes',
      'RAM gauge',
      registry=registry
    )
  
    ## loop over RAM consumption and push to the gateway
    #
    while True:
      ram_output = check_output(['cat','/sys/fs/cgroup/memory/memory.usage_in_bytes'])
      g.set(ram_output.decode())
      label=sys.argv[1]
      host_ip=sys.argv[2]
      push_to_gateway(f'{host_ip}:9091', job=label, registry=registry)
      time.sleep(1)
  