-
Notifications
You must be signed in to change notification settings - Fork 79
/
powerlog_power_state.txt
282 lines (263 loc) · 11 KB
/
powerlog_power_state.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# --------------------------------------------------------------------------------
# Copyright (c) 2018-2020 Sarah Edwards (Station X Labs, LLC,
# @iamevltwin, mac4n6.com). All rights reserved.
# This software is provided "as is," without warranty of any kind,
# express or implied. In no event shall the author or contributors
# be held liable for any damages arising in any way from the use of
# this software.
# The contents of this file are DUAL-LICENSED. You may modify and/or
# redistribute this software according to the terms of one of the
# following two licenses (at your option):
# LICENSE 1 ("BSD-like with acknowledgment clause"):
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute
# it freely, subject to the following restrictions:
# 1. Redistributions of source code must retain the above copyright
# notice, disclaimer, and this list of conditions.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, disclaimer, and this list of conditions in the documenta-
# tion and/or other materials provided with the distribution.
# 3. All advertising, training, and documentation materials mentioning
# features or use of this software must display the following
# acknowledgment. Character-limited social media may abbreviate this
# acknowledgment to include author and APOLLO name ie: "This new
# feature brought to you by @iamevltwin's APOLLO". Please make an
# effort credit the appropriate authors on specific APOLLO modules.
# The spirit of this clause is to give public acknowledgment to
# researchers where credit is due.
# This product includes software developed by Sarah Edwards
# (Station X Labs, LLC, @iamevltwin, mac4n6.com) and other
# contributors as part of APOLLO (Apple Pattern of Life Lazy
# Output'er).
# LICENSE 2 (GNU GPL v3 or later):
# This file is part of APOLLO (Apple Pattern of Life Lazy Output'er).
# APOLLO is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# APOLLO is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with APOLLO. If not, see <https://www.gnu.org/licenses/>.
# --------------------------------------------------------------------------------
[Module Metadata]
AUTHOR=Sarah Edwards/mac4n6.com/@iamevltwin
MODULE_NOTES=Power State, Sleep/Wake Status
[Database Metadata]
DATABASE=CurrentPowerlog.PLSQL
PLATFORM=MACOS
VERSIONS=10.14,10.15,10.16
[Query Metadata]
QUERY_NAME=powerlog_power_state
ACTIVITY=Power State
KEY_TIMESTAMP=ADJUSTED_TIMESTAMP
[SQL Query 10.16]
QUERY=
SELECT
DATETIME(TIMESTAMP + SYSTEM, 'UNIXEPOCH') AS ADJUSTED_TIMESTAMP,
DATETIME(TIMESTAMPLOGGED + SYSTEM, 'UNIXEPOCH') AS ADJUSTED_LOGGED_TIMESTAMP,
UUID AS 'UUID',
REASON AS 'REASON',
REASONVALUE AS 'REASON VALUE',
WAKEREASON AS 'WAKE REASON',
SLEEPTRIGGERS AS 'SLEEP TRIGGERS',
STATE AS 'STATE',
EVENT AS 'EVENT',
DRIVERWAKEREASON,
CAPABILITIES AS 'CAPABILITIES',
CURRENTKERNELWAKETIME AS 'CURRENT KERNEL WAKE TIME',
DATETIME(KERNELSLEEPDATE, 'UNIXEPOCH') AS 'KERNEL SLEEP DATE',
DATETIME(TIMESTAMP, 'UNIXEPOCH') AS ORIGINAL_TIMESTAMP,
DATETIME(TIME_OFFSET_TIMESTAMP, 'UNIXEPOCH') AS OFFSET_TIMESTAMP,
SYSTEM AS TIME_OFFSET,
TABLE_ID AS "PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE TABLE ID"
FROM
(
SELECT
TABLE_ID,
TIMESTAMP,
TIME_OFFSET_TIMESTAMP,
MAX(TIME_OFFSET_ID) AS MAX_ID,
TIMESTAMPLOGGED,
CAPABILITIES,
CURRENTKERNELWAKETIME,
EVENT,
KERNELSLEEPDATE,
REASON,
SLEEPTRIGGERS,
STATE,
UUID,
DRIVERWAKEREASON,
REASONVALUE,
WAKEREASON,
SYSTEM
FROM
(
SELECT
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.TIMESTAMP,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.TIMESTAMPLOGGED,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.CAPABILITIES,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.CURRENTKERNELWAKETIME,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.EVENT,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.KERNELSLEEPDATE,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.REASON,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.SLEEPTRIGGERS,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.STATE,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.UUID,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE_ARRAY_DRIVERWAKEREASON.VALUE AS DRIVERWAKEREASON,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE_ARRAY_REASON.VALUE AS REASONVALUE,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE_ARRAY_WAKETYPE.VALUE AS WAKEREASON,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.ID AS "TABLE_ID",
PLSTORAGEOPERATOR_EVENTFORWARD_TIMEOFFSET.TIMESTAMP AS TIME_OFFSET_TIMESTAMP,
PLSTORAGEOPERATOR_EVENTFORWARD_TIMEOFFSET.ID AS TIME_OFFSET_ID,
PLSTORAGEOPERATOR_EVENTFORWARD_TIMEOFFSET.SYSTEM
FROM
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE
LEFT JOIN PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE_ARRAY_REASON ON PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.ID == PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE_ARRAY_REASON.FK_ID
LEFT JOIN PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE_ARRAY_WAKETYPE ON PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.ID == PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE_ARRAY_WAKETYPE.FK_ID
LEFT JOIN PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE_ARRAY_DRIVERWAKEREASON ON PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.ID == PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE_ARRAY_DRIVERWAKEREASON.FK_ID
LEFT JOIN
PLSTORAGEOPERATOR_EVENTFORWARD_TIMEOFFSET
)
GROUP BY
TABLE_ID
)
[SQL Query 10.15]
QUERY=
SELECT
DATETIME(TIMESTAMP + SYSTEM, 'UNIXEPOCH') AS ADJUSTED_TIMESTAMP,
DATETIME(TIMESTAMPLOGGED + SYSTEM, 'UNIXEPOCH') AS ADJUSTED_LOGGED_TIMESTAMP,
UUID AS 'UUID',
REASON AS 'REASON',
REASONVALUE AS 'REASON VALUE',
WAKEREASON AS 'WAKE REASON',
SLEEPTRIGGERS AS 'SLEEP TRIGGERS',
STATE AS 'STATE',
EVENT AS 'EVENT',
WAKETRIGGERSUBCLASS AS 'WAKE TRIGGER SUBCLASS',
CAPABILITIES AS 'CAPABILITIES',
CURRENTKERNELWAKETIME AS 'CURRENT KERNEL WAKE TIME',
DATETIME(KERNELSLEEPDATE, 'UNIXEPOCH') AS 'KERNEL SLEEP DATE',
DATETIME(TIMESTAMP, 'UNIXEPOCH') AS ORIGINAL_TIMESTAMP,
DATETIME(TIME_OFFSET_TIMESTAMP, 'UNIXEPOCH') AS OFFSET_TIMESTAMP,
SYSTEM AS TIME_OFFSET,
TABLE_ID AS "PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE TABLE ID"
FROM
(
SELECT
TABLE_ID,
TIMESTAMP,
TIME_OFFSET_TIMESTAMP,
MAX(TIME_OFFSET_ID) AS MAX_ID,
TIMESTAMPLOGGED,
CAPABILITIES,
CURRENTKERNELWAKETIME,
EVENT,
KERNELSLEEPDATE,
REASON,
SLEEPTRIGGERS,
STATE,
UUID,
WAKETRIGGERSUBCLASS,
REASONVALUE,
WAKEREASON,
SYSTEM
FROM
(
SELECT
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.TIMESTAMP,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.TIMESTAMPLOGGED,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.CAPABILITIES,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.CURRENTKERNELWAKETIME,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.EVENT,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.KERNELSLEEPDATE,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.REASON,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.SLEEPTRIGGERS,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.STATE,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.UUID,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.WAKETRIGGERSUBCLASS,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE_ARRAY_REASON.VALUE AS REASONVALUE,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE_ARRAY_WAKETRIGGERSUBCLASS.VALUE AS WAKEREASON,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.ID AS "TABLE_ID",
PLSTORAGEOPERATOR_EVENTFORWARD_TIMEOFFSET.TIMESTAMP AS TIME_OFFSET_TIMESTAMP,
PLSTORAGEOPERATOR_EVENTFORWARD_TIMEOFFSET.ID AS TIME_OFFSET_ID,
PLSTORAGEOPERATOR_EVENTFORWARD_TIMEOFFSET.SYSTEM
FROM
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE
LEFT JOIN PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE_ARRAY_REASON ON PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.ID == PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE_ARRAY_REASON.FK_ID
LEFT JOIN PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE_ARRAY_WAKETRIGGERSUBCLASS ON PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.ID == PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE_ARRAY_WAKETRIGGERSUBCLASS.FK_ID
LEFT JOIN
PLSTORAGEOPERATOR_EVENTFORWARD_TIMEOFFSET
)
GROUP BY
TABLE_ID
)
[SQL Query 10.14]
QUERY=
SELECT
DATETIME(TIMESTAMP + SYSTEM, 'UNIXEPOCH') AS ADJUSTED_TIMESTAMP,
DATETIME(TIMESTAMPLOGGED + SYSTEM, 'UNIXEPOCH') AS ADJUSTED_LOGGED_TIMESTAMP,
UUID AS 'UUID',
REASON AS 'REASON',
REASONVALUE AS 'REASON VALUE',
WAKEREASON AS 'WAKE REASON',
STATE AS 'STATE',
EVENT AS 'EVENT',
WAKETRIGGERSUBCLASS AS 'WAKE TRIGGER SUBCLASS',
CAPABILITIES AS 'CAPABILITIES',
CURRENTKERNELWAKETIME AS 'CURRENT KERNEL WAKE TIME',
DATETIME(KERNELSLEEPDATE, 'UNIXEPOCH') AS 'KERNEL SLEEP DATE',
DATETIME(TIMESTAMP, 'UNIXEPOCH') AS ORIGINAL_TIMESTAMP,
DATETIME(TIME_OFFSET_TIMESTAMP, 'UNIXEPOCH') AS OFFSET_TIMESTAMP,
SYSTEM AS TIME_OFFSET,
TABLE_ID AS "PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE TABLE ID"
FROM
(
SELECT
TABLE_ID,
TIMESTAMP,
TIME_OFFSET_TIMESTAMP,
MAX(TIME_OFFSET_ID) AS MAX_ID,
TIMESTAMPLOGGED,
CAPABILITIES,
CURRENTKERNELWAKETIME,
EVENT,
KERNELSLEEPDATE,
REASON,
STATE,
UUID,
WAKETRIGGERSUBCLASS,
REASONVALUE,
WAKEREASON,
SYSTEM
FROM
(
SELECT
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.TIMESTAMP,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.TIMESTAMPLOGGED,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.CAPABILITIES,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.CURRENTKERNELWAKETIME,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.EVENT,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.KERNELSLEEPDATE,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.REASON,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.STATE,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.UUID,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.WAKETRIGGERSUBCLASS,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE_ARRAY_REASON.VALUE AS REASONVALUE,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE_ARRAY_WAKETRIGGERSUBCLASS.VALUE AS WAKEREASON,
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.ID AS "TABLE_ID",
PLSTORAGEOPERATOR_EVENTFORWARD_TIMEOFFSET.TIMESTAMP AS TIME_OFFSET_TIMESTAMP,
PLSTORAGEOPERATOR_EVENTFORWARD_TIMEOFFSET.ID AS TIME_OFFSET_ID,
PLSTORAGEOPERATOR_EVENTFORWARD_TIMEOFFSET.SYSTEM
FROM
PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE
LEFT JOIN PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE_ARRAY_REASON ON PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.ID == PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE_ARRAY_REASON.FK_ID
LEFT JOIN PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE_ARRAY_WAKETRIGGERSUBCLASS ON PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE.ID == PLSLEEPWAKEAGENT_EVENTFORWARD_POWERSTATE_ARRAY_WAKETRIGGERSUBCLASS.FK_ID
LEFT JOIN
PLSTORAGEOPERATOR_EVENTFORWARD_TIMEOFFSET
)
GROUP BY
TABLE_ID
)