ansible/roles/nagios_server/files/nagios/plugins/check_lock
2017-01-05 00:55:16 +00:00

17 lines
307 B
Python
Executable file

#!/usr/bin/python
import fcntl
import sys
try:
f = open('/mnt/koji/.nagios_test', 'r')
f.close()
f = open('/mnt/koji/.nagios_test', 'w')
except IOError:
print "Could not create file"
sys.exit(2)
fcntl.flock(f, fcntl.LOCK_EX)
f.close()
print "File Locked Successfully"
sys.exit(0)