nbtstat

Need new test, action, option? Post request here.
Post Reply
tmazzini
Posts: 23
Joined: Wed Dec 08, 2004 5:34 am
Location: Milano Italy

nbtstat

Post by tmazzini »

Hi,
I use static IP in my lan, when a new IP is used I can see it by an alert from HostMonitor; I want know also the name of machine (nbtstat -a %testName%) and send it in the mail alert.
I tried an "execute external command" nbtstat -a ipaddress > filename.txt but don't work.

Any idea?

Thanks
TM
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

What exactly means "don't work"? I assume you are receiving mail but it does not contain information about correct ip address. Am I right?

It happens because "Execute external command" action launch external application but it does not wait until application terminates. So, e-mail message could be send before external application creates file.

Solution: use HMScript action with ExecuteProgram command instead (http://www.ks-soft.net/hostmon.eng/mfra ... #actScript). Please note: you should add "HM Script" action 1st and THEN add "Send e-mail" action to the profile.

Regards
Alex
tmazzini
Posts: 23
Joined: Wed Dec 08, 2004 5:34 am
Location: Milano Italy

nbtstat ...long

Post by tmazzini »

Alex thanks for the answer,
"don't work" means that i'm not able to create the file independently to send mail; I tried (after reading other msgs in forum) using HMscript action but I'm only able to execute a bat (or cmd) file with inside the command. In other case the "filename.txt (output redirected) is not create.
Example HMscript:
ExecuteProgram 5000 nbtstat -a 192.168.10.103 > c:\filename.txt
do not create any file
ExecuteProgram 5000 c:\batfile.cmd
(where batfile.cmd contains nbtstat -a 192.168.10.103 > c:\filename.txt) works fine.
Note that I would want use %TestName% not the ip address... but how can i put in batfile.cmd ip variable?
The real problem is that i have many ip in 7 subnet; create bat-files and alerts for any ip to monitor require a lot of work... :o . I hope that using %TestName% or something like it i can control entire network with only 3 or 4 different alerts or script.
May be I'm wrong in writing the HMscript... (?)
The initial idea is create a file containing the resolved name of "bad" ip and send it in a mail-alert (attached or in the body). May be that there is a better way for obtaining this...
I also hope my orrible english is :oops: ...readable.
regards and sorry for th log msg
TM
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Example HMscript:
ExecuteProgram 5000 nbtstat -a 192.168.10.103 > c:\filename.txt
do not create any file
ExecuteProgram 5000 c:\batfile.cmd
(where batfile.cmd contains nbtstat -a 192.168.10.103 > c:\filename.txt) works fine.
One solution - BAT file.
Another solution - simply modify command: ExecuteProgram 5000 cmd /c nbtstat -a 192.168.10.103 >c:\filename.txt
Note that I would want use %TestName% not the ip address... but how can i put in batfile.cmd ip variable?
Its easy.
Script command: ExecuteProgram 5000 c:\batfile.cmd "%TestName%"
BAT file: nbtstat -a %1 > c:\filename.txt

Regards
Alex
tmazzini
Posts: 23
Joined: Wed Dec 08, 2004 5:34 am
Location: Milano Italy

Post by tmazzini »

Thanks a lot.
Now it works fine; the writing of the command was wrong.

p.s.
I am evaluating the product; I wish to compliment the efficiency of the servicing that will be of aid for the purchase

Best regards

TM
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

You are welcome :)
tmazzini
Posts: 23
Joined: Wed Dec 08, 2004 5:34 am
Location: Milano Italy

test runs only one time...

Post by tmazzini »

...now I'm a registred user :D , but my script do not run regulary, it runs only sometimes... :o

Example: if you copy (duplicate) the test it runs, if you re-assign the filename of .hms file and then try the test it runs.
...if the test is activated because there is an event, it do not runs...

My test is in two parts:
one --> create a txt file with inside the result of nbtstat,
two --> send a mail with in attachment the file.

Part two works fine every time, but part one ...never.
Better, not never, but sometimes ...yes, sometimes ...not
May be that execute program 1000 is too short?
may be the pc is too slow (Celeron 633+326MB ram+W2k)?

i don't understand where the process is defective
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Example: if you copy (duplicate) the test it runs, if you re-assign the filename of .hms file and then try the test it runs.
...if the test is activated because there is an event, it do not runs...
What test method do you use? NT Event Log?
What parameters of the action you have set? "Start when ?? consecutive Bad results occur", "Repeat ?? times"?

Regards
Alex
tmazzini
Posts: 23
Joined: Wed Dec 08, 2004 5:34 am
Location: Milano Italy

Oooppss....

Post by tmazzini »

ok, test is "ping test" reverse alert (starts when ip good)
the alert is
1- "execute hml script" starts when 2 consecutive bad... repeat 1
2- send email with attachment "C:\Programmi\HostMonitor4\Examples\%HostAddr%.txt"

hml script is "C:\Programmi\HostMonitor4\Examples\nb.hms"

nb.hms contains:
ExecuteProgram 10000 batfile.cmd "%HostAddr%"

batfile.cmd contains:
nbtstat -a %1 > %1.txt

there is no way to run the first part of alert... but it worked some time ago
so the alert is sent without attachment.
Test always works... excuse for the question made badly, problem is first part of alert, "nbtstat execution is not executed"...

Best regards
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

the alert is
1- "execute hml script" starts when 2 consecutive bad... repeat 1
2- send email with attachment "C:\Programmi\HostMonitor4\Examples\%HostAddr%.txt"
So, 1st action should be executed when host joins network, after 2nd ping test. You are using the same parameters for "send e-mail" action?
What action was created 1st? If you are using the same start parameters, "send e-mail" action should be created after "HM Script" action. If you are not sure, remove "send e-mail" action and create it again.

If HostMonitor really does not execute external program, please check system log (log that is specified on Advanced Logs page in the Options dialog). There should be a message that explains why HostMonitor cannot start external program

Regards
Alex
tmazzini
Posts: 23
Joined: Wed Dec 08, 2004 5:34 am
Location: Milano Italy

Post by tmazzini »

syslog.htm says cannot execute command "batfile.cmd"

...done:

1 send mail was executed before external prg
2 problem in path, %HostAddr%.txt was created in winnnt\system32...
3 problem executing cmd without path.

solved:
1 deleted "send e-mail" action and created again
2 now hms has complete path c:\programmi\hostmonitor4\examples\batfile.cmd "%hostaddr%" ...not only batfile.cmd ....
3 now batfile.cmd declare the complete destination path where create file used in mail-attach

I only cannot understand why it worked some time ago with all these problems (?)
In any case now it works fine and seems ok

Many thanks for your great help.

Best regards
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

I only cannot understand why it worked some time ago with all these problems (?)
Probably because you started HostMonitor as application before?
When you start application, HostMonitor uses work directory as default path. When its started as service, Windows says that %system% directory is current path

Regards
Alex
tmazzini
Posts: 23
Joined: Wed Dec 08, 2004 5:34 am
Location: Milano Italy

yes

Post by tmazzini »

Yes, you are right, in fact HostMonitor is now running as service, at that time it was started as application...

Thank you
:D
Post Reply