运维常用命令记录
2 min read

运维常用命令记录

数据库中删除falcon中无用的监控项

例如:删除/snap/分区的监控

mysql> delete from graph.tag_endpoint where tag like "%snap%";
mysql> delete from graph.endpoint_counter where counter like "%snap%";
mysql> deletefrom alarms.event_cases where metric like "%snap%";

扫网段IP使用信息

方法一:arp-scan
# arp-scan -I eth0 -l
Interface: eth0, type: EN10MB, MAC: 00:0c:29:70:70:62, IPv4: 192.168.9.235
Starting arp-scan 1.9.7 with 256 hosts (https://github.com/royhills/arp-scan)
192.168.9.318:66:da:f1:f1:98Dell Inc.
192.168.9.418:66:da:f0:f3:38Dell Inc.
192.168.9.5f8:0f:41:7f:b1:3aWistron Infocomm (Zhongshan) Corporation
192.168.9.6f8:0f:41:7f:b1:46Wistron Infocomm (Zhongshan) Corporation
192.168.9.7f8:0f:41:7d:ec:f2Wistron Infocomm (Zhongshan) Corporation
192.168.9.8f8:bc:12:38:ce:ecDell Inc.
.
.
.
192.168.9.25100:0c:29:a0:ab:6bVMware, Inc.
192.168.9.252cc:16:7e:fa:57:dfCisco Systems, Inc
192.168.9.25300:62:ec:netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}':fe:59Cisco Systems, Inc
192.168.9.25400:00:0c:9f:f0:09Cisco Systems, Inc
113 packets received by filter, 0 packets dropped by kernel
Ending arp-scan 1.9.7: 256 hosts scanned in 3.150 seconds (81.27 hosts/sec). 111 responded
方法二:nmap
# nmap -sP 192.168.9.0/24
Starting Nmap 6.40 ( http://nmap.org ) at 2020-10-29 15:21 CST
Nmap scan report for 192.168.9.3
Host is up (0.00066s latency).
MAC Address: 18:66:DA:F1:F1:98 (Unknown)
Nmap scan report for 192.168.9.4
Host is up (0.00043s latency).
MAC Address: 18:66:DA:F0:F3:38 (Unknown)
Nmap scan report for 192.168.9.5
Host is up (0.00048s latency).
MAC Address: F8:0F:41:7F:B1:3A (Wistron InfoComm(ZhongShan))
.
.
.
Nmap scan report for 192.168.9.253
Host is up (-0.099s latency).
MAC Address: 00:62:EC:netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}':FE:59 (Unknown)
Nmap scan report for 192.168.9.254
Host is up (-0.099s latency).
MAC Address: 00:00:0C:9F:F0:09 (Cisco Systems)
Nmap scan report for 192.168.9.235
Host is up.
Nmap done: 256 IP addresses (111 hosts up) scanned in 9.08 seconds

kubernetes相关

清除Evicted状态的pod
# cat >>/usr/local/bin/DeletePod.sh <<-EOF
#!/bin/bash
kubectl get pods -n jsmh| grep Evicted | awk '{print \$1}' |xargs -I {} kubectl delete pod {} -n jsmh
EOF

# chmod +x /usr/local/bin/DeletePod.sh

# echo "00 */6 * * * bash /usr/local/bin/DeletePod.sh 2>&1 &" >> /var/spool/cron/root
批量删除镜像
# for i in `docker images|awk '{print $3}'|grep -v IMAGE`;do docker rmi ${i};done

kafka相关

查看topic分布情况
# /opt/app/kafka_2.12-2.4.0/bin/kafka-consumer-groups.sh --bootstrap-server 172.31.8.118:9092 --group tracklog --describe
查看topic详细信息
# /opt/app/kafka_2.12-2.4.0/bin/kafka-topics.sh --zookeeper 172.31.8.118:2181 --describe --topic tracklog
京ICP备19055754号