KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

Text file search question

 
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting
View previous topic :: View next topic  
Author Message
pmwither



Joined: 19 Feb 2004
Posts: 16

PostPosted: Mon Mar 01, 2004 1:10 pm    Post subject: Text file search question Reply with quote

I have a text file that gets created by a script every 10 minutes or so. I want to setup another task that searches this new text file for a specific text string, and then alarm us when the string is found.

The text file that is created is called the same thing each time it is created (list.txt), it just overwrites what was there before.

When I use the text log test, it doesn't seem to find the string. Is it because the file is not getting appended to each time? Can I get Hostmonitor to forget about the previous version of this file and just search it new each time?

Thanks!
Back to top
View user's profile Send private message
pmwither



Joined: 19 Feb 2004
Posts: 16

PostPosted: Mon Mar 01, 2004 1:33 pm    Post subject: More Information Reply with quote

I have also tried the compare files test and this finds when the string is found.

However, there is a possibility that the string I am looking for will be found on multiple lines within the file, so I need to be able to send every line where this text string is found to an email message.

Thanks!
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12795
Location: USA

PostPosted: Mon Mar 01, 2004 6:59 pm    Post subject: Reply with quote

Quote:
When I use the text log test, it doesn't seem to find the string. Is it because the file is not getting appended to each time?


Yes.

Quote:
Can I get Hostmonitor to forget about the previous version of this file and just search it new each time?


If test will be performed at the moment when this file is empty...
I think you need to remove file (or better create empty one) using "Execute external program" action (it can be simple command like "echo . >path\file") and use "Repeat test" action to set new information about test. When you will create alert profile, add "Execute external program" action first and then add "Repeat test" action.

Also, I assume you are using "Warn of all new event" option of the test? In this case both actions should be "good" actions.

Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
pmwither



Joined: 19 Feb 2004
Posts: 16

PostPosted: Mon Apr 05, 2004 9:24 am    Post subject: Still having trouble picking up text in a file Reply with quote

I have tried your suggestion of using the echo .> //path/file command and that does not seem to help. I have also setup our build script to create a brand new file each day. Still, using the Text Log Test, it does not pick up the string as being in the file.

I have several files that I need to search for specific text strings and the only way I can get this particular test to work is to cause the 'build' script to append the messages to another file. For the file that I am searching above, it is not practical to append the messages to another file because of the amount of data that is written to this file each day.

Is there anyway to tell HostMonitor to just read the entire file each time rather than looking for new records? Or, why does it not find the search string when it is a brand new file?

Thanks!
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12795
Location: USA

PostPosted: Mon Apr 05, 2004 4:12 pm    Post subject: Reply with quote

Quote:
I have tried your suggestion of using the echo .> //path/file command and that does not seem to help.


Have you added this command as "good" action? Have you added "Repeat test" action? Have you setup "execute external program" action BEFORE "repeat test" action?

Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
pmwither



Joined: 19 Feb 2004
Posts: 16

PostPosted: Tue Apr 06, 2004 5:53 am    Post subject: Reply with quote

Yes - I did all that.

Speaking of setting up the actions in specific orders... it seems like they order themselves alphabetically. Is this correct or are they ordered based on the order they were setup?

Thanks!
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12795
Location: USA

PostPosted: Tue Apr 06, 2004 12:34 pm    Post subject: Reply with quote

Quote:
Yes - I did all that.


I have setup this configuration as well and it works.
But there are several issues:
1) echo . >filename will not reset filesize to 0, it will store 4 bytes in the file. So, if you can, modify your script to include any 4 bytes at the begining of the file.
2) if you are using "irregular schedule" test will not start many time. So, use "Regular schedule" mode (and some Schedule if you need).
3) if your tests runs with long interval, add "bad" "Repeat test" action with "repeat: untis staus changes" option.

Quote:
Speaking of setting up the actions in specific orders... it seems like they order themselves alphabetically. Is this correct or are they ordered based on the order they were setup?


Generally "Start after" parameter defines order to start actions. But if this parameter has the same value for several action, actions will be started in creation order. So, "repeat test" action must be created after "execute external program" action.

Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
pmwither



Joined: 19 Feb 2004
Posts: 16

PostPosted: Tue Apr 06, 2004 1:43 pm    Post subject: Reply with quote

Thanks....I'll try this...
But I have another question... in the case where another process on the individual server is building the log file (not a HostMonitor script), how can I get HostMonitor to just check the entire file each time rather than expect it to be a file that builds to itself each time? Because another process is building the text file, I can't understand how I can create it empty (or with 4 bytes) with HostMonitor, have the other process put the stuff in the file and then have HostMonitor check the file. (Please excuse my ignorance if I am missing something here in the translation).

In a future upgrade could you add a selection box on the Text Log Test screen that would give a choice for something like "Check entire file" and then it wouldn't be necessary to "trick" HostMonitor each time?

