0
我有辦法返回狀態消息以及狀態代碼。 這裏是我的python腳本中的一個例子,我如何返回狀態碼,但不是消息: def checkResults(): 如果不是os.path.exists(jmeter_run_log): print「Status:Unknown。Error processing jmeter results file。文件不存在%路徑。「 %jmeter_run_log sys.exit(3);NRPE狀態消息
numberOfFailures = 0
try:
fileHandler = open(jmeter_run_log, 'r')
#Check for failing requests
for line in fileHandler :
if line.split(jmeter_result_delimiter)[7] == "false":
numberOfFailures += 1
fileHandler.close()
except IOError, (errno, strerror):
print "Status: Critical. CRITICAL - reading jmeter results file failed with error: %s" %(strerror)
sys.exit(2)
if numberOfFailures > 0 :
print "Status: Critical. Number of failure requests = %s " % numberOfFailures
#sendNotificationEmail("Status: Critical. Number of failure requests = %s " % numberOfFailures)
sys.exit(2)
else:
print "Status: OK"
sys.exit(0)