Read a file in Linux server

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
ets_user
Posts: 78
Joined: Mon Mar 30, 2020 2:50 am

Read a file in Linux server

Post by ets_user »

Hi,

We want to read a file in a specific path in a linux server (Alarm file) and them send the contents over mail.

Pls let us know how we can achieve it.

PS: We have email configured already.

Thanks.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Read a file in Linux server

Post by benjaminsmith »

Hello @ets_user,

Just to clarify, you want to monitor a file on a Linux server, and when some value or keyword is present in the file, you want to send the contents of the file by email.

One option is to use Event Handlers in Nagios XI to execute a bash script send the file. The development of customs scripts is out of scope for product support, but the following document will help get you started.

Introduction to Event Handlers in Nagios XI

Take a look and let me know if you have any questions.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Read a file in Linux server

Post by cdienger »

I don't think I have enough detail to provide solution yet but There is the /usr/local/nagios/libexec/check_log plugin which is default on XI systems. You may also want to check out - https://labs.consol.de/nagios/check_logfiles/index.html.

If you need further assistance please answer the following:

Is the file on the XI server or another remote server that XI is monitoring?

Are you trying to alert if specific strings are found or when other conditions are met?

Are you trying to send the entire file or just a portion? This may not be doable, but if you can provide more details we can better provide guidance.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
ets_user
Posts: 78
Joined: Mon Mar 30, 2020 2:50 am

Re: Read a file in Linux server

Post by ets_user »

Kinldy find below details for more clarity.

Is the file on the XI server or another remote server that XI is monitoring?
Its on another remote Linux server where NRPE agent is running and monitoring CPU,Memory etc..
Are you trying to alert if specific strings are found or when other conditions are met?
Yes, if the file has error string we want to send that error message by email
Are you trying to send the entire file or just a portion? This may not be doable, but if you can provide more details we can better provide guidance.
Entire file for now, but we might need to parse the file and get the required format in future
Please advise.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Read a file in Linux server

Post by cdienger »

Thanks for the extra information. With that I would second the recommendation of @benjaminsmith of using an event handler to email the file. https://assets.nagios.com/downloads/nag ... ios-XI.pdf
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked