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
c4887f20
Commit
c4887f20
authored
Jul 12, 2023
by
Bashar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Before Primary Presentation
parent
406501e0
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
26 additions
and
12 deletions
+26
-12
SnmpListener.java
.../src/main/java/com/example/SnmpReciever/SnmpListener.java
+5
-5
KafkaService.java
.../java/com/example/SnmpReciever/services/KafkaService.java
+17
-0
SnmpListener.class
...arget/classes/com/example/SnmpReciever/SnmpListener.class
+0
-0
RethinkController.java
.../example/WebApplication/controller/RethinkController.java
+1
-2
KafkaConsumerSnmpApplication.java
...ample/kafkaConsumerSNMP/KafkaConsumerSnmpApplication.java
+3
-3
RethinkDBService.java
.../example/kafkaConsumerSNMP/services/RethinkDBService.java
+0
-2
KafkaConsumerSnmpApplication.class
...mple/kafkaConsumerSNMP/KafkaConsumerSnmpApplication.class
+0
-0
No files found.
SNMP_Pipeline/SnmpReciever/src/main/java/com/example/SnmpReciever/SnmpListener.java
View file @
c4887f20
package
com
.
example
.
SnmpReciever
;
import
com.example.SnmpReciever.enitites.TrapData
;
//import com.example.SnmpReciever.services.KafkaService;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
lombok.AllArgsConstructor
;
import
org.snmp4j.*
;
import
org.snmp4j.smi.UdpAddress
;
import
org.snmp4j.transport.DefaultUdpTransportMapping
;
...
...
@@ -13,14 +15,12 @@ import java.io.IOException;
/*@RestController
@RequestMapping("/api/product")*/
@Component
@AllArgsConstructor
public
class
SnmpListener
implements
CommandResponder
{
private
final
KafkaTemplate
<
String
,
String
>
kafkaTemplate
;
private
final
ObjectMapper
objectMapper
;
public
SnmpListener
(
KafkaTemplate
<
String
,
String
>
kafkaTemplate
,
ObjectMapper
objectMapper
)
{
this
.
kafkaTemplate
=
kafkaTemplate
;
this
.
objectMapper
=
objectMapper
;
}
@Override
public
synchronized
void
processPdu
(
CommandResponderEvent
event
)
{
...
...
@@ -44,7 +44,7 @@ public class SnmpListener implements CommandResponder {
}
public
void
startTrapListener
()
{
try
{
TransportMapping
<?>
transport
=
new
DefaultUdpTransportMapping
(
new
UdpAddress
(
"192.168.2
5.254
/1625"
));
TransportMapping
<?>
transport
=
new
DefaultUdpTransportMapping
(
new
UdpAddress
(
"192.168.2
6.46
/1625"
));
System
.
out
.
println
(
"Listening to SNMP Trap"
);
Snmp
snmp
=
new
Snmp
(
transport
);
snmp
.
addCommandResponder
(
this
);
...
...
SNMP_Pipeline/SnmpReciever/src/main/java/com/example/SnmpReciever/services/KafkaService.java
0 → 100644
View file @
c4887f20
//package com.example.SnmpReciever.services;
//
//import com.fasterxml.jackson.core.JsonProcessingException;
//import com.fasterxml.jackson.databind.ObjectMapper;
//import lombok.AllArgsConstructor;
//import org.springframework.kafka.core.KafkaTemplate;
//import org.springframework.stereotype.Service;
//
//@Service
//@AllArgsConstructor
//public class KafkaService {
// private final KafkaTemplate<String, String> kafkaTemplate;
//
// public void send(String topic,String message){
// kafkaTemplate.send(topic,message);
// }
//}
SNMP_Pipeline/SnmpReciever/target/classes/com/example/SnmpReciever/SnmpListener.class
View file @
c4887f20
No preview for this file type
SNMP_Pipeline/Web-Application/src/main/java/com/example/WebApplication/controller/RethinkController.java
View file @
c4887f20
...
...
@@ -15,8 +15,8 @@ import java.util.List;
import
java.util.Map
;
@RestController
@CrossOrigin
(
"192.168.25.254:3000"
)
@RequestMapping
(
"/api/rethink"
)
@CrossOrigin
(
origins
=
{
"http://localhost:3000"
})
public
class
RethinkController
{
@Autowired
private
RethinkDBService
rethinkDBService
;
...
...
@@ -24,7 +24,6 @@ public class RethinkController {
public
void
delete
(
@RequestBody
String
id
){
rethinkDBService
.
deleteById
(
id
);
}
@GetMapping
(
"/data"
)
public
ResponseEntity
<
List
<
Map
<
String
,
Object
>>>
getData
()
{
List
<
Map
<
String
,
Object
>>
result
=
rethinkDBService
.
getData
();
...
...
SNMP_Pipeline/kafkaConsumerSNMP/src/main/java/com/example/kafkaConsumerSNMP/KafkaConsumerSnmpApplication.java
View file @
c4887f20
...
...
@@ -32,9 +32,9 @@ public class KafkaConsumerSnmpApplication {
TrapData
t
=
objectMapper
.
readValue
(
json
,
TrapData
.
class
);
//Some Processing: Add this later
EnrichedTrap
t2
=
new
EnrichedTrap
(
t
);
//
System.out.println("Not sent yet");
//
sender.send(t2);
//
System.out.println("Sent now!");
System
.
out
.
println
(
"Not sent yet"
);
sender
.
send
(
t2
);
System
.
out
.
println
(
"Sent now!"
);
rethinkDBService
.
saveKafkaMessageToRethink
(
t2
);
if
(
num
==
1
)
System
.
out
.
println
(
rethinkDBService
.
getData
());
...
...
SNMP_Pipeline/kafkaConsumerSNMP/src/main/java/com/example/kafkaConsumerSNMP/services/RethinkDBService.java
View file @
c4887f20
...
...
@@ -35,9 +35,7 @@ public class RethinkDBService {
System
.
out
.
println
(
jsonString
);
System
.
out
.
println
(
jsonNode
);
System
.
out
.
println
(
document
);
System
.
out
.
println
(
"I am here reem "
+
connectionFactory
.
getDbName
()
+
" "
+
connectionFactory
.
getDbTableName
());
r
.
db
(
connectionFactory
.
getDbName
()).
table
(
connectionFactory
.
getDbTableName
()).
insert
(
document
).
run
(
connectionFactory
.
getConnection
());
System
.
out
.
println
(
"I am here now reem"
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"error "
+
e
);
}
...
...
SNMP_Pipeline/kafkaConsumerSNMP/target/classes/com/example/kafkaConsumerSNMP/KafkaConsumerSnmpApplication.class
View file @
c4887f20
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