- Posts: 1302
- Thank you received: 0
Performance and logs alerts
19 years 8 months ago #7726
by DaLight
Replied by DaLight on topic Re: Performance and logs alerts
What you could do is leave the checking interval at 5 secs and update a textfile with the value of current FTP connections. Then if it changes from the last value, tell it to send an email.
That way, you still get it checking every 5 secs, but it only sends an email when the number of current connections changes.
That way, you still get it checking every 5 secs, but it only sends an email when the number of current connections changes.
19 years 8 months ago #7742
by DaLight
Replied by DaLight on topic Re: Performance and logs alerts
OK aminos,
I've put something together. You'll have to test it yourself though.
You may also want to increase the checking interval to something like 30 or 60 seconds as you don't want it accessing a file every 5 secs.
First you need to alter Command Line Arguments option in Alerts i.e. the window where you entered the VBscript file name. Make sure only the "Measured value" option is checked.
This gives us access to the FTP service\current connections value or whatever value you're monitoring.
Now for the script (No error checking, you'll have to sort that out):
CurrentFTPconn = int(WScript.Arguments.Item(0)) 'read number of connections from command line
Dim xFSO ' As FileSystemObject
Dim xFile ' As Scripting.TextStream
Dim Result
Set xFSO = CreateObject("Scripting.FileSystemObject")
If (xFSO.FileExists("C:\Counter.txt")) Then
' File exists, grab its contents.
Set xFile = xFSO.OpenTextFile("c:\Counter.txt")
LastFTPconn = int(xFile.ReadLine())
xFile.Close
If LastFTPconn <> CurrentFTPconn then
'send and email if number of connections changes (up or down)
objEmail.From = "xxxxx@xxxx.xx"
objEmail.To = "yyyyy@yyy.yy"
objEmail.Subject = " ftp Server"
objEmail.Textbody = "Someone is here "
objEmail.Send
Set xFile = xFSO.CreateTextFile("c:\Counter.txt", True)
xFile.Write (CurrentFTPconn)
xFile.Close
End If
Else 'file does not exist
Set xFile = xFSO.CreateTextFile("c:\Counter.txt", True)
xFile.Write (CurrentFTPconn)
xFile.Close
End If
Set xFile = Nothing
Set xFSO = Nothing
Hope this helps
I've put something together. You'll have to test it yourself though.
You may also want to increase the checking interval to something like 30 or 60 seconds as you don't want it accessing a file every 5 secs.
First you need to alter Command Line Arguments option in Alerts i.e. the window where you entered the VBscript file name. Make sure only the "Measured value" option is checked.
This gives us access to the FTP service\current connections value or whatever value you're monitoring.
Now for the script (No error checking, you'll have to sort that out):
CurrentFTPconn = int(WScript.Arguments.Item(0)) 'read number of connections from command line
Dim xFSO ' As FileSystemObject
Dim xFile ' As Scripting.TextStream
Dim Result
Set xFSO = CreateObject("Scripting.FileSystemObject")
If (xFSO.FileExists("C:\Counter.txt")) Then
' File exists, grab its contents.
Set xFile = xFSO.OpenTextFile("c:\Counter.txt")
LastFTPconn = int(xFile.ReadLine())
xFile.Close
If LastFTPconn <> CurrentFTPconn then
'send and email if number of connections changes (up or down)
objEmail.From = "xxxxx@xxxx.xx"
objEmail.To = "yyyyy@yyy.yy"
objEmail.Subject = " ftp Server"
objEmail.Textbody = "Someone is here "
objEmail.Send
Set xFile = xFSO.CreateTextFile("c:\Counter.txt", True)
xFile.Write (CurrentFTPconn)
xFile.Close
End If
Else 'file does not exist
Set xFile = xFSO.CreateTextFile("c:\Counter.txt", True)
xFile.Write (CurrentFTPconn)
xFile.Close
End If
Set xFile = Nothing
Set xFSO = Nothing
Hope this helps
19 years 8 months ago #7744
by aminos
Replied by aminos on topic Thanks a lot Dalight
Thanks that's really great,
But i have a problem :
[code:1]WScript.Arguments.Item(0)) 'read number of connections from command line [/code:1]
how do i do this, i mean i want the vbscript of the FTP number of connections :roll:
but i'll check the Microsoft scripting center for that and tell you,
anyways thanks a lot for responding, you did a greatt job
if you have any ideas i'll be here
But i have a problem :
[code:1]WScript.Arguments.Item(0)) 'read number of connections from command line [/code:1]
how do i do this, i mean i want the vbscript of the FTP number of connections :roll:
but i'll check the Microsoft scripting center for that and tell you,
anyways thanks a lot for responding, you did a greatt job
if you have any ideas i'll be here
19 years 8 months ago #7745
by DaLight
Replied by DaLight on topic Re: Performance and logs alerts
WScript.Arguments.Item(0)) gives you the first command line argument.
From my post:
You can see that this argument gives you the "Measured Value" of whatever parameter you're monitoring i.e FTP connections or whatever. So you don't have to figure out how to get hold of this value from the code. It's already been done for you if you set it up as I've suggested.
From my post:
First you need to alter Command Line Arguments option in Alerts i.e. the window where you entered the VBscript file name. Make sure only the "Measured value" option is checked.
This gives us access to the FTP service\current connections value or whatever value you're monitoring.
You can see that this argument gives you the "Measured Value" of whatever parameter you're monitoring i.e FTP connections or whatever. So you don't have to figure out how to get hold of this value from the code. It's already been done for you if you set it up as I've suggested.
19 years 8 months ago #7747
by aminos
Hi Dalight,
well actually i've got a problem, when i execute the script without
specifying the argument command ligne it works fine,
but with "Measured value" as command line argument i've got nothing
i guess that happened becuase i specify MyScript.bat as the program to run.
myscript contains:
[code:1] wscript.exe Yourdcript.vbd[/code:1]
so i'll check how to tackle this
well actually i've got a problem, when i execute the script without
specifying the argument command ligne it works fine,
but with "Measured value" as command line argument i've got nothing
i guess that happened becuase i specify MyScript.bat as the program to run.
myscript contains:
[code:1] wscript.exe Yourdcript.vbd[/code:1]
so i'll check how to tackle this
Time to create page: 0.132 seconds