示例#1
0
        public AgentContext()
        {
            //Import state strings
            dictStates.Add(0, rm.GetString("state_0"));
            dictStates.Add(1, rm.GetString("state_1"));
            dictStates.Add(2, rm.GetString("state_2"));
            dictStates.Add(3, rm.GetString("state_3"));
            dictStatesHost.Add(0, rm.GetString("state_0"));
            dictStatesHost.Add(1, rm.GetString("state_2"));
            dictStatesHost.Add(2, rm.GetString("state_2"));
            dictStatesHost.Add(3, rm.GetString("state_2"));

            //Import color settings
            color_up_ok        = Properties.Settings.Default.color_up_ok;
            color_unreach_warn = Properties.Settings.Default.color_unreach_warn;
            color_down_crit    = Properties.Settings.Default.color_down_crit;
            color_unknown      = Properties.Settings.Default.color_unknown;
            dictColor.Add(0, new BusylightColor
            {
                RedRgbValue   = color_up_ok.R,
                GreenRgbValue = color_up_ok.G,
                BlueRgbValue  = color_up_ok.B
            });
            dictColor.Add(1, new BusylightColor
            {
                RedRgbValue   = color_unreach_warn.R,
                GreenRgbValue = color_unreach_warn.G,
                BlueRgbValue  = color_unreach_warn.B
            });
            dictColor.Add(2, new BusylightColor
            {
                RedRgbValue   = color_down_crit.R,
                GreenRgbValue = color_down_crit.G,
                BlueRgbValue  = color_down_crit.B
            });
            dictColor.Add(3, new BusylightColor
            {
                RedRgbValue   = color_unknown.R,
                GreenRgbValue = color_unknown.G,
                BlueRgbValue  = color_unknown.B
            });
            dictColorHost.Add(0, new BusylightColor
            {
                RedRgbValue   = color_up_ok.R,
                GreenRgbValue = color_up_ok.G,
                BlueRgbValue  = color_up_ok.B
            });
            dictColorHost.Add(1, new BusylightColor
            {
                RedRgbValue   = color_down_crit.R,
                GreenRgbValue = color_down_crit.G,
                BlueRgbValue  = color_down_crit.B
            });
            dictColorHost.Add(2, new BusylightColor
            {
                RedRgbValue   = color_down_crit.R,
                GreenRgbValue = color_down_crit.G,
                BlueRgbValue  = color_down_crit.B
            });
            dictColorHost.Add(3, new BusylightColor
            {
                RedRgbValue   = color_down_crit.R,
                GreenRgbValue = color_down_crit.G,
                BlueRgbValue  = color_down_crit.B
            });

            //Import sound settings
            sound      = Properties.Settings.Default.sound;
            volume     = Properties.Settings.Default.sound_volume;
            sound_file = Properties.Settings.Default.sound_file;

            //Initialize tray icon
            trayIcon = new NotifyIcon()
            {
                Icon        = Properties.Resources.icinga,
                ContextMenu = new ContextMenu(
                    new MenuItem[] {
                    new MenuItem(rm.GetString("mnu_configure"), configure),
                    new MenuItem(rm.GetString("mnu_update"), update),
                    new MenuItem("-"),
                    new MenuItem(rm.GetString("mnu_about"), about),
                    new MenuItem(rm.GetString("mnu_exit"), exit)
                }
                    ),
                Visible = true,
                Text    = "Icinga Busylight Agent"
            };

            //Start data thread
            initializeThread();

            //Show tool-tip
            Assembly     assem     = Assembly.GetEntryAssembly();
            AssemblyName assemName = assem.GetName();
            Version      ver       = assemName.Version;

            if (Properties.Settings.Default.balloon_enable_start == true)
            {
                showTip(rm.GetString("welcome_title"),
                        "Icinga Busylight Agent " + ver.ToString() + " " +
                        rm.GetString("welcome_message"), ToolTipIcon.Info);
            }

            //Initialize log
            SimpleLoggerHelper.Log(Properties.Settings.Default.log_mode, string.Format("Application startup completed at {0}", DateTime.Now.ToString()), Properties.Settings.Default.log_level, 2);
        }
 private static void alert(BusylightColor color, BusylightSoundClip sound = BusylightSoundClip.FairyTale, BusylightVolume volume = BusylightVolume.Middle)
 {
     sdk.Light(BusylightColor.Off);
     sdk.Alert(color, sound, volume);
 }