- distribute peers equally among island nodes on SuperMUC
[oweals/gnunet.git] / src / testbed / gnunet_testbed_ll_monitor.c
1 /*
2       This file is part of GNUnet
3       (C) 2008--2013 Christian Grothoff (and other contributing authors)
4
5       GNUnet is free software; you can redistribute it and/or modify
6       it under the terms of the GNU General Public License as published
7       by the Free Software Foundation; either version 3, or (at your
8       option) any later version.
9
10       GNUnet is distributed in the hope that it will be useful, but
11       WITHOUT ANY WARRANTY; without even the implied warranty of
12       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13       General Public License for more details.
14
15       You should have received a copy of the GNU General Public License
16       along with GNUnet; see the file COPYING.  If not, write to the
17       Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18       Boston, MA 02111-1307, USA.
19  */
20
21 /**
22  * @file testbed/gnunet_testbed_ll_monitor.c
23  * @brief The load level monitor process. This is called whenever a job event
24  *          happens. This file is called with the following syntax:
25  *          "monitor_program job_id user_arg state exit_status"
26  * @author Sree Harsha Totakura <sreeharsha@totakura.in>
27  */
28
29 #include "platform.h"
30 #include "gnunet_common.h"
31 #include <llapi.h>
32
33
34 /**
35  * Main function
36  *
37  * @param argc the number of command line arguments
38  * @param argv command line arg array
39  * @return return code
40  */
41 int
42 main (int argc, char **argv)
43 {
44   char *job_id;
45   char *user_arg;
46   char *state;
47   char *exit_status;
48   char *outfile;
49   FILE *out;
50
51   if (5 != argc)
52   {
53     fprintf (stderr, "Invalid number of arguments\n");
54     return 1;
55   }
56   job_id = argv[1];
57   user_arg = argv[2];
58   state = argv[3];
59   exit_status = argv[4];
60   PRINTF ("Job id: %s\n", job_id);
61   PRINTF ("\t User arg: %s \n", user_arg);
62   PRINTF ("\t Job state: %s \n", state);
63   PRINTF ("\t Exit status: %s \n", exit_status);
64
65   if (-1 == asprintf (&outfile, "job-%s.status", job_id))
66     return 1;
67   out = fopen (outfile, "a");
68   if (NULL == out)
69     return 1;
70   fprintf (out, "Job id: %s\n", job_id);
71   fprintf (out, "\t User arg: %s \n", user_arg);
72   fprintf (out, "\t Job state: %s \n", state);
73   fprintf (out, "\t Exit status: %s \n", exit_status);
74   fclose (out);
75   return 0;
76 }