Is there a way to pass selinux security when executing netstat command in keepalived? I get below message when I execute netstat in vrrp_scrpt of keepalived. My goal is to monitor udp/2048 change Master and Backup when the port is down.

Nov 24 02:36:25 server1 setroubleshoot: SELinux is preventing /usr/bin/netstat from using the getattr access on a process. For complete SELinux messages. run sealert -l 09a907de-253e-4c61-8506-1c247c1daf11
Nov 24 02:36:25 server1 python: SELinux is preventing /usr/bin/netstat from using the getattr access on a process.#012#012*****  Plugin catchall (100. confidence) suggests   **************************#012#012If you believe that netstat should be allowed getattr access on processes labeled tuned_t by default.#012Then you should report this as a bug.#012You can generate a local policy module to allow this access.#012Do#012allow this access for now by executing:#012# grep netstat /var/log/audit/audit.log | audit2allow -M mypol#012# semodule -i mypol.pp#012

My environement is below.

[root@server230 ~]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.1 (Maipo)
[root@server230 ~]# rpm -qa | grep keepalived

My keepalived config is below.

global_defs {
   notification_email {
   notification_email_from root@localhost.localdomain
   smtp_connect_timeout 60

vrrp_script chk_logstash {
  script "netstat -atunp | grep 2048 &>/dev/null"
  interval 2 # every 2 seconds
  weight 2 # add 2 points if OK

vrrp_instance RH_1 {
    state MASTER 
    interface eth0
    virtual_router_id 50
    priority 10
    advert_int 1
    virtual_ipaddress {

    track_script {

netstat and keepalived process has below selinux context

[root@server230 ~]# ls -lZ /usr/bin/netstat 
-rwxr-xr-x. root root system_u:object_r:bin_t:s0       /usr/bin/netstat
[root@server230 ~]# ps -eZ | grep keepalived
system_u:system_r:keepalived_t:s0 2913 ?       00:00:00 keepalived
system_u:system_r:keepalived_t:s0 2914 ?       00:00:00 keepalived
system_u:system_r:keepalived_t:s0 2915 ?       00:00:00 keepalived
system_u:system_r:keepalived_t:s0 4609 ?       00:00:00 keepalived
  • First, update the system. There have been numerous fixes to SELinux policy in the two years since you last updated this system. – Michael Hampton Nov 23 '16 at 18:53
  • I have updated to RHEL 7.3 using yum update but error is still occuring. – Yu Watanabe Nov 24 '16 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.