蓝鲸:主机频繁提示“You have new mail in /var/spool/mail/root” 定位解决

2020-03-09 13:27:31 浏览数 (2)

前些天安装蓝鲸的测试环境频繁出现You have new mail in /var/spool/mail/root,查看发现是/usr/local/gse/agent/bin/gsectl: line 19: ip: command not found,查了下报错频率基本上是每分钟报错一次。

代码语言:javascript复制
[root@rbtnode1 install]# 
You have new mail in /var/spool/mail/root
[root@rbtnode1 install]# 
[root@rbtnode1 install]# tail -20f /var/spool/mail/root
        id D85A730F67A5; Sun,  8 Mar 2020 16:51:02  0800 (CST)
From: "(Cron Daemon)" <root@rbtnode1.localdomain>
To: root@rbtnode1.localdomain
Subject: Cron <root@rbtnode1> /usr/local/gse/agent/bin/gsectl watch
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
Precedence: bulk
X-Cron-Env: <XDG_SESSION_ID=3138>
X-Cron-Env: <XDG_RUNTIME_DIR=/run/user/0>
X-Cron-Env: <LANG=en_US.UTF-8>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
Message-Id: <20200308085102.D85A730F67A5@rbtnode1.localdomain>
Date: Sun,  8 Mar 2020 16:51:01  0800 (CST)

/usr/local/gse/agent/bin/gsectl: line 19: ip: command not found

^C

看下目前为止的报错次数:

代码语言:javascript复制
[root@rbtnode1 install]# grep "line 19: ip: command not found" /var/spool/mail/root |wc -l
15748
[root@rbtnode1 install]# 
You have new mail in /var/spool/mail/root
[root@rbtnode1 install]# grep "line 19: ip: command not found" /var/spool/mail/root |wc -l
15750

查看/usr/local/gse/agent/bin/gsectl文件,vi定位到19行:

代码语言:javascript复制
     17 get_lan_ip  () {
     18    #
     19    ip addr | 
     20        awk -F'[ /] ' '/inet/{
     21                split($3, N, ".")
     22                if ($3 ~ /^192.168/) {
     23                    print $3
     24                }
     25                if (($3 ~ /^172/) && (N[2] >= 16)) {
     26                    print $3
     27                }
     28                if ($3 ~ /^10./) {
     29                    print $3
     30                }
     31           }'
     32     return $?
     33 }
     34 export LAN_IP=$(get_lan_ip | head -1)

使用which ip 查看系统ip命令的路径:

代码语言:javascript复制
[root@rbtnode1 install]# which ip
/usr/sbin/ip

尝试修改第19行,ip命令的调用改为绝对路径:/usr/sbin/ip

代码语言:javascript复制
     19    /usr/sbin/ip addr | 

再次查看报错次数和最近的报错时间:

代码语言:javascript复制
[root@rbtnode1 install]# grep "line 19: ip: command not found" /var/spool/mail/root |wc -l
15755

[root@rbtnode1 install]# tail -20f /var/spool/mail/root
        id 9647530F67A5; Sun,  8 Mar 2020 16:58:03  0800 (CST)
From: "(Cron Daemon)" <root@rbtnode1.localdomain>
To: root@rbtnode1.localdomain
Subject: Cron <root@rbtnode1> /usr/local/gse/agent/bin/gsectl watch
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
Precedence: bulk
X-Cron-Env: <XDG_SESSION_ID=3279>
X-Cron-Env: <XDG_RUNTIME_DIR=/run/user/0>
X-Cron-Env: <LANG=en_US.UTF-8>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
Message-Id: <20200308085803.9647530F67A5@rbtnode1.localdomain>
Date: Sun,  8 Mar 2020 16:58:02  0800 (CST)

/usr/local/gse/agent/bin/gsectl: line 19: ip: command not found

后续观察没再发现这个报错计数增长,也没有16:58:03之后的报错信息,说明改动有效。

0 人点赞