作者:邓聪聪
提取日志或文本中的关键内容
1 Apr 23 09:34:05 localhost NetworkManager[1399]:(eno16777736): Activation: starting connection 'eno16777736' (ecefc7de-e893-4eee-88fd-bb9843616ec2) 2 Apr 23 09:34:05 localhost NetworkManager[1399]: (eno16777736): device state change: disconnected -> prepare (reason 'none') [30 40 0] 3 Apr 23 09:34:05 localhost NetworkManager[1399]: NetworkManager state is now CONNECTING 4 Apr 23 09:34:05 localhost NetworkManager[1399]: (eno16777736): device state change: prepare -> config (reason 'none') [40 50 0] 5 Apr 23 09:34:05 localhost NetworkManager[1399]: (eno16777736): device state change: config -> ip-config (reason 'none') [50 70 0] 6 Apr 23 09:34:05 localhost NetworkManager[1399]: Activation (eno16777736) Beginning DHCPv4 transaction (timeout in 45 seconds) 7 Apr 23 09:34:05 localhost NetworkManager[1399]: dhclient started with pid 11327 8 Apr 23 09:34:05 localhost dhclient[11327]: DHCPDISCOVER on eno16777736 to 255.255.255.255 port 67 interval 7 (xid=0x398e2136) 9 Apr 23 09:34:06 localhost dhclient[11327]: DHCPREQUEST on eno16777736 to 255.255.255.255 port 67 (xid=0x398e2136) 10 Apr 23 09:34:06 localhost dhclient[11327]: DHCPOFFER from 10.0.0.254 11 Apr 23 09:34:06 localhost dhclient[11327]: DHCPACK from 10.0.0.254 (xid=0x398e2136) 12 Apr 23 09:34:06 localhost NetworkManager[1399]: address 10.0.0.132 13 Apr 23 09:34:06 localhost NetworkManager[1399]: plen 24 (255.255.255.0) 14 Apr 23 09:34:06 localhost NetworkManager[1399]: gateway 10.0.0.2 15 Apr 23 09:34:06 localhost NetworkManager[1399]: server identifier 10.0.0.254 16 Apr 23 09:34:06 localhost NetworkManager[1399]: lease time 1800 17 Apr 23 09:34:06 localhost NetworkManager[1399]: nameserver '10.0.0.2' 18 Apr 23 09:34:06 localhost NetworkManager[1399]: domain name 'localdomain' 19 Apr 23 09:34:06 localhost NetworkManager[1399]: (eno16777736): DHCPv4 state changed unknown -> bound 20 Apr 23 09:34:06 localhost NetworkManager[1399]: (eno16777736): device state change: ip-config -> ip-check (reason 'none') [70 80 0] 21 Apr 23 09:34:06 localhost NetworkManager[1399]: (eno16777736): device state change: ip-check -> secondaries (reason 'none') [80 90 0] 22 Apr 23 09:34:06 localhost NetworkManager[1399]: (eno16777736): device state change: secondaries -> activated (reason 'none') [90 100 0] 23 Apr 23 09:34:06 localhost NetworkManager[1399]: NetworkManager state is now CONNECTED_LOCAL 24 Apr 23 09:34:06 localhost NetworkManager[1399]: NetworkManager state is now CONNECTED_GLOBAL 25 Apr 23 09:34:06 localhost NetworkManager[1399]: Policy set 'eno16777736' (eno16777736) as default for IPv4 routing and DNS. 26 Apr 23 09:34:06 localhost NetworkManager[1399]: (eno16777736): Activation: successful, device activated. 27 Apr 23 09:34:06 localhost nm-dispatcher: Dispatching action 'up' for eno16777736 28 Apr 23 09:34:06 localhost network: Bringing up interface eno16777736: Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/1) 29 Apr 23 09:34:06 localhost dhclient[11327]: bound to 10.0.0.132 -- renewal in 735 seconds. 30 Apr 23 09:34:06 localhost network: [ OK ] 31 Apr 23 09:34:06 localhost systemd: Started LSB: Bring up/down networking. 32 Apr 23 09:35:47 localhost dbus[1172]: avc: received setenforce notice (enforcing=0) 33 Apr 23 09:35:47 localhost dbus-daemon: dbus[1172]: avc: received setenforce notice (enforcing=0) 34 Apr 23 09:37:16 localhost systemd: Stopping firewalld - dynamic firewall daemon... 35 Apr 23 09:37:16 localhost kernel: Ebtables v2.0 unregistered 36 Apr 23 09:37:16 localhost systemd: Stopped firewalld - dynamic firewall daemon. 37 Apr 23 09:37:56 localhost systemd: Started Session 2 of user root. 38 Apr 23 09:37:56 localhost systemd-logind: New session 2 of user root. 39 Apr 23 09:37:56 localhost systemd: Starting Session 2 of user root. 40 Apr 23 09:46:21 localhost dhclient[11327]: DHCPREQUEST on eno16777736 to 10.0.0.254 port 67 (xid=0x398e2136) 41 Apr 23 09:46:21 localhost dhclient[11327]: DHCPACK from 10.0.0.254 (xid=0x398e2136) 42 Apr 23 09:46:21 localhost NetworkManager[1399]: address 10.0.0.132 43 Apr 23 09:46:21 localhost NetworkManager[1399]: plen 24 (255.255.255.0) 44 Apr 23 09:46:21 localhost NetworkManager[1399]: gateway 10.0.0.2 45 Apr 23 09:46:21 localhost NetworkManager[1399]: server identifier 10.0.0.254 46 Apr 23 09:46:21 localhost NetworkManager[1399]: lease time 1800 47 Apr 23 09:46:21 localhost NetworkManager[1399]: nameserver '10.0.0.2' 48 Apr 23 09:46:21 localhost NetworkManager[1399]: domain name 'localdomain' 49 Apr 23 09:46:21 localhost NetworkManager[1399]: (eno16777736): DHCPv4 state changed bound -> bound 50 Apr 23 09:46:21 localhost dbus[1172]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' 51 Apr 23 09:46:21 localhost systemd: Starting Network Manager Script Dispatcher Service... 52 Apr 23 09:46:21 localhost dbus-daemon: dbus[1172]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' 53 Apr 23 09:46:21 localhost dhclient[11327]: bound to 10.0.0.132 -- renewal in 823 seconds. 54 Apr 23 09:46:21 localhost dbus[1172]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher' 55 Apr 23 09:46:21 localhost dbus-daemon: dbus[1172]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher' 56 Apr 23 09:46:21 localhost systemd: Started Network Manager Script Dispatcher Service. 57 Apr 23 09:46:21 localhost nm-dispatcher: Dispatching action 'dhcp4-change' for eno16777736 58 Apr 23 09:46:57 localhost systemd: Starting Cleanup of Temporary Directories... 59 Apr 23 09:46:57 localhost systemd: Started Cleanup of Temporary Directories. 60 Apr 23 10:00:04 localhost dhclient[11327]: DHCPREQUEST on eno16777736 to 10.0.0.254 port 67 (xid=0x398e2136) 61 Apr 23 10:00:04 localhost dhclient[11327]: DHCPACK from 10.0.0.254 (xid=0x398e2136) 62 Apr 23 10:00:04 localhost NetworkManager[1399]: address 10.0.0.132 63 Apr 23 10:00:04 localhost NetworkManager[1399]: plen 24 (255.255.255.0) 64 Apr 23 10:00:04 localhost NetworkManager[1399]: gateway 10.0.0.2 65 Apr 23 10:00:04 localhost NetworkManager[1399]: server identifier 10.0.0.254 66 Apr 23 10:00:04 localhost NetworkManager[1399]: lease time 1800 67 Apr 23 10:00:04 localhost NetworkManager[1399]: nameserver '10.0.0.2' 68 Apr 23 10:00:04 localhost NetworkManager[1399]: domain name 'localdomain' 69 Apr 23 10:00:04 localhost NetworkManager[1399]: (eno16777736): DHCPv4 state changed bound -> bound 70 Apr 23 10:00:04 localhost dbus[1172]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' 71 Apr 23 10:00:04 localhost dbus-daemon: dbus[1172]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' 72 Apr 23 10:00:04 localhost systemd: Starting Network Manager Script Dispatcher Service... 73 Apr 23 10:00:04 localhost dhclient[11327]: bound to 10.0.0.132 -- renewal in 707 seconds. 74 Apr 23 10:00:04 localhost dbus[1172]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher' 75 Apr 23 10:00:04 localhost dbus-daemon: dbus[1172]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher' 76 Apr 23 10:00:04 localhost systemd: Started Network Manager Script Dispatcher Service. 77 Apr 23 10:00:04 localhost nm-dispatcher: Dispatching action 'dhcp4-change' for eno16777736 78 Apr 23 10:01:01 localhost systemd: Started Session 3 of user root. 79 Apr 23 10:01:01 localhost systemd: Starting Session 3 of user root. 80 Apr 23 10:11:51 localhost dhclient[11327]: DHCPREQUEST on eno16777736 to 10.0.0.254 port 67 (xid=0x398e2136) 81 Apr 23 10:11:51 localhost dhclient[11327]: DHCPACK from 10.0.0.254 (xid=0x398e2136) 82 Apr 23 10:11:51 localhost NetworkManager[1399]: address 10.0.0.132 83 Apr 23 10:11:51 localhost NetworkManager[1399]: plen 24 (255.255.255.0) 84 Apr 23 10:11:51 localhost NetworkManager[1399]: gateway 10.0.0.2 85 Apr 23 10:11:51 localhost NetworkManager[1399]: server identifier 10.0.0.254 86 Apr 23 10:11:51 localhost NetworkManager[1399]: lease time 1800 87 Apr 23 10:11:51 localhost NetworkManager[1399]: nameserver '10.0.0.2' 88 Apr 23 10:11:51 localhost NetworkManager[1399]: domain name 'localdomain' 89 Apr 23 10:11:51 localhost NetworkManager[1399]: (eno16777736): DHCPv4 state changed bound -> bound 90 Apr 23 10:11:51 localhost dbus[1172]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' 91 Apr 23 10:11:51 localhost systemd: Starting Network Manager Script Dispatcher Service... 92 Apr 23 10:11:51 localhost dbus-daemon: dbus[1172]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' 93 Apr 23 10:11:51 localhost dhclient[11327]: bound to 10.0.0.132 -- renewal in 781 seconds. 94 Apr 23 10:11:51 localhost dbus[1172]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher' 95 Apr 23 10:11:51 localhost dbus-daemon: dbus[1172]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher' 96 Apr 23 10:11:51 localhost systemd: Started Network Manager Script Dispatcher Service. 97 Apr 23 10:11:51 localhost nm-dispatcher: Dispatching action 'dhcp4-change' for eno16777736 98 Apr 23 10:24:52 localhost dhclient[11327]: DHCPREQUEST on eno16777736 to 10.0.0.254 port 67 (xid=0x398e2136) 99 Apr 23 10:24:52 localhost dhclient[11327]: DHCPACK from 10.0.0.254 (xid=0x398e2136)100 Apr 23 10:24:52 localhost NetworkManager[1399]: address 10.0.0.132101 Apr 23 10:24:52 localhost NetworkManager[1399]: plen 24 (255.255.255.0)102 Apr 23 10:24:52 localhost NetworkManager[1399]: gateway 10.0.0.2103 Apr 23 10:24:52 localhost NetworkManager[1399]: server identifier 10.0.0.254104 Apr 23 10:24:52 localhost NetworkManager[1399]: lease time 1800105 Apr 23 10:24:52 localhost NetworkManager[1399]: nameserver '10.0.0.2'106 Apr 23 10:24:52 localhost NetworkManager[1399]: domain name 'localdomain'107 Apr 23 10:24:52 localhost NetworkManager[1399]: (eno16777736): DHCPv4 state changed bound -> bound108 Apr 23 10:24:52 localhost dbus[1172]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service'109 Apr 23 10:24:52 localhost systemd: Starting Network Manager Script Dispatcher Service...110 Apr 23 10:24:52 localhost dbus-daemon: dbus[1172]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service'111 Apr 23 10:24:52 localhost dhclient[11327]: bound to 10.0.0.132 -- renewal in 885 seconds.112 Apr 23 10:24:52 localhost dbus[1172]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'113 Apr 23 10:24:52 localhost dbus-daemon: dbus[1172]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'114 Apr 23 10:24:52 localhost systemd: Started Network Manager Script Dispatcher Service.115 Apr 23 10:24:52 localhost nm-dispatcher: Dispatching action 'dhcp4-change' for eno16777736116 Apr 23 10:39:38 localhost dhclient[11327]: DHCPREQUEST on eno16777736 to 10.0.0.254 port 67 (xid=0x398e2136)117 Apr 23 10:39:38 localhost dhclient[11327]: DHCPACK from 10.0.0.254 (xid=0x398e2136)118 Apr 23 10:39:38 localhost NetworkManager[1399]: address 10.0.0.132119 Apr 23 10:39:38 localhost NetworkManager[1399]: plen 24 (255.255.255.0)120 Apr 23 10:39:38 localhost NetworkManager[1399]: gateway 10.0.0.2121 Apr 23 10:39:38 localhost NetworkManager[1399]: server identifier 10.0.0.254122 Apr 23 10:39:38 localhost NetworkManager[1399]: lease time 1800123 Apr 23 10:39:38 localhost NetworkManager[1399]: nameserver '10.0.0.2'124 Apr 23 10:39:38 localhost NetworkManager[1399]: domain name 'localdomain'125 Apr 23 10:39:38 localhost NetworkManager[1399]: (eno16777736): DHCPv4 state changed bound -> bound126 Apr 23 10:39:38 localhost dbus[1172]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service'127 Apr 23 10:39:38 localhost systemd: Starting Network Manager Script Dispatcher Service...128 Apr 23 10:39:38 localhost dbus-daemon: dbus[1172]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service'129 Apr 23 10:39:38 localhost dhclient[11327]: bound to 10.0.0.132 -- renewal in 830 seconds.130 Apr 23 10:39:38 localhost dbus[1172]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'131 Apr 23 10:39:38 localhost dbus-daemon: dbus[1172]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'132 Apr 23 10:39:38 localhost systemd: Started Network Manager Script Dispatcher Service.133 Apr 23 10:39:38 localhost nm-dispatcher: Dispatching action 'dhcp4-change' for eno16777736134 Apr 23 10:53:28 localhost dhclient[11327]: DHCPREQUEST on eno16777736 to 10.0.0.254 port 67 (xid=0x398e2136)135 Apr 23 10:53:28 localhost dhclient[11327]: DHCPACK from 10.0.0.254 (xid=0x398e2136)136 Apr 23 10:53:28 localhost NetworkManager[1399]: address 10.0.0.132137 Apr 23 10:53:28 localhost NetworkManager[1399]: plen 24 (255.255.255.0)138 Apr 23 10:53:28 localhost NetworkManager[1399]: gateway 10.0.0.2139 Apr 23 10:53:28 localhost NetworkManager[1399]: server identifier 10.0.0.254140 Apr 23 10:53:28 localhost NetworkManager[1399]: lease time 1800141 Apr 23 10:53:28 localhost NetworkManager[1399]: nameserver '10.0.0.2'142 Apr 23 10:53:28 localhost NetworkManager[1399]: domain name 'localdomain'143 Apr 23 10:53:28 localhost NetworkManager[1399]: (eno16777736): DHCPv4 state changed bound -> bound144 Apr 23 10:53:28 localhost dbus[1172]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service'145 Apr 23 10:53:28 localhost dbus-daemon: dbus[1172]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service'146 Apr 23 10:53:28 localhost systemd: Starting Network Manager Script Dispatcher Service...147 Apr 23 10:53:28 localhost dhclient[11327]: bound to 10.0.0.132 -- renewal in 747 seconds.148 Apr 23 10:53:28 localhost dbus[1172]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'149 Apr 23 10:53:28 localhost dbus-daemon: dbus[1172]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'150 Apr 23 10:53:28 localhost systemd: Started Network Manager Script Dispatcher Service.151 Apr 23 10:53:28 localhost nm-dispatcher: Dispatching action 'dhcp4-change' for eno16777736152 Apr 23 11:01:01 localhost systemd: Started Session 4 of user root.153 Apr 23 11:01:01 localhost systemd: Starting Session 4 of user root.154 Apr 23 11:05:55 localhost dhclient[11327]: DHCPREQUEST on eno16777736 to 10.0.0.254 port 67 (xid=0x398e2136)155 Apr 23 11:05:55 localhost dhclient[11327]: DHCPACK from 10.0.0.254 (xid=0x398e2136)156 Apr 23 11:05:55 localhost NetworkManager[1399]: address 10.0.0.132157 Apr 23 11:05:55 localhost NetworkManager[1399]: plen 24 (255.255.255.0)158 Apr 23 11:05:55 localhost NetworkManager[1399]: gateway 10.0.0.2159 Apr 23 11:05:55 localhost NetworkManager[1399]: server identifier 10.0.0.254160 Apr 23 11:05:55 localhost NetworkManager[1399]: lease time 1800161 Apr 23 11:05:55 localhost NetworkManager[1399]: nameserver '10.0.0.2'162 Apr 23 11:05:55 localhost NetworkManager[1399]: domain name 'localdomain'163 Apr 23 11:05:55 localhost NetworkManager[1399]: (eno16777736): DHCPv4 state changed bound -> bound164 Apr 23 11:05:55 localhost dbus[1172]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service'165 Apr 23 11:05:55 localhost systemd: Starting Network Manager Script Dispatcher Service...166 Apr 23 11:05:55 localhost dbus-daemon: dbus[1172]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service'167 Apr 23 11:05:55 localhost dhclient[11327]: bound to 10.0.0.132 -- renewal in 869 seconds.168 Apr 23 11:05:55 localhost dbus[1172]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'169 Apr 23 11:05:55 localhost dbus-daemon: dbus[1172]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'170 Apr 23 11:05:55 localhost systemd: Started Network Manager Script Dispatcher Service.171 Apr 23 11:05:55 localhost nm-dispatcher: Dispatching action 'dhcp4-change' for eno16777736
grep dbus 3.log |sed -r 's/^.*host (.*): .*$/\1/g'|sed 's/dbus-daemon: //g'|awk '{print $1}'
过滤关键字 搜索
[root@admin ~]# ss -natState Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 :::10050 :::* LISTEN 0 128 *:10050 *:* LISTEN 0 25 :::514 :::* LISTEN 0 25 *:514 *:* LISTEN 0 128 127.0.0.1:199 *:* LISTEN 0 50 *:3306 *:* LISTEN 0 20 *:587 *:* LISTEN 0 20 :::587 :::* LISTEN 0 128 :::80 :::* LISTEN 0 20 *:465 *:* LISTEN 0 20 :::465 :::* LISTEN 0 128 :::22 :::* LISTEN 0 128 *:22 *:* LISTEN 0 20 *:25 *:* LISTEN 0 20 :::25 :::* ESTAB 0 52 118.188.20.3:22 221.122.103.135:62086 TIME-WAIT 0 0 172.16.16.2:10050 172.16.16.9:55678 TIME-WAIT 0 0 172.16.16.2:10050 172.16.16.9:55900 TIME-WAIT 0 0 172.16.16.2:10050 172.16.16.9:55904 TIME-WAIT 0 0 172.16.16.2:10050 172.16.16.9:55844 TIME-WAIT 0 0 172.16.16.2:10050 172.16.16.9:55872 TIME-WAIT 0 0 172.16.16.2:10050 172.16.16.9:55684 TIME-WAIT 0 0 172.16.16.2:10050 172.16.16.9:55700
用sed取第一列:
ss -ant|sed 's/[ \t].*//'
取出第一行的指定字符串,后项引用 磁盘使用率
df |sed -nr '/^\/dev/s/([^ ]+).*$/\1/p'
df |sed -nr '/^\/dev/s/.* (.*)%.*/\1/p'