record processes' memory usage every N seconds

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Ravikimt
Posts: 77
Joined: Tue Apr 03, 2018 12:02 pm

record processes' memory usage every N seconds

Post by Ravikimt »

Hi All,

I am using Nagios Core version 4.2.0. I can see in nagios log (/usr/local/nagios/var/archives/nagios-04-18-2018-00.log) there is only single entry for my X service. I want the all the logs of all the activity which I am performing to monitor the hosts.

For example:- Suppose I am checking the memory usage of one of my host. I am checking the memory usage service in every 15 mins time interval. So I want to capture all the activity whether if the service is OK or not Ok means ( It can be Warning or Critical) in the logs.

But Currently It is showing only one entry in the logs file saying that Memory service OK for my host but It is not capturing all the event logs.
It should capture all the activity logs in every 15 mins because I am checking the service every 15 mins

Lets take on example I have to provide memory usage details from 18-04-2018 to 19-04-2018 .

Please help me here, Thanks in advance.
User avatar
tacolover101
Posts: 432
Joined: Mon Apr 10, 2017 11:55 am

Re: record processes' memory usage every N seconds

Post by tacolover101 »

you could send your nagios.log somewhere to be retained, enable service output, and then parse through them in your favorite log viewer such as NLS, ELK, or Splunk. this would provide a full audit history.

another option is getting crafty with your performance data processing / output, which would allow you to direct the results to a place / script of your choosing. this link covers the basics: https://assets.nagios.com/downloads/nag ... fdata.html
Ravikimt
Posts: 77
Joined: Tue Apr 03, 2018 12:02 pm

Re: record processes' memory usage every N seconds

Post by Ravikimt »

Thanks tacolover101 for your response.

I will try and let u know.
Ravikimt
Posts: 77
Joined: Tue Apr 03, 2018 12:02 pm

Re: record processes' memory usage every N seconds

Post by Ravikimt »

Hi tacolover101 It will be great, if you can give some example for memory usage service.

It really help me to understand in a better way.
Ravikimt
Posts: 77
Joined: Tue Apr 03, 2018 12:02 pm

Re: record processes' memory usage every N seconds

Post by Ravikimt »

Hi tacolover101 thanks a lot, It's done Now I am getting all the activity logs in service-perfdata file.

But I am getting this data without time stamp and it will be difficult for me to create a report without time stamp & date

Can you please help me here and how I can get the data with time & date.?

Please have a look at data logs.
*********************************************
[SERVICEPERFDATA] 1524226891 XYZ Memory Usage 0.502 0.000 Memory usage: total:19422.50 MB - used: 10500.91 MB (54%) - free: 8921.59 MB (46%) 'Memory usage'=10500.91MB;11653.50;15538.00;0.00;19422.50
************************************************

************************************
[SERVICEPERFDATA] 1524226924 XYZ Memory Usage 0.499 0.000 Memory usage: total:8319.62 MB - used: 4213.97 MB (51%) - free: 4105.66 MB (49%) 'Memory usage'=4213.97MB;6655.70;7487.66;0.00;8319.62
*******************************************
kyang

Re: record processes' memory usage every N seconds

Post by kyang »

Thanks for the help @tacolover101!

Ravikimt, The logs are sending back a timestamp, but they are just UNIX timestamps.

You would need to convert them in order to get a human readable timestamp for your purpose.

Here's something I found which does it towards the nagios.log file. You would do it accordingly to your file of course.perl -pe 's/(\d+)/localtime($1)/e

Code: Select all

cat /usr/local/nagios/var/nagios.log | perl -pe 's/(\d+)/localtime($1)/e'
https://geekpeek.net/nagios-log-convert-timestamp/

You could just save the output into a new file for you to review and record for logging.
Ravikimt
Posts: 77
Joined: Tue Apr 03, 2018 12:02 pm

Re: record processes' memory usage every N seconds

Post by Ravikimt »

Thanks Kyang for your response.
Now I can do that in different way.
kyang

Re: record processes' memory usage every N seconds

Post by kyang »

No problem,

Did you have any more questions on this or are we okay to lock this up?
User avatar
tacolover101
Posts: 432
Joined: Mon Apr 10, 2017 11:55 am

Re: record processes' memory usage every N seconds

Post by tacolover101 »

Ravikimt wrote:Hi tacolover101 thanks a lot, It's done Now I am getting all the activity logs in service-perfdata file.

But I am getting this data without time stamp and it will be difficult for me to create a report without time stamp & date

Can you please help me here and how I can get the data with time & date.?

Please have a look at data logs.
*********************************************
[SERVICEPERFDATA] 1524226891 XYZ Memory Usage 0.502 0.000 Memory usage: total:19422.50 MB - used: 10500.91 MB (54%) - free: 8921.59 MB (46%) 'Memory usage'=10500.91MB;11653.50;15538.00;0.00;19422.50
************************************************

************************************
[SERVICEPERFDATA] 1524226924 XYZ Memory Usage 0.499 0.000 Memory usage: total:8319.62 MB - used: 4213.97 MB (51%) - free: 4105.66 MB (49%) 'Memory usage'=4213.97MB;6655.70;7487.66;0.00;8319.62
*******************************************
nice work. that looks like it may be the basic templated way - you can add further variables to your commands if you want to, for timestamp i use - $LONGDATETIME$

other variables can be found here: https://assets.nagios.com/downloads/nag ... olist.html
kyang

Re: record processes' memory usage every N seconds

Post by kyang »

Thanks for the help @tacolover101!

I forgot about those.

Ravikimt, let us know if you have any more questions.
Locked