原日志文件:logger.log  内容:

{"peer":"kts_001","type":"http","date":"2023-06-14 14:42:30","content":{"ip":"192.168.6.177","method":"GET","uri":"\/kts\/nts\/info","body":"","httpCode":200,"respond":"{\"code\":0,\"msg\":\"成功\",\"result\":{\"type\":1,\"utc\":1686724950400374,\"ltc\":1686724950404128,\"gpsStatus\":1,\"cdmaStatus\":0,\"ktMode\":6,\"ktStatus\":1,\"ftMode\":1,\"gpsEnable\":1,\"cdmaEnable\":0}}"}}
{"peer":"kts_001","type":"http","date":"2023-06-14 14:42:30","content":{"ip":"192.168.6.177","method":"GET","uri":"\/kts\/nts\/info","body":"","httpCode":200,"respond":"{\"code\":0,\"msg\":\"成功\",\"result\":{\"type\":1,\"utc\":1686724950511202,\"ltc\":1686724950514957,\"gpsStatus\":1,\"cdmaStatus\":0,\"ktMode\":6,\"ktStatus\":1,\"ftMode\":1,\"gpsEnable\":1,\"cdmaEnable\":0}}"}}
{"peer":"kts_001","type":"ntp","date":"2023-06-14 14:42:30","content":{"clientIp":"192.168.6.177","clientPort":45189,"referenceId":5460039,"rootDispersion":76,"referenceTimestamp":1686724857229845,"originatorTimestamp":1686724952319001,"receiveTimestamp":1686724950601704,"transmitTimestamp":1686724950601921}}
{"peer":"kts_001","type":"http","date":"2023-06-14 14:42:30","content":{"ip":"192.168.6.177","method":"GET","uri":"\/kts\/nts\/info","body":"","httpCode":200,"respond":"{\"code\":0,\"msg\":\"成功\",\"result\":{\"type\":1,\"utc\":1686724950604910,\"ltc\":1686724950608664,\"gpsStatus\":1,\"cdmaStatus\":0,\"ktMode\":6,\"ktStatus\":1,\"ftMode\":1,\"gpsEnable\":1,\"cdmaEnable\":0}}"}}
{"peer":"kts_001","type":"ntp","date":"2023-06-14 14:42:30","content":{"clientIp":"192.168.6.177","clientPort":37480,"referenceId":5460039,"rootDispersion":76,"referenceTimestamp":1686724857229845,"originatorTimestamp":1686724952416000,"receiveTimestamp":1686724950698109,"transmitTimestamp":1686724950698350}}
{"peer":"kts_001","type":"http","date":"2023-06-14 14:42:30","content":{"ip":"192.168.6.177","method":"GET","uri":"\/kts\/nts\/info","body":"","httpCode":200,"respond":"{\"code\":0,\"msg\":\"成功\",\"result\":{\"type\":1,\"utc\":1686724950700964,\"ltc\":1686724950704719,\"gpsStatus\":1,\"cdmaStatus\":0,\"ktMode\":6,\"ktStatus\":1,\"ftMode\":1,\"gpsEnable\":1,\"cdmaEnable\":0}}"}}
{"peer":"kts_001","type":"http","date":"2023-06-14 14:42:30","content":{"ip":"192.168.6.177","method":"GET","uri":"\/kts\/satellite\/info","body":"","httpCode":200,"respond":"{\"code\":0,\"msg\":\"成功\",\"result\":{\"gpsInviewCount\":13,\"bdInviewCount\":11,\"gpsInuseCount\":12,\"bdInuseCount\":13,\"latitude\":4001.4611799999998,\"latitudeHemisphere\":78,\"longitude\":11625.88177,\"longitudeHemisphere\":69,\"gpsSatelliteList\":[{\"id\":4,\"angleElevation\":6,\"angleAzimuth\":33,\"nsRatio\":35},{\"id\":5,\"angleElevation\":42,\"angleAzimuth\":245,\"nsRatio\":42},{\"id\":6,\"angleElevation\":44,\"angleAzimuth\":81,\"nsRatio\":42},{\"id\":9,\"angleElevation\":29,\"angleAzimuth\":53,\"nsRatio\":39},{\"id\":11,\"angleElevation\":70,\"angleAzimuth\":353,\"nsRatio\":44},{\"id\":12,\"angleElevation\":25,\"angleAzimuth\":248,\"nsRatio\":38},{\"id\":17,\"angleElevation\":7,\"angleAzimuth\":147,\"nsRatio\":21},{\"id\":19,\"angleElevation\":25,\"angleAzimuth\":148,\"nsRatio\":39},{\"id\":20,\"angleElevation\":68,\"angleAzimuth\":270,\"nsRatio\":42},{\"id\":25,\"angleElevation\":19,\"angleAzimuth\":286,\"nsRatio\":36},{\"id\":29,\"angleElevation\":14,\"angleAzimuth\":318,\"nsRatio\":27},{\"id\":50,\"angleElevation\":42,\"angleAzimuth\":164,\"nsRatio\":37}],\"bdSatelliteList\":[{\"id\":1,\"angleElevation\":0,\"angleAzimuth\":0,\"nsRatio\":31},{\"id\":3,\"angleElevation\":0,\"angleAzimuth\":0,\"nsRatio\":27},{\"id\":4,\"angleElevation\":0,\"angleAzimuth\":0,\"nsRatio\":28},{\"id\":5,\"angleElevation\":0,\"angleAzimuth\":0,\"nsRatio\":28},{\"id\":6,\"angleElevation\":0,\"angleAzimuth\":0,\"nsRatio\":16},{\"id\":7,\"angleElevation\":0,\"angleAzimuth\":0,\"nsRatio\":15},{\"id\":8,\"angleElevation\":0,\"angleAzimuth\":0,\"nsRatio\":14},{\"id\":10,\"angleElevation\":0,\"angleAzimuth\":0,\"nsRatio\":16},{\"id\":11,\"angleElevation\":0,\"angleAzimuth\":0,\"nsRatio\":15},{\"id\":12,\"angleElevation\":0,\"angleAzimuth\":0,\"nsRatio\":16},{\"id\":13,\"angleElevation\":0,\"angleAzimuth\":0,\"nsRatio\":13},{\"id\":14,\"angleElevation\":0,\"angleAzimuth\":0,\"nsRatio\":15},{\"id\":15,\"angleElevation\":0,\"angleAzimuth\":0,\"nsRatio\":22}]}}"}}
{"peer":"kts_001","type":"http","date":"2023-06-14 14:42:30","content":{"ip":"192.168.6.177","method":"GET","uri":"\/kts\/system\/role\/get","body":"","httpCode":200,"respond":"{\"code\":0,\"msg\":\"成功\",\"result\":{\"timeSrc\":\"GPS\",\"level\":1,\"isOK\":true}}"}}
{"peer":"kts_001","type":"http","date":"2023-06-14 14:42:30","content":{"ip":"192.168.6.177","method":"GET","uri":"\/kts\/nts\/info","body":"","httpCode":200,"respond":"{\"code\":0,\"msg\":\"成功\",\"result\":{\"type\":1,\"utc\":1686724950708567,\"ltc\":1686724950712321,\"gpsStatus\":1,\"cdmaStatus\":0,\"ktMode\":6,\"ktStatus\":1,\"ftMode\":1,\"gpsEnable\":1,\"cdmaEnable\":0}}"}}
{"peer":"kts_001","type":"http","date":"2023-06-14 14:42:33","content":{"ip":"127.0.0.1","method":"GET","uri":"\/kts\/nts\/version","body":"","httpCode":200,"respond":"3.1.7"}}
{"peer":"kts_001","type":"http","date":"2023-06-14 14:42:38","content":{"ip":"127.0.0.1","method":"GET","uri":"\/kts\/nts\/version","body":"","httpCode":200,"respond":"3.1.7"}}
.....

