Пример #1
0
        public static IcmpV4Statistics CreateIcmpV4Statistics()
        {
            LinuxIcmpV4Statistics stats = new LinuxIcmpV4Statistics();
            string fileContents = File.ReadAllText(NetworkFiles.SnmpV4StatsFile);
            int firstIpHeader = fileContents.IndexOf("Icmp:");
            int secondIpHeader = fileContents.IndexOf("Icmp:", firstIpHeader + 1);
            int endOfSecondLine = fileContents.IndexOf(Environment.NewLine, secondIpHeader);
            string icmpData = fileContents.Substring(secondIpHeader, endOfSecondLine - secondIpHeader);
            StringParser parser = new StringParser(icmpData, ' ');

            // NOTE: Need to verify that this order is consistent. Otherwise, we need to parse the first-line header
            // to determine the order of information contained in the file.

            parser.MoveNextOrFail(); // Skip Icmp:

            stats._inMsgs = parser.ParseNextInt32();
            stats._inErrors = parser.ParseNextInt32();
            stats._inCsumErrors = parser.ParseNextInt32();
            stats._inDestUnreachs = parser.ParseNextInt32();
            stats._inTimeExcds = parser.ParseNextInt32();
            stats._inParmProbs = parser.ParseNextInt32();
            stats._inSrcQuenchs = parser.ParseNextInt32();
            stats._inRedirects = parser.ParseNextInt32();
            stats._inEchos = parser.ParseNextInt32();
            stats._inEchoReps = parser.ParseNextInt32();
            stats._inTimestamps = parser.ParseNextInt32();
            stats._inTimeStampReps = parser.ParseNextInt32();
            stats._inAddrMasks = parser.ParseNextInt32();
            stats._inAddrMaskReps = parser.ParseNextInt32();
            stats._outMsgs = parser.ParseNextInt32();
            stats._outErrors = parser.ParseNextInt32();
            stats._outDestUnreachs = parser.ParseNextInt32();
            stats._outTimeExcds = parser.ParseNextInt32();
            stats._outParmProbs = parser.ParseNextInt32();
            stats._outSrcQuenchs = parser.ParseNextInt32();
            stats._outRedirects = parser.ParseNextInt32();
            stats._outEchos = parser.ParseNextInt32();
            stats._outEchoReps = parser.ParseNextInt32();
            stats._outTimestamps = parser.ParseNextInt32();
            stats._outTimestampReps = parser.ParseNextInt32();
            stats._outAddrMasks = parser.ParseNextInt32();
            stats._outAddrMaskReps = parser.ParseNextInt32();

            return stats;
        }
Пример #2
0
        public static IcmpV4Statistics CreateIcmpV4Statistics()
        {
            LinuxIcmpV4Statistics stats  = new LinuxIcmpV4Statistics();
            string       fileContents    = File.ReadAllText(NetworkFiles.SnmpV4StatsFile);
            int          firstIpHeader   = fileContents.IndexOf("Icmp:");
            int          secondIpHeader  = fileContents.IndexOf("Icmp:", firstIpHeader + 1);
            int          endOfSecondLine = fileContents.IndexOf(Environment.NewLine, secondIpHeader);
            string       icmpData        = fileContents.Substring(secondIpHeader, endOfSecondLine - secondIpHeader);
            StringParser parser          = new StringParser(icmpData, ' ');

            // NOTE: Need to verify that this order is consistent. Otherwise, we need to parse the first-line header
            // to determine the order of information contained in the file.

            parser.MoveNextOrFail(); // Skip Icmp:

            stats._inMsgs           = parser.ParseNextInt32();
            stats._inErrors         = parser.ParseNextInt32();
            stats._inCsumErrors     = parser.ParseNextInt32();
            stats._inDestUnreachs   = parser.ParseNextInt32();
            stats._inTimeExcds      = parser.ParseNextInt32();
            stats._inParmProbs      = parser.ParseNextInt32();
            stats._inSrcQuenchs     = parser.ParseNextInt32();
            stats._inRedirects      = parser.ParseNextInt32();
            stats._inEchos          = parser.ParseNextInt32();
            stats._inEchoReps       = parser.ParseNextInt32();
            stats._inTimestamps     = parser.ParseNextInt32();
            stats._inTimeStampReps  = parser.ParseNextInt32();
            stats._inAddrMasks      = parser.ParseNextInt32();
            stats._inAddrMaskReps   = parser.ParseNextInt32();
            stats._outMsgs          = parser.ParseNextInt32();
            stats._outErrors        = parser.ParseNextInt32();
            stats._outDestUnreachs  = parser.ParseNextInt32();
            stats._outTimeExcds     = parser.ParseNextInt32();
            stats._outParmProbs     = parser.ParseNextInt32();
            stats._outSrcQuenchs    = parser.ParseNextInt32();
            stats._outRedirects     = parser.ParseNextInt32();
            stats._outEchos         = parser.ParseNextInt32();
            stats._outEchoReps      = parser.ParseNextInt32();
            stats._outTimestamps    = parser.ParseNextInt32();
            stats._outTimestampReps = parser.ParseNextInt32();
            stats._outAddrMasks     = parser.ParseNextInt32();
            stats._outAddrMaskReps  = parser.ParseNextInt32();

            return(stats);
        }
 public override IcmpV4Statistics GetIcmpV4Statistics()
 {
     return(LinuxIcmpV4Statistics.CreateIcmpV4Statistics());
 }