forked from canonical/landscape-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecuritystatus.py
More file actions
22 lines (17 loc) · 764 Bytes
/
securitystatus.py
File metadata and controls
22 lines (17 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python3
import json
import subprocess
import sys
return_info = subprocess.check_output(["ua", "security-status", "--format=json"])
json_output = return_info.decode(sys.stdout.encoding)
ua_security_status = json.loads(json_output)
if "esm-infra" not in ua_security_status["summary"]["ua"]["enabled_services"]:
unpatchable_esm_infra = ua_security_status["summary"]["num_esm_infra_updates"]
else:
unpatchable_esm_infra = 0
if "esm-apps" not in ua_security_status["summary"]["ua"]["enabled_services"]:
unpatchable_esm_apps = ua_security_status["summary"]["num_esm_apps_updates"]
else:
unpatchable_esm_apps = 0
total_unpatchable_esm_updates = unpatchable_esm_infra + unpatchable_esm_apps
print(total_unpatchable_esm_updates)