ns::stats::linuxNetworkSnapshot

 ns::stats::linuxNetworkSnapshot

Defined in

Partial Call Graph (max 5 caller/called nodes):
Class ::ns::stats::Collector Class ::ns::stats::Collector (public) ns::stats::linuxNetworkSnapshot ns::stats::linuxNetworkSnapshot Class ::ns::stats::Collector->ns::stats::linuxNetworkSnapshot ns::stats::Collector instproc snapshot ns::stats::Collector instproc snapshot (public) ns::stats::Collector instproc snapshot->ns::stats::linuxNetworkSnapshot ns::stats::linuxDiskSnapshot ns::stats::linuxDiskSnapshot ns::stats::linuxNetworkSnapshot->ns::stats::linuxDiskSnapshot ns::stats::linuxReadDeviceCounters ns::stats::linuxReadDeviceCounters ns::stats::linuxNetworkSnapshot->ns::stats::linuxReadDeviceCounters ns::stats::linuxReadNamedCounters ns::stats::linuxReadNamedCounters ns::stats::linuxNetworkSnapshot->ns::stats::linuxReadNamedCounters ns::stats::linuxReadSnmp6 ns::stats::linuxReadSnmp6 ns::stats::linuxNetworkSnapshot->ns::stats::linuxReadSnmp6 ns::stats::linuxReadSocketQueues ns::stats::linuxReadSocketQueues ns::stats::linuxNetworkSnapshot->ns::stats::linuxReadSocketQueues

Testcases:
No testcase defined.
Source code:

    if {![string equal -nocase Linux $::tcl_platform(os)]} {
        return {}
    }

    set snmp    [::ns::stats::linuxReadNamedCounters /proc/net/snmp]
    set netstat [::ns::stats::linuxReadNamedCounters /proc/net/netstat]
    set snmp6   [::ns::stats::linuxReadSnmp6]
    set devices [::ns::stats::linuxReadDeviceCounters]
    set queues  [::ns::stats::linuxReadSocketQueues]
    set disks   [::ns::stats::linuxDiskSnapshot]

    set counters {}

    foreach {target source section name} {
        tcpListenOverflows netstat TcpExt ListenOverflows
        tcpListenDrops     netstat TcpExt ListenDrops
        tcpBacklogDrops    netstat TcpExt TCPBacklogDrop
        tcpReceiveDrops    netstat TcpExt TCPRcvQDrop
        tcpRetransmits     snmp    Tcp    RetransSegs
        tcpInputErrors     snmp    Tcp    InErrs
        udpReceiveDrops4   snmp    Udp    RcvbufErrors
        udpSendDrops4      snmp    Udp    SndbufErrors
        udpInputErrors4    snmp    Udp    InErrors
    } {
        set data [set $source]

        if {[dict exists $data $section $name]} {
            dict set counters $target [dict get $data $section $name]
        }
    }

    foreach {target name} {
        udpReceiveDrops6 Udp6RcvbufErrors
        udpSendDrops6    Udp6SndbufErrors
        udpInputErrors6  Udp6InErrors
    } {
        if {[dict exists $snmp6 $name]} {
            dict set counters $target [dict get $snmp6 $name]
        }
    }

    #
    # Provide combined IPv4/IPv6 UDP counters for the summary.
    #
    foreach {combined ipv4 ipv6} {
        udpReceiveDrops udpReceiveDrops4 udpReceiveDrops6
        udpSendDrops    udpSendDrops4    udpSendDrops6
        udpInputErrors  udpInputErrors4  udpInputErrors6
    } {
        set found 0
        set total 0

        foreach name [list $ipv4 $ipv6] {
            if {[dict exists $counters $name]} {
                incr total [dict get $counters $name]
                set found 1
            }
        }

        if {$found} {
            dict set counters $combined $total
        }
    }

    dict for {name value} $devices {
        dict set counters $name $value
    }

    if {[dict size $counters] == 0
        && [dict size $queues] == 0 && [dict size $disks] == 0} {
        return {}
    }

    if {[dict exists $queues udpSocketDrops]} {
        dict set counters udpSocketDrops [dict get $queues udpSocketDrops]
        dict unset queues udpSocketDrops
    }

    return [dict create  counters $counters  gauges   $queues  disks    $disks]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: