/log_check

The variant of parsing some text/log file

Primary LanguageC

log_check

The variant of parsing some text/log file and send it to Zabbix

Possible applicable case: There is some log file and we need to monitor lines with certain words in this log.

Firstly, the application parses log file line by line and search matched two regular expressions.
Secondly, findings will be added into two varibles coincide regex.
Thirdly, there will be computed the difference of two variables count.
Then, if the difference value becomes more than 0, the following result will be printed: "Result: 1".
If the difference value becomes more less than 0 or equal, the result will be printed as: "Result: 0".

Additional: In Zabbix we may use zabbix agent (active checks) to monitor this log. It is necessary to configure zabbix_agentd.conf file (user parameters) and add item (type: text) in Zabbix web interface using the same item key as set in agent config file. It is important to provide required access to read log_check application for Zabbix and read + write access for counter file.

For compilation: gcc or another C compiler.

Example of command: cc log_check.c -o log_check