On RHEL, there is a possibility that bash hostmonitor fails to get interface name

Bug #1762958 reported by takahara.kengo
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
masakari-monitors
Invalid
Undecided
takahara.kengo

Bug Description

[Bug]
Currently, bash hostmonitor gets the interface name which specifies as option of tcpdump from output of ifconfig.
But the output of ifconfig differs between RHEL and Ubuntu.
Therefore, on RHEL, there is a possibility that bash hostmonitor fails to get interface.

[Cause]
Line 299 of masakarimonitors/hostmonitor/hostmonitor.sh is where the problem is.
----------
...
271 get_mcast_nic () {
...
299 MCAST_NIC=`cat -n ${TMP_IFCONFIG_FILE} | grep " ${S_LINE}" | awk '{print $2}'`
...
----------

The output of ifconfig differs between RHEL and Ubuntu as follows.
----------
* Ubuntu
lo Link encap:Local Loopback
          inet addr:127.0.0.1 Mask:255.0.0.0
          UP LOOPBACK RUNNING MTU:65536 Metric:1
          RX packets:50127469 errors:0 dropped:0 overruns:0 frame:0
          TX packets:50127469 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:3390780924 (3.3 GB) TX bytes:3390780924 (3.3 GB)

* RHEL
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
        inet 127.0.0.1 netmask 255.0.0.0
        loop txqueuelen 0 (Local Loopback)
        RX packets 40637770 bytes 2178749630 (2.0 GiB) # *Possibility of hit to grep search*
        RX errors 0 dropped 0 overruns 0 frame 0 # *Possibility of hit to grep search*
        TX packets 40637770 bytes 2178749630 (2.0 GiB) # *Possibility of hit to grep search*
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
----------

As above, on RHEL, packets and bytes are followed by space instead of ":".
So there is a possibility of hit to grep search " ${S_LINE}" .

[Amendment]
In get_mcast_nic(), it should get the interface name by using ip route command instead of ifconfig as follow:
----------
get_mcast_nic () {
    BIND_NET_ADDR=$1
    sudo ip route > ${TMP_IP_ROUTE_FILE}

    if [ `grep "${BIND_NET_ADDR}" ${TMP_IP_ROUTE_FILE} | wc -l` -eq 0 ]; then
        return 1
    fi

    MCAST_NIC=`grep "${BIND_NET_ADDR}" ${TMP_IP_ROUTE_FILE} | awk '{print $3}'`

    return 0
}
----------

Changed in masakari-monitors:
assignee: nobody → takahara.kengo (takahara.kengo)
status: New → In Progress
Revision history for this message
takahara.kengo (takahara.kengo) wrote :
Revision history for this message
Radosław Piliszek (yoctozepto) wrote :

shell-based monitor is long gone

Changed in masakari-monitors:
status: In Progress → Invalid
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on masakari-monitors (master)

Change abandoned by "Radosław Piliszek <email address hidden>" on branch: master
Review: https://review.opendev.org/c/openstack/masakari-monitors/+/560324
Reason: shell-based monitor is long gone

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.