Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
FMS_Project
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bashar.hussein
FMS_Project
Commits
e47acd41
Commit
e47acd41
authored
Jul 18, 2023
by
ReemyHasan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add About page settings
parent
89927da6
Changes
19
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
293 additions
and
12 deletions
+293
-12
Maven__org_eclipse_angus_angus_activation_2_0_1.xml
...aries/Maven__org_eclipse_angus_angus_activation_2_0_1.xml
+13
-0
Maven__org_eclipse_angus_jakarta_mail_1_1_0.xml
...libraries/Maven__org_eclipse_angus_jakarta_mail_1_1_0.xml
+13
-0
Maven__org_springframework_boot_spring_boot_starter_mail_3_1_1.xml
...g_springframework_boot_spring_boot_starter_mail_3_1_1.xml
+13
-0
Maven__org_springframework_spring_context_support_6_0_10.xml
...en__org_springframework_spring_context_support_6_0_10.xml
+13
-0
application.properties
...ne/SnmpReciever/src/main/resources/application.properties
+1
-1
application.properties
...peline/SnmpReciever/target/classes/application.properties
+1
-1
SnmpReceiverApplicationTests.class
...m/example/SnmpReciever/SnmpReceiverApplicationTests.class
+0
-0
pom.xml
SNMP_Pipeline/Web-Application/pom.xml
+4
-1
RethinkController.java
.../example/WebApplication/controller/RethinkController.java
+2
-2
SettingController.java
.../example/WebApplication/controller/SettingController.java
+75
-0
SocketTextHandler.java
.../example/WebApplication/controller/SocketTextHandler.java
+2
-2
AboutInfo.java
...n/java/com/example/WebApplication/entities/AboutInfo.java
+18
-0
RethinkDBConnectionFactory.java
...le/WebApplication/factory/RethinkDBConnectionFactory.java
+19
-3
SettingService.java
...a/com/example/WebApplication/services/SettingService.java
+106
-0
application.properties
...Web-Application/src/main/resources/application.properties
+8
-0
EnrichedTrap.java
.../com/example/kafkaConsumerSNMP/entities/EnrichedTrap.java
+4
-0
RethinkDBService.java
.../example/kafkaConsumerSNMP/services/RethinkDBService.java
+1
-2
EnrichedTrap.class
...com/example/kafkaConsumerSNMP/entities/EnrichedTrap.class
+0
-0
RethinkDBService.class
...example/kafkaConsumerSNMP/services/RethinkDBService.class
+0
-0
No files found.
SNMP_Pipeline/.idea/libraries/Maven__org_eclipse_angus_angus_activation_2_0_1.xml
0 → 100644
View file @
e47acd41
<component
name=
"libraryTable"
>
<library
name=
"Maven: org.eclipse.angus:angus-activation:2.0.1"
>
<CLASSES>
<root
url=
"jar://$MAVEN_REPOSITORY$/org/eclipse/angus/angus-activation/2.0.1/angus-activation-2.0.1.jar!/"
/>
</CLASSES>
<JAVADOC>
<root
url=
"jar://$MAVEN_REPOSITORY$/org/eclipse/angus/angus-activation/2.0.1/angus-activation-2.0.1-javadoc.jar!/"
/>
</JAVADOC>
<SOURCES>
<root
url=
"jar://$MAVEN_REPOSITORY$/org/eclipse/angus/angus-activation/2.0.1/angus-activation-2.0.1-sources.jar!/"
/>
</SOURCES>
</library>
</component>
\ No newline at end of file
SNMP_Pipeline/.idea/libraries/Maven__org_eclipse_angus_jakarta_mail_1_1_0.xml
0 → 100644
View file @
e47acd41
<component
name=
"libraryTable"
>
<library
name=
"Maven: org.eclipse.angus:jakarta.mail:1.1.0"
>
<CLASSES>
<root
url=
"jar://$MAVEN_REPOSITORY$/org/eclipse/angus/jakarta.mail/1.1.0/jakarta.mail-1.1.0.jar!/"
/>
</CLASSES>
<JAVADOC>
<root
url=
"jar://$MAVEN_REPOSITORY$/org/eclipse/angus/jakarta.mail/1.1.0/jakarta.mail-1.1.0-javadoc.jar!/"
/>
</JAVADOC>
<SOURCES>
<root
url=
"jar://$MAVEN_REPOSITORY$/org/eclipse/angus/jakarta.mail/1.1.0/jakarta.mail-1.1.0-sources.jar!/"
/>
</SOURCES>
</library>
</component>
\ No newline at end of file
SNMP_Pipeline/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_mail_3_1_1.xml
0 → 100644
View file @
e47acd41
<component
name=
"libraryTable"
>
<library
name=
"Maven: org.springframework.boot:spring-boot-starter-mail:3.1.1"
>
<CLASSES>
<root
url=
"jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-mail/3.1.1/spring-boot-starter-mail-3.1.1.jar!/"
/>
</CLASSES>
<JAVADOC>
<root
url=
"jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-mail/3.1.1/spring-boot-starter-mail-3.1.1-javadoc.jar!/"
/>
</JAVADOC>
<SOURCES>
<root
url=
"jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-mail/3.1.1/spring-boot-starter-mail-3.1.1-sources.jar!/"
/>
</SOURCES>
</library>
</component>
\ No newline at end of file
SNMP_Pipeline/.idea/libraries/Maven__org_springframework_spring_context_support_6_0_10.xml
0 → 100644
View file @
e47acd41
<component
name=
"libraryTable"
>
<library
name=
"Maven: org.springframework:spring-context-support:6.0.10"
>
<CLASSES>
<root
url=
"jar://$MAVEN_REPOSITORY$/org/springframework/spring-context-support/6.0.10/spring-context-support-6.0.10.jar!/"
/>
</CLASSES>
<JAVADOC>
<root
url=
"jar://$MAVEN_REPOSITORY$/org/springframework/spring-context-support/6.0.10/spring-context-support-6.0.10-javadoc.jar!/"
/>
</JAVADOC>
<SOURCES>
<root
url=
"jar://$MAVEN_REPOSITORY$/org/springframework/spring-context-support/6.0.10/spring-context-support-6.0.10-sources.jar!/"
/>
</SOURCES>
</library>
</component>
\ No newline at end of file
SNMP_Pipeline/SnmpReciever/src/main/resources/application.properties
View file @
e47acd41
...
@@ -2,6 +2,6 @@ server.port = 0
...
@@ -2,6 +2,6 @@ server.port = 0
spring.kafka.bootstrap-servers
=
http://172.29.3.220:9092
spring.kafka.bootstrap-servers
=
http://172.29.3.220:9092
spring.kafka.producer.key-serializer
=
org.apache.kafka.common.serialization.StringSerializer
spring.kafka.producer.key-serializer
=
org.apache.kafka.common.serialization.StringSerializer
spring.kafka.producer.value-serializer
=
org.apache.kafka.common.serialization.StringSerializer
spring.kafka.producer.value-serializer
=
org.apache.kafka.common.serialization.StringSerializer
spring.listener.address
=
192.168.
26.46
/1625
spring.listener.address
=
192.168.
93.198
/1625
spring.listener.threads
=
20
spring.listener.threads
=
20
spring.listener.community
=
public
spring.listener.community
=
public
SNMP_Pipeline/SnmpReciever/target/classes/application.properties
View file @
e47acd41
...
@@ -2,6 +2,6 @@ server.port = 0
...
@@ -2,6 +2,6 @@ server.port = 0
spring.kafka.bootstrap-servers
=
http://172.29.3.220:9092
spring.kafka.bootstrap-servers
=
http://172.29.3.220:9092
spring.kafka.producer.key-serializer
=
org.apache.kafka.common.serialization.StringSerializer
spring.kafka.producer.key-serializer
=
org.apache.kafka.common.serialization.StringSerializer
spring.kafka.producer.value-serializer
=
org.apache.kafka.common.serialization.StringSerializer
spring.kafka.producer.value-serializer
=
org.apache.kafka.common.serialization.StringSerializer
spring.listener.address
=
192.168.
26.46
/1625
spring.listener.address
=
192.168.
93.198
/1625
spring.listener.threads
=
20
spring.listener.threads
=
20
spring.listener.community
=
public
spring.listener.community
=
public
SNMP_Pipeline/SnmpReciever/target/test-classes/com/example/SnmpReciever/SnmpReceiverApplicationTests.class
0 → 100644
View file @
e47acd41
File added
SNMP_Pipeline/Web-Application/pom.xml
View file @
e47acd41
...
@@ -73,7 +73,10 @@
...
@@ -73,7 +73,10 @@
<artifactId>
javax.persistence-api
</artifactId>
<artifactId>
javax.persistence-api
</artifactId>
<version>
2.2
</version>
<version>
2.2
</version>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-mail
</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<artifactId>
spring-boot-starter-test
</artifactId>
...
...
SNMP_Pipeline/Web-Application/src/main/java/com/example/WebApplication/controller/RethinkController.java
View file @
e47acd41
...
@@ -15,7 +15,7 @@ import java.util.List;
...
@@ -15,7 +15,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
@RestController
@RestController
@CrossOrigin
(
"
192.168.25.254:3000
"
)
@CrossOrigin
(
"
*
"
)
@RequestMapping
(
"/api/rethink"
)
@RequestMapping
(
"/api/rethink"
)
public
class
RethinkController
{
public
class
RethinkController
{
@Autowired
@Autowired
...
@@ -27,7 +27,7 @@ public class RethinkController {
...
@@ -27,7 +27,7 @@ public class RethinkController {
@GetMapping
(
"/data"
)
@GetMapping
(
"/data"
)
public
ResponseEntity
<
List
<
Map
<
String
,
Object
>>>
getData
()
{
public
ResponseEntity
<
List
<
Map
<
String
,
Object
>>>
getData
()
{
List
<
Map
<
String
,
Object
>>
result
=
rethinkDBService
.
getData
();
List
<
Map
<
String
,
Object
>>
result
=
rethinkDBService
.
getData
();
System
.
out
.
println
(
result
);
//
System.out.println(result);
if
(
result
!=
null
)
{
if
(
result
!=
null
)
{
return
ResponseEntity
.
ok
(
result
);
return
ResponseEntity
.
ok
(
result
);
}
else
{
}
else
{
...
...
SNMP_Pipeline/Web-Application/src/main/java/com/example/WebApplication/controller/SettingController.java
0 → 100644
View file @
e47acd41
package
com
.
example
.
WebApplication
.
controller
;
import
com.example.WebApplication.entities.AboutInfo
;
import
com.example.WebApplication.services.SettingService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@CrossOrigin
(
"*"
)
@RequestMapping
(
"/api/about"
)
public
class
SettingController
{
@Autowired
private
SettingService
settingService
;
@DeleteMapping
(
"/delete/{key}"
)
public
void
delete
(
@PathVariable
String
key
){
settingService
.
deleteAboutInfo
(
key
);
}
@GetMapping
(
"/get/{key}"
)
public
ResponseEntity
<
AboutInfo
>
getByKey
(
@PathVariable
String
key
)
{
AboutInfo
result
=
settingService
.
getByKey
(
key
);
System
.
out
.
println
(
result
);
if
(
result
!=
null
)
{
return
ResponseEntity
.
ok
(
result
);
}
else
{
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
build
();
}
}
@GetMapping
(
"/data"
)
public
ResponseEntity
<
List
<
Map
<
String
,
AboutInfo
>>>
getData
()
{
List
<
Map
<
String
,
AboutInfo
>>
result
=
settingService
.
getData
();
System
.
out
.
println
(
result
);
if
(
result
!=
null
)
{
return
ResponseEntity
.
ok
(
result
);
}
else
{
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
build
();
}
}
@PostMapping
(
"/post"
)
public
ResponseEntity
<
Boolean
>
postData
(
@RequestBody
AboutInfo
aboutInfo
)
{
boolean
result
=
settingService
.
putAboutInfo
(
aboutInfo
);
if
(
result
==
true
)
{
return
ResponseEntity
.
ok
(
result
);
}
else
{
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
build
();
}
}
@PutMapping
(
"/update"
)
public
ResponseEntity
<
Boolean
>
UpdateData
(
@RequestBody
AboutInfo
aboutInfo
)
{
try
{
Boolean
result
=
settingService
.
updateAboutInfo
(
aboutInfo
);
return
ResponseEntity
.
ok
(
result
);
}
catch
(
Exception
e
){
return
ResponseEntity
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
build
();
}
}
@PostMapping
(
"/send-message"
)
public
ResponseEntity
<
Boolean
>
sendMessage
(
@RequestBody
Map
<
String
,
String
>
message
)
{
try
{
String
subject
=
message
.
get
(
"subject"
);
String
body
=
message
.
get
(
"body"
);
String
email
=
message
.
get
(
"email"
);
settingService
.
sendMessage
(
subject
,
body
,
email
);
return
ResponseEntity
.
ok
(
true
);
}
catch
(
Exception
e
){
return
ResponseEntity
.
ok
(
false
);
}
}
}
SNMP_Pipeline/Web-Application/src/main/java/com/example/WebApplication/controller/SocketTextHandler.java
View file @
e47acd41
...
@@ -55,7 +55,7 @@ public class SocketTextHandler extends TextWebSocketHandler implements CommandLi
...
@@ -55,7 +55,7 @@ public class SocketTextHandler extends TextWebSocketHandler implements CommandLi
System
.
out
.
println
(
message
);
System
.
out
.
println
(
message
);
ObjectWriter
ow
=
new
ObjectMapper
().
writer
().
withDefaultPrettyPrinter
();
ObjectWriter
ow
=
new
ObjectMapper
().
writer
().
withDefaultPrettyPrinter
();
String
json
=
ow
.
writeValueAsString
(
message
);
String
json
=
ow
.
writeValueAsString
(
message
);
System
.
out
.
println
(
json
);
//
System.out.println(json);
TextMessage
s
=
new
TextMessage
(
json
);
TextMessage
s
=
new
TextMessage
(
json
);
//System.out.println(s);
//System.out.println(s);
for
(
WebSocketSession
session
:
sessions
)
{
for
(
WebSocketSession
session
:
sessions
)
{
...
@@ -72,7 +72,7 @@ public class SocketTextHandler extends TextWebSocketHandler implements CommandLi
...
@@ -72,7 +72,7 @@ public class SocketTextHandler extends TextWebSocketHandler implements CommandLi
}
catch
(
JsonProcessingException
e
)
{
}
catch
(
JsonProcessingException
e
)
{
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
System
.
out
.
println
(
json
);
//
System.out.println(json);
TextMessage
s
=
new
TextMessage
(
json
);
TextMessage
s
=
new
TextMessage
(
json
);
if
(
session
.
isOpen
())
{
if
(
session
.
isOpen
())
{
try
{
try
{
...
...
SNMP_Pipeline/Web-Application/src/main/java/com/example/WebApplication/entities/AboutInfo.java
0 → 100644
View file @
e47acd41
package
com
.
example
.
WebApplication
.
entities
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public
class
AboutInfo
{
@JsonProperty
(
"key"
)
public
String
key
;
@JsonProperty
(
"value"
)
public
String
value
;
}
SNMP_Pipeline/Web-Application/src/main/java/com/example/WebApplication/factory/RethinkDBConnectionFactory.java
View file @
e47acd41
...
@@ -33,6 +33,12 @@ public class RethinkDBConnectionFactory {
...
@@ -33,6 +33,12 @@ public class RethinkDBConnectionFactory {
@Value
(
"${rethinkDBTableName}"
)
@Value
(
"${rethinkDBTableName}"
)
private
String
dbTableName
;
private
String
dbTableName
;
@Value
(
"${rethinkDBAbout}"
)
private
String
dbAbout
;
@Value
(
"${rethinkDBAboutTable}"
)
private
String
dbTableAbout
;
@PostConstruct
@PostConstruct
public
Connection
init
()
{
public
Connection
init
()
{
try
{
try
{
...
@@ -40,18 +46,28 @@ public class RethinkDBConnectionFactory {
...
@@ -40,18 +46,28 @@ public class RethinkDBConnectionFactory {
log
.
info
(
"RethinkDB connected successfully"
);
log
.
info
(
"RethinkDB connected successfully"
);
List
<
String
>
dbList
=
r
.
dbList
().
run
(
connection
);
List
<
String
>
dbList
=
r
.
dbList
().
run
(
connection
);
if
(!
dbList
.
contains
(
dbName
))
{
if
(!
dbList
.
contains
(
dbName
))
{
// System.out.println("Creating DATABASE Heeeeeeeeeeeeeeeeeeeeeeeeeere
");
System
.
out
.
println
(
"Creating DATABASE
"
);
r
.
dbCreate
(
dbName
).
run
(
connection
);
r
.
dbCreate
(
dbName
).
run
(
connection
);
}
}
List
<
String
>
tables
=
r
.
db
(
dbName
).
tableList
().
run
(
connection
);
List
<
String
>
tables
=
r
.
db
(
dbName
).
tableList
().
run
(
connection
);
if
(!
tables
.
contains
(
dbTableName
))
{
if
(!
tables
.
contains
(
dbTableName
))
{
// System.out.println("Creating Table Heeeeeeeeeeeeeeeeeeeeeeeeeer
e");
System
.
out
.
println
(
"Creating Tabl
e"
);
r
.
db
(
dbName
).
tableCreate
(
dbTableName
).
run
(
connection
);
r
.
db
(
dbName
).
tableCreate
(
dbTableName
).
run
(
connection
);
//r.db(dbName).table(dbTableName).indexCreate("timestamp").run(connection);
//r.db(dbName).table(dbTableName).indexCreate("timestamp").run(connection);
//r.db("my_database").table("my_table").indexCreate("trap").run(connection);
//r.db("my_database").table("my_table").indexCreate("trap").run(connection);
}
}
if
(!
dbList
.
contains
(
dbAbout
))
{
System
.
out
.
println
(
"Creating DATABASE"
);
r
.
dbCreate
(
dbAbout
).
run
(
connection
);
}
List
<
String
>
aboutTables
=
r
.
db
(
dbAbout
).
tableList
().
run
(
connection
);
if
(!
tables
.
contains
(
dbTableAbout
))
{
System
.
out
.
println
(
"Creating Table"
);
r
.
db
(
dbAbout
).
tableCreate
(
dbTableAbout
).
run
(
connection
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"Error connecting to RethinkDB"
,
e
);
log
.
error
(
"Error connecting to RethinkDB"
);
}
}
return
null
;
return
null
;
}
}
...
...
SNMP_Pipeline/Web-Application/src/main/java/com/example/WebApplication/services/SettingService.java
0 → 100644
View file @
e47acd41
package
com
.
example
.
WebApplication
.
services
;
import
com.example.WebApplication.entities.AboutInfo
;
import
com.example.WebApplication.factory.RethinkDBConnectionFactory
;
import
com.rethinkdb.RethinkDB
;
import
com.rethinkdb.net.Cursor
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.mail.SimpleMailMessage
;
import
org.springframework.mail.javamail.JavaMailSender
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
@Service
public
class
SettingService
{
@Autowired
private
JavaMailSender
mailSender
;
private
final
Logger
log
=
LoggerFactory
.
getLogger
(
RethinkDBService
.
class
);
private
final
RethinkDB
r
=
RethinkDB
.
r
;
@Autowired
public
RethinkDBConnectionFactory
connectionFactory
;
public
List
<
Map
<
String
,
AboutInfo
>>
getData
()
{
try
{
Cursor
<
Map
<
String
,
AboutInfo
>>
cursor
=
r
.
db
(
connectionFactory
.
getDbAbout
()).
table
(
connectionFactory
.
getDbTableAbout
()).
run
(
connectionFactory
.
getConnection
());
List
<
Map
<
String
,
AboutInfo
>>
result
=
new
ArrayList
<>();
while
(
cursor
.
hasNext
())
{
result
.
add
(
cursor
.
next
());
}
return
result
;
}
catch
(
Exception
e
)
{
log
.
error
(
"Error getting data from RethinkDB"
,
e
);
return
null
;
}
}
public
AboutInfo
getByKey
(
String
key
)
{
try
{
Cursor
<
Map
<
String
,
AboutInfo
>>
cursor
=
r
.
db
(
connectionFactory
.
getDbAbout
())
.
table
(
connectionFactory
.
getDbTableAbout
())
.
filter
(
row
->
row
.
g
(
"key"
).
eq
(
key
))
.
run
(
connectionFactory
.
getConnection
());
if
(
cursor
.
hasNext
())
{
return
cursor
.
next
().
get
(
"value"
);
}
else
{
return
null
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
"Error getting data from RethinkDB"
,
e
);
return
null
;
}
}
public
boolean
putAboutInfo
(
AboutInfo
aboutInfo
)
{
try
{
r
.
db
(
connectionFactory
.
getDbAbout
())
.
table
(
connectionFactory
.
getDbTableAbout
())
.
insert
(
r
.
hashMap
(
"key"
,
aboutInfo
.
getKey
())
.
with
(
"value"
,
aboutInfo
.
getValue
()))
.
run
(
connectionFactory
.
getConnection
());
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
"Error saving data to RethinkDB"
,
e
);
return
false
;
}
}
public
boolean
updateAboutInfo
(
AboutInfo
aboutInfo
)
{
try
{
r
.
db
(
connectionFactory
.
getDbAbout
())
.
table
(
connectionFactory
.
getDbTableAbout
())
.
filter
(
row
->
row
.
g
(
"key"
).
eq
(
aboutInfo
.
getKey
()))
.
update
(
r
.
hashMap
(
"value"
,
aboutInfo
.
getValue
()))
.
run
(
connectionFactory
.
getConnection
());
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
"Error updating data in RethinkDB"
,
e
);
return
false
;
}
}
public
void
deleteAboutInfo
(
String
key
)
{
try
{
r
.
db
(
connectionFactory
.
getDbAbout
())
.
table
(
connectionFactory
.
getDbTableAbout
())
.
filter
(
row
->
row
.
g
(
"key"
).
eq
(
key
))
.
delete
()
.
run
(
connectionFactory
.
getConnection
());
}
catch
(
Exception
e
)
{
log
.
error
(
"Error deleting data from RethinkDB"
,
e
);
}
}
public
void
sendMessage
(
String
subject
,
String
body
,
String
email
){
SimpleMailMessage
message
=
new
SimpleMailMessage
();
message
.
setFrom
(
"projectfms6@gmail.com"
);
message
.
setTo
(
"projectfms6@gmail.com"
);
message
.
setText
(
email
+
"\n"
+
body
);
message
.
setSubject
(
"FeedBack from: "
+
subject
);
mailSender
.
send
(
message
);
System
.
out
.
println
(
"Mail Send..."
);
}
}
SNMP_Pipeline/Web-Application/src/main/resources/application.properties
View file @
e47acd41
...
@@ -4,4 +4,12 @@ rethinkdb.port = 28015
...
@@ -4,4 +4,12 @@ rethinkdb.port = 28015
rethinkDBName
=
Traps
rethinkDBName
=
Traps
rethinkDBTableName
=
Raw-Traps
rethinkDBTableName
=
Raw-Traps
websocket.path
=
/fms-websocket
websocket.path
=
/fms-websocket
rethinkDBAbout
=
About
rethinkDBAboutTable
=
About-table
spring.mail.host
=
smtp.gmail.com
spring.mail.port
=
587
spring.mail.username
=
projectfms6@gmail.com
spring.mail.password
=
qajvviuzidnrimnh
spring.mail.properties.mail.smtp.auth
=
true
spring.mail.properties.mail.smtp.starttls.enable
=
true
SNMP_Pipeline/kafkaConsumerSNMP/src/main/java/com/example/kafkaConsumerSNMP/entities/EnrichedTrap.java
View file @
e47acd41
...
@@ -7,6 +7,7 @@ import org.snmp4j.PDUv1;
...
@@ -7,6 +7,7 @@ import org.snmp4j.PDUv1;
import
org.snmp4j.smi.VariableBinding
;
import
org.snmp4j.smi.VariableBinding
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
@Setter
@Setter
@Getter
@Getter
...
@@ -22,6 +23,8 @@ public class EnrichedTrap {
...
@@ -22,6 +23,8 @@ public class EnrichedTrap {
@JsonProperty
(
"timestamp"
)
@JsonProperty
(
"timestamp"
)
public
long
timestamp
;
public
long
timestamp
;
@JsonProperty
(
"date"
)
public
long
date
;
@JsonProperty
(
"severity"
)
@JsonProperty
(
"severity"
)
public
SeverityLevel
severity
;
public
SeverityLevel
severity
;
...
@@ -35,6 +38,7 @@ public class EnrichedTrap {
...
@@ -35,6 +38,7 @@ public class EnrichedTrap {
this
.
timestamp
=
pdu
.
getTimestamp
();
this
.
timestamp
=
pdu
.
getTimestamp
();
this
.
agentAddress
=
pdu
.
getAgentAddress
().
toString
();
this
.
agentAddress
=
pdu
.
getAgentAddress
().
toString
();
this
.
variableBindings
=
pdu
.
getVariableBindings
();
this
.
variableBindings
=
pdu
.
getVariableBindings
();
this
.
date
=
new
Date
().
getTime
();
if
(
this
.
variableBindings
.
size
()
>
5
){
if
(
this
.
variableBindings
.
size
()
>
5
){
this
.
severity
=
SeverityLevel
.
WARNING
;
this
.
severity
=
SeverityLevel
.
WARNING
;
}
}
...
...
SNMP_Pipeline/kafkaConsumerSNMP/src/main/java/com/example/kafkaConsumerSNMP/services/RethinkDBService.java
View file @
e47acd41
...
@@ -26,9 +26,8 @@ public class RethinkDBService {
...
@@ -26,9 +26,8 @@ public class RethinkDBService {
public
void
saveKafkaMessageToRethink
(
EnrichedTrap
rethinkTrap
)
{
public
void
saveKafkaMessageToRethink
(
EnrichedTrap
rethinkTrap
)
{
try
{
try
{
System
.
out
.
println
(
rethinkTrap
.
getDate
());
ObjectMapper
objectMapper
=
new
ObjectMapper
();
ObjectMapper
objectMapper
=
new
ObjectMapper
();
//
String
jsonString
=
objectMapper
.
writeValueAsString
(
rethinkTrap
);
String
jsonString
=
objectMapper
.
writeValueAsString
(
rethinkTrap
);
JsonNode
jsonNode
=
objectMapper
.
readTree
(
jsonString
);
JsonNode
jsonNode
=
objectMapper
.
readTree
(
jsonString
);
Map
<
String
,
EnrichedTrap
>
document
=
objectMapper
.
convertValue
(
jsonNode
,
Map
.
class
);
Map
<
String
,
EnrichedTrap
>
document
=
objectMapper
.
convertValue
(
jsonNode
,
Map
.
class
);
...
...
SNMP_Pipeline/kafkaConsumerSNMP/target/classes/com/example/kafkaConsumerSNMP/entities/EnrichedTrap.class
View file @
e47acd41
No preview for this file type
SNMP_Pipeline/kafkaConsumerSNMP/target/classes/com/example/kafkaConsumerSNMP/services/RethinkDBService.class
View file @
e47acd41
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment