Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I writing a program to alert if a mail queue exceeds a threshold using an SSH control in VB.NET, however if the result if NULL then it throws an exception and displays cannot that value should be less than infinity.

Can anyone shed any light to help me resolve this as I'm new to VB.Net ?

Thanks

VB
Private Function MonitorMAILSERVER()

        Dim connInfoMAILSERVER As New Renci.SshNet.PasswordConnectionInfo("MAILSERVER", "username", "password")
        Dim sshClientMAILSERVER As New Renci.SshNet.SshClient(connInfoMAILSERVER)
        Dim queueMAILSERVER As Renci.SshNet.SshCommand

        Using sshClientMAILSERVER

            sshClientMAILSERVER.Connect()
            queueMAILSERVER = sshClientMAILSERVER.RunCommand("/usr/sbin/postqueue -p | tail -n1 | awk '{print $5}'")
            txtMAILSERVER.Text = queueMAILSERVER.Result
            sshClientMAILSERVER.Disconnect()

        End Using

        If queueMAILSERVER.Result >= 20 Then

            imgMAILSERVER.Image = Mail_Queue_Monitor.My.Resources.red
        Else

            imgMAILSERVER.Image = Mail_Queue_Monitor.My.Resources.green

        End If

    End Function
Posted
Updated 19-Jan-15 4:25am
v2
Comments
CHill60 19-Jan-15 10:28am    
Which line throws the exception?
Gromble 19-Jan-15 10:53am    
HiIf the mail queue is empty and the command returns 0 then the following line exceptions, I assuming that it is becuase the value is being returned as a string ?

If queueMAILSERVER.Result >= 20 Then
Wombaticus 19-Jan-15 12:22pm    
I would presume you should check for this condition first then - something along the lines of
If queueMAILSERVER.Result Is Nothing Then...
ZurdoDev 19-Jan-15 14:40pm    
Exactly.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900