Skip to content

Commit 42e8a36

Browse files
authored
v2.4.1 merge
with #39
1 parent 9638b8a commit 42e8a36

File tree

3 files changed

+31
-26
lines changed

3 files changed

+31
-26
lines changed

Getipinfo.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,35 @@
11
#!/usr/bin/python3
22

33
import sys
4+
import os
45
print ('**************** start *********************')
56
measurement_name = (sys.argv[5]) # get measurement from argv
67
print ('Measurement-name: '+measurement_name)
78

8-
# argv1 = outsideip, agrv2 = Domain, argv3 length, argv4 tragetip, sys.argv[5] bucketname, sys.argv[6] date, sys.argv[7] asn
9+
# argv1 = outsideip, agrv2 = Domain, argv3 length, argv4 tragetip, sys.argv[5] bucketname, sys.argv[6] date, sys.argv[7] asn, sys.argv[8] abuse
10+
11+
12+
13+
14+
abuseip_key = os.getenv('ABUSEIP_KEY')
15+
if abuseip_key is not None:
16+
import requests
17+
import json
18+
url = 'https://api.abuseipdb.com/api/v2/check'
19+
querystring = {
20+
'ipAddress': str(sys.argv[1]),
21+
'maxAgeInDays': '90'
22+
}
23+
headers = {
24+
'Accept': 'application/json',
25+
'Key': abuseip_key
26+
}
27+
28+
response = requests.request(method='GET', url=url, headers=headers, params=querystring)
29+
abuseip_response = json.loads(response.text)
30+
abuseConfidenceScore = str(abuseip_response["data"]["abuseConfidenceScore"])
31+
totalReports = str(abuseip_response["data"]["totalReports"])
32+
#print(json.dumps(abuseip_response, sort_keys=True, indent=4))
933

1034

1135
asn = str(sys.argv[7])
@@ -36,29 +60,6 @@
3660
Asn = response.autonomous_system_organization
3761
reader.close()
3862

39-
## get env vars and use
40-
import os
41-
import requests
42-
import json
43-
44-
abuseip_key = os.getenv('ABUSEIP_KEY')
45-
if abuseip_key is not None:
46-
url = 'https://api.abuseipdb.com/api/v2/check'
47-
querystring = {
48-
'ipAddress': str(sys.argv[1]),
49-
'maxAgeInDays': '90'
50-
}
51-
headers = {
52-
'Accept': 'application/json',
53-
'Key': abuseip_key
54-
}
55-
56-
response = requests.request(method='GET', url=url, headers=headers, params=querystring)
57-
abuseip_response = json.loads(response.text)
58-
abuseConfidenceScore = str(abuseip_response["data"]["abuseConfidenceScore"])
59-
totalReports = str(abuseip_response["data"]["totalReports"])
60-
#print(json.dumps(abuseip_response, sort_keys=True, indent=4))
61-
6263
# print to log
6364
print (Country)
6465
print (State)
@@ -79,6 +80,7 @@
7980
import influxdb_client
8081
from influxdb_client.client.write_api import SYNCHRONOUS
8182

83+
8284
# influx configuration - edit these
8385
npmhome = "/root/.config/NPMGRAF"
8486
ifhost = os.getenv('INFLUX_HOST')
@@ -167,4 +169,4 @@
167169

168170
ifclient.close()
169171

170-
print ('*************** data send ******************')
172+
print ('*************** data send ******************')

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
- maybe analys fallback/default/error logs
99
- grafan 10.1 missle map (route feature only one and not multiple possible)
1010

11+
## v2.4.1
12+
- add AbuseIPDB check to container (not included in Grafana Dashboard, add manually) Thanks to @maxdd in #38 and #39
13+
1114
## v2.4.0
1215
- add ASN as optional feature see #32 and #33 thanks to @maxdd
1316
- added ASN to Grafana

start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
echo "npmGrafStats: v2.4.0-pre"
2+
echo "npmGrafStats: v2.4.1"
33
echo "Startup: lets get the logs send them to influx"
44

55

0 commit comments

Comments
 (0)