Skip to content

Instantly share code, notes, and snippets.

View fortitudepub's full-sized avatar
💭
Enthusiast of networking and systems, happy hacking

dyz fortitudepub

💭
Enthusiast of networking and systems, happy hacking
View GitHub Profile
cat xxx.txt | tr , ' ' | grep keepalive | awk '{ sum+=$1 } END {print sum/160}'
<?xml version="1.0" encoding="UTF-8"?>
<!-- vi: set et smarttab sw=2 tabstop=2: -->
<!--
Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v1.0 which accompanies this distribution,
and is available at http://www.eclipse.org/legal/epl-v10.html
-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
function string_ops:string (val) %{
strlcpy (STAP_RETVALUE, (char*)STAP_ARG_val, MAXSTRINGLEN);
%}
probe kernel.function("__dev_queue_xmit") {
if (execname() =~ "keepalived") {
printf("__dev_queue_xmit %d %s(%d/%d) %s\n", gettimeofday_us(), execname(), pid(), cpu(), $$vars);
i = 0;
printf("dump begin, skb->gso %d\n", @cast($skb->head+$skb->end, "skb_shared_info", "")->gso_size);
for (; i< 14; i++) {
@fortitudepub
fortitudepub / gist:19ec6a6b3d2eb9612009493f05cb6bb1
Created August 2, 2016 07:15
A awk source code to extract some useful logline from log data.
BEGIN {
net2req["id1"] = "req1"
allreq["req1"] = "req1"
}
# 1. found received rpc named 'network_sync', extracted req-id and store it to associative arrays.
# print the line
# 2. found arg dropped for the req-id, print the line
# 3. found notify agen add-fdb, delete the req-id in the associative array, print the line
{
@fortitudepub
fortitudepub / gist:138e49779c99ec9f96c45e8a10a1d17b
Created August 17, 2016 02:30
onliner to transform nova hypervisors to ip address.
nova host-list | grep compute | awk '{print $2}' | sed 's/-/\./g'
@fortitudepub
fortitudepub / gist:3e46295512b437af901aa3d4e7cd7824
Created August 29, 2016 08:19
onliner to check all host command result by ssh remote
cat hostlist | grep compute | awk '{print $2}' | xargs -I X > all_drops.txt 2>&1 ssh X -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 1046 source check-qdisc.sh
BTW:
using the same command while using SCP to upload the script to each host.
@fortitudepub
fortitudepub / gist:be8618f595dbfacc503e043a3887e181
Created September 9, 2016 07:58
ovs simple nat extracted from system-traffic.at
# ns0
ip netns del natns0
ip netns add natns0
ip netns exec natns0 ip link set lo up
ip link add natp0 type veth peer name natp0p
ip link set natp0 netns natns0
ip link set natp0p up
ip netns exec natns0 ip link set natp0 up
ip netns exec natns0 ip link set natp0 address 80:88:88:88:88:88
ip netns exec natns0 ip addr add 10.1.1.1/24 dev natp0
@fortitudepub
fortitudepub / gist:2baf1bb8f06c5956e701e837d276928c
Created December 23, 2016 08:51
Scala actor with pcap thread send packet to itself.
package com.netease.cns.proton.agent.dhcp
import akka.actor.{Actor, ActorLogging}
import com.netease.cns.proton.agent.dhcp.DHCPPktRxActor.PcapRxPacket
import org.pcap4j.core.PcapNetworkInterface.PromiscuousMode
import org.pcap4j.core.Pcaps
import org.pcap4j.packet.Packet
object DHCPPktRxActor {
// TODO: define a packet which will be processed by each NetworkDHCPActor.
#################################################
# Sample OpenVPN 2.0 config file for #
# multi-client server. #
# #
# This file is for the server side #
# of a many-clients <-> one-server #
# OpenVPN configuration. #
# #
# OpenVPN also supports #
# single-machine <-> single-machine #
function string_ops:string (val) %{
strlcpy (STAP_RETVALUE, (char*)STAP_ARG_val, MAXSTRINGLEN);
%}
probe kernel.function("udp_gro_receive") {
if (cpu() == 0) {
printf("udp_gro_receive %d %s(%d/%d) %s %d, %d, %d\n", gettimeofday_us(), execname(), pid(), cpu(), $$vars, $skb->ip_summed, @cast($skb->cb, "struct napi_gro_cb")->csum_cnt, @cast($skb->cb, "struct napi_gro_cb")->csum_valid);
print_backtrace();
}
}