Thanks again for your help. I trained the rest of my group on HostMonitor today... everyone was very impressed with the ability and functionality that is already part of the system... good job!
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12795
Location: USA

PostPosted: Tue Apr 06, 2004 2:19 pm    Post subject: Reply with quote

Quote:
But I have another question... in the case where another process on the individual server is building the log file (not a HostMonitor script), how can I get HostMonitor to just check the entire file each time rather than expect it to be a file that builds to itself each time?


I am confused. I thought we are talking about this from the begining. No?
So, in you case HostMonitor creates some file that you are checking again using HostMonitor? Why?

Quote:
In a future upgrade could you add a selection box on the Text Log Test screen that would give a choice for something like "Check entire file" and then it wouldn't be necessary to "trick" HostMonitor each time?


HostMonitor has this option. "Compare files" test method works exactly in this way.

Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
pmwither



Joined: 19 Feb 2004
Posts: 16

PostPosted: Tue Apr 06, 2004 2:32 pm    Post subject: Reply with quote

I have both cases... some where HostMonitor is running a script that builds an output file and then checks for certain strings in that output file. I have others where another process is building an output file (one time each day) and then HostMonitor just needs to read this file at the same time each day. (By the way... an irregular schedule option of "1 time per day at the same time each day" would be great too!)

Anyway, when I do the echo .> command, is that not going to create a new file with the name that I give it? Wouldn't this overwrite the file that has been built by my other process?

You are right that the Compare Files test does check for a new file each time. But, it does not give me the option to look for an expression (just a single string) and then I also need to be able to email the line(s) that contained the string(s). Compare Files just replies with the fact that the string(s) were found... unless I am missing something there too...
Back to top
View user's profile Send private message
Stoltze



Joined: 03 Feb 2004
Posts: 174
Location: Denmark

PostPosted: Wed Apr 07, 2004 12:02 am    Post subject: Reply with quote

pmwither wrote:
(By the way... an irregular schedule option of "1 time per day at the same time each day" would be great too!)


I have been looking for this option as well. Eg. checking diskspace.
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12795
Location: USA

PostPosted: Wed Apr 07, 2004 8:17 pm    Post subject: Reply with quote

Quote:
Anyway, when I do the echo .> command, is that not going to create a new file with the name that I give it? Wouldn't this overwrite the file that has been built by my other process?


Yes, of course it will overwrite the file. That is the point. You said script overwrites the file, so we can do the same. Right?
Actually that's why we have problem. Text Log test method was designed to check log - single file that grows. In you case we actually have new file every time, so its not log at all.

Quote:
You are right that the Compare Files test does check for a new file each time. But, it does not give me the option to look for an expression (just a single string) and then I also need to be able to email the line(s) that contained the string(s). Compare Files just replies with the fact that the string(s) were found


Yes, its true. Probably the best solution - create custom script that will fit your needs...

Quote:
By the way... an irregular schedule option of "1 time per day at the same time each day" would be great too


Its very easy to configure using regular schedule.

Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
pmwither



Joined: 19 Feb 2004
Posts: 16

PostPosted: Thu Apr 08, 2004 5:53 am    Post subject: Reply with quote

[quote]Its very easy to configure using regular schedule. [/quote]

Maybe all my confusion, then, is related to the timing thing. How do I schedule a test to run at exactly the same time each day? It looks like the hours/minutes/seconds runs as an interval in accordance to when HM was restarted.

I have written a script as you suggested, but again, I need it to run at the same time everyday. The only way I could figure how to do this is to setup a schedule with a small 'green' time window and then set the interval to something smaller. Is there a better way to do this?

Can you give me specific instructions on how to make many tests run one time per day at 7am?

BTW... thanks for the permanent license keys!

Thanks!
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12795
Location: USA

PostPosted: Thu Apr 08, 2004 2:56 pm    Post subject: Reply with quote

Quote:
The only way I could figure how to do this is to setup a schedule with a small 'green' time window and then set the interval to something smaller


Not smaller. Time interval specified for the test should be longer then allowed ("green") schedule interval. Otherwise test will be executed several times.
E.g. if you setup "green" schedule to 19:00-19:05, interval should be > 5 min (6, 10, 15, or 40 min - no difference).

Quote:
How do I schedule a test to run at exactly the same time each day?


If you have many tests, I cannot guarantee test will be executed EXACTLY at specified time. HostMonitor (and OS/hardware) cannot perform 1000 tests at the same second.
But if you need to perform test between 19:00 and 19:03 I don't see big problem.

Quote:
It looks like the hours/minutes/seconds runs as an interval in accordance to when HM was restarted.


If test configured to use regular schedule 24/7, yes.
But if you configured schedule to execute test between 15:00 and 19:00, 1st time test will be executed at 15:00[+ 1 or 2 min if you have a lot of other tests], following checks will be started depending on time interval specified for the test.

Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index