]> git.sur5r.net Git - bacula/bacula/commitdiff
Add RefreshInterval to tray-monitor.conf
authorNicolas Boichat <nicolas@boichat.ch>
Wed, 25 Aug 2004 13:13:33 +0000 (13:13 +0000)
committerNicolas Boichat <nicolas@boichat.ch>
Wed, 25 Aug 2004 13:13:33 +0000 (13:13 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1555 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/tray-monitor/TODO
bacula/src/tray-monitor/tray-monitor.c
bacula/src/tray-monitor/tray-monitor.conf.in
bacula/src/tray-monitor/tray_conf.c
bacula/src/tray-monitor/tray_conf.h

index 4bba59373e6e70aaba36af69fe660acd948f7ff9..47e81a294bb632f448e91b273ab89719fd1dc832 100644 (file)
@@ -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
index c1af26d1f46c1523efd43c4e5cb406118a01351d..481b669762e531f779beee870590cf79cf82eb74 100644 (file)
@@ -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);
index bdf17307e974909abd178b52db295b0a95c62b42..2e5870348d550dbafae1ff9701d735807210227a 100644 (file)
@@ -5,6 +5,7 @@
 Monitor {
   Name = @hostname@-mon
   Password = "@mon_dir_password@"         # password for the Directors   
+  RefreshInterval = 5 seconds
 }
    
 Client {
index c5c7c98b54a2d557be0bdc62c76eba60409e8f9a..0c53f17d00f22d4e3e1532d993a2e3cbb25a8a36 100644 (file)
@@ -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}
index 6e57878216bed6cc49099f57dabf085df4b49598..0ee985f710e66316094fbeb66d10148f78223b7c 100644 (file)
@@ -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 */
 };