marker_file=[ ]
netstat -ntp
sudo netstat -ntp | grep tcp | grep -v ::
#!/bin/sh # , netstat'a STAT_FILE=`mktemp` # MARKER_FILE="ipm" sudo netstat -nutp | grep tcp | grep -v :: > $STAT_FILE # ./net_draw.py $STAT_FILE > $MARKER_FILE # . # -output p.jpg - # -geometry 1920X1080 - # -projection rectangular - , . # -longitude 15 - ( "") # -num_times 1 - 1 # -quality 100 - xplanet -output p.jpg -geometry 1920X1080 -projection rectangular -longitude 15 -quality 100 -num_times 1 # rm $STAT_FILE
#!/usr/bin/env python # -*- coding: utf-8 -*- import pygeoip import sys input_file = sys.argv[1] # gi = pygeoip.GeoIP("GeoLiteCity.dat") marker_map = {} # - # : class Col: def __init__(self): # , self.c_id = 0 # self.color_map = {} # self.colors = ["White", "Red", "Green", "Yellow", "Purple", "Brown", "Blue", "Pink", "Gray", "Orange"] def get_color(self,id): if id in self.color_map: return self.color_map[id] self.color_map[id] = self.colors[self.c_id] self.c_id = self.c_id + 1 # , if self.c_id == len(self.colors): self.c_id = 0 return self.color_map[id] c_c = Col() i_f = open(input_file, 'r') for l in i_f: # fields = l.split() # IP pos = fields[4].find(':') ip = fields[4][:pos] gi_pos = gi.record_by_addr(ip) # name = fields[6] # , None if gi_pos != None: color = c_c.get_color(name) marker_id = "%5.2f %5.2f \"\" color=%s" % (gi_pos['latitude'], gi_pos['longitude'],color) # , , 2 if marker_id in marker_map: marker_map[marker_id] = marker_map[marker_id] + 1 else: marker_map[marker_id] = 2 # for mid in marker_map: print (mid + " symbolsize=%d" % marker_map[mid]) # , x, y - x = 0 y = 50 for key in c_c.color_map: print ("%5.2f %5.2f \"%s\" color=%s" % (x, y, key, c_c.color_map[key])) x = x - 2.5 y = y + 0
Source: https://habr.com/ru/post/143504/
All Articles