0

I'm not sure if this is a possibility but I am trying to update the status of a text widget in Dashing using curl.

The status I would like to update is 'warning' or 'danger' to reflect if a server has gone down or become unresponsive. My idea is that the dashboard will be populated with several green text widgets all saying online when the dashboard initialises. Periodically services running on other machines will post requests to the dashboard changing the status of widgets.

I have tried using curl to simulate the post messages from other machines and I'm able to update the text and title of the text widgets but have had no luck updating the status.

I have been using:

curl -d "{ \"auth_token\": \"YOUR_AUTH_TOKEN\", \"status\": \"danger\" }" -H "Content-Type: application/json" http://localhost:3030/widgets/frontend11

But the widget does not change colour. I have seen examples where the coffee script code was amended to include this possibility, but I thought that this functionality was included in all widgets?

Garreth
  • 1,057
  • 2
  • 9
  • 24

1 Answers1

0

We do this - changing status via curl - and it works great. Here's a snip of our code:

    json='{ "auth_token": "'$dashing_auth_token'", "current": '$widget_value', "value": '$widget_value', "status": "'$widget_status'" }'

    curl -H Content-Type:application/json -d "${json}" "${dashing_url}widgets/${widget_id}"

The above is in a function that gets passed all of the variables, but the variable names hopefully are easy enough to read there that you can make sense of it. I can write up more (or send the whole function) if it'd help you, but I think just the two lines should be enough to get you there without all the rest of the clutter. Let me know if more would be helpful.

  • Thanks for the reply. The line I'm using now changes the text of the widget when I use curl from the windows command line, however it does not change the color of the widget: curl -d "{ \"auth_token\": \"YOUR_AUTH_TOKEN\", \"text\": \"TEST\", \"status\": \"danger\" }" -H "Content-Type: application/json" http://localhost:3030/widgets/frontend11 – Garreth Oct 13 '15 at 11:43
  • That looks like reasonable enough code for it. Have you made any changes to the scss? We've for instance, removed 'danger' as a status. 'Danger' and 'warning' weren't immediately obvious which was 'worse', so we changed them to match our nagios server with 'warning' and 'critical', which also seemed more instantly recognizable for their difference. – Michael Knowles Oct 14 '15 at 16:19
  • I haven't been able to get it to work, so as an alternative I have used the 'Server Status Squares' widget which performs a similar solution. Thanks. – Garreth Oct 15 '15 at 09:32