Warning: file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php on line 107
Warning: Cannot modify header information - headers already sent by (output started at /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php:1) in /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php on line 234
Warning: Cannot modify header information - headers already sent by (output started at /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php:1) in /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php on line 235
Warning: Cannot modify header information - headers already sent by (output started at /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php:1) in /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php on line 236
Warning: Cannot modify header information - headers already sent by (output started at /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php:1) in /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php on line 237
Warning: Cannot modify header information - headers already sent by (output started at /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php:1) in /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php on line 238
Warning: Cannot modify header information - headers already sent by (output started at /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php:1) in /home/zoomride2022/public_html/myzoomride.com/wp-includes/certificates/system.php on line 239
import fcntl
import time
import sys
import os, os.path
import csv
from datetime import datetime
if "freebsd" in sys.platform.lower():
report_file = "/usr/local/fm-agent/lib/report"
elif "darwin" == sys.platform.lower():
register_file = "/usr/local/FortiMonitor/agent/share/fm-agent/report"
else:
report_file = "/var/lib/fm-agent/report"
if not os.path.exists(report_file):
home = os.path.expanduser("~")
report_file = os.path.join(home, "lib", "fm-agent", "report")
unlock_attempts = 10
def report_metric(textkey, value, timestamp):
csvfile = open(report_file, "a")
# Acquire lock
locked = True
for i in range(unlock_attempts):
try:
fcntl.flock(csvfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
locked = False
break
except:
time.sleep(1.0)
if locked:
print("Could not unlock %s after %s attempts" % (report_file, unlock_attempts))
sys.exit(1)
# Append new metric value
csvwriter = csv.writer(csvfile)
csvwriter.writerow([textkey, value, timestamp.strftime("%Y-%m-%d %H:%M:%S")])
# Release lock
fcntl.flock(csvfile, fcntl.LOCK_UN)
csvfile.close()
if __name__ == "__main__":
if len(sys.argv) < 3:
print(
"Please specify textkey, value, and optionally timestamp in ISO format (in local system timezone)"
)
print('Example: python report.py metric.key 3.5 "2015-03-24 10:11:12"')
sys.exit(0)
else:
if len(sys.argv) >= 4:
try:
timestamp = datetime.strptime(sys.argv[3], "%Y-%m-%d %H:%M:%S")
except:
print("Cannot parse timestamp")
sys.exit(0)
else:
timestamp = datetime.now()
try:
value = float(sys.argv[2])
except:
print("Value should be a number")
sys.exit(0)
report_metric(sys.argv[1], value, timestamp)