// /*************************************************************************** // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // // Filename : Statistics.cs // Author(s) : Natalia Portillo // // Component : XML metadata. // // --[ Description ] ---------------------------------------------------------- // // Define XML for statistics. // // --[ License ] -------------------------------------------------------------- // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // // ---------------------------------------------------------------------------- // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ // ReSharper disable ClassNeverInstantiated.Global // ReSharper disable UnusedMember.Global using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Text.Json.Serialization; using System.Xml.Serialization; namespace Aaru.CommonTypes.Metadata; /// Statistics [XmlRoot("DicStats", Namespace = "", IsNullable = false)] public class Stats { /// Executed commands public CommandsStats Commands; /// Operating systems Aaru has run from [XmlArrayItem("OperatingSystem")] public List OperatingSystems { get; set; } /// Aaru versions [XmlArrayItem("Version")] public List Versions { get; set; } /// Detected filesystems [XmlArrayItem("Filesystem")] public List Filesystems { get; set; } /// Detected partitioning schemes [XmlArrayItem("Scheme")] public List Partitions { get; set; } /// Media image formats [XmlArrayItem("Format")] public List MediaImages { get; set; } /// Used filters [XmlArrayItem("Filter", IsNullable = true)] public List Filters { get; set; } /// Found devices [XmlArrayItem("Device", IsNullable = true)] public List Devices { get; set; } /// Found media types, real, and in image [XmlArrayItem("Media")] public List Medias { get; set; } /// Benchmark statistics public BenchmarkStats Benchmark { get; set; } /// Media scanning statistics public MediaScanStats MediaScan { get; set; } /// Image verification statistics public VerifyStats Verify { get; set; } } [JsonSourceGenerationOptions(WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, IncludeFields = true)] [JsonSerializable(typeof(StatsDto))] // ReSharper disable once PartialTypeWithSinglePart public partial class StatsDtoContext : JsonSerializerContext {} /// DTO for statistics [SuppressMessage("ReSharper", "CollectionNeverQueried.Global")] public class StatsDto { /// Executed commands public List Commands { get; set; } /// Operating systems Aaru has run from public List OperatingSystems { get; set; } /// Aaru versions public List Versions { get; set; } /// Detected filesystems public List Filesystems { get; set; } /// Detected partitioning schemes public List Partitions { get; set; } /// Media image formats public List MediaFormats { get; set; } /// Used filters public List Filters { get; set; } /// Found devices public List Devices { get; set; } /// Found media types, real, and in image public List Medias { get; set; } /// Remote applications public List RemoteApplications { get; set; } /// Remote application architectures public List RemoteArchitectures { get; set; } /// Operating systems where a remote application has been running public List RemoteOperatingSystems { get; set; } } /// Command execution statistics [SuppressMessage("ReSharper", "UnassignedField.Global")] public class CommandsStats { /// Number of times the filesystem info command has been used public long Analyze; /// Number of times the benchmark command has been used public long Benchmark; /// Number of times the image checksum command has been used public long Checksum; /// Number of times the image compare command has been used public long Compare; /// Number of times the image convert command has been used public long ConvertImage; /// Number of times the image create-sidecar command has been used public long CreateSidecar; /// Number of times the image decode command has been used public long Decode; /// Number of times the device info command has been used public long DeviceInfo; /// Number of times the device report command has been used public long DeviceReport; /// Number of times the media dump command has been used public long DumpMedia; /// Number of times the image entropy command has been used public long Entropy; /// Number of times the filesystem extract command has been used public long ExtractFiles; /// Number of times the list formats command has been used public long Formats; /// Number of times the image info command has been used public long ImageInfo; /// Number of times the device list command has been used public long ListDevices; /// Number of times the list encodings command has been used public long ListEncodings; /// Number of times the filesystem ls command has been used public long Ls; /// Number of times the media info command has been used public long MediaInfo; /// Number of times the media scan command has been used public long MediaScan; /// Number of times the image printhex command has been used public long PrintHex; /// Number of times the image verify command has been used public long Verify; } /// Statistics of verified media public class VerifiedItems { /// Number of correct images public long Correct; /// Number of failed images public long Failed; } /// Verification statistics public class VerifyStats { /// Image verification statistics public VerifiedItems MediaImages; /// Image contents verification statistics public ScannedSectors Sectors; } /// Image contents verification statistics public class ScannedSectors { /// Sectors found to be correct public long Correct; /// Sectors found to be incorrect public long Error; /// Total number of verified sectors public long Total; /// Total number of sectors that could not be verified public long Unverifiable; } /// Media scanning time statistics [SuppressMessage("ReSharper", "InconsistentNaming")] public class TimeStats { /// Number of sectors that took more than 3ms but less than 100ms to read public long LessThan10ms; /// Number of sectors that took more than 50ms but less than 150ms to read public long LessThan150ms; /// Number of sectors that took less than 3ms to read public long LessThan3ms; /// Number of sectors that took more than 150ms but less than 500ms to read public long LessThan500ms; /// Number of sectors that took more than 10ms but less than 50ms to read public long LessThan50ms; /// Number of sectors that took more than 500ms to read public long MoreThan500ms; } /// Media scanning statistics public class MediaScanStats { /// Statistics of scanned sectors public ScannedSectors Sectors; /// Scan time statistics public TimeStats Times; } /// Checksum type statistics [SuppressMessage("ReSharper", "InconsistentNaming")] public class ChecksumStats { /// Checksum algorithm [XmlAttribute] public string algorithm; /// Time taken to execute algorithm [XmlText] public double Value; } /// Benchmark statistics public class BenchmarkStats { /// Total time taken to run the checksum algorithms in parallel public double All; /// List of time taken by each checksum algorithm [XmlElement("Checksum")] public List Checksum; /// Time taken to benchmark entropy calculation public double Entropy; /// Maximum amount of memory used while running the benchmark public long MaxMemory; /// Minimum amount of memory used while running the benchmark public long MinMemory; /// Total time taken to run the checksum algorithms sequentially public double Sequential; } /// Media statistics [SuppressMessage("ReSharper", "InconsistentNaming")] public class MediaStats { /// Found in a real device? [XmlAttribute] public bool real; /// Media type [XmlAttribute(AttributeName = "type")] [JsonPropertyName("type")] public string MediaType; /// Number of times it has been found [XmlText] public long Value; } /// Device statistics public class DeviceStats { /// Is manufacturer null? [XmlIgnore] public bool ManufacturerSpecified; /// Manufacturer string public string Manufacturer { get; set; } /// Model string public string Model { get; set; } /// Revision or firmware version public string Revision { get; set; } /// Bus the device was attached to public string Bus { get; set; } } /// Name=value pair statistics [SuppressMessage("ReSharper", "InconsistentNaming")] public class NameValueStats { /// Name [XmlAttribute] public string name { get; set; } /// Number of times it has been used/found [XmlText] public long Value { get; set; } } /// Operating system statistics [SuppressMessage("ReSharper", "InconsistentNaming")] public class OsStats { /// Operating system name [XmlAttribute] public string name { get; set; } /// Operating system version [XmlAttribute] public string version { get; set; } /// Number of times Aaru run on it [XmlText] public long Value { get; set; } }