parser=argparse.ArgumentParser(description='Check the Proxmox API for network traffic for a host.')
parser.add_argument('--node',required=True,help='The name and address of Proxmox node in valid JSON in this format: ["bigserver", "192.168.1.222"]. This allows you to use datalists in Director.')
parser.add_argument('--user',required=True,help='The Proxmox user. Something like "monitoring@pve!icinga2"')
parser.add_argument('--timeframe',default=5,help='Timeframe to average the data to in minutes. Default: 5 minutes')
parser.add_argument('--verify',default=True,help="What to verify the SSL connection with. Can be a file path, or false to disable verification. If you're having issues with CA certs, try setting it to your system's CA bundle (/etc/ssl/certs/ca-certificates.crt).")
parser.add_argument('--verify-force',action='store_true',help="Delete the certifi cert and replace it with whatever you specify in --verify")
parser.add_argument('--table',action='store_true',help='Print the results in a table.')
args=parser.parse_args()
# def where():
# return args.verify
defmain():
ifargs.verify_force:
ifnotargs.verify:
print('UNKNOWN: must supply --verify when using --verify-force')
sys.exit(nagios.UNKNOWN)
ifPath(certifi.where()).exists():
os.remove(certifi.where())
os.symlink(args.verify,certifi.where())
print(f'Pointed {certifi.where()} to {args.verify}')
ifPath(requests.certs.where()).exists():
os.remove(requests.certs.where())
os.symlink(args.verify,requests.certs.where())
print(f'Pointed {requests.certs.where()} to {args.verify}')
try:
metrics_levels=json.loads(args.levels)
exceptExceptionase:
print('UNKNOWN: Failed to parse --levels JSON:',e)