I have a simple monitoring system based on Conky. (GitHub - brndnmtthws/conky: Light-weight system monitor for X.)
I would like to output the date of the last sync to conky, and in order to do that, I need the “Last Seen” timestamp at the “devices” pane in the Syncthing web ui.
What is the recommended way of getting the last sync date programmatically?
Thanks a lot!
Do some curl’ing of the rest api
The last seen info for a device is available at
/rest/stats/file: REST API — Syncthing v1 documentation
That’s a huge step forward for me!
However, it says “CSRF Error”, even though I am accessing it from localhost.
Did you set the api key? Example curl command in this section: REST API — Syncthing v1 documentation
I ended up using the following command:
curl -X GET -H “X-API-Key: mykey” -s ‘http://localhost:8384/rest/stats/device’ | sed ‘s/[^[:print:]]//g’ | jq -Mar -c ‘.“DEV-ID”.“lastSeen”’ | cut -c 2-36
There is one problem with it, however: the date that the command is returning, varies from run to run:
Would it be possible to make it be of a fixed length?
The sub-second precision is useless here - we should truncate that to seconds. Can you open an issue on github please (or a PR ).
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.