Skip to content

Commit bee3201

Browse files
committed
20000a20210407
1 parent b9bcdf6 commit bee3201

23 files changed

+251
-0
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[tcpserver]
2+
; the TCO server is where the devices connects and send data via a TCP4 protocol
3+
tcp_port : 3333 ; tcp server port
4+
5+
[apiserver]
6+
; the api server is sued by any client to access system data via the API (See README for details)
7+
api_port : 8079 ; API server port
8+
disable_cors : true ; disable CORS if true
9+
10+
[database]
11+
disable : false ; if true, the database is disabled (not available in embedded builds)
12+
13+
[export]
14+
; specified the commands for export mode. the argument fiels can be left empty is not needed
15+
; export mode must be enabled for this section to have any effect
16+
async : true ; if true export does not wait for a script answer
17+
;current_command : test.exe ; command to be executed for current data (leave empty to disable)
18+
;current_argument : example.py ; command argument for current data script
19+
;reference_command : python ; command to be executed for reference data (leave empty to disable)
20+
;reference_argument : example.py ; command argument for reference data script
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
; this configuration files affects cache performance and operation.
2+
; it is advised to consult with support before modifying its content
3+
; it si needed only for the mipsle binaries
4+
5+
[paths]
6+
; folder for the working cache
7+
WorkingFolder : ./tables
8+
; folder for the cache recovery files
9+
RecoveryFolder : ./tables
10+
11+
[system]
12+
InternalBuffering : 20 ; length of internal buffers, affect performance
13+
LoadDelayMs : 10 ; delay between data load in recovery; affect performance and cache error rate
14+
15+
[data]
16+
ExpirationTime : 10 ; data life time if relevant (in minutes)
17+
MaximumAge : 5 ; maximum age of recovery data (in minutes)
18+
IntervalConsolidation : 1 ; minimum interval between two working file consolidation cycles (in minutes)
19+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[sensors]
2+
; declaration of individual sensors are optional (MAC without ':')
3+
; if not defined the server will use the id provided by the sensor and ignore any ID=65535
4+
;
5+
; The statement format is:
6+
; mac : id rate attribute attribute {attribute}
7+
; The id must be an integer and at least one attribute must be specified.
8+
; The rate indicates minimum time distance between samples (in ms). Set to 0 to disable.
9+
; The attribute can be one of the following strings:
10+
; bypass : this mac will use used as a sensor of the given ID
11+
; report : report if the sensor uses a different id
12+
; enforce : force the device id to the given value (has no effect with strict)
13+
; strict : if the device id is not as the declared id, the sensor is ignored (overridden by bypass)
14+
;0a0b0c010209 : 0 0 bypass
15+
16+
[gates]
17+
; list of gates and their composing devices with indication if the device is reversed or not
18+
; name : {!}sensor_id {{!}sensor_id}
19+
; a ! before a sensor_id indicates a reversed sensor
20+
; a gate accepts one or two sensors only
21+
kit0 : 1 0
22+
kit1 : !2 3
23+
24+
[entries]
25+
; list of entries and their composing gates with indication if the gate is reversed or not
26+
; name : {!}gate_name {{!}gate_name} ...
27+
; a ! before a gate name indicated that the gate is reversed
28+
e0 : kit0
29+
e1 : kit1
30+
31+
[spaces]
32+
; list of spaces and their composing entries with indication if the entry is reversed or not
33+
; name : {!}gate_name {{!}gate_name} ...
34+
h0 : e0 e1
35+
36+
[reset]
37+
; declares the interval during which the space are to be considered empty. The internal counters, accumulators and sensors are reset
38+
; space_name : start(xx.xx) end(yy.yy)
39+
h0 : 23.00 23.29
40+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
; this configuration files affects server performance and operation.
2+
; it is advised to consult with support before modifying its content
3+
[buffers]
4+
channelling : 5 ; sets internal channel buffer size
5+
security : 100 ; size of buffers that when exceeded trigger a security alert
6+
7+
[corrections]
8+
shadowing : false ; if true, uncorrected data will be saved in the shadow data database
9+
accept_errors : false ; if true, negative occupancy will be allowed
10+
11+
[eeprom]
12+
eeprom_delay : 10 ; Defines delay before the eeprom refresh (in s)
13+
eeprom_step : 3 ; Defines delay between eeprom refresh commands (in s)
14+
; indicate the name of the file where the EEPROM refresh values are
15+
sensorEEPROM : sensors.settings
16+
17+
[security]
18+
maliciousIP_threshold : 10 ; the number of suspected connection before an IP gets banned
19+
maliciousMAC_threshold : 10 ; the number of suspected connection before a MAC gets banned
20+
malicious_control : 0 ; 0 - off, 1 - normal, 2 - severe
21+
failure_threshold : 10 ; number of errors before a MAC is marked suspicious in normal mode (severe overrides this command)
22+
CRC_errors_included : false ; indicate if a failed CRC is to be considered a failure
23+
enforce_strict : false ; if true, failing to enforce an ID will result in sensor being disconnected
24+
25+
[sensors]
26+
crc_enabled : true ; sets crc usage (normally on)
27+
maximum_undefined_time = 3 ; maximum time a sensor is allowed to be without a valid or used ID in minutes
28+
reset_slot : 22.15 22.50 ; sensor reset is tried from aa.aa to bb.bb
29+
reset_period : 10 ; period the reset is tried (in minutes)
30+
reset_closure : false ; if true tcp channel is closed after sensor reset
31+
asymmetry_max : 3 ; asymmetry recurrence number triggering a reset
32+
asymmetry_iter : 0 ; maximum number of asymmetry reset before the sensor gets disabled
33+
asymmetric_null : false ; if true is counts zero detection as no detection
34+
asymmetry_reset : 100 ; number of samples after which asymmetry errors are discarded (forced minimum 50)
35+
36+
[timeouts]
37+
server : 10 ; server timeout (in s)
38+
device : 10 ; sensor timeout (in s)
39+
malicious : 120 ; timeout on suspected malicious attacks (in s)
40+
zombie : 48 ; maximum life of suspected Zombie processes (in hours)
41+
repetitive : 120 ; timeout or reference timing among repetitive actions (in s)
42+
settle : 1 ; settle delay is used for start/stop settling. Longer values only result longer start and shutdown times
43+
44+
[shutdown]
45+
save_state : false ; if true the server state will be saved/restored
46+
state_max_age : 60 ; maximum allowed age of any save state (in s), default is 30s
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
; measurements are classified in three types.
2+
;
3+
; 'realtime' measurements are defines as a sliding windows (in seconds) and they calculate the average count and flow
4+
; in such sliding window. For example, specifying 5 means that the measure will give the average value for the last 5 seconds
5+
; as count and the flows in the last 5 seconds
6+
;
7+
; 'reference' measurement are specifying with a repetition interval.
8+
; For example, specifying 5s means that we will calculate a new average and flows every 5s.
9+
;
10+
; 'current' data is the real time as generated without any averaging performed and uit includes also accumulated in/out flows.
11+
; this data is available both via scripting and via the API (must be enabled, see below).
12+
13+
[realtime]
14+
; name : sliding_window_in_seconds
15+
tenSec : 10
16+
;twentySec : 20
17+
;minute : 60
18+
;hourly : 3600
19+
;daily : 86400
20+
21+
[reference]
22+
; name : interval_in_seconds
23+
;quarter : 900
24+
;tenSec : 10
25+
twentySec : 20
26+
27+
[system]
28+
current : true ; if true, the current data is also made available
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Sensor setting file
2+
# Format:
3+
# {mac} {srate} {savg} {bgth} {occth}
4+
# mac can be of form 0a0b0c010209 or 0a:0b:0c:01:02:09
5+
* 64 10 1.7 1.8
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package exportExamples
2+
3+
import (
4+
"encoding/json"
5+
"fmt"
6+
"os"
7+
"strconv"
8+
"strings"
9+
)
10+
11+
// example exporting current data
12+
13+
// generic flow
14+
type FlowWithFlows struct {
15+
Id string `json:"id"`
16+
Variation int `json:"-"`
17+
Netflow int `json:"netflow"`
18+
TsOverflow int64 `json:"overflowTs"`
19+
Reversed bool `json:"-"`
20+
FlowIn int `json:"in"`
21+
FlowOut int `json:"out"`
22+
}
23+
24+
// entry flow data model used for database storage
25+
type EntryStateWithFlows struct {
26+
Id string `json:"id"`
27+
Ts int64 `json:"Ts"`
28+
Variation int `json:"-"`
29+
Netflow int `json:"netflow"`
30+
TsOverflow int64 `json:"overflowTs"`
31+
FlowIn int `json:"in"`
32+
FlowOut int `json:"out"`
33+
State bool `json:"-"`
34+
Reversed bool `json:"-"`
35+
Flows map[string]FlowWithFlows `json:"flows"`
36+
}
37+
38+
type MeasurementSample struct {
39+
Qualifier string `json:"qualifier"`
40+
Space string `json:"space"`
41+
Ts int64 `json:"timestamp"`
42+
Count float64 `json:"count"`
43+
FlowIn int `json:"in"`
44+
FlowOut int `json:"out"`
45+
StartTimeFlows int64 `json:"startTimeFlows"`
46+
TsOverflow int64 `json:"overflowTs"`
47+
Flows map[string]EntryStateWithFlows `json:"flows"`
48+
}
49+
50+
func _example() {
51+
if len(os.Args) > 1 {
52+
var receivedData MeasurementSample
53+
str := strings.Replace(os.Args[1], "'", "\"", -1)
54+
if file, err := os.OpenFile("exportedData.txt", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644); err == nil {
55+
_, _ = file.WriteString(str + "\n")
56+
defer file.Close()
57+
if err := json.Unmarshal([]byte(str), &receivedData); err == nil {
58+
_, _ = file.WriteString("Space " + receivedData.Space + " has counter " + receivedData.Qualifier +
59+
" equal to " + fmt.Sprintf("%f", receivedData.Count) + " at time " + strconv.Itoa(int(receivedData.Ts)) + "\n")
60+
}
61+
}
62+
}
63+
}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import sys, json
2+
3+
# example exporting 'current' data
4+
5+
if len(sys.argv) == 2:
6+
try:
7+
receivedData = json.loads(sys.argv[1].replace("'", '"'))
8+
with open('./exportedData.txt', 'a') as f:
9+
f.write("Space " + receivedData["space"] + " has counter " + receivedData["qualifier"] +
10+
" equal to " + str(receivedData["count"]) + " at time " + str(receivedData["timestamp"]) + "\n")
11+
except:
12+
print("failed")
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# tested on Raspbian,
2+
3+
[Unit]
4+
Description=XetalFlow
5+
After=network.target
6+
7+
[Service]
8+
# please set the executable with the suitable options, this is only an example
9+
ExecStart=/home/pi/gateflow/gateserver -dev -export
10+
# Set the directory to the one where the server has been copied
11+
WorkingDirectory=/home/pi/gateflow
12+
StandardOutput=inherit
13+
StandardError=inherit
14+
Restart=always
15+
User=pi
16+
17+
[Install]
18+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)