mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-03 20:31:35 +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> ::=
|
<CrOSOrderByFieldName> ::=
|
||||||
lastsync|location|notes|serialnumber|status|supportenddate|user
|
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> ::=
|
<DriveFieldName> ::=
|
||||||
appdatacontents|
|
appdatacontents|
|
||||||
cancomment|
|
cancomment|
|
||||||
@@ -583,6 +602,7 @@ Items, separated by spaces, with spaces, commas or single quotes in the items th
|
|||||||
<CourseStateList> ::= "<CourseState>(,<CourseState>)*"
|
<CourseStateList> ::= "<CourseState>(,<CourseState>)*"
|
||||||
<CrOSFieldNameList> ::= "<CrOSFieldName>(,<CrOSFieldName>)*"
|
<CrOSFieldNameList> ::= "<CrOSFieldName>(,<CrOSFieldName>)*"
|
||||||
<CrOSIDList> ::= "<CrOSID>(,<CrOSID>)*"
|
<CrOSIDList> ::= "<CrOSID>(,<CrOSID>)*"
|
||||||
|
<CrOSTelemetryFieldNameList> ::= "<CrOSFieldName>(,<CrOSFieldName>)*"
|
||||||
<DriveFileList> ::= "<DriveFileItem>(,<DriveFileItem>)*"
|
<DriveFileList> ::= "<DriveFileItem>(,<DriveFileItem>)*"
|
||||||
<EmailAddressList> ::= "<EmailAddress>(,<EmailAddress>)*"
|
<EmailAddressList> ::= "<EmailAddress>(,<EmailAddress>)*"
|
||||||
<EmailItemList> ::= "<EmailItem>(,<EmailItem>)*"
|
<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.
|
The start <Date> and end <Date> arguments filter the time ranges.
|
||||||
Delimiter defaults to comma.
|
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]
|
gam print chromeapps [todrive]
|
||||||
[ou|org|orgunit <OrgUnitItem>]
|
[ou|org|orgunit <OrgUnitItem>]
|
||||||
[filter <String>]
|
[filter <String>]
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ from gam import controlflow
|
|||||||
from gam import display
|
from gam import display
|
||||||
from gam import gapi
|
from gam import gapi
|
||||||
from gam import utils
|
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 import orgunits as gapi_directory_orgunits
|
||||||
from gam.gapi.directory.cros import _getFilterDate
|
from gam.gapi.directory.cros import _getFilterDate
|
||||||
|
|
||||||
@@ -204,15 +205,17 @@ def printAppDevices():
|
|||||||
|
|
||||||
def printShowCrosTelemetry(show=False):
|
def printShowCrosTelemetry(show=False):
|
||||||
cm = build()
|
cm = build()
|
||||||
|
cd = None
|
||||||
parent = _get_customerid()
|
parent = _get_customerid()
|
||||||
todrive = False
|
todrive = False
|
||||||
filter_ = None
|
filter_ = None
|
||||||
readMask = []
|
readMask = []
|
||||||
|
orgUnitIdPathMap = {}
|
||||||
diskpercentonly = False
|
diskpercentonly = False
|
||||||
|
showOrgUnitPath = False
|
||||||
supported_readmask_values = list(cm._rootDesc['schemas']['GoogleChromeManagementV1TelemetryDevice']['properties'].keys())
|
supported_readmask_values = list(cm._rootDesc['schemas']['GoogleChromeManagementV1TelemetryDevice']['properties'].keys())
|
||||||
supported_readmask_values.sort()
|
supported_readmask_values.sort()
|
||||||
supported_readmask_map = {item.lower():item for item in supported_readmask_values}
|
supported_readmask_map = {item.lower():item for item in supported_readmask_values}
|
||||||
listLimit = 0
|
|
||||||
i = 3
|
i = 3
|
||||||
while i < len(sys.argv):
|
while i < len(sys.argv):
|
||||||
myarg = sys.argv[i].lower().replace('_', '')
|
myarg = sys.argv[i].lower().replace('_', '')
|
||||||
@@ -226,12 +229,26 @@ def printShowCrosTelemetry(show=False):
|
|||||||
else:
|
else:
|
||||||
readMask.append(supported_readmask_map[field_item])
|
readMask.append(supported_readmask_map[field_item])
|
||||||
i += 2
|
i += 2
|
||||||
|
elif myarg in supported_readmask_map:
|
||||||
|
readMask.append(supported_readmask_map[myarg])
|
||||||
|
i += 1
|
||||||
elif myarg == 'filter':
|
elif myarg == 'filter':
|
||||||
filter_ = sys.argv[i+1]
|
filter_ = sys.argv[i+1]
|
||||||
i += 2
|
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':
|
elif myarg == 'todrive':
|
||||||
todrive = True
|
todrive = True
|
||||||
i += 1
|
i += 1
|
||||||
|
elif myarg == 'showorgunitpath':
|
||||||
|
showOrgUnitPath = True
|
||||||
|
cd = gapi_directory.build()
|
||||||
|
i += 1
|
||||||
elif myarg == 'storagepercentonly':
|
elif myarg == 'storagepercentonly':
|
||||||
diskpercentonly = True
|
diskpercentonly = True
|
||||||
i += 1
|
i += 1
|
||||||
@@ -261,6 +278,14 @@ def printShowCrosTelemetry(show=False):
|
|||||||
device['storageInfo'] = {}
|
device['storageInfo'] = {}
|
||||||
device['storageInfo']['percentDiskFree'] = int((disk_avail / disk_size) * 100)
|
device['storageInfo']['percentDiskFree'] = int((disk_avail / disk_size) * 100)
|
||||||
device['storageInfo']['percentDiskUsed'] = 100 - device['storageInfo']['percentDiskFree']
|
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:
|
if show:
|
||||||
for device in devices:
|
for device in devices:
|
||||||
display.print_json(device)
|
display.print_json(device)
|
||||||
|
|||||||
Reference in New Issue
Block a user