/// <summary>
        /// Initializes a new instance of the <see cref="ExeXmlSensorParameters"/> class.
        /// </summary>
        /// <param name="exeFile">The EXE or Script this sensor will execute. Must be located in the Custom Sensors\EXEXML folder on the target device's probe server.</param>
        /// <param name="sensorName">The name to use for this sensor.</param>
        /// <param name="exeParameters">Parameters to pass to the <paramref name="exeFile"/> on each scan.</param>
        /// <param name="setExeEnvironmentVariables">Whether PRTG Environment Variables (%host, %windowsusername, etc) will be available as System Environment Variables inside the EXE/Script.</param>
        /// <param name="useWindowsAuthentication">Whether to use the Windows Credentials of the parent device to execute the specified EXE/Script file. If custom credentials are not used, the file will be executed under the credentials of the PRTG Probe Service.</param>
        /// <param name="mutex">The mutex name to use. All sensors with the same mutex name will be executed sequentially, reducing resource utilization.</param>
        /// <param name="timeout">The duration (in seconds) this sensor can run for before timing out. This value must be between 1-900.</param>
        /// <param name="debugMode">Indicates whether to store raw EXE/Script XML/JSON output for debugging purposes.</param>
        /// <param name="inheritInterval">Whether this sensor's scanning interval settings are inherited from its parent.</param>
        /// <param name="interval">The scanning interval of the sensor. Applies only if <paramref name="inheritInterval"/> is false. If you wish to specify a non-standard scanning interval, you may do so by specifying a <see cref="TimeSpan"/> to property <see cref="NewSensorParameters.Interval"/>.</param>
        /// <param name="intervalErrorMode">The number of scanning intervals the sensor will wait before entering a <see cref="Status.Down"/> state when the sensor reports an error.</param>
        /// <param name="tags">Tags that should be applied to this sensor. If this value is null or no tags are specified, default value is "xmlexesensor".</param>
        public ExeXmlSensorParameters(ExeFileTarget exeFile, string sensorName = "XML Custom EXE/Script Sensor", string exeParameters = null,
                                      bool setExeEnvironmentVariables          = false, bool useWindowsAuthentication = false,
                                      string mutex = null, int timeout = 60, DebugMode debugMode = DebugMode.Discard, bool inheritInterval = true,
                                      StandardScanningInterval interval   = StandardScanningInterval.SixtySeconds,
                                      IntervalErrorMode intervalErrorMode = PrtgAPI.IntervalErrorMode.OneWarningThenDown, params string[] tags) :

            base(sensorName, SensorType.ExeXml)
        {
            if (exeFile == null)
            {
                throw new ArgumentNullException(nameof(exeFile));
            }

            ExeFile = exeFile;

            if (tags == null || tags.Length == 0)
            {
                Tags = new[] { "xmlexesensor" }
            }
            ;

            ExeParameters = exeParameters;
            SetExeEnvironmentVariables = setExeEnvironmentVariables;
            UseWindowsAuthentication   = useWindowsAuthentication;
            Mutex             = mutex;
            Timeout           = timeout;
            DebugMode         = debugMode;
            InheritInterval   = inheritInterval;
            Interval          = interval;
            IntervalErrorMode = intervalErrorMode;
        }
Exemple #2
0
        public void SensorTarget_ReferenceEquals_SensorTarget()
        {
            ExeFileTarget target1 = "test.ps1";
            ExeFileTarget target2 = target1;

            Assert.IsTrue(target1.Equals(target2));
        }
Exemple #3
0
        public void SensorTarget_ValueEquals_SensorTarget()
        {
            ExeFileTarget target1 = "test.ps1";
            ExeFileTarget target2 = "test.ps1";
            ExeFileTarget target3 = "test.ps2";

            Assert.IsTrue(target1.Equals(target2));
            Assert.IsFalse(target1.Equals(target3));
        }
Exemple #4
0
        public void SensorTarget_HashCodeEquals_SensorTarget()
        {
            ExeFileTarget target1 = "test.ps1";
            ExeFileTarget target2 = "test.ps1";

            var target1Hash = target1.GetHashCode();
            var target2Hash = target2.GetHashCode();

            Assert.AreEqual(target1Hash, target2Hash);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ExeXmlSensorParameters"/> class.
        /// </summary>
        /// <param name="exeFile">The EXE or Script this sensor will execute. Must be located in the Custom Sensors\EXEXML folder on the target device's probe server.</param>
        /// <param name="sensorName">The name to use for the sensor.</param>
        /// <param name="exeParameters">Parameters to pass to the <paramref name="exeFile"/> on each scan.</param>
        /// <param name="setExeEnvironmentVariables">Whether PRTG Environment Variables (%host, %windowsusername, etc) will be available as System Environment Variables inside the EXE/Script.</param>
        /// <param name="useWindowsAuthentication">Whether to use the Windows Credentials of the parent device to execute the specified EXE/Script file. If custom credentials are not used, the file will be executed under the credentials of the PRTG Probe Service.</param>
        /// <param name="mutex">The mutex name to use. All sensors with the same mutex name will be executed sequentially, reducing resource utilization.</param>
        /// <param name="timeout">The duration (in seconds) this sensor can run for before timing out. This value must be between 1-900.</param>
        /// <param name="debugMode">Indicates whether to store raw EXE/Script XML/JSON output for debugging purposes.</param>
        public ExeXmlSensorParameters(ExeFileTarget exeFile, string sensorName = "XML Custom EXE/Script Sensor", string exeParameters = null,
                                      bool setExeEnvironmentVariables          = false, bool useWindowsAuthentication = false,
                                      string mutex = null, int timeout = 60, DebugMode debugMode = DebugMode.Discard) :

            base(sensorName, SensorType.ExeXml)
        {
            if (exeFile == null)
            {
                throw new ArgumentNullException(nameof(exeFile));
            }

            ExeFile = exeFile;

            ExeParameters = exeParameters;
            SetExeEnvironmentVariables = setExeEnvironmentVariables;
            UseWindowsAuthentication   = useWindowsAuthentication;
            Mutex     = mutex;
            Timeout   = timeout;
            DebugMode = debugMode;
        }