2020-10-05 15:17:25 +01:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
from __future__ import print_function
|
2017-01-05 00:55:16 +00:00
|
|
|
import fcntl
|
|
|
|
import sys
|
2020-10-05 15:17:25 +01:00
|
|
|
|
2017-01-05 00:55:16 +00:00
|
|
|
try:
|
|
|
|
f = open('/mnt/koji/.nagios_test', 'r')
|
|
|
|
f.close()
|
|
|
|
f = open('/mnt/koji/.nagios_test', 'w')
|
2020-10-05 15:17:25 +01:00
|
|
|
except IOError as e:
|
|
|
|
print(e)
|
|
|
|
print("Could not create file")
|
2017-01-05 00:55:16 +00:00
|
|
|
sys.exit(2)
|
|
|
|
|
|
|
|
fcntl.flock(f, fcntl.LOCK_EX)
|
|
|
|
f.close()
|
2020-10-05 15:17:25 +01:00
|
|
|
print("File Locked Successfully")
|
2017-01-05 00:55:16 +00:00
|
|
|
sys.exit(0)
|