VB.NET App that lets you monitor your Network Equipment with Logs
DOWNLOAD SOURCE CODE: MONITOR NETWORK PING
Imports System.Text.RegularExpressions
Public Class Form1
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
Application.Exit()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
logs.ScrollBars = ScrollBars.Vertical
logs.Multiline = True
txttmr.Enabled = False
txttmr.Text = 50
Dim line As String
Dim IPini() As String
Dim desc() As String = {"a", "b"}
Dim ips() As String = {"a", "b"}
Dim icount As Integer
Dim isplit() As String
Using sr As New System.IO.StreamReader(".\settings.ini")
line = sr.ReadToEnd
IPini = line.Split(vbCrLf)
While IPini.Length <> icount
IPini(icount) = IPini(icount).Replace(vbCr, "").Replace(vbLf, "")
isplit = IPini(icount).Split(",")
desc(icount) = isplit(0)
ips(icount) = isplit(1)
icount = icount + 1
End While
End Using
lblip1.Text = ips(0)
lblip2.Text = ips(1)
btnip1.Text = desc(0)
btnip2.Text = desc(1)
ipwatch(lblip1.Text, btnip1)
ipwatch(lblip2.Text, btnip2)
Tmr.Enabled = True
Try
Dim objreader As New System.IO.StreamReader(".\logs.txt")
logs.Text = objreader.ReadToEnd
objreader.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "load")
End Try
End Sub
Public Sub ipwatch(ByVal ip As String, ByVal desc As Button)
If My.Computer.Network.Ping(ip) Then
desc.BackColor = Color.Green
Else
desc.BackColor = Color.Red
Try
Dim objreader As New System.IO.StreamReader(".\logs.txt")
logs.Text = objreader.ReadToEnd
objreader.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "load")
End Try
logs.Text = DateTime.Now & " - " & ip & " - timeout" & vbCrLf & logs.Text
Try
Dim objwrite As New System.IO.StreamWriter(".\logs.txt")
objwrite.Write(logs.Text)
objwrite.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "load")
End Try
Try
Dim objreader As New System.IO.StreamReader(".\logs.txt")
logs.Text = objreader.ReadToEnd
objreader.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "load")
End Try
End If
End Sub
Private Sub btnip1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnip1.Click
Form2.lblbtn.Text = 1
Form2.txtip.Text = lblip1.Text
Form2.txtdesc.Text = btnip1.Text
Form2.Show()
Me.Hide()
End Sub
Private Sub btnip2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnip2.Click
Form2.lblbtn.Text = 2
Form2.txtip.Text = lblip2.Text
Form2.txtdesc.Text = btnip2.Text
Form2.Show()
Me.Hide()
End Sub
Private Sub Tmr_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tmr.Tick
If ProgressBar1.Value < 100 Then
ProgressBar1.Value = CDbl(ProgressBar1.Value) + 2
txttmr.Text = Val(txttmr.Text) - 1
Else
ipwatch(lblip1.Text, btnip1)
ipwatch(lblip2.Text, btnip2)
ProgressBar1.Value = 0
txttmr.Text = 50
End If
End Sub
End Class
'CREATED BY ROSSI CATLY
No comments:
Post a Comment