@@ -81,6 +81,7 @@ qevent_options *Global_qevent_options;
8181static void qevent_show_usage ();
8282static void qevent_testsuite_mode (sge_evc_class_t *evc);
8383static void qevent_subscribe_mode (sge_evc_class_t *evc);
84+ static void qevent_monitor_all_mode (sge_evc_class_t *evc);
8485static const char * qevent_get_event_name (int event);
8586static void qevent_trigger_scripts (int qevent_event, qevent_options *option_struct, lListElem *event);
8687static void qevent_start_trigger_script (int qevent_event, const char * script_file, lListElem *event);
@@ -326,11 +327,13 @@ static void qevent_show_usage() {
326327
327328 fprintf (stdout," qevent [-h|-help] -ts|-testsuite\n " );
328329 fprintf (stdout," qevent [-h|-help] -sm|-subscribe\n " );
330+ fprintf (stdout," qevent [-h|-help] -am|-all\n " );
329331 fprintf (stdout," qevent [-h|-help] -trigger EVENT SCRIPT [ -trigger EVENT SCRIPT, ... ]\n\n " );
330332
331333 fprintf (stdout," -h, -help show usage\n " );
332334 fprintf (stdout," -ts, -testsuite run in testsuite mode\n " );
333335 fprintf (stdout," -sm, -subscribe run in subscribe mode\n " );
336+ fprintf (stdout," -am, -all subscribe to and print all events\n " );
334337 fprintf (stdout," -trigger EVENT SCRIPT start SCRIPT (executable) when EVENT occurs\n " );
335338 fprintf (stdout," \n " );
336339 fprintf (stdout," SCRIPT - path to a executable shell script\n " );
@@ -351,6 +354,7 @@ static void qevent_parse_command_line([[maybe_unused]] int argc, char **argv, qe
351354 option_struct->help_option = 0 ;
352355 option_struct->testsuite_option = 0 ;
353356 option_struct->subscribe_option = 0 ;
357+ option_struct->monitor_all_option = 0 ;
354358 option_struct->trigger_option_count =0 ;
355359
356360 while (*(++argv)) {
@@ -366,6 +370,10 @@ static void qevent_parse_command_line([[maybe_unused]] int argc, char **argv, qe
366370 option_struct->subscribe_option = 1 ;
367371 continue ;
368372 }
373+ if (!strcmp (" -am" , *argv) || !strcmp (" -all" , *argv)) {
374+ option_struct->monitor_all_option = 1 ;
375+ continue ;
376+ }
369377 if (!strcmp (" -trigger" , *argv)) {
370378 int ok = 0 ;
371379 if (option_struct->trigger_option_count >= MAX_TRIGGER_SCRIPTS ) {
@@ -512,6 +520,13 @@ int main(int argc, char *argv[])
512520 sge_exit (0 );
513521 }
514522
523+ /* check for monitor-all option */
524+ if (enabled_options.monitor_all_option ) {
525+ qevent_monitor_all_mode (evc);
526+ sge_dstring_free (enabled_options.error_message );
527+ sge_exit (0 );
528+ }
529+
515530 if (enabled_options.trigger_option_count > 0 ) {
516531 lCondition *where =nullptr ;
517532 lEnumeration *what = nullptr ;
@@ -747,3 +762,42 @@ static void qevent_subscribe_mode(sge_evc_class_t *evc)
747762 DRETURN_VOID ;
748763}
749764
765+ /* * @brief Subscribe to and print every event (diagnostic / testsuite mode).
766+ *
767+ * Subscribes to all event types (SGE_TYPE_ALL) and prints a one-line
768+ * description of every received event via print_event(), e.g.
769+ * "<n>. EVENT MOD PROJECT <name>" for a sgeE_PROJECT_MOD event. The function
770+ * blocks and keeps processing events until the client is shut down.
771+ *
772+ * Unlike the testsuite mode (-ts) and subscribe mode (-sm), which only
773+ * register for JOB and JATASK events, this mode makes every event type
774+ * observable. It is used by the testsuite to watch event types that are
775+ * otherwise invisible through qevent (e.g. PROJECT_MOD, see CS-2266).
776+ *
777+ * @param evc the enrolled event client to subscribe with and run
778+ */
779+ static void qevent_monitor_all_mode (sge_evc_class_t *evc)
780+ {
781+ DENTER (TOP_LAYER );
782+
783+ sge_mirror_initialize (evc, nullptr , nullptr , nullptr , nullptr , nullptr , nullptr );
784+ sge_mirror_subscribe (evc, SGE_TYPE_ALL , print_event, nullptr , nullptr , nullptr , nullptr );
785+
786+ // Deliver events quickly and flush PROJECT_MOD immediately, so that an
787+ // observer (e.g. the testsuite) sees them within a scheduler interval
788+ // instead of waiting for the default event delivery interval.
789+ evc->ec_set_edtime (evc, 2 );
790+ evc->ec_set_flush (evc, sgeE_PROJECT_MOD, true , 1 );
791+
792+ while (!shut_me_down) {
793+ sge_mirror_error error = sge_mirror_process_events (evc);
794+ if (error == SGE_EM_TIMEOUT && !shut_me_down) {
795+ sleep (10 );
796+ continue ;
797+ }
798+ }
799+
800+ sge_mirror_shutdown (evc);
801+ DRETURN_VOID ;
802+ }
803+
0 commit comments