From: Omar Tarabai Date: Mon, 5 May 2014 15:46:28 +0000 (+0000) Subject: executing sensor processes OK X-Git-Tag: initial-import-from-subversion-38251~4121 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=4864f0e9dd779f5a36c798293336e5aab4ad685a;p=oweals%2Fgnunet.git executing sensor processes OK --- diff --git a/src/sensor/Makefile.am b/src/sensor/Makefile.am index fe461d1bc..e3d9bbe69 100644 --- a/src/sensor/Makefile.am +++ b/src/sensor/Makefile.am @@ -64,7 +64,5 @@ install-data-local: $(mkinstalldirs) $(datadir)/$(PACKAGE)/$(pkgsensordir) @$(NORMAL_INSTALL) for sensor in $(pkgsensordir)/*; do \ - if test -f $$sensor; then \ - $(INSTALL_DATA) $$sensor $(datadir)/$(PACKAGE)/$(pkgsensordir)/ ; \ - fi \ + cp -a $$sensor $(datadir)/$(PACKAGE)/$(pkgsensordir)/ ; \ done diff --git a/src/sensor/gnunet-service-sensor.c b/src/sensor/gnunet-service-sensor.c index 7718fafee..b831b2be7 100644 --- a/src/sensor/gnunet-service-sensor.c +++ b/src/sensor/gnunet-service-sensor.c @@ -776,6 +776,24 @@ void end_sensor_run_stat (void *cls, int success) sensorinfo->running = GNUNET_NO; } +/** + * Callback for output of executed sensor process + * + * @param cls 'struct SensorInfo *' + * @param line line of output from a command, NULL for the end + */ +void sensor_process_callback (void *cls, const char *line) +{ + struct SensorInfo *sensorinfo = cls; + + if(NULL == line) + { + sensorinfo->running = GNUNET_NO; + return; + } + GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Received a value for sensor `%s': %s\n", sensorinfo->name, line); +} + /** * Actual execution of a sensor * @@ -788,6 +806,8 @@ sensor_run (void *cls, { struct SensorInfo *sensorinfo = cls; int check_result; + char *sensors_dir; + char *process_path; sensorinfo->execution_task = GNUNET_SCHEDULER_add_delayed(sensorinfo->interval, &sensor_run, sensorinfo); if(GNUNET_YES == sensorinfo->running) //FIXME: should we try to kill? @@ -815,13 +835,45 @@ sensor_run (void *cls, } else if(sources[1] == sensorinfo->source) { + /*GNUNET_OS_start_process_s(GNUNET_NO, + GNUNET_OS_INHERIT_STD_OUT_AND_ERR, + NULL, + "touch", + "touch /home/omar/hiii");*/ + /*GNUNET_OS_start_process(GNUNET_NO, + GNUNET_OS_INHERIT_STD_OUT_AND_ERR, + NULL, + NULL, + NULL, + "/home/omar/workspace/gnunet/src/sensor/sensors/averagepingrtt-files/avgping.sh", + "avgping.sh", + NULL); + GNUNET_OS_start_process(GNUNET_NO, + GNUNET_OS_INHERIT_STD_OUT_AND_ERR, + NULL, + NULL, + NULL, + "whoami", + "whoami", + NULL);*/ + //FIXME: break execution if process is a path //check if the process exists in $PATH + process_path = GNUNET_strdup(sensorinfo->ext_process); check_result = GNUNET_OS_check_helper_binary(sensorinfo->ext_process, GNUNET_NO, NULL); //search in $PATH if(GNUNET_SYSERR == check_result) { //search in sensor directory - + sensors_dir = get_sensor_dir(); + GNUNET_free(process_path); + GNUNET_asprintf(&process_path, "%s%s-files%s%s", + sensors_dir, + sensorinfo->name, + DIR_SEPARATOR_STR, + sensorinfo->ext_process); + GNUNET_free(sensors_dir); + check_result = + GNUNET_OS_check_helper_binary(process_path, GNUNET_NO, NULL); } if(GNUNET_SYSERR == check_result) { @@ -830,12 +882,25 @@ sensor_run (void *cls, sensorinfo->ext_process); //FIXME: disable sensor here? sensorinfo->running = GNUNET_NO; + GNUNET_free(process_path); return; } - else if(GNUNET_NO == check_result) - { - - } + /*GNUNET_OS_start_process(GNUNET_NO, + GNUNET_OS_INHERIT_STD_OUT_AND_ERR, + NULL, + NULL, + NULL, + process_path, + sensorinfo->ext_process, + sensorinfo->ext_args, + NULL)*/ + GNUNET_OS_command_run(&sensor_process_callback, + sensorinfo, + GNUNET_TIME_UNIT_FOREVER_REL, + process_path, + sensorinfo->ext_process, + sensorinfo->ext_args, + NULL); GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Process started for sensor `%s'\n", sensorinfo->name); } else diff --git a/src/sensor/sensors/averagepingrtt b/src/sensor/sensors/averagepingrtt index 2012f555e..b8880c696 100644 --- a/src/sensor/sensors/averagepingrtt +++ b/src/sensor/sensors/averagepingrtt @@ -3,13 +3,13 @@ VERSION = 1.0 DESCRIPTION = Calculate average ping latency to gnunet.org CATEGORY = Internet-Connectivity -ENABLED = NO +ENABLED = YES # Start and end time format: %Y-%m-%d %H:%M:%S #START_TIME = #END_TIME = #Interval in seconds -INTERVAL = 3600 +INTERVAL = 30 #LIFETIME = #CAPABILITIES = diff --git a/src/sensor/sensors/gnunetversion b/src/sensor/sensors/gnunetversion index deb0e5f2d..dd213b605 100644 --- a/src/sensor/sensors/gnunetversion +++ b/src/sensor/sensors/gnunetversion @@ -9,8 +9,8 @@ ENABLED = YES #START_TIME = #END_TIME = #Interval in seconds -INTERVAL = 86400 -LIFETIME = 86400 +INTERVAL = 30 +LIFETIME = 30 #CAPABILITIES =