Es kann schon mal vorkommen, das es ein Problem gibt und die Ursache nicht von vorn herein klar ist, woran es liegt. Beim Troubleshooting selbst hat sich das OSI Modell als ersten Ansatz bewährt die verschiedenen Komponenten zu testen.
https://de.wikipedia.org/wiki/OSI-Modell
Ich habe mir ein kleines Tool zum testen bis zur Schicht 3 geschrieben, was es mir erlaubt einen Endpunkt zu Pingen und zu protokollieren. Es werden Response Zeiten und Zeitstempel dokumentiert und können bei bedarf in eine .txt File exportiert werden. Da ich dieses Tool auch für nicht IT’ler geschrieben habe, gibt es auch ein gewisses Maß an Visualisierung in der GUI.
Das Protokoll kann über das System Tray Icon rechte Maustaste exportiert werden. Zusätzlich kann man auch die Benachrichtigung deaktivieren falls die Verbindung flattert und es ständig aus den Lautsprecher “bingt”.
Als Hostname kann auch ein DNS Namen eingesetzt werden.
Hier das Projekt als Download:
responseGadget
Nur die .EXE
responseGadget
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.Net.NetworkInformation;
using System.Threading;
using System.IO;
namespace responseGadget
{
public partial class TGui : Form
{
private static Ping pingSender = new Ping();
private TimeSpan interval = new TimeSpan(0, 0, 2);
private PingReply reply;
//String host = "192.168.1.1";
private String host = "192.168.1.1";
// option for parameters
private string[] args;
//
private int goodCounter = 0, midCounter = 0, badCounter = 0, timeoutCounter = 0;
// tray entries
private NotifyIcon trayIcon;
private ContextMenu trayMenu;
// state falgs
private bool hostReachable = false;
private bool startState = false;
private bool notificationState = false;
private String oldConnectionState, connectionState = "";
public TGui()
{
InitializeComponent();
var timer = new System.Windows.Forms.Timer();
timer.Interval = 10000; //3 seconds
timer.Tick += new EventHandler(ch);
timer.Start();
txtBox.ScrollBars = ScrollBars.Vertical;
trayMenu = new ContextMenu();
trayMenu.MenuItems.Add("Export log", exportLog);
trayMenu.MenuItems.Add("activate notification", activateNotification);
trayMenu.MenuItems.Add("dectivate notification", dectivateNotification);
trayMenu.MenuItems.Add("Exit", OnExit);
trayIcon = new NotifyIcon();
trayIcon.Text = "Response";
trayIcon.Icon = new Icon(SystemIcons.Application, 40, 40);
trayIcon.ContextMenu = trayMenu;
trayIcon.Visible = true;
}
/*
public TGui(string[] args)
{
this.args = args;
MessageBox.Show(args.ToString());
}
*/
private void OnExit(object sender, EventArgs e)
{
Application.Exit();
}
private void exportLog(object sender, EventArgs e)
{
try
{
SaveFileDialog saveFileDialogoutputStream = new SaveFileDialog();
saveFileDialogoutputStream.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
saveFileDialogoutputStream.FilterIndex = 1;
saveFileDialogoutputStream.RestoreDirectory = true;
if (saveFileDialogoutputStream.ShowDialog() == DialogResult.OK)
{
File.WriteAllText(saveFileDialogoutputStream.FileName, txtBox.Text);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private void button1_Click(object sender, EventArgs e)
{
txtLastBoxHostaddress.Text = host;
host = txtBoxHostaddress.Text;
}
private void button2_Click(object sender, EventArgs e)
{
String hostTmp = "";
if (txtBoxHostaddress != txtLastBoxHostaddress)
{
hostTmp = txtBoxHostaddress.Text;
}
host = txtLastBoxHostaddress.Text;
txtLastBoxHostaddress.Text = hostTmp;
txtBoxHostaddress.Text = host;
}
public void ch(Object myObject, EventArgs myEventArgs)
{
try
{
good.Text = goodCounter.ToString();
mid.Text = midCounter.ToString();
bad.Text = badCounter.ToString();
timeout.Text = timeoutCounter.ToString();
// host + timeout settings
reply = pingSender.Send(host, 3);
if (reply.Status == IPStatus.Success)
{
if (reply.RoundtripTime >= 0 && reply.RoundtripTime < 50) { connectionState = "good"; txtBox.BackColor = Color.LightGreen; this.trayIcon.Icon = responseGadget.Properties.Resources.okIcon; goodCounter++; } else if (reply.RoundtripTime >= 50 && reply.RoundtripTime < 200)
{
connectionState = "medium";
txtBox.BackColor = Color.LightGreen;
this.trayIcon.Icon = responseGadget.Properties.Resources.okIcon;
midCounter++;
}
else
{
connectionState = "bad";
txtBox.BackColor = Color.Moccasin;
this.trayIcon.Icon = responseGadget.Properties.Resources.medIcon;
badCounter++;
}
if (connectionState != oldConnectionState)
{
if (connectionState == "good")
{
this.trayIcon.Icon = responseGadget.Properties.Resources.okIcon;
}
if (connectionState == "medium")
{
this.trayIcon.Icon = responseGadget.Properties.Resources.medIcon;
}
if (connectionState == "bad")
{
this.trayIcon.Icon = responseGadget.Properties.Resources.nokIcon;
}
oldConnectionState = connectionState;
}
txtBox.Text += "\r\n" + DateTime.Now.ToString("HH:mm:ss") + " : connection ok with : " + reply.RoundtripTime.ToString() + " ms";
if (!startState || !hostReachable)
{
trayIcon.BalloonTipText = host + " Infrastruktur erreichbar";
trayIcon.ShowBalloonTip(2);
hostReachable = true;
if (!startState)
startState = true;
}
}
else
{
txtBox.BackColor = Color.Tomato;
txtBox.Text += "\r\n" + DateTime.Now.ToString("HH:mm:ss") + " : no connection";
timeoutCounter++;
if (!startState || hostReachable)
{
trayIcon.BalloonTipText = host + " Infrastruktur nicht erreichbar";
trayIcon.ShowBalloonTip(2);
hostReachable = false;
if (!startState)
startState = true;
this.trayIcon.Icon = responseGadget.Properties.Resources.nokIcon;
}
}
txtBox.SelectionStart = txtBox.Text.Length;
txtBox.ScrollToCaret();
}
catch
{
txtBox.BackColor = Color.Tomato;
txtBox.Text += "\r\n" + DateTime.Now.ToString("HH:mm:ss") + " : no connection";
txtBox.SelectionStart = txtBox.Text.Length;
txtBox.ScrollToCaret();
}
}
private void activateNotification(object sender, EventArgs e)
{
notificationState = true;
}
private void dectivateNotification(object sender, EventArgs e)
{
notificationState = false;
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
txtBox.Text = "systemtime : " + DateTime.Now.ToString();
txtBox.Text += "\r\nhostname : " + Dns.GetHostName();
txtBox.Text += "\r\nrunning ping on : " + host;
txtBox.Text += "\r\n----------------------------------------------------";
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}