From: Nicolas Boichat Date: Wed, 25 Aug 2004 13:13:33 +0000 (+0000) Subject: Add RefreshInterval to tray-monitor.conf X-Git-Tag: Release-1.35.2~18 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7b8a40a1b9db92b89f56a0c77c8f346a51337ec5;p=bacula%2Fbacula Add RefreshInterval to tray-monitor.conf git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1555 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/tray-monitor/TODO b/bacula/src/tray-monitor/TODO index 4bba59373e..47e81a294b 100644 --- a/bacula/src/tray-monitor/TODO +++ b/bacula/src/tray-monitor/TODO @@ -1 +1,2 @@ - - Check status of the FD/SD in a separate thread. \ No newline at end of file + - Check status of the FD/SD in a separate thread. + - Left light should be blinking diff --git a/bacula/src/tray-monitor/tray-monitor.c b/bacula/src/tray-monitor/tray-monitor.c index c1af26d1f4..481b669762 100644 --- a/bacula/src/tray-monitor/tray-monitor.c +++ b/bacula/src/tray-monitor/tray-monitor.c @@ -190,6 +190,16 @@ int main(int argc, char *argv[]) parse_config(configfile); LockRes(); + nitems = 0; + foreach_res(monitor, R_MONITOR) { + nitems++; + } + + if (nitems != 1) { + Emsg2(M_ERROR_TERM, 0, + _("Error: %d Monitor resource defined in %s. You must define one and only one Monitor resource.\n"), nitems, configfile); + } + nitems = 0; foreach_res(dird, R_DIRECTOR) { items[nitems].type = R_DIRECTOR; @@ -215,8 +225,8 @@ int main(int argc, char *argv[]) UnlockRes(); if (nitems == 0) { - Emsg1(M_ERROR_TERM, 0, _("No Client nor Storage resource defined in %s\n\ -Without that I don't how to get status from the File or Storage Daemon :-(\n"), configfile); + Emsg1(M_ERROR_TERM, 0, _("No Client, Storage nor Director resource defined in %s\n\ +Without that I don't how to get status from the File, Storage or Director Daemon :-(\n"), configfile); } if (test_config) { @@ -224,18 +234,23 @@ Without that I don't how to get status from the File or Storage Daemon :-(\n"), } //Copy the content of xpm_generic in xpm_generic_var to be able to modify it - xpm_generic_var = (char**)g_malloc(sizeof(xpm_generic)); + g_assert((xpm_generic_var = (char**)g_malloc(sizeof(xpm_generic)))); for (i = 0; i < (int)(sizeof(xpm_generic)/sizeof(const char*)); i++) { - xpm_generic_var[i] = (char*)g_malloc(strlen(xpm_generic[i])*sizeof(char)); + g_assert((xpm_generic_var[i] = (char*)g_malloc(strlen(xpm_generic[i])*sizeof(char)))); strcpy(xpm_generic_var[i], xpm_generic[i]); } (void)WSA_Init(); /* Initialize Windows sockets */ - + LockRes(); monitor = (MONITOR*)GetNextRes(R_MONITOR, (RES *)NULL); UnlockRes(); + if ((monitor->RefreshInterval < 1) || (monitor->RefreshInterval > 600)) { + Emsg2(M_ERROR_TERM, 0, _("Invalid refresh interval defined in %s\n\ +This value must be greater or equal to 1 second and less or equal to 10 minutes (read value: %d).\n"), configfile, monitor->RefreshInterval); + } + gtk_init (&argc, &argv); GdkPixbuf* pixbuf = gdk_pixbuf_new_from_xpm_data(generateXPM(warn, warn)); @@ -261,7 +276,7 @@ Without that I don't how to get status from the File or Storage Daemon :-(\n"), gtk_widget_show_all(mTrayMenu); - timerTag = g_timeout_add( 2000, fd_read, NULL ); + timerTag = g_timeout_add( monitor->RefreshInterval/nitems, fd_read, NULL ); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); @@ -354,7 +369,7 @@ Without that I don't how to get status from the File or Storage Daemon :-(\n"), GtkWidget* hbox2 = gtk_hbox_new(FALSE, 0); GtkWidget* label = gtk_label_new(_("Refresh interval in seconds: ")); gtk_box_pack_start(GTK_BOX(hbox2), label, TRUE, FALSE, 0); - GtkAdjustment *spinner_adj = (GtkAdjustment *) gtk_adjustment_new (nitems*2, nitems, 120.0, 1.0, 5.0, 5.0); + GtkAdjustment *spinner_adj = (GtkAdjustment *) gtk_adjustment_new (monitor->RefreshInterval, 1.0, 600.0, 1.0, 5.0, 5.0); timeoutspinner = gtk_spin_button_new (spinner_adj, 1.0, 0); g_signal_connect(G_OBJECT(timeoutspinner), "value-changed", G_CALLBACK(IntervalChanged), NULL); gtk_box_pack_start(GTK_BOX(hbox2), timeoutspinner, TRUE, FALSE, 0); diff --git a/bacula/src/tray-monitor/tray-monitor.conf.in b/bacula/src/tray-monitor/tray-monitor.conf.in index bdf17307e9..2e5870348d 100644 --- a/bacula/src/tray-monitor/tray-monitor.conf.in +++ b/bacula/src/tray-monitor/tray-monitor.conf.in @@ -5,6 +5,7 @@ Monitor { Name = @hostname@-mon Password = "@mon_dir_password@" # password for the Directors + RefreshInterval = 5 seconds } Client { diff --git a/bacula/src/tray-monitor/tray_conf.c b/bacula/src/tray-monitor/tray_conf.c index c5c7c98b54..0c53f17d00 100644 --- a/bacula/src/tray-monitor/tray_conf.c +++ b/bacula/src/tray-monitor/tray_conf.c @@ -76,6 +76,7 @@ static RES_ITEM mon_items[] = { {"description", store_str, ITEM(res_monitor.hdr.desc), 0, 0, 0}, {"requiressl", store_yesno, ITEM(res_monitor.require_ssl), 1, ITEM_DEFAULT, 0}, {"password", store_password, ITEM(res_monitor.password), 0, ITEM_REQUIRED, 0}, + {"refreshinterval", store_time,ITEM(res_monitor.RefreshInterval), 0, ITEM_DEFAULT, 5}, {"fdconnecttimeout", store_time,ITEM(res_monitor.FDConnectTimeout), 0, ITEM_DEFAULT, 60 * 30}, {"sdconnecttimeout", store_time,ITEM(res_monitor.SDConnectTimeout), 0, ITEM_DEFAULT, 60 * 30}, {NULL, NULL, NULL, 0, 0, 0} diff --git a/bacula/src/tray-monitor/tray_conf.h b/bacula/src/tray-monitor/tray_conf.h index 6e57878216..0ee985f710 100644 --- a/bacula/src/tray-monitor/tray_conf.h +++ b/bacula/src/tray-monitor/tray_conf.h @@ -70,6 +70,7 @@ struct MONITOR { int require_ssl; /* Require SSL for all connections */ MSGS *messages; /* Daemon message handler */ char *password; /* UA server password */ + utime_t RefreshInterval; /* Status refresh interval */ utime_t FDConnectTimeout; /* timeout for connect in seconds */ utime_t SDConnectTimeout; /* timeout in seconds */ };