提取所有type为ntp的日志

cat /tmp/logger.log |grep ntp > ntp.log

得到一个ntp.log文件

{"peer":"kts_001","type":"ntp","date":"2023-06-14 14:42:30","content":{"clientIp":"192.168.6.177","clientPort":45189,"referenceId":5460039,"rootDispersion":76,"referenceTimestamp":1686724857229845,"originatorTimestamp":1686724952319001,"receiveTimestamp":1686724950601704,"transmitTimestamp":1686724950601921}}
{"peer":"kts_001","type":"ntp","date":"2023-06-14 14:42:30","content":{"clientIp":"192.168.6.177","clientPort":37480,"referenceId":5460039,"rootDispersion":76,"referenceTimestamp":1686724857229845,"originatorTimestamp":1686724952416000,"receiveTimestamp":1686724950698109,"transmitTimestamp":1686724950698350}}
......

提取IP地址并根据IP去重

cat ntp.log |grep -o '\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}'|sort -d | uniq  >> ip.txt

得到一个ip.txt文件,里面是所有去重过的ip地址。

Linux提取日志中的IP地址并去重的更多相关文章

  1. logresolve - 解析Apache日志中的IP地址为主机名

    logresolve是一个解析Apache访问日志中IP地址的后处理程序. 为了使对名称服务器的影响降到最低,logresolve拥有极为自主的内部散列表缓存, 使每个IP值仅仅在第一次从日志文件中读 ...

  2. Java正则表达式提取String字符串中的IP地址

    /** * 正则提前字符串中的IP地址 * @param ipString * @return */ public static List<String> getIps(String ip ...

  3. Python统计日志中每个IP出现次数

    介绍了Python统计日志中每个IP出现次数的方法,实例分析了Python基于正则表达式解析日志文件的相关技巧,需要的朋友可以参考下 本脚本可用于多种日志类型 #-*- coding:utf-8 -* ...

  4. Linux环境下如何配置IP地址、MAC地址

    Linux环境下如何配置IP地址.MAC地址 1.配置IP地址 进入配置IP地址路径,进行修改即可 cd /etc/network vim interface 加入以下内容: iface eth0 i ...

  5. Linux系统下如何设置IP地址?

    Linux系统下如何设置IP地址?我们可以通过命令设定IP的方法,不过此方法的前提条件是用户需root权限.在linux系统的 /etc/sysconfig/network-script/ifcfg- ...

  6. 配置日志中显示IP

    package com.demo.conf; import ch.qos.logback.classic.pattern.ClassicConverter; import ch.qos.logback ...

  7. Linux下获取本机IP地址的代码

    Linux下获取本机IP地址的代码,返回值即为互联网标准点分格式的字符串. #define ETH_NAME "eth0" //获得本机IP地址 char* GetLocalAdd ...

  8. linux(Ubuntu/Centos) iproute 路由IP地址等命令集合,查看端口链接

    原 linux(Ubuntu/Centos) iproute 路由IP地址等命令集合,查看端口链接 2017年03月20日 16:55:57 风来了- 阅读数:2291 标签: centoslinux ...

  9. PHP提取字符串中的图片地址

    PHP提取字符串中的图片地址 $str='<p><img border="0" src="upfiles/2009/07/1246430143_1.jp ...

  10. ubuntu中配置ip地址和上网配置

    ubuntu中的ip地址配置: 基于NAT模式: 如果能正常连接ip,但不能ping动www.baidu.com的话,我们需要在配置文件中配置主机上网的DNS地址,如下: 如果上面图片上的DNS se ...

随机推荐

  1. Qt开发-共享内存使用范例,配合开发者密钥使用后台调试程序或者进入调试模式

    共享内存 就之前不是开发了一个Leventure_DeveloperKey用以调试程序嘛,在这里简单聊一下调试模式的方案. 这里的调试分为了两种,一种是调试模式,一种是开发者模式.需要这两种模式的原因 ...

  2. appium(二)安装(Android)

    一.安装Appium-desktop 1.官网下载安装包: http://appium.io/

  3. Jstack 查看线程状态及定位占用 cpu 较高的 java 线程

    本文为博主原创,未经允许不得转载: 1. Jstack 用来查看 java 指定进程所包含的 java 线程状态:    "arthas-NettyHttpTelnetBootstrap-3 ...

  4. Avalonia使用默认弹窗

    Avalonia使用默认弹窗 在Avalonia中使用官方默认弹窗WindowNotificationManager Views\MainWindow.axaml相关代码 <Window xml ...

  5. 如何使用单纯的`WebAssembly`

    一般来说在.net core使用WebAssembly 都是Blazor ,但是Blazor渲染界面,.net core也提供单纯的WebAssembly这篇博客我将讲解如何使用单纯的WebAssem ...

  6. 基于java+springboot的图书借阅网站-在线图书借阅管理系统

    该系统是基于java+springboot开发的图书借阅管理系统.是给师弟开发的课程作业.大家学习过程中,遇到问题可以github咨询作者. 系统演示地址 前台 http://book.gitapp. ...

  7. Laravel - 虚拟主机引入静态资源

    一. 注意: 引用的静态文件要放在根目录,不要放在assets目录下 二. 引入方法 1.  模板中引入 css      <link rel="stylesheet" hr ...

  8. [转帖]理解 Linux backlog/somaxconn 内核参数

    引言 在研究IOTDB的时候,启动服务的时候会有个报警. WARN: the value of net.core.somaxconn (=4096) is too small, please set ...

  9. [转帖]tcp、http和socket的区别

    https://www.jianshu.com/p/88d69454bdde 一:tcp协议 tcp协议属于传输层协议(UDP也属于传输层协议,但是UDP协议是无状态的).建立一个TCP连接需要三次握 ...

  10. [转帖]Linux终端:用cat命令查看不可见字符

    https://developer.aliyun.com/article/80607 printf 'testing\012\011\011testing\014\010\012more testin ...