11#!/usr/bin/python3
22
33import sys
4+ import os
45print ('**************** start *********************' )
56measurement_name = (sys .argv [5 ]) # get measurement from argv
67print ('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
1135asn = str (sys .argv [7 ])
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
6364print (Country )
6465print (State )
7980import influxdb_client
8081from influxdb_client .client .write_api import SYNCHRONOUS
8182
83+
8284# influx configuration - edit these
8385npmhome = "/root/.config/NPMGRAF"
8486ifhost = os .getenv ('INFLUX_HOST' )
167169
168170ifclient .close ()
169171
170- print ('*************** data send ******************' )
172+ print ('*************** data send ******************' )
0 commit comments