Tag Archives: cron

How to Remove the Note: You have new mail in /var/spool/mail/root

The terminal often prompts you have new mail in/var/spool/mail/root after remote login

This prompt is that Linux will check all kinds of Linux status regularly to make a summary. After a period of time, it will send the summary information to root’s mailbox for viewing when necessary.

Generally, the content of the mail is just some normal system information or more important error reports. If you have installed MUTT, you can directly use this command to view the contents of the mail (log in with root first). If not, you can use cat/var/spool/mail/root (log in with root first).

View content:

[root@check1 ~]# cat /var/spool/mail/root

24 May 01:03:01 ntpdate[24397]: the NTP socket is in use, exiting

From [email protected] Thu May 24 01:04:01 2018
Return-Path: <[email protected]&>
X-Original-To: root
Delivered-To: [email protected]
Received: by check1.localdomain (Postfix, from userid 0)
id 5C6D2C0BB7; Thu, 24 May 2018 01:04:01 +0800 (CST)
From: [email protected] (Cron Daemon)
To: [email protected]
Subject: Cron <root@check1&> /usr/sbin/ntpdate 202.112.31.197
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
X-Cron-Env: <LANG=en_US.UTF-8>
X-Cron-Env: <SHELL=/bin/bash>
X-Cron-Env: <PATH=/sbin:/bin:/usr/sbin:/usr/bin&>
X-Cron-Env: <MAILTO=root>
X-Cron-Env: <HOME=/>
X-Cron-Env: <LOGNAME=root&>
X-Cron-Env: <USER=root&>
Message-Id: <[email protected]>
Date: Thu, 24 May 2018 01:04:01 +0800 (CST)

24 May 01:04:01 ntpdate[24552]: the NTP socket is in use, exiting

You can also set to send this information to the administrator mailbox

Log analysis tool logwatch can analyze the log files of Linux, and automatically send mail to the relevant processing personnel, which can be customized. The mail function of logwatch is to send mail with the help of the mail server of the host system. The system needs to install mail server, such as sendmail, postfix, qmail, etc. the specific configuration is not described

Closing prompt:

[root@check1 ~]# echo "unset MAILCHECK">> /etc/profile
[root@check1 ~]# source /etc/profile

View:

[root@check1 ~]# ls -lth /var/spool/mail/
total 49M
-rw------- 1 root mail 49M Jul 4 13:43 root
-rw-rw---- 1 nginx mail 0 May 21 11:46 nginx
-rw-rw---- 1 zabbix mail 0 May 16 15:48 zabbix

Empty:

[root@check1 ~]# cat /dev/null > /var/spool/mail/root

MYSQL: You must reset your password using ALTER USER statement before executing this statement.[How to Solve]

1. Problem: after logging into mysql, no matter what command you run, you will always prompt this

mysql&> select user,authentication from mysql.user;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql&> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

2. Solutions

The solution is as follows.

(1) MySQL version 5.7.6 (previous) users can use the following command.
        mysql&> SET PASSWORD = PASSWORD('l!vWT#mL93');
 
(2) Users of MySQL version 5.7.6 (after the start) can use the following command.
        mysql&> ALTER USER USER() IDENTIFIED BY 'l!vWT#mL93';
     

3. Cause analysis

(1) MySQL version 5.6.6 onwards adds the password_expired feature, which allows setting a user's expiration time. This feature has been added to the mysql.user data table, but its default value is "N", which can be changed using the ALTER USER statement.
  Enter the following command to force the account password to expire.
  mysql&> ALTER USER 'root'@'localhost' PASSWORD EXPIRE;
  At this point, the user can log in to the MYSQL server, but cannot run any commands until the user sets a new password for the account, and will get the above error, and can run all commands within the account permissions normally by changing the password. Since the password expiration days cannot be achieved by command in this version, the DBA can set the password expiration time for MySQL users by cron timer task.

(2) Starting from MySQL version 5.7.4, the feature of password expiration time for users has been improved, and a global variable default_password_lifetime can be used to set the password expiration policy, and this global variable can set a global automatic password expiration policy. A default value can be set in MySQL's my.cnf configuration file.
  (a) This will cause all MySQL users to have a password expiration time of 120 days, and MySQL will start counting the time from startup.
    The my.cnf configuration is as follows.
    [mysqld]
    default_password_lifetime=120
  (b) If you want to set the password to never expire, my.cnf is configured as follows.
    my.cnf is configured as follows.
    [mysqld]
    default_password_lifetime=0
(3) If you want to set individual specific values for each specific user account, you can use the following command (note: this command will override the global policy) in "days", the command is as follows.
  ALTER USER 'root'@'localhost' PASSWORD EXPIRE INTERVAL 250 DAY;

(4) If you want the user to restore the default policy, the command is as follows.
  ALTER USER 'root'@'localhost' PASSWORD EXPIRE DEFAULT;
(5) Individual users will disable the password expiration function for late trouble, the command is as follows.
  ALTER USER 'testuser'@'localhost' PASSWORD EXPIRE NEVER;

Zabbix unreachable poller processes more than 75% busy

“ZABBIX poller processes more than 75% busy” alert problem solved

Although there are various monitoring alarms in ZABBIX, the most frequently encountered ones are memory exhaustion, network congestion, IO slow and “ZABBIX poller processes more than 75% busy”. At the beginning, I didn’t care much because it didn’t affect the use and lasted for a while. With the increase of the database, ZABBIX consumes more and more memory. Poller processes are busy every day, and finally ZABBIX has to be moved to another server.

But this has not completely solved the problem, and the alarm is still coming for several days. When the email function of ZABBIX alert is turned on, this kind of email is frequently received. There are many problems causing busy polling. It is possible that MySQL supporting ZABBIX is stuck, io of ZABBIX server is stuck, and ZABBIX process is not enough to allocate memory. A simple way is to increase the number of processes initialized at the start of ZABBIX server, which directly increases the polling load and proportionally reduces the busy situation.

The method of adding initialization process is very simple. Edit the configuration file/ZABBIX of ZABBIX server_ server.conf , find the paragraph to configure startpollers:

one

two

three

four

five

six

seven

### Option: StartPollers

# Number of pre-forked instances of pollers.

#

# Mandatory: no

# Range: 0-1000

# Default:

# StartPollers=5

Cancel the comment of “startpollers = line” or add it directly after:

one

StartPollers=10

How many startpollers are changed depends on the performance of the server and the number of monitors. Kaijia did not encounter any alerts after setting startpollers to 12. If there is enough memory, it can be set higher. Run after setup:

one

servicezabbix-serverrestart

Restart ZABBIX. Of course, another way to reduce the load of ZABBIX server as a whole is to restart ZABBIX regularly. This method can be implemented with cron

one

crontab-e

Add a plan in the cron editor:

one

@dailyservicezabbix-serverrestart&>/dev/null2&>&1

This plan will automatically restart ZABBIX service every day to end the zombie process and clean up memory. At present, Kaijia has not encountered the problem of “ZABBIX poller processes more than 75% busy” again after configuring ZABBIX in this way.

or/ZABBIX_ server.conf

Most likely, you have this setting:
startdiscoverers = 1 can also become larger
continue to increase the number of instances discovered by pre forced.

If you decide not to use the discovery function, you can set the parameters:
startdiscoverers = 0