Informazioni su SQLite in Remote Desktop
Remote Desktop archivia le informazioni che raccoglie in un database SQLite.
Informazioni sul database
Remote Desktop raccoglie le informazioni del sistema in una tabella chiamata “systeminformation”. Non mantiene dati storici. I nuovi valori sovrascrivono le informazioni precedentemente acquisite ogni volta che i dati vengono raccolti. Se desideri conservare i dati storici, dovresti acquisire i dati in un secondo database. Inoltre, i dati del database possono risultare utili anche per la distribuzione di macOS, poiché le app possono accedere ai resoconti del computer o sincronizzare impostazioni specifiche sulla base dei valori del database.
Per scopi pratici dovresti trattare il database come se fosse di sola lettura. La struttura del database potrebbe cambiare per adattarsi alle necessità di nuove versioni di Remote Desktop, oppure Remote Desktop, in determinate circostanze, libera il database per prevenire problemi.
Puoi trovare il database SQLite in /private/var/db/RemoteManagement/RMDB/rmdb.sqlite3. L'accesso alla directory RMDB è limitato all'utente daemon, perciò è richiesto l'accesso da super utente (sudo) per accedere ai file. Quando utilizzi sudo prima dei comandi, ti verrà richiesta la password di amministratore.
Recuperare i dati utilizzando la linea di comando
Lo strumento sqlite3 è installato in /usr/bin/sqlite3.
Lo strumento sqlite3 fornisce l'accesso alle tabelle e ai dati nel database di Remote Desktop. Il seguente comando invia una richiesta ad SQL nella tabella “systeminformation” (la tabella che raccoglie i dati del resoconto).
sudo sqlite3 /var/db/RemoteManagement/RMDB/rmdb.sqlite3 "select * from systeminformation"Ecco un esempio delle prime linee di output. Le linee potrebbero apparire diversamente in base alle dimensioni del font e della finestra.
00:0d:93:9c:0a:e4|Mac_HardDriveElement|DataDate|0|2008-12-11T23:05:58Z|2008-12-11T23:05:58Z00:0d:93:9c:0a:e4|Mac_HardDriveElement|Model|0|Hitachi HDS722580VLSA80|2008-12-11T23:05:58Z00:0d:93:9c:0a:e4|Mac_HardDriveElement|VolumeName|0|Server HD|2008-12-11T23:05:58Z00:0d:93:9c:0a:e4|Mac_HardDriveElement|JournalingIsActive|0|true|2008-12-11T23:05:58Z00:0d:93:9c:0a:e4|Mac_HardDriveElement|LastBackupDate|0|2008-09-05T18:13:22Z|2008-12-11T23:05:58Z00:0d:93:9c:0a:e4|Mac_HardDriveElement|LastModificationDate|0|2008-12-11T23:05:57Z|2008-12-11T23:05:58ZRegola il limitatore utilizzato tra le colonne con l'opzione -separator. Questo esempio usa un separatore virgola.
sudo sqlite3 -separator , /var/db/RemoteManagement/RMDB/rmdb.sqlite3 "select * from systeminformation"Altre opzioni utili sono -html, -line, -list e -column. Per maggiori dettagli consulta la pagina man di sqlite3.
Questo comando fornisce un output in colonne ben leggibili e mostra le intestazioni delle colonne.
sudo sqlite3 -header -column /var/db/RemoteManagement/RMDB/rmdb.sqlite3 \    "select * from systeminformation"ComputerID        ObjectName           PropertyName ItemSeq    Value                LastUpdated----------------- -------------------- ------------ ---------- -------------------- --------------------00:0d:93:9c:0a:e4 Mac_HardDriveElement DataDate     0          2008-12-11T23:05:58Z 2008-12-11T23:05:58Z00:0d:93:9c:0a:e4 Mac_HardDriveElement Model        0          Hitachi HDS722580VLS 2008-12-11T23:05:58Z00:0d:93:9c:0a:e4 Mac_HardDriveElement VolumeName   0          Server HD            2008-12-11T23:05:58Z00:0d:93:9c:0a:e4 Mac_HardDriveElement JournalingIs 0          true                 2008-12-11T23:05:58Z00:0d:93:9c:0a:e4 Mac_HardDriveElement LastBackupDa 0          2008-09-05T18:13:22Z 2008-12-11T23:05:58Z00:0d:93:9c:0a:e4 Mac_HardDriveElement LastModifica 0          2008-12-11T23:05:57Z 2008-12-11T23:05:58Z00:0d:93:9c:0a:e4 Mac_HardDriveElement TotalSize    0          80287128.000000      2008-12-11T23:05:58ZIl campo ComputerID riporta l'indirizzo MAC Ethernet del client che ha risposto con dati di resoconto e può essere utilizzato come valore unico per formulare le richieste SQL. Visualizza tutti gli objectname modificando l'SQL dall'esempio qui sopra, in modo che riporti:
sudo sqlite3 -header -column /var/db/RemoteManagement/RMDB/rmdb.sqlite3 \    "SELECT distinct objectname FROM systeminformation"Output:
ObjectName -------------------- Mac_HardDriveElementMac_NetworkInterfaceMac_SystemInfoElemenMac_RAMSlotElementMac_PCIBusElementMac_USBDeviceElementMac_FireWireDeviceElPer ogni objectname ci sono un gran numero di possibili valori propertyname. Modificando la tua richiesta, riceverai le coppie objectname/propertyname disponibili:
sudo sqlite3 -header -column /var/db/RemoteManagement/RMDB/rmdb.sqlite3 \    "SELECT distinct objectname, propertyname FROM systeminformation"Output:
ObjectName           PropertyName -------------------- ------------Mac_HardDriveElement DataDateMac_HardDriveElement ModelMac_HardDriveElement VolumeNameMac_HardDriveElement JournalingIsMac_HardDriveElement LastBackupDaMac_HardDriveElement LastModificaQueste proprietà si combineranno per aiutarti a formare una richiesta SQL che riporti un valore specifico. Per esempio, per trovare i numeri di serie dei client, potresti utilizzare:
sudo sqlite3 -header -column /var/db/RemoteManagement/RMDB/rmdb.sqlite3 "SELECT distinct computerid, propertyname, value FROM systeminformation WHERE propertyname = 'MachineSerialNumber'"ComputerID        PropertyName        Value ----------------- ------------------- ----------- 00:0d:93:9c:0a:e4 MachineSerialNumber QP4241FHPMZ 00:16:cb:a2:6d:1b MachineSerialNumber YM6090M9U39 00:16:cb:ca:81:52 MachineSerialNumber W862100NW92 00:17:f2:04:db:24 MachineSerialNumber G86492DVX68 00:14:51:22:28:38 MachineSerialNumber W854503QURC 00:17:f2:2b:b9:59 MachineSerialNumber 4H63861KVMMAssicurati che la richiesta SQL riporti un elenco dei nomi dei computer (al posto degli ID Ethernet) e dei valori:
sudo sqlite3 -header -column /var/db/RemoteManagement/RMDB/rmdb.sqlite3 "SELECT R1.value, R2.value FROM systeminformation R1, systeminformation R2 WHERE R1.computerid=R2.computerid AND R1.propertyname='ComputerName' AND R2.propertyName='MachineSerialNumber'"Output:
Value      Value ---------- ----------- mini     X0XX234XYXYX mini       X01X23X4XXXX NetBoot001 X01X0101XXX0 Server     XX12345XXX6 Server2    PPYWWSSSEEER Aga O    X0XX123XY4XYUtilizzare Automator con un comando sqlite
Dato che Automator può eseguire comandi shell, può essere utilizzato per raccogliere output sqlite3 e inviarli ad altre app. Questo esempio raccoglie dati da un resoconto e li invia a TextEdit:
on run {input, parameters}    return do shell script "/usr/bin/sqlite3 -separator " & quote & tab & quote & " /var/db/RemoteManagement/RMDB/rmdb.sqlite3 " & quote & input & quote with administrator privilegesend runIl flusso di lavoro fornisce un comando SQL, quindi costruisce un comando della shell utilizzando l'azione “Esegui AppleScript”, che può far apparire una finestra d'autenticazione. Il limitatore nell'esempio è tabulazione.
Elementi delle richieste sqlite
I seguenti elementi possono essere richiesti utilizzando sqlite:
Mac_SystemInfoElement
- ActiveProcessorCount 
- AppleTalkIsActive 
- ATADeviceCount 
- ARDComputerInfo1 
- ARDComputerInfo2 
- ARDComputerInfo3 
- ARDComputerInfo4 
- BootROMVersion 
- BusDataSize 
- BusSpeed 
- BusSpeedString 
- ComputerName 
- DataDate 
- En0Address 
- FileSharingIsEnabled 
- FireWireDeviceCount 
- FTPIsEnabled 
- HasKeyboardConnected 
- HasLightsOutController 
- HasMouseConnected 
- HasVectorProcessingUnit 
- KernelVersion 
- Level2CacheSize 
- MachineClass 
- MachineModel 
- MachineSerialNumber 
- MainMonitorDepth 
- MainMonitorHeight 
- MainMonitorType 
- MainMonitorWidth 
- ModemCountryInfo 
- ModemDescription 
- ModemDriverInfo 
- ModemInstalled 
- ModemInterfaceType 
- OpticalDriveType 
- PCISlotsUsedCount 
- PhysicalMemorySize 
- PrimaryIPAddress 
- PrimaryNetworkCollisions 
- PrimaryNetworkFlags 
- PrimaryNetworkHardwareAddress 
- PrimaryNetworkInputErrors 
- PrimaryNetworkInputPackets 
- PrimaryNetworkOutputErrors 
- PrimaryNetworkOutputPackets 
- PrimaryNetworkType 
- PrinterSharingEnabled 
- ProcessorCount 
- ProcessorSpeed 
- ProcessorSpeedString 
- ProcessorType 
- RemoteAppleEventsEnabled 
- RemoteLoginEnabled 
- SCSIDeviceCount 
- SelectedPrinterName 
- SelectedPrinterPostScriptVersion 
- SelectedPrinterType 
- SleepDisplayWhenInactive 
- SleepWhenInactive 
- SpinDownHardDrive 
- SystemVersion 
- SystemVersionString 
- TotalFreeHardDriveSpace 
- TotalHardDriveSpace 
- TotalRAMSlots 
- TotalSwapFileSize 
- TrashSize 
- UnixHostName 
- UnusedRAMSlots 
- USBDeviceCount 
- UserMemorySize 
- WakeOnLanEnabled 
- WebSharingIsEnabled 
- WindowsFileSharingEnabled 
- WirelessCardFirmwareVersion 
- WirelessCardHardwareAddress 
- WirelessCardIsActive 
- WirelessCardInstalled 
- WirelessCardLocale 
- WirelessCardType 
- WirelessChannelNumber 
- WirelessIsComputerToComputer 
- WirelessNetworkAvailable 
- WirelessNetworkName 
Mac_HardDriveElement
- CreationDate 
- DataDate 
- FileSystemType 
- FreeSpace 
- GroupName 
- IsBootVolume 
- IsCasePreserving 
- IsCaseSensitive 
- IsDetachable 
- IsWritable 
- JournalingIsActive 
- LastBackupDate 
- LastConsistencyCheckDate 
- LastModificationDate 
- LogicalUnitNumber 
- Produttore 
- Modello 
- OwnerName 
- PermissionModes 
- PermissionsAreEnabled 
- Protocollo 
- RemovableMedia 
- Revision 
- SerialNumber 
- SupportsJournaling 
- TotalFileCount 
- TotalFolderCount 
- TotalSize 
- UnixMountPoint 
- VolumeName 
Mac_NetworkInterfaceElement
- AllDNSServers 
- AllIPAddresses 
- ConfigurationName 
- ConfigurationType 
- DataDate 
- DomainName 
- EthernetAlignmentErrors 
- EthernetCarrierSenseErrors 
- EthernetChipSet 
- EthernetCollisionFrequencies 
- EthernetDeferredTransmissions 
- EthernetExcessiveCollisions 
- EthernetFCSErrors 
- EthernetFrameTooLongs 
- EthernetInternalMacRxErrors 
- EthernetInternalMacTxErrors 
- EthernetLateCollisions 
- EthernetMissedFrames 
- EthernetMultipleCollisionFrames 
- EthernetRxCollisionErrors 
- EthernetRxFrameTooShorts 
- EthernetRxInterrupts 
- EthernetRxOverruns 
- EthernetRxPHYTransmissionErrors 
- EthernetRxResets 
- EthernetRxResourceErrors 
- EthernetRxTimeouts 
- EthernetRxWatchdogTimeouts 
- EthernetSingleCollisionFrames 
- EthernetSQETestErrors 
- EthernetTxInterrupts 
- EthernetTxJabberEvents 
- EthernetTxPHYTransmissionErrors 
- EthernetTxResets 
- EthernetTxResourceErrors 
- EthernetTxTimeouts 
- EthernetTxUnderruns 
- HardwareAddress 
- InterfaceFlags 
- InterfaceName 
- IsActive 
- IsPrimary 
- NetworkCollisions 
- NetworkInputErrors 
- NetworkInputPackets 
- NetworkOutputErrors 
- NetworkOutputPackets 
- OutputQueueCapacity 
- OutputQueueDropCount 
- OutputQueueOutputCount 
- OutputQueuePeakSize 
- OutputQueueRetryCount 
- OutputQueueSize 
- OutputQueueStallCount 
- PrimaryDNSServer 
- PrimaryIPAddress 
- RouterAddress 
Mac_USBDeviceElement
- BusPower 
- DataDate 
- DeviceSpeed 
- ProductID 
- ProductName 
- SerialNumber 
- VendorID 
Mac_FireWireDeviceElement
- DataDate 
- DeviceSpeed 
- Produttore 
- Modello 
Mac_RAMSlotElement
- DataDate 
- MemoryModuleSize 
- MemoryModuleSpeed 
- MemoryModuleSpeed 
- MemoryModuleSpeed 
Mac_PCIBusElement
- CardMemory 
- CardName 
- CardRevision 
- CardType 
- DataDate 
- DeviceID 
- RomRevision 
- SlotName 
- VendorID