mirror of
https://github.com/GAM-team/GAM.git
synced 2026-06-28 09:51:36 +00:00
Make print crostelemetry consistent print cros (#1463)
* Make print crostelemetry consistent print cros Strip newline from cpuStatusReport.cpuTemperature.label Replace list of label/temperatureCelsius pairs with cpuStatusReport.cpuTemperature.label = temperaureCelsius * Document print crostelemetry * Update GamCommands.txt * More work on print crostelemetry
This commit is contained in:
@@ -316,6 +316,25 @@ If an item contains spaces, it should be surrounded by ".
|
||||
<CrOSOrderByFieldName> ::=
|
||||
lastsync|location|notes|serialnumber|status|supportenddate|user
|
||||
|
||||
<CrOSTelemetryFieldName> ::=
|
||||
batteryinfo|
|
||||
batterystatusreport|
|
||||
cpuinfo|
|
||||
cpustatusreport|
|
||||
customer|
|
||||
deviceid|
|
||||
graphicsinfo|
|
||||
graphicsstatusreport|
|
||||
memoryinfo|
|
||||
memorystatusreport|
|
||||
name|
|
||||
networkstatusreport|
|
||||
orgunitid|
|
||||
osupdatestatus|
|
||||
serialnumber|
|
||||
storageinfo|
|
||||
storagestatusreport
|
||||
|
||||
<DriveFieldName> ::=
|
||||
appdatacontents|
|
||||
cancomment|
|
||||
@@ -583,6 +602,7 @@ Items, separated by spaces, with spaces, commas or single quotes in the items th
|
||||
<CourseStateList> ::= "<CourseState>(,<CourseState>)*"
|
||||
<CrOSFieldNameList> ::= "<CrOSFieldName>(,<CrOSFieldName>)*"
|
||||
<CrOSIDList> ::= "<CrOSID>(,<CrOSID>)*"
|
||||
<CrOSTelemetryFieldNameList> ::= "<CrOSFieldName>(,<CrOSFieldName>)*"
|
||||
<DriveFileList> ::= "<DriveFileItem>(,<DriveFileItem>)*"
|
||||
<EmailAddressList> ::= "<EmailAddress>(,<EmailAddress>)*"
|
||||
<EmailItemList> ::= "<EmailItem>(,<EmailItem>)*"
|
||||
@@ -1265,6 +1285,15 @@ The listlimit <Number> argument limits the number of recent users, time ranges a
|
||||
The start <Date> and end <Date> arguments filter the time ranges.
|
||||
Delimiter defaults to comma.
|
||||
|
||||
gam show crostelemetry
|
||||
[(ou|org|orgunit <OrgUnitItem>)|(cros_sn <SerialNumber>)|(filter <String>)]
|
||||
<CrOSTelemetryFieldName>* [fields <CrOSTelemetryFieldNameList>]
|
||||
[storagepercentonly] [showorgunitpath]
|
||||
gam print crostelemetry [todrive]
|
||||
[(ou|org|orgunit <OrgUnitItem>)|(cros_sn <SerialNumber>)|(filter <String>)]
|
||||
<CrOSTelemetryFieldName>* [fields <CrOSTelemetryFieldNameList>]
|
||||
[storagepercentonly] [showorgunitpath]
|
||||
|
||||
gam print chromeapps [todrive]
|
||||
[ou|org|orgunit <OrgUnitItem>]
|
||||
[filter <String>]
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user