diff --git a/src/GamCommands.txt b/src/GamCommands.txt index af15a9eb..942c5fed 100644 --- a/src/GamCommands.txt +++ b/src/GamCommands.txt @@ -316,6 +316,25 @@ If an item contains spaces, it should be surrounded by ". ::= lastsync|location|notes|serialnumber|status|supportenddate|user + ::= + batteryinfo| + batterystatusreport| + cpuinfo| + cpustatusreport| + customer| + deviceid| + graphicsinfo| + graphicsstatusreport| + memoryinfo| + memorystatusreport| + name| + networkstatusreport| + orgunitid| + osupdatestatus| + serialnumber| + storageinfo| + storagestatusreport + ::= appdatacontents| cancomment| @@ -583,6 +602,7 @@ Items, separated by spaces, with spaces, commas or single quotes in the items th ::= "(,)*" ::= "(,)*" ::= "(,)*" + ::= "(,)*" ::= "(,)*" ::= "(,)*" ::= "(,)*" @@ -1265,6 +1285,15 @@ The listlimit argument limits the number of recent users, time ranges a The start and end arguments filter the time ranges. Delimiter defaults to comma. +gam show crostelemetry + [(ou|org|orgunit )|(cros_sn )|(filter )] + * [fields ] + [storagepercentonly] [showorgunitpath] +gam print crostelemetry [todrive] + [(ou|org|orgunit )|(cros_sn )|(filter )] + * [fields ] + [storagepercentonly] [showorgunitpath] + gam print chromeapps [todrive] [ou|org|orgunit ] [filter ] diff --git a/src/gam/gapi/chromemanagement.py b/src/gam/gapi/chromemanagement.py index 59b79558..436ec735 100644 --- a/src/gam/gapi/chromemanagement.py +++ b/src/gam/gapi/chromemanagement.py @@ -10,6 +10,7 @@ from gam import controlflow from gam import display from gam import gapi from gam import utils +from gam.gapi import directory as gapi_directory from gam.gapi.directory import orgunits as gapi_directory_orgunits from gam.gapi.directory.cros import _getFilterDate @@ -204,15 +205,17 @@ def printAppDevices(): def printShowCrosTelemetry(show=False): cm = build() + cd = None parent = _get_customerid() todrive = False filter_ = None readMask = [] + orgUnitIdPathMap = {} diskpercentonly = False + showOrgUnitPath = False supported_readmask_values = list(cm._rootDesc['schemas']['GoogleChromeManagementV1TelemetryDevice']['properties'].keys()) supported_readmask_values.sort() supported_readmask_map = {item.lower():item for item in supported_readmask_values} - listLimit = 0 i = 3 while i < len(sys.argv): myarg = sys.argv[i].lower().replace('_', '') @@ -226,12 +229,26 @@ def printShowCrosTelemetry(show=False): else: readMask.append(supported_readmask_map[field_item]) i += 2 + elif myarg in supported_readmask_map: + readMask.append(supported_readmask_map[myarg]) + i += 1 elif myarg == 'filter': filter_ = sys.argv[i+1] i += 2 + elif myarg in ['ou', 'org', 'orgunit']: + _, orgUnitId = gapi_directory_orgunits.getOrgUnitId(sys.argv[i + 1], None) + filter_ = f'orgUnitId={orgUnitId[3:]}' + i += 2 + elif myarg == 'crossn': + filter_ = f'serialNumber={sys.argv[i + 1]}' + i += 2 elif myarg == 'todrive': todrive = True i += 1 + elif myarg == 'showorgunitpath': + showOrgUnitPath = True + cd = gapi_directory.build() + i += 1 elif myarg == 'storagepercentonly': diskpercentonly = True i += 1 @@ -261,6 +278,14 @@ def printShowCrosTelemetry(show=False): device['storageInfo'] = {} device['storageInfo']['percentDiskFree'] = int((disk_avail / disk_size) * 100) device['storageInfo']['percentDiskUsed'] = 100 - device['storageInfo']['percentDiskFree'] + for cpuStatusReport in device.get('cpuStatusReport', []): + for tempInfo in cpuStatusReport.pop('cpuTemperatureInfo', []): + cpuStatusReport[f"cpuTemperatureInfo.{tempInfo['label'].strip()}"] = tempInfo['temperatureCelsius'] + if showOrgUnitPath: + orgUnitId = device.get('orgUnitId') + if orgUnitId not in orgUnitIdPathMap: + orgUnitIdPathMap[orgUnitId] = gapi_directory_orgunits.orgunit_from_orgunitid(orgUnitId, cd) + device['orgUnitPath'] = orgUnitIdPathMap[orgUnitId] if show: for device in devices: display.print_json(device)