예제 #1
0
        private void validateSettings()
        {
            //Validate settings and pre-select listbox items

            //Test login
            demoClient = new Icinga2Client(
                txt_url.Text,
                txt_username.Text,
                txt_password.Text,
                (track_timer.Value * 1000 * 60)
                );

            //Retrieve hostgroups
            try
            {
                List <apiDataset> hostgroups = demoClient.getInventory("HostGroup");
                foreach (apiDataset entry in hostgroups)
                {
                    //add entry
                    lbox_hostgroups.Items.Add(entry.name + " (" + entry.attrs.display_name + ")");
                }
            }
            catch (NullReferenceException)
            {
                MessageBox.Show(rm.GetString("msgbox_icinga_unavailable"), rm.GetString("msgbox_error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                SimpleLoggerHelper.Log(Properties.Settings.Default.log_mode, "Unable to connect to Icinga2 instance", Properties.Settings.Default.log_level);
            }
            catch (FormatException)
            {
                MessageBox.Show(rm.GetString("msgbox_icinga_unavailable"), rm.GetString("msgbox_error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                SimpleLoggerHelper.Log(Properties.Settings.Default.log_mode, "Unable to connect to Icinga2 instance", Properties.Settings.Default.log_level);
            }
        }
예제 #2
0
        void initializeThread()
        {
            //Create and (re-)start data thread
            workerObject = new Icinga2Client(
                Properties.Settings.Default.icinga_url,
                Properties.Settings.Default.icinga_user,
                Properties.Settings.Default.icinga_pass,
                (Properties.Settings.Default.icinga_update_interval * 1000 * 60)
                );

            //Set hostgroup filter
            if (Properties.Settings.Default.icinga_hostgroups.Length > 0)
            {
                workerObject.setHostgroups(Properties.Settings.Default.icinga_hostgroups.Split(';'));
            }

            //Update _all_ the data
            dataThread = new Thread(workerObject.updateData);
            //Set update event
            workerObject.complete   += WorkerObject_complete;
            workerObject.inProgress += WorkerObject_inProgress;
        }