Server IP : 92.204.138.22 / Your IP : 3.133.152.153 Web Server : Apache System : Linux ns1009439.ip-92-204-138.us 4.18.0-553.8.1.el8_10.x86_64 #1 SMP Tue Jul 2 07:26:33 EDT 2024 x86_64 User : internationaljou ( 1019) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/internationaljou/public_html/admin/js/BROKY_ADMIN/alfasymlink/root/proc/thread-self/root/bin/panopta-agent/ |
Upload File : |
import fcntl import time import sys import os, os.path import csv if 'freebsd' in sys.platform.lower() or "darwin" in sys.platform.lower(): register_file = "/usr/local/panopta-agent/lib/register" else: register_file = '/var/lib/panopta-agent/register' if not os.path.exists(register_file): home = os.path.expanduser("~") register_file = os.path.join(home, "lib", "panopta-agent", "register") unlock_attempts = 10 def register_metric(textkey, description): csvfile = open(register_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" % (register_file, unlock_attempts)) sys.exit(1) # Append new metrics csvwriter = csv.writer(csvfile) csvwriter.writerow([textkey, description]) # Release lock fcntl.flock(csvfile, fcntl.LOCK_UN) csvfile.close() if __name__ == "__main__": if len(sys.argv) < 3: print("Please specify textkey and description") sys.exit(0) else: register_metric(sys.argv[1], sys.argv[2])