public override Enum GetAction(MonitorAction action) { Enum eEnum = null; switch (action) { case MonitorAction.getMonitors: eEnum = ExternalMonitorAction.tests; break; case MonitorAction.getMonitorInfo: eEnum = ExternalMonitorAction.testinfo; break; case MonitorAction.getMonitorResults: eEnum = ExternalMonitorAction.testresult; break; case MonitorAction.suspendMonitors: eEnum = ExternalMonitorAction.suspendExternalMonitor; break; case MonitorAction.activateMonitors: eEnum = ExternalMonitorAction.activateExternalMonitor; break; } return(eEnum); }
public String Monitorear(String Canal) { MonitorAction mo = new MonitorAction(Canal, UniqueId, "gsm", true); ManagerResponse response2 = Conn.SendAction(mo, 15000); return(response2.Message); }
public void 获取应用程序池_GetApplications_TM() { IISMonitorDX.Core.MonitorAction action = new MonitorAction(); var lists = action.GetApplications(); Assert.IsTrue(lists.Count > 0); }
public void AddSlaveMonitor (IProgressMonitor slaveMonitor, MonitorAction actionMask) { MonitorInfo smon = new MonitorInfo (); smon.ActionMask = actionMask; smon.Monitor = slaveMonitor; monitors.Add (smon); if ((actionMask & MonitorAction.SlaveCancel) != 0) slaveMonitor.CancelRequested += new MonitorHandler (OnSlaveCancelRequested); }
public static string GetSipChannel(ManagerConnection _ami) { MonitorAction m = new MonitorAction() { Channel = "all" }; var res = _ami.SendAction(m); Console.WriteLine($"Get Sip Channel : {res.Response} : {res.Message}"); return("works"); }
public void AddSlaveMonitor(ProgressMonitor slaveMonitor, MonitorAction actionMask) { MonitorInfo smon = new MonitorInfo(); smon.ActionMask = actionMask; smon.Monitor = slaveMonitor; monitors.Add(smon); if ((actionMask & MonitorAction.SlaveCancel) != 0) { smon.CancellationTokenRegistration = slaveMonitor.CancellationToken.Register(OnSlaveCancelRequested); } }
public void AddFollowerMonitor(ProgressMonitor followerMonitor, MonitorAction actionMask) { MonitorInfo smon = new MonitorInfo(); smon.ActionMask = actionMask; smon.Monitor = followerMonitor; monitors.Add(smon); if ((actionMask & MonitorAction.FollowerCancel) != 0) { smon.CancellationTokenRegistration = followerMonitor.CancellationToken.Register(OnFollowerCancelRequested); } }
public void AddSlaveMonitor(IProgressMonitor slaveMonitor, MonitorAction actionMask) { MonitorInfo smon = new MonitorInfo(); smon.ActionMask = actionMask; smon.Monitor = slaveMonitor; monitors.Add(smon); if ((actionMask & MonitorAction.SlaveCancel) != 0) { slaveMonitor.CancelRequested += new MonitorHandler(OnSlaveCancelRequested); } }
public LogSearchRuleData(AzureLocation location, MonitorSource source, MonitorAction action) : base(location) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (action == null) { throw new ArgumentNullException(nameof(action)); } Source = source; Action = action; }
internal LogSearchRuleData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary <string, string> tags, AzureLocation location, string kind, string etag, string createdWithApiVersion, bool?isLegacyLogAnalyticsRule, string description, string displayName, bool?autoMitigate, Enabled?enabled, DateTimeOffset?lastUpdatedOn, ProvisioningState?provisioningState, MonitorSource source, MonitorSchedule schedule, MonitorAction action) : base(id, name, resourceType, systemData, tags, location, kind, etag) { CreatedWithApiVersion = createdWithApiVersion; IsLegacyLogAnalyticsRule = isLegacyLogAnalyticsRule; Description = description; DisplayName = displayName; AutoMitigate = autoMitigate; Enabled = enabled; LastUpdatedOn = lastUpdatedOn; ProvisioningState = provisioningState; Source = source; Schedule = schedule; Action = action; }
public ConditionMetEventArgs(MonitorAction action) { Action = action; }
public void AddFollowerMonitor (ProgressMonitor followerMonitor, MonitorAction actionMask) { MonitorInfo smon = new MonitorInfo (); smon.ActionMask = actionMask; smon.Monitor = followerMonitor; monitors.Add (smon); if ((actionMask & MonitorAction.FollowerCancel) != 0) smon.CancellationTokenRegistration = followerMonitor.CancellationToken.Register (OnFollowerCancelRequested); }
public virtual Enum GetAction(MonitorAction action) { return(action); }
public FilteredProgressMonitor(ProgressMonitor targetMonitor, MonitorAction actionMask) { AddFollowerMonitor(targetMonitor, actionMask); }
public static void RegisterGUIAction(string name, MonitorAction action) { if( !guiActions.ContainsKey( name ) ) guiActions.Add(name, action); }
public virtual Enum GetAction(MonitorAction action) { return action; }
internal static LogSearchRuleData DeserializeLogSearchRuleData(JsonElement element) { Optional <string> kind = default; Optional <string> etag = default; IDictionary <string, string> tags = default; AzureLocation location = default; ResourceIdentifier id = default; string name = default; ResourceType type = default; SystemData systemData = default; Optional <string> createdWithApiVersion = default; Optional <bool> isLegacyLogAnalyticsRule = default; Optional <string> description = default; Optional <string> displayName = default; Optional <bool> autoMitigate = default; Optional <Enabled> enabled = default; Optional <DateTimeOffset> lastUpdatedTime = default; Optional <ProvisioningState> provisioningState = default; MonitorSource source = default; Optional <MonitorSchedule> schedule = default; MonitorAction action = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("kind")) { kind = property.Value.GetString(); continue; } if (property.NameEquals("etag")) { etag = property.Value.GetString(); continue; } if (property.NameEquals("tags")) { Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, property0.Value.GetString()); } tags = dictionary; continue; } if (property.NameEquals("location")) { location = new AzureLocation(property.Value.GetString()); continue; } if (property.NameEquals("id")) { id = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = new ResourceType(property.Value.GetString()); continue; } if (property.NameEquals("systemData")) { systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString()); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("createdWithApiVersion")) { createdWithApiVersion = property0.Value.GetString(); continue; } if (property0.NameEquals("isLegacyLogAnalyticsRule")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } isLegacyLogAnalyticsRule = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("description")) { description = property0.Value.GetString(); continue; } if (property0.NameEquals("displayName")) { displayName = property0.Value.GetString(); continue; } if (property0.NameEquals("autoMitigate")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } autoMitigate = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("enabled")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } enabled = new Enabled(property0.Value.GetString()); continue; } if (property0.NameEquals("lastUpdatedTime")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } lastUpdatedTime = property0.Value.GetDateTimeOffset("O"); continue; } if (property0.NameEquals("provisioningState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } provisioningState = new ProvisioningState(property0.Value.GetString()); continue; } if (property0.NameEquals("source")) { source = MonitorSource.DeserializeMonitorSource(property0.Value); continue; } if (property0.NameEquals("schedule")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } schedule = MonitorSchedule.DeserializeMonitorSchedule(property0.Value); continue; } if (property0.NameEquals("action")) { action = MonitorAction.DeserializeMonitorAction(property0.Value); continue; } } continue; } } return(new LogSearchRuleData(id, name, type, systemData, tags, location, kind.Value, etag.Value, createdWithApiVersion.Value, Optional.ToNullable(isLegacyLogAnalyticsRule), description.Value, displayName.Value, Optional.ToNullable(autoMitigate), Optional.ToNullable(enabled), Optional.ToNullable(lastUpdatedTime), Optional.ToNullable(provisioningState), source, schedule.Value, action)); }
public virtual void OnMonitorAction(string monitorTypeName, MonitorId monitorId, string currentStateName, string actionName) { MonitorAction?.Invoke(monitorTypeName, monitorId, currentStateName, actionName); }
private static void checkManagerAPI() { manager = new ManagerConnection(ASTERISK_HOST, ASTERISK_PORT, ASTERISK_LOGINNAME, ASTERISK_LOGINPWD); // Register user event class manager.RegisterUserEventClass(typeof(UserAgentLoginEvent)); // Add or Remove events manager.UserEvents += new UserEventHandler(dam_UserEvents); // Dont't display this event manager.NewExten += new NewExtenEventHandler(manager_IgnoreEvent); // Display all other manager.UnhandledEvent += new ManagerEventHandler(dam_Events); // +++ Only to debug purpose manager.FireAllEvents = true; // manager.DefaultEventTimeout = 0; // manager.DefaultResponseTimeout = 0; manager.PingInterval = 0; // +++ try { manager.Login(); // Login only (fast) Console.WriteLine("Asterisk version : " + manager.Version); } catch (Exception ex) { Console.WriteLine(ex); Console.ReadLine(); manager.Logoff(); return; } { Console.WriteLine("\nGetConfig action"); ManagerResponse response = manager.SendAction(new GetConfigAction("manager.conf")); if (response.IsSuccess()) { GetConfigResponse responseConfig = (GetConfigResponse)response; foreach (int key in responseConfig.Categories.Keys) { Console.WriteLine(string.Format("{0}:{1}", key, responseConfig.Categories[key])); foreach (int keyLine in responseConfig.Lines(key).Keys) { Console.WriteLine(string.Format("\t{0}:{1}", keyLine, responseConfig.Lines(key)[keyLine])); } } } else { Console.WriteLine(response); } } { Console.WriteLine("\nUpdateConfig action"); UpdateConfigAction config = new UpdateConfigAction("manager.conf", "manager.conf"); config.AddCommand(UpdateConfigAction.ACTION_NEWCAT, "testadmin"); config.AddCommand(UpdateConfigAction.ACTION_APPEND, "testadmin", "secret", "blabla"); ManagerResponse response = manager.SendAction(config); Console.WriteLine(response); } // Originate call example Console.WriteLine("\nPress ENTER key to originate call.\n" + "Start phone (or connect) or make a call to see events.\n" + "After all events press a key to originate call."); Console.ReadLine(); OriginateAction oc = new OriginateAction(); oc.Context = ORIGINATE_CONTEXT; oc.Priority = "1"; oc.Channel = ORIGINATE_CHANNEL; oc.CallerId = ORIGINATE_CALLERID; oc.Exten = ORIGINATE_EXTEN; oc.Timeout = ORIGINATE_TIMEOUT; // oc.Variable = "VAR1=abc|VAR2=def"; // oc.SetVariable("VAR3", "ghi"); ManagerResponse originateResponse = manager.SendAction(oc, oc.Timeout); Console.WriteLine("Response:"); Console.WriteLine(originateResponse); Console.WriteLine("Press ENTER key to next test."); Console.ReadLine(); // // Display result of Show Queues command // { CommandAction command = new CommandAction(); CommandResponse response = new CommandResponse(); if (manager.AsteriskVersion == AsteriskVersion.ASTERISK_1_6) { command.Command = "queue show"; } else { command.Command = "show queues"; } try { response = (CommandResponse)manager.SendAction(command); Console.WriteLine("Result of " + command.Command); foreach (string str in response.Result) { Console.WriteLine("\t" + str); } } catch (Exception err) { Console.WriteLine("Response error: " + err); } Console.WriteLine("Press ENTER to next test or CTRL-C to exit."); Console.ReadLine(); } // // Display Queues and Members // ResponseEvents re; try { re = manager.SendEventGeneratingAction(new QueueStatusAction()); } catch (EventTimeoutException e) { // this happens with Asterisk 1.0.x as it doesn't send a QueueStatusCompleteEvent re = e.PartialResult; } foreach (ManagerEvent e in re.Events) { if (e is QueueParamsEvent) { QueueParamsEvent qe = (QueueParamsEvent)e; Console.WriteLine("QueueParamsEvent" + "\n\tQueue:\t\t" + qe.Queue + "\n\tServiceLevel:\t" + qe.ServiceLevel); } else if (e is QueueMemberEvent) { QueueMemberEvent qme = (QueueMemberEvent)e; Console.WriteLine("QueueMemberEvent" + "\n\tQueue:\t\t" + qme.Queue + "\n\tLocation:\t" + qme.Location); } else if (e is QueueEntryEvent) { QueueEntryEvent qee = (QueueEntryEvent)e; Console.WriteLine("QueueEntryEvent" + "\n\tQueue:\t\t" + qee.Queue + "\n\tChannel:\t" + qee.Channel + "\n\tPosition:\t" + qee.Position); } } Console.WriteLine("Press ENTER to next test or CTRL-C to exit."); Console.ReadLine(); // // To test create 3 extensions: // 1 - SIP/4012 w/o voicemail (with eyeBeam softphone) // 2 - IAX2/4008 w/o voicemail (with iaxComm softphone) // 3 - SIP/4010 w/ voicemal but no phone connect // RedirectCall: call from IAX2/4008 to SIP/4012 // Don't answer on SIP/4012 and call must redirect to SIP/4010 (to voicemail really) // Dial event used to define redirect channel Console.WriteLine("Redirect Call from " + ORIGINATE_CHANNEL + " to " + ORIGINATE_EXTRA_CHANNEL + " or press ESC."); // Wait for Dial Event from ORIGINATE_CHANNEL DialEventHandler de = new DialEventHandler(dam_Dial); manager.Dial += de; while (transferChannel == null) { System.Threading.Thread.Sleep(100); if (Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape) { break; } } manager.Dial -= de; // Now send Redirect action RedirectAction ra = new RedirectAction(); ra.Channel = transferChannel; ra.ExtraChannel = ORIGINATE_EXTRA_CHANNEL; ra.Context = ORIGINATE_CONTEXT; ra.Exten = ORIGINATE_EXTRA_EXTEN; ra.Priority = 1; try { ManagerResponse mr = manager.SendAction(ra, 10000); Console.WriteLine("Transfer Call" + "\n\tResponse:" + mr.Response + "\n\tMessage:" + mr.Message ); } catch (Exception ex) { Console.WriteLine(ex.Message); } // Monitor call. // Call from IA2/4008 to SIP/4012 // Link event used to define monitor channel Console.WriteLine("Monitor call. Please call " + ORIGINATE_CHANNEL + " and answer or press ESC."); // Wait for Link event LinkEventHandler le = new LinkEventHandler(dam_Link); manager.Link += le; while (monitorChannel == null) { System.Threading.Thread.Sleep(100); if (Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape) { break; } } manager.Link -= le; // Now send Monitor action MonitorAction ma = new MonitorAction(); ma.Channel = monitorChannel; ma.File = "voicefile"; ma.Format = "gsm"; ma.Mix = true; try { ManagerResponse mr = manager.SendAction(ma, 10000); Console.WriteLine("Monitor Call" + "\n\tResponse:" + mr.Response); } catch (Exception ex) { Console.WriteLine(ex.Message); } manager.Logoff(); }
/// <inheritdoc /> protected sealed override async Task MonitorLifetimes(CancellationToken cancellationToken) { Logger.LogTrace("Entered MonitorLifetimes"); // this function is responsible for calling HandlerMonitorWakeup when necessary and manitaining the MonitorState var iteration = 1; for (MonitorAction nextAction = MonitorAction.Continue; nextAction != MonitorAction.Exit; ++iteration) { // always start out with continue nextAction = MonitorAction.Continue; // dump some info to the logs Logger.LogDebug("Iteration {0} of monitor loop", iteration); try { Logger.LogDebug("Server Compile Job ID: {0}", Server.Dmb.CompileJob.Id); // load the activation tasks into local variables Task activeServerLifetime = Server.Lifetime; var activeServerReboot = Server.OnReboot; Task activeLaunchParametersChanged = ActiveParametersUpdated.Task; var newDmbAvailable = DmbFactory.OnNewerDmb; // cancel waiting if requested var cancelTcs = new TaskCompletionSource <object>(); using (cancellationToken.Register(() => cancelTcs.SetCanceled())) { var toWaitOn = Task.WhenAny(activeServerLifetime, activeServerReboot, newDmbAvailable, cancelTcs.Task, activeLaunchParametersChanged); // wait for something to happen await toWaitOn.ConfigureAwait(false); cancellationToken.ThrowIfCancellationRequested(); } var chatTask = Task.CompletedTask; using (await SemaphoreSlimContext.Lock(Semaphore, cancellationToken).ConfigureAwait(false)) { // always run HandleMonitorWakeup from the context of the semaphore lock // multiple things may have happened, handle them one at a time for (var moreActivationsToProcess = true; moreActivationsToProcess && (nextAction == MonitorAction.Continue || nextAction == MonitorAction.Skip);) { MonitorActivationReason activationReason = default; // this will always be assigned before being used // process the tasks in this order and call HandlerMonitorWakup for each bool CheckActivationReason(ref Task task, MonitorActivationReason testActivationReason) { var taskCompleted = task?.IsCompleted == true; task = null; if (nextAction == MonitorAction.Skip) { nextAction = MonitorAction.Continue; } else if (taskCompleted) { activationReason = testActivationReason; return(true); } return(false); } if (CheckActivationReason(ref activeServerLifetime, MonitorActivationReason.ActiveServerCrashed) || CheckActivationReason(ref activeServerReboot, MonitorActivationReason.ActiveServerRebooted) || CheckActivationReason(ref newDmbAvailable, MonitorActivationReason.NewDmbAvailable) || CheckActivationReason(ref activeLaunchParametersChanged, MonitorActivationReason.ActiveLaunchParametersUpdated)) { Logger.LogTrace("Monitor activation: {0}", activationReason); nextAction = await HandleMonitorWakeup(activationReason, cancellationToken).ConfigureAwait(false); } else { moreActivationsToProcess = false; } } } // full reboot required if (nextAction == MonitorAction.Restart) { Logger.LogDebug("Next state action is to restart"); DisposeAndNullControllers(); for (var retryAttempts = 1; nextAction == MonitorAction.Restart; ++retryAttempts) { Exception launchException = null; using (await SemaphoreSlimContext.Lock(Semaphore, cancellationToken).ConfigureAwait(false)) try { // use LaunchImplNoLock without announcements or restarting the monitor await LaunchImplNoLock(false, false, null, cancellationToken).ConfigureAwait(false); if (Running) { Logger.LogDebug("Relaunch successful, resetting monitor state..."); break; // continue on main loop } } catch (OperationCanceledException) { throw; } catch (Exception e) { launchException = e; } await chatTask.ConfigureAwait(false); if (!Running) { if (launchException == null) { Logger.LogWarning("Failed to automatically restart the watchdog! Attempt: {0}", retryAttempts); } else { Logger.LogWarning("Failed to automatically restart the watchdog! Attempt: {0}, Exception: {1}", retryAttempts, launchException); } var retryDelay = Math.Min(Math.Pow(2, retryAttempts), 3600); // max of one hour, increasing by a power of 2 each time chatTask = Chat.SendWatchdogMessage(String.Format(CultureInfo.InvariantCulture, "Failed to restart watchdog (Attempt: {0}), retrying in {1} seconds...", retryAttempts, retryDelay), cancellationToken); await Task.WhenAll(AsyncDelayer.Delay(TimeSpan.FromSeconds(retryDelay), cancellationToken), chatTask).ConfigureAwait(false); } } } } catch (OperationCanceledException) { Logger.LogDebug("Monitor cancelled"); break; } catch (Exception e) { // really, this should NEVER happen Logger.LogError("Monitor crashed! Iteration: {0}, NextAction: {1}, Exception: {2}", iteration, nextAction, e); await Chat.SendWatchdogMessage(String.Format(CultureInfo.InvariantCulture, "Monitor crashed, this should NEVER happen! Please report this, full details in logs! Restarting monitor... Error: {0}", e.Message), cancellationToken).ConfigureAwait(false); } } Logger.LogTrace("Monitor exiting..."); }
public static void RegisterUpdateAction(string name, MonitorAction action) { if( !updateActions.ContainsKey( name ) ) updateActions.Add(name, action); }
public static void RegisterTickAction(string name, MonitorAction action) { if( !tickActions.ContainsKey( name ) ) tickActions.Add(name, action); }
public static void RegisterOccasionalAction(string name, MonitorAction action) { if( !occasionalActions.ContainsKey( name ) ) occasionalActions.Add(name, action); }
public FilteredProgressMonitor(IProgressMonitor targetMonitor, MonitorAction actionMask) { AddSlaveMonitor(targetMonitor, actionMask); }
private void PerformMonitorAction(string options, string callbackId, string caller, MonitorAction action) { PerformMonitorAction(options, callbackId, caller, args => { action(args); return null; }); }
public void AddSlaveMonitor (ProgressMonitor slaveMonitor, MonitorAction actionMask) { MonitorInfo smon = new MonitorInfo (); smon.ActionMask = actionMask; smon.Monitor = slaveMonitor; monitors.Add (smon); if ((actionMask & MonitorAction.SlaveCancel) != 0) smon.CancellationTokenRegistration = slaveMonitor.CancellationToken.Register (OnSlaveCancelRequested); }
private void PerformMonitorAction(string options, string callbackId, string caller, MonitorAction action) { PerformMonitorAction(options, callbackId, caller, args => { action(args); return(null); }); }
public FilteredProgressMonitor (ProgressMonitor targetMonitor, MonitorAction actionMask) { AddFollowerMonitor (targetMonitor, actionMask); }
public override Enum GetAction(MonitorAction action) { Enum eEnum = null; switch (action) { case MonitorAction.getMonitors: eEnum = ExternalMonitorAction.tests; break; case MonitorAction.getMonitorInfo: eEnum = ExternalMonitorAction.testinfo; break; case MonitorAction.getMonitorResults: eEnum = ExternalMonitorAction.testresult; break; case MonitorAction.suspendMonitors: eEnum = ExternalMonitorAction.suspendExternalMonitor; break; case MonitorAction.activateMonitors: eEnum = ExternalMonitorAction.activateExternalMonitor; break; } return eEnum; }
public static void RegisterExposeDataAction(string name, MonitorAction action) { if( !exposeActions.ContainsKey( name ) ) exposeActions.Add(name, action); }
public FilteredProgressMonitor (ProgressMonitor targetMonitor, MonitorAction actionMask) { AddSlaveMonitor (targetMonitor, actionMask); }
private void Monitor() { IISModel iisModel = MonitorAction.Instance().GetIISInformation(); }