I am opening a file in append mode once and then writing to it in a loop But I hit this error after a while and my script dies.
This is what I run
python monitor_free.py ucs107-cip-m 86400 &
My script goes like this
import sys
import time
from sp_cluster import SpCluster
clusterip = sys.argv[1]
timeout = int(sys.argv[2])
cl = SpCluster(str(clusterip))
x = cl.stctlvms
f = open("free_stat.txt", "a")
start_time = time.time()
elapsed = 0
seperator = "*" * 79
while(elapsed < timeout):
for vm in x:
text, _, _ = vm.ssh_cmd("free -ko -bm")
dates, _, _ = vm.ssh_cmd("date")
f.write(seperator)
f.write("\n")
f.write(str(vm.fqdn))
f.write("\n")
f.write(str(dates))
f.write("\n")
f.write(str(text))
f.write("\n")
time.sleep(10)
elapsed = time.time() - start_time
My understanding was that there should only be one fd open the whole time....but seems like its wrong... anyone knows whats happening?
Error is thrown by paramiko
ERROR: Unknown exception: [Errno 24] Too many open files: '/dev/urandom'
ERROR: Traceback (most recent call last):
ERROR: File "/usr/local/lib/python2.7/dist- packages/paramiko/transport.py", line 1719, in run
ERROR: File "/usr/local/lib/python2.7/dist-packages/paramiko/transport.py", line 1909, in _send_kex_init
ERROR: OSError: [Errno 24] Too many open files: '/dev/urandom'