actually we want password auth

This commit is contained in:
Cyberes 2023-09-09 12:15:36 -06:00
parent bae0d7acb6
commit 6c5c6ea7cb
1 changed files with 3 additions and 5 deletions

View File

@ -18,8 +18,7 @@ from checker.units import filesize
parser = argparse.ArgumentParser(description='Check the Proxmox API for network traffic for a host.') 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('--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"') parser.add_argument('--user', required=True, help='The Proxmox user. Something like "monitoring@pve"')
parser.add_argument('--token', required=True, help='API token.') parser.add_argument('--password', required=True, help='API password.')
parser.add_argument('--token-name', required=True, help='API token name.')
parser.add_argument('--host', required=True, help='The ID of the host to check.') parser.add_argument('--host', required=True, help='The ID of the host to check.')
parser.add_argument('--type', required=True, choices=['qemu', 'lxc'], help='Type of host. "qemu" or "lxc"') parser.add_argument('--type', required=True, choices=['qemu', 'lxc'], help='Type of host. "qemu" or "lxc"')
parser.add_argument('--metrics', required=True, help='What stats to check. Can list multiple seperated by commas. For example, "netin,netout"') parser.add_argument('--metrics', required=True, help='What stats to check. Can list multiple seperated by commas. For example, "netin,netout"')
@ -64,7 +63,7 @@ def main():
print('UNKNOWN: Failed to parse --node JSON:', e) print('UNKNOWN: Failed to parse --node JSON:', e)
sys.exit(nagios.UNKNOWN) sys.exit(nagios.UNKNOWN)
prox = ProxmoxAPI(pve_node_address, user=args.user, token_name=args.token_name, token_value=args.token, verify_ssl=args.verify) prox = ProxmoxAPI(pve_node_address, user=args.user, password=args.password, verify_ssl=args.verify)
try: try:
user_perms = prox('access/permissions').get() user_perms = prox('access/permissions').get()
@ -84,8 +83,7 @@ def main():
sys.exit(nagios.UNKNOWN) sys.exit(nagios.UNKNOWN)
except ResourceException as e: except ResourceException as e:
print('UNKNOWN:', e) print('UNKNOWN:', e)
print(f'Proxmox reported "{args.user}!{args.token_name}" permissions as:', user_perms) print(f'Proxmox reported "{args.user}" permissions as:', user_perms)
print("Did you remember to give both your user and the user's API token the same privileges?")
sys.exit(nagios.UNKNOWN) sys.exit(nagios.UNKNOWN)
except Exception as e: except Exception as e:
print('UNKNOWN: failed to connect to Proxmox API:', e) print('UNKNOWN: failed to connect to Proxmox API:', e)