Page 1 of 1

Monitoring CSV or XLXS content

Posted: Tue Mar 06, 2018 5:58 am
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??

Re: Monitoring CSV or XLXS content

Posted: Tue Mar 06, 2018 3:59 pm
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

Re: Monitoring CSV or XLXS content

Posted: Wed Mar 07, 2018 2:33 am
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 | #

Re: Monitoring CSV or XLXS content

Posted: Thu Mar 08, 2018 3:27 am
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?

Re: Monitoring CSV or XLXS content

Posted: Thu Mar 08, 2018 12:04 pm
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.

Re: Monitoring CSV or XLXS content

Posted: Thu Mar 08, 2018 12:05 pm
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.

Re: Monitoring CSV or XLXS content

Posted: Sun Mar 11, 2018 1:05 pm
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 !!

Re: Monitoring CSV or XLXS content

Posted: Mon Mar 12, 2018 10:46 am
by cdienger
No problem : )