cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post

Can SAM pull data from the output file of a cron job?

Jump to solution

One of our devs would love to have nice historical data reside in SAM about the number of active users on a Solaris box.

He's going to add the script to a nightly cron job, which in turn outputs it to a file on said box.

Is there a method for having SAM pull data out of that result file and populate the Solarwinds DB?

Thanks for any info.

Labels (1)
1 Solution
Product Manager
Product Manager

Why not simply have the script that the cron job is running executed by SAM as a Linux/Unix Script Monitor?

View solution in original post

18 Replies
Product Manager
Product Manager

Why not simply have the script that the cron job is running executed by SAM as a Linux/Unix Script Monitor?

View solution in original post

aLTeReGo​ Is it possible to monitor a cron job which generates a txt file everyday at specific time? The requirement is to read a string 'error' from that file whenever it generates...

0 Kudos

Yes. That is the very purpose of the Log Parser (Perl) template.

aLTeReGo

I was trying out the template and i may need some more help.

So the txt file gets generated everyday in below format to a particular path.

pastedImage_0.png

So how do i mention the path in the arguments so that it finds this txt file? I will put the string in the regex parameter.

0 Kudos

pastedImage_0.png

0 Kudos

is Solarwinds only return numerical value?

or can be varchar?

0 Kudos

M is correct, to add to this we skirt around it by putting in a clause along the lines of:

If output = expected, statistic = 0.

Else, statistic = 1 and then set the component that anything > 0 is critical.

You can do this with exit codes if you want the status to be actually down, for example, but for us it's usually that or returning a count of components in a bad status which allows for easy alerting.

0 Kudos

it requires a numerical value for the statistic output, but optionally you can add a message output with strings in it

- Marc Netterfield, Github
0 Kudos

aLTeReGo

Sorry i wasnt clear in my earlier statement.

I know the path will go into that place where u mentioned, but if u look at the screenshot then the file that gets generated has a date change everytime so its not unique..

So in this case, how do i mention the path till the text file?

0 Kudos

That is not possible with the template as it is currently written. The script within the template is expecting a static file name. The script would need to be adapted to look at the last modified or last updated date/time of the files in a file system to ensure it's always looking at the lastest.

0 Kudos

Thanks @alterego.. I will work the script then...

0 Kudos

Okay, got some more info and my desired task is even simpler than I thought - but I'm having a challenge finding the way to quickly accomplish it.

It's not a script per se - instead, it's the output of this command:

who | cut -f1 -d " " | sort | uniq | wc -l

It returns one numerical value.

My goal is to build a component monitor or other mechanism to perform this command, take the output and get it into Solarwinds.

What the heck am I missing? It sure seems like this should be possible.

Thanks for any info.

0 Kudos

Put this in a Linux monitor:

#!/bin/bash

Value=`who | cut -f1 -d " " | sort | uniq | wc -l`

  echo "\nStatistic: $Value";

  echo "\nMessage: This is your value"

Obviously you can change the \nMessage to whatever pleases you.   Note that before the who and after the -l is the back ticks.

0 Kudos

I'm still missing something - getting barked at on testing it with

Get Output Failed: Can't identify dynamic column definitions from script output...

I'll keep at it...gotta be something small. Thanks.

0 Kudos

Here..made it even easier for you:

Linux Command

Be sure your command gives a numeric value out as a return, no spaces or such.

Perfection....I thank you very much for taking the time to assist - I owe you big time!

0 Kudos

Thank you - I'll give that a try!

0 Kudos

It's a great point.....duhhhhhh!

Thank you.

0 Kudos