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.

118 lines
4.1 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. <br>
  51. <br>
  52. <div class="text-right">
  53. <button type="submit" class="btn btn-primary">Save Integration</button>
  54. </div>
  55. </form>
  56. </div>
  57. </div>
  58. <div id="reference-modal" class="modal">
  59. <div class="modal-dialog">
  60. <div class="modal-content">
  61. <div class="modal-header">
  62. <h4>Supported Placeholders</h4>
  63. </div>
  64. <div class="modal-body">
  65. <p>
  66. You can use the below placeholders in the command.
  67. {{ site_name }} will replace the placeholders
  68. with the correct values.
  69. </p>
  70. <table id="webhook-variables" class="table modal-body">
  71. <tr>
  72. <th><code>$CODE</code></th>
  73. <td>The UUID code of the check</td>
  74. </tr>
  75. <tr>
  76. <th><code>$NAME</code></th>
  77. <td>Name of the check</td>
  78. </tr>
  79. <tr>
  80. <th><code>$NOW</code></th>
  81. <td>
  82. Current UTC time in ISO8601 format.<br />
  83. Example: "{% now_isoformat %}"
  84. </td>
  85. </tr>
  86. <tr>
  87. <th><code>$STATUS</code></th>
  88. <td>Check's current status ("up" or "down")</td>
  89. </tr>
  90. <tr>
  91. <th><code>$TAGS</code></th>
  92. <td>Check's tags, separated by spaces</td>
  93. </tr>
  94. <tr>
  95. <th><code>$TAG1, $TAG2, …</code></th>
  96. <td>Value of the first tag, the second tag, …</td>
  97. </tr>
  98. </table>
  99. </div>
  100. <div class="modal-footer">
  101. <button type="button" class="btn btn-default" data-dismiss="modal">Got It!</button>
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. {% endblock %}