ansible/roles/nagios_client/files/scripts/check_lock
2020-10-05 15:17:25 +01:00

19 lines
367 B
Python

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