Nagios Python Plugin Check Lock File Exists

#!/usr/bin/python

import os.path
import time
import datetime
import sys
import optparse

"""Check the status of application lock file to be sure it is not stale, warn at critical at 18000 seconds warn at 10800"""
parser = optparse.OptionParser()
parser.add_option('-w', action="store", default="10800", help="seconds to warn", type="int")
parser.add_option('-c', action="store", default="18000", help="seconds to crit", type="int")
options, args = parser.parse_args()

nagOk = 0
nagWarn = 1
nagCrit = 2

try:
    statInfo = os.stat('/opt/application/.sync-lock')
except OSError:
    print("WAITING FOR LOCK FILE")
    sys.exit(nagOk)

now = int(time.time())
statInfoSlice = statInfo[8]
timeDiff = now - statInfoSlice
#print("NOW: %s") % now
#print("FILEAGE: %s") %  statInfoSlice
#print("TIMEDIFF: %s") % timeDiff

if timeDiff > options.c:
    print("CRIT: lock file is older than 5 hours")
    sys.exit(nagCrit)
elif timeDiff > options.w:
    print("WARN: lock file is older than 3 hours")
    sys.exit(nagWarn)
else:
    print("OK: lock file is under 3 hours")
    sys.exit(nagOk)