I'm using CentOS 7 and I would like to know of a way to read each line and search for a specific word. For example, if it finds the word "Fail" it sends it to a variable, and pipes it to a folder on the network.
What would be the best way in making this work in a Linux environment?
I wrote a script that connects to ESXi host via SSH, and when connection is made to ESXi server, the script runs a command to check RAID 5 hard drive status.
I created cron job to initiate script to run everyday at a certain time and sends me an email displaying RAID 5 disk drive status. I am very satisfied with my results.
Now, I would like to add to my script. So when a hard drive does fail! I can be notified every hour. We have an application on the network, that we can dump text files in and as a result sends an email out every hour.
With that said. I would like new script to read each line and look for the word "fail" and when it finds the word, it will send it to a file on the network.
So far I was able to run a command and locate the word fail. But, I don't know of a way to send results to a file on the network. The command I use is this:
#find /tmp -type f -name "*.txt" -exec grep -l "failed" {} \+
The reason why I don't want to modify my current script to run RAID checks every hour is because we have more than ten ESXi host servers.
I would not like to receive fifteen emails every hour and look for a failed hard drive.
It's better to receive one email indicating a failed disk drive. I am open to new creative ideas.