You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
4.2 KiB

  1. {% extends "base.html" %}
  2. {% load compress humanize static hc_extras %}
  3. {% block title %}Add Shell Command - {% site_name %}{% endblock %}
  4. {% block content %}
  5. <div class="row">
  6. <div class="col-sm-12">
  7. <h1>Shell Command</h1>
  8. <p>Executes a local shell command when a check
  9. goes up or down.</p>
  10. <p>
  11. You can use placeholders <strong>$NAME</strong>, <strong>$STATUS</strong>
  12. and others
  13. <a href="#" data-toggle="modal" data-target="#reference-modal">(quick reference)</a>.
  14. </p>
  15. <br />
  16. <form id="add-shell-form" method="post">
  17. {% csrf_token %}
  18. <div class="row">
  19. <div class="col-sm-6">
  20. <div class="form-group {{ form.cmd_down.css_classes }}">
  21. <label class="control-label">Execute when a check goes <span class="label-down">down</span></label>
  22. <textarea
  23. class="form-control"
  24. rows="3"
  25. name="cmd_down"
  26. placeholder='/home/user/notify.sh "$NAME has gone down"'>{{ form.cmd_down.value|default:"" }}</textarea>
  27. {% if form.cmd_down.errors %}
  28. <div class="help-block">
  29. {{ form.cmd_down.errors|join:"" }}
  30. </div>
  31. {% endif %}
  32. </div>
  33. </div>
  34. <div class="col-sm-6">
  35. <div class="form-group {{ form.cmd_up.css_classes }}">
  36. <label class="control-label">Execute when a check goes <span class="label-up">up</span></label>
  37. <textarea
  38. class="form-control"
  39. rows="3"
  40. name="cmd_up"
  41. placeholder='/home/user/notify.sh "$NAME is back up"'>{{ form.cmd_up.value|default:"" }}</textarea>
  42. {% if form.cmd_up.errors %}
  43. <div class="help-block">
  44. {{ form.cmd_up.errors|join:"" }}
  45. </div>
  46. {% endif %}
  47. </div>
  48. </div>
  49. </div>
  50. <div class="form-group" class="clearfix">
  51. <br>
  52. <br>
  53. <div class="text-right">
  54. <button type="submit" class="btn btn-primary">Save Integration</button>
  55. </div>
  56. </div>
  57. </form>
  58. </div>
  59. </div>
  60. <div id="reference-modal" class="modal">
  61. <div class="modal-dialog">
  62. <div class="modal-content">
  63. <div class="modal-header">
  64. <h4>Supported Placeholders</h4>
  65. </div>
  66. <div class="modal-body">
  67. <p>
  68. You can use the below placeholders in the command.
  69. {% site_name %} will replace the placeholders
  70. with the correct values.
  71. </p>
  72. <table id="webhook-variables" class="table modal-body">
  73. <tr>
  74. <th><code>$CODE</code></th>
  75. <td>The UUID code of the check</td>
  76. </tr>
  77. <tr>
  78. <th><code>$NAME</code></th>
  79. <td>Name of the check</td>
  80. </tr>
  81. <tr>
  82. <th><code>$NOW</code></th>
  83. <td>
  84. Current UTC time in ISO8601 format.<br />
  85. Example: "{% now_isoformat %}"
  86. </td>
  87. </tr>
  88. <tr>
  89. <th><code>$STATUS</code></th>
  90. <td>Check's current status ("up" or "down")</td>
  91. </tr>
  92. <tr>
  93. <th><code>$TAGS</code></th>
  94. <td>Check's tags, separated by spaces</td>
  95. </tr>
  96. <tr>
  97. <th><code>$TAG1, $TAG2, …</code></th>
  98. <td>Value of the first tag, the second tag, …</td>
  99. </tr>
  100. </table>
  101. </div>
  102. <div class="modal-footer">
  103. <button type="button" class="btn btn-default" data-dismiss="modal">Got It!</button>
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. {% endblock %}