File: show_alerts.lua

package info (click to toggle)
ntopng 2.4%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 15,888 kB
  • ctags: 8,091
  • sloc: cpp: 21,442; ansic: 10,999; sh: 1,627; makefile: 423; pascal: 312; ruby: 34; exp: 4
file content (123 lines) | stat: -rw-r--r-- 2,833 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
--
-- (C) 2013-16 - ntop.org
--

dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path

require "lua_utils"

sendHTTPHeader('text/html; charset=iso-8859-1')
ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/header.inc")

if(_GET["csrf"] ~= nil) then
   if(_GET["id_to_delete"] ~= nil) then
      if(_GET["id_to_delete"] == "__all__") then
	 ntop.flushAllQueuedAlerts()
	 print("")
      else
	 ntop.deleteQueuedAlert(tonumber(_GET["id_to_delete"]))
      end
   end
end

active_page = "alerts"
dofile(dirs.installdir .. "/scripts/lua/inc/menu.lua")

print [[
      <hr>
      <div id="table-alerts"></div>
	 <script>
	 $("#table-alerts").datatable({
			url: "]]
print (ntop.getHttpPrefix())
print [[/lua/get_alerts_data.lua",
	       showPagination: true,
]]

if(_GET["currentPage"] ~= nil) then print("currentPage: ".._GET["currentPage"]..",\n") end
if(_GET["perPage"] ~= nil)     then print("perPage: ".._GET["perPage"]..",\n") end

print [[
	        title: "Queued Alerts",
      columns: [
	 {
	    title: "Action",
	    field: "column_key",
	    css: { 
	       textAlign: 'center'
	    }
	 },
	 
	 {
	    title: "Date",
	    field: "column_date",
	    css: { 
	       textAlign: 'center'
	    }
	 },
	 {
	    title: "Severity",
	    field: "column_severity",
	    css: { 
	       textAlign: 'center'
	    }
	 },
	 
	 {
	    title: "Type",
	    field: "column_type",
	    css: { 
	       textAlign: 'center'
	    }
	 },

	 {
	    title: "Description",
	    field: "column_msg",
	    css: { 
	       textAlign: 'left'
	    }
	 }
      ]
   });
   </script>
	      ]]


if(ntop.getNumQueuedAlerts() > 0) then
   print [[

<a href="#myModal" role="button" class="btn btn-default" data-toggle="modal"><i type="submit" class="fa fa-trash-o"></i> Purge All Alerts</button></a>
 
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>
    <h3 id="myModalLabel">Confirm Action</h3>
  </div>
  <div class="modal-body">
    <p>Do you really want to purge all alerts?</p>
  </div>
  <div class="modal-footer">

    <form class=form-inline style="margin-bottom: 0px;" method=get action="#"><input type=hidden name=id_to_delete value="__all__">
      ]]

print('<input id="csrf" name="csrf" type="hidden" value="'..ntop.getRandomCSRFValue()..'" />\n')

print [[
    <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
    <button class="btn btn-primary" type="submit">Purge All</button>
</form>
  </div>
  </div>
</div>
</div>

      ]]
end

dofile(dirs.installdir .. "/scripts/lua/inc/footer.lua")