-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathmonitor_reboot.py
More file actions
35 lines (31 loc) · 1 KB
/
monitor_reboot.py
File metadata and controls
35 lines (31 loc) · 1 KB
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
import psutil
import time
import sys
from ISStreamer.Streamer import Streamer
# --------- User Settings ---------
# Initial State settings
BUCKET_NAME = ":computer: Processes"
BUCKET_KEY = "pr1208"
ACCESS_KEY = "PLACE YOUR INITIAL STATE ACCESS KEY HERE"
PROCESS_NAME = "PLACE THE NAME OF YOUR PROCESS HERE"
# Set the time to wait until you are sure reboot is complete and network connections are restored (i.e. power outage)
MINUTES_DELAY = 5
# ---------------------------------
def main():
# Wait for ntpd to run for sync of the clock
found_ntpd = False
cnt = 0
while found_ntpd == False:
for proc in psutil.process_iter():
if proc.name() == "ntpd":
found_ntpd = True
cnt += 1
if cnt == 60: # assume that ntpd has already run if not found in 60 seconds
found_ntpd=True
time.sleep(1)
time.sleep(60*MINUTES_DELAY)
streamer = Streamer(bucket_name=BUCKET_NAME, bucket_key=BUCKET_KEY, access_key=ACCESS_KEY)
streamer.log(PROCESS_NAME,"Exited")
streamer.flush()
if __name__ == "__main__":
main()