An error occurs when awk script cuts database 8.0 command results

Scenario: I built a zabbix, and when I monitored mysql8.0 through the agent script, an error occurred: awk: cmd. Line: 1: (FILENAME =-FNR = 1) fatal: division by zero attempted

The configuration of the corresponding SQL is as follows. The SQL is the serial number of the obtained binlog log file:
An error occurs when awk script cuts database 8.0 command results

Execution results found an error
An error occurs when awk script cuts database 8.0 command results

So I suspected that it was an abnormal result of the sql command itself, so I removed the awk command part and executed it again to find that the sql execution is normal, but why does this problem occur?
An error occurs when awk script cuts database 8.0 command results

After calmly thinking, sql itself is definitely no problem, it is a problem when awk cutting, how to deal with it to get the result I want. .

At this moment, I suddenly thought that I used to cut from the front, then this time I cut the desired data from the back to see.
An error occurs when awk script cuts database 8.0 command results

So the awk cutting process was readjusted, and finally the binlog log file serial number was successfully cut out.
An error occurs when awk script cuts database 8.0 command results

Although the awk error was not resolved from the front this time, the problem was solved from the side and the result I achieved was achieved. The idea of ​​solving the problem is still very important.

Guess you like

Origin blog.51cto.com/14483703/2486830