Monitoring CSV or XLXS content

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.
Locked
Dotzek
Posts: 5
Joined: Sun Mar 04, 2018 4:52 am

Monitoring CSV or XLXS content

Post by Dotzek »

Hi,

I'm kind of new in Nagios, and i'm trying to search a way to monitor the content of a CSV file.

I need to monitor 12 different rows separately inside it, which every row has 1 or a 0,
If one of those rows change from 1 to 0 -> PROBLEM in ## row
If one of those rows change from 0 to 1 -> row ## is OK

is it possible??
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Monitoring CSV or XLXS content

Post by cdienger »

I'm not finding an existing plugin to do exactly this, but fortunately something along these lines should be pretty easy to script. Is the file located on a web site or another system? Linux or Windows or other? Can you provide a sample of the file that would be read?

Creating a new plugin is a viable option if you're familiar with any programming or scripting languages. Here are some good resources to help:

https://exchange.nagios.org/directory/T ... pt/details
https://assets.nagios.com/downloads/nag ... inapi.html
https://assets.nagios.com/downloads/nag ... inapi.html
http://nagios-plugins.org/doc/guidelines.html
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Dotzek
Posts: 5
Joined: Sun Mar 04, 2018 4:52 am

Re: Monitoring CSV or XLXS content

Post by Dotzek »

Hi cdienger,

thanks for the reply,

The csv file in located in a Windows OS, in a folder, it goes like this:
snapshot: https://imgur.com/90DTU05

or an example here:
SERVICE | OUTPUT
serviceA | #
serviceB | #
serviceC | #
serviceD | #
serviceE | #
serviceF | #
Dotzek
Posts: 5
Joined: Sun Mar 04, 2018 4:52 am

Re: Monitoring CSV or XLXS content

Post by Dotzek »

cdienger wrote:I'm not finding an existing plugin to do exactly this, but fortunately something along these lines should be pretty easy to script. Is the file located on a web site or another system? Linux or Windows or other? Can you provide a sample of the file that would be read?

Creating a new plugin is a viable option if you're familiar with any programming or scripting languages. Here are some good resources to help:

https://exchange.nagios.org/directory/T ... pt/details
https://assets.nagios.com/downloads/nag ... inapi.html
https://assets.nagios.com/downloads/nag ... inapi.html
http://nagios-plugins.org/doc/guidelines.html
Hi cdienger,
Thanks for the response! i'm not that good with scripts and bash, i was hoping to have some help here from an expert :)
It's a file located in windows OS not on a website, I added a snapshot of the looks of the file: imgur.com/a/A0tlg
is it possible to track rows in a csv as this?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Monitoring CSV or XLXS content

Post by scottwilkerson »

Dotzek wrote: is it possible to track rows in a csv as this?
It is possible, however, it would be a custom solution you would have to create, and that is going to involve writing a script/program to do it unfortunately.

If you aren't a developer maybe you programmer on your team you can work with.
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Monitoring CSV or XLXS content

Post by cdienger »

I would recommend installing ncpa on the Windows machine and configuring it to use external script to check the file.

https://www.nagios.org/ncpa/
https://www.nagios.org/ncpa/getting-started.php
https://support.nagios.com/kb/article/n ... a-722.html

I've made an rough pass at doing this in powershell with promising results:

Code: Select all

$lines = import-csv "c:\file.csv" -header Unit,Collected
ForEach ($line in $lines){
$Unit = $($line.Unit)
$Collected = $($line.Collected)
If ($Collected -eq 0){
	$not = $not + $Unit + ","
}
}
If ($not){
Write-Host $not
exit 2
}else{
Write-Host "All is good!"
exit 0
}
Note the above hasn't been thoroughly tested and we don't typically write custom scripts. It's meant more as a proof of concept and will likely need to be modified to fit your needs exactly.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Dotzek
Posts: 5
Joined: Sun Mar 04, 2018 4:52 am

Re: Monitoring CSV or XLXS content

Post by Dotzek »

cdienger wrote:I would recommend installing ncpa on the Windows machine and configuring it to use external script to check the file.

https://www.nagios.org/ncpa/
https://www.nagios.org/ncpa/getting-started.php
https://support.nagios.com/kb/article/n ... a-722.html

I've made an rough pass at doing this in powershell with promising results:

Code: Select all

$lines = import-csv "c:\file.csv" -header Unit,Collected
ForEach ($line in $lines){
$Unit = $($line.Unit)
$Collected = $($line.Collected)
If ($Collected -eq 0){
	$not = $not + $Unit + ","
}
}
If ($not){
Write-Host $not
exit 2
}else{
Write-Host "All is good!"
exit 0
}
Note the above hasn't been thoroughly tested and we don't typically write custom scripts. It's meant more as a proof of concept and will likely need to be modified to fit your needs exactly.
Thanks alot for the help, i've tried it and it's not working yet, i'll work on it and hopefuly will make it work,
thank you for the help !!
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Monitoring CSV or XLXS content

Post by cdienger »

No problem : )
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked