The batch files that run when our Cortex server starts up write entries in a log file recording the date and time of each event; over the years this has proven useful when investigating problems, such as when the server reboots unexpectedly.
Recently I decided that it would be helpful to have the latest boot date/time available on a Notice Board rather than having to login to the server and view the logfile. So I started to look at ways of presenting the information so that I could get it via the app on my Android device. I realised that the ideal would be to present a built-in object that held the Cortex start date/time, but that doesn't seem to exist, so I had to construct something similar myself.
I modified a batch file to write the boot date and time to a file 'index.html' in JSON format, set-up a copy of the TinyWeb web server on port 8000 and added a Cortex Web Client API object to read the website at 127.0.0.1 - I now had the information I wanted in a Cortex object that I could present on the Notice Board.
The index.html file looks like this:
{
"At":"17:40:47 on 10-03-2019"
}
When decoded this gives me a Cortex object called "Server Boot At Response 0" under "Web API Client".
I have added the entry 'Server booted at <Web API Client.Server Boot At Response 0=$0>' to "All Display" and connected this to "Martin Notice Board - New Message in" to display a formatted message - it is triggered by the 'Server Boot Finished' signal from the 'Web API Client'.
In order to force the message to be sticky on the Notice Board I send an event to the Web Client API Server Boot Send trigger every 15 minutes.
Although this seems to be working as desired I do have a couple of questions:
1) Is there an easier way of doing this?
2) Is there an existing Cortex object that I could have used instead?
Recently I decided that it would be helpful to have the latest boot date/time available on a Notice Board rather than having to login to the server and view the logfile. So I started to look at ways of presenting the information so that I could get it via the app on my Android device. I realised that the ideal would be to present a built-in object that held the Cortex start date/time, but that doesn't seem to exist, so I had to construct something similar myself.
I modified a batch file to write the boot date and time to a file 'index.html' in JSON format, set-up a copy of the TinyWeb web server on port 8000 and added a Cortex Web Client API object to read the website at 127.0.0.1 - I now had the information I wanted in a Cortex object that I could present on the Notice Board.
The index.html file looks like this:
{
"At":"17:40:47 on 10-03-2019"
}
When decoded this gives me a Cortex object called "Server Boot At Response 0" under "Web API Client".
I have added the entry 'Server booted at <Web API Client.Server Boot At Response 0=$0>' to "All Display" and connected this to "Martin Notice Board - New Message in" to display a formatted message - it is triggered by the 'Server Boot Finished' signal from the 'Web API Client'.
In order to force the message to be sticky on the Notice Board I send an event to the Web Client API Server Boot Send trigger every 15 minutes.
Although this seems to be working as desired I do have a couple of questions:
1) Is there an easier way of doing this?
2) Is there an existing Cortex object that I could have used instead?
Comment