-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotifications.php
308 lines (231 loc) · 7.48 KB
/
notifications.php
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<!DOCTYPE html>
<html>
<body>
<head>
<title>Page Title</title>
<style>
html {
background: url(image.jpg) no-repeat center center fixed;
background-size: cover;
}
body {
color: white;
}
</style>
</head>
<?php
$path = dirname(__FILE__);
$path1 = explode("/",$path,-1);
$path1[count($path1)+1]='db.conf';
$finalpath = implode("/",$path1);
$handle = fopen($finalpath, "r");
while (!feof($handle)) {
$line = fgets($handle);
$data = explode("'",$line);
if($data[0]=='host=>')
{
$host= $data[1];
}
elseif($data[0]=='port=>')
{
$port= $data[1];
}
elseif($data[0]=='username=>')
{
$username= $data[1];
}
elseif($data[0]=='password=>')
{
$password= $data[1];
}
elseif($data[0]=='database=>')
{
$database= $data[1];
}
}
?>
<h1>Notifications</h1>
<form method="GET" >
thresholdRTT: <br>
<input type="text" name="thresholdRTT" > <br>
thresholdRTT1: <br>
<input type="text" name="thresholdRTT1" > <br>
thresholdSST: <br>
<input type="text" name="thresholdSST" > <br>
thresholdSST1: <br>
<input type="text" name="thresholdSST1" > <br>
thresholdDRATE: <br>
<input type="text" name="thresholdDRATE"> <br>
thresholdDRATE1: <br>
<input type="text" name="thresholdDRATE1"> <br>
Emailid: <br>
<input type="text" name="Emailid"> <br>
IPAddress: <br>
<input type="text" name="IPAddress"> <br>
OID: <br>
<input type="text" name="OID"> <br>
port: <br>
<input type="text" name="port"> <br>
SNMPCommunity: <br>
<input type="text" name="SNMPCommunity"> <br>
SMS: <br>
<input type="text" name="SMS"> <br>
<input type="submit" value="Submit">
</form>
<?php
$dbhandle = mysql_connect($host, $username, $password, $database)
or die("Unable to connect to MySQL");
//select a database to work with
$selected = mysql_select_db("ENIGMA",$dbhandle)
or die("Could not select databse");
//$sql="DROP TABLE `notifications` IF EXISTS";
//$del=mysql_query($sql,$dbhandle);
//sql to create a table
/*$sql1= " CREATE TABLE `tcp` (
`thresholdRTT` VARCHAR(20) NOT NULL,
`thresholdSST` VARCHAR(30) NOT NULL,
`thresholdDRATE` VARCHAR(30) NOT NULL,
`Emailid` VARCHAR(50) NOT NULL,
`IPAddress` VARCHAR(30) NOT NULL,
`OID` VARCHAR(20) NOT NULL,
`Hostname` VARCHAR(20) NOT NULL,
`port` VARCHAR(20) NOT NULL,
`SNMPCommunity` VARCHAR(20) NOT NULL,
`SMS` VARCHAR(20) NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=latin1";
$create=mysql_query($sql1,$dbhandle);*/
$sql="CREATE TABLE IF NOT EXISTS `notifications` (
`id` INT(8) NOT NULL,
`thresholdRTT` VARCHAR(20) NOT NULL,`thresholdRTT1` VARCHAR(20) NOT NULL,
`thresholdSST` VARCHAR(30) NOT NULL,`thresholdSST1` VARCHAR(30) NOT NULL,
`thresholdDRATE` VARCHAR(30) NOT NULL,`thresholdDRATE1` VARCHAR(30) NOT NULL,
`Emailid` VARCHAR(30) NOT NULL,
`IPAddress` VARCHAR(4800) NOT NULL,
`OID` VARCHAR(4800) NOT NULL,`port` VARCHAR(4800) NOT NULL,
`SNMPCommunity` VARCHAR(4800) NOT NULL,
`SMS` VARCHAR(4800) NOT NULL,
PRIMARY KEY (`id`) )
ENGINE=InnoDB DEFAULT CHARSET=latin1";
mysql_query($sql,$dbhandle);
$sql2=mysql_query("INSERT INTO `notifications` (id,thresholdRTT,thresholdRTT1, thresholdSST,thresholdSST1, thresholdDRATE,thresholdDRATE1,Emailid,IPAddress,OID,port,SNMPCommunity,SMS)
VALUES ('1','1','1','1','1','1','1','1','1','1','1','1','1') ");
$thresholdRTT=htmlspecialchars($_GET['thresholdRTT']);
$thresholdRTT1=htmlspecialchars($_GET['thresholdRTT1']);
$thresholdSST=htmlspecialchars($_GET['thresholdSST']);
$thresholdSST1=htmlspecialchars($_GET['thresholdSST1']);
$thresholdDRATE=htmlspecialchars($_GET['thresholdDRATE']);
$thresholdDRATE1=htmlspecialchars($_GET['thresholdDRATE1']);
$Emailid=htmlspecialchars($_GET['Emailid']);
$IPAddress=htmlspecialchars($_GET['IPAddress']);
$OID=htmlspecialchars($_GET['OID']);
$port=htmlspecialchars($_GET['port']);
$SNMPCommunity=htmlspecialchars($_GET['SNMPCommunity']);
$SMS=htmlspecialchars($_GET['SMS']);
if($thresholdRTT== '' && $thresholdRTT1== '' && $thresholdSST== '' && $thresholdSST1== '' && $thresholdDRATE== '' && $thresholdDRATE1== '' )
{
}
else
{
//Updating data into mysql
$sql3 = "UPDATE notifications SET thresholdRTT='$thresholdRTT',thresholdRTT1='$thresholdRTT1', thresholdSST='$thresholdSST',thresholdSST1='$thresholdSST1', thresholdDRATE='$thresholdDRATE',thresholdDRATE1='$thresholdDRATE1',Emailid='$Emailid',IPAddress='$IPAddress',OID='$OID',port='$port',SNMPCommunity='$SNMPCommunity',SMS='$SMS' WHERE id=1";
}
//VALUES ('',,,,,,,) ";
$ins=mysql_query($sql3,$dbhandle);
//execute the SQL query and return records
$i = 0;
$j = 0;
$result = mysql_query("SELECT * FROM Average");
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$average[0] = $row['averageRRT'];
$average[1] = $row['averageSST'];
$average[2] = $row['averageDRATE'];
$i++;
}
$result1 = mysql_query("SELECT thresholdRTT,thresholdRTT1,thresholdSST,thresholdSST1,thresholdDRATE,thresholdDRATE1 FROM notifications");
while($ring = mysql_fetch_array($result1))
{
$thresh[0] = $ring['thresholdRTT'];
$thresh[1] = $ring['thresholdRTT1'];
$thresh[2] = $ring['thresholdSST'];
$thresh[3] = $ring['thresholdSST1'];
$thresh[4] = $ring['thresholdDRATE'];
$thresh[5] = $ring['thresholdDRATE1'];
$j++;
}
echo "thresholdRTT: " . $thresh[0] . "</br>thresholdRTT1: " . $thresh[1] . "</br>thresholdSST: " . $thresh[2] . "</br>thresholdSST1: " . $thresh[3] . "</br>thresholdDRATE: " . $thresh[4] . "</br>thresholdDRATE1: " . $thresh[5] . "</br>";
//$aver = array("averageRRT","averageSST","averageDRATE");
//$thr = array("thresholdRTT","thresholdSST","thresholdDRATE");
echo "<table border='1'>
<thead>average</thead>
<tr>
<th>averageRRT</th>
<th>averageSST</th>
<th>averageDRATE</th>
</tr>";
if ($average[0] >= $thresh[0] && $average[0] < $thresh[1])
{
$color_class1 = '#FF850A';
}
elseif($average[0] >= $thresh[1])
{
$color_class1 = '#FF0000';
}
else
{
$color_class1 = '#00CC00';
}
if ($average[1] >= $thresh[2] && $average[1] < $thresh[3])
{
$color_class2 = '#FF850A';
}
elseif($average[1] >= $thresh[3])
{
$color_class2 = '#FF0000';
}
else
{
$color_class2 = '#00CC00';
}
if ($average[2] >= $thresh[4] && $average[2] < $thresh[5])
{
$color_class3 = '#FF850A';
}
elseif($average[2] >= $thresh[5])
{
$color_class3 = '#FF0000';
}
else
{
$color_class3 = '#00CC00';
}
echo "<td style = 'background-color: " . $color_class1 . "'>" . $average[0] . "</td>";
echo "<td style = 'background-color: " . $color_class2 . "'>" . $average[1] . "</td>";
echo "<td style = 'background-color: " . $color_class3 . "'>" . $average[2] . "</td>";
echo "</tr></table>";
/*
echo "<tr class={$color_class}>" ;
echo "<td>" . $row['averageRRT'] . "</td>" ;
echo "<td>" . $row['averageSST'] . "</td>>" ;
echo "<td>" . $row['averageDRATE'] . "</td>" ;
echo "</tr>";*/
//echo "</table>";
?>
</body>
</html>
<html>
<body>
<div class="input-color">
<input type="text" value="Green indicates normal" readonly />
<div class="color-box" style="background-color: #00CC00"></div>
<!-- Replace "#FF850A" to change the color -->
</div>
<div class="input-color">
<input type="text" value="orange indicates warning" readonly />
<div class="color-box" style="background-color: #FF850A"></div>
<div class="input-color">
<input type="text" value="red indicates critical" readonly />
<div class="color-box" style="background-color: #FF0000;">
</div>
</body>
</html>