]> git.sur5r.net Git - i3/i3status/blob - wmiistatus.c
ac1f778953c37484e82a4a04ac02dad85304a126
[i3/i3status] / wmiistatus.c
1 /*
2  * Generates a status line for use with wmii or other minimal window managers
3  *
4  *
5  * Copyright (c) 2008-2009 Michael Stapelberg and contributors
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without modification,
9  * are permitted provided that the following conditions are met:
10  *
11  * * Redistributions of source code must retain the above copyright notice, this
12  *   list of conditions and the following disclaimer.
13  *
14  * * Redistributions in binary form must reproduce the above copyright notice, this
15  *   list of conditions and the following disclaimer in the documentation and/or other
16  *   materials provided with the distribution.
17  *
18  * * Neither the name of Michael Stapelberg nor the names of contributors
19  *   may be used to endorse or promote products derived from this software without
20  *   specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
23  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
25  * SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
27  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
31  * DAMAGE.
32  *
33  */
34 #include <sys/types.h>
35 #include <sys/stat.h>
36 #include <fcntl.h>
37 #include <string.h>
38 #include <stdio.h>
39 #include <time.h>
40 #include <stdbool.h>
41 #include <stdarg.h>
42 #include <unistd.h>
43 #include <stdlib.h>
44 #include <limits.h>
45 #include <ctype.h>
46 #include <net/if.h>
47 #include <sys/ioctl.h>
48 #include <sys/socket.h>
49 #include <netinet/in.h>
50 #include <arpa/inet.h>
51 #include <glob.h>
52 #include <dirent.h>
53 #include <getopt.h>
54
55 #ifdef LINUX
56 #include <linux/ethtool.h>
57 #include <linux/sockios.h>
58 #else
59 /* TODO: correctly check for *BSD */
60 #include <sys/param.h>
61 #include <sys/sysctl.h>
62 #include <sys/resource.h>
63 #endif
64
65 #include "wmiistatus.h"
66
67 /* socket file descriptor for general purposes */
68 static int general_socket;
69
70 static const char *wlan_interface;
71 static const char *eth_interface;
72 static char *wmii_path;
73 static const char *time_format;
74 static const char *battery_path;
75 static bool use_colors;
76 static bool get_ethspeed;
77 static const char *wmii_normcolors = "#222222 #333333";
78 static char order[MAX_ORDER][2];
79 static const char **run_watches;
80 static unsigned int num_run_watches;
81 static unsigned int interval = 1;
82
83 /*
84  * This function just concats two strings in place, it should only be used
85  * for concatting order to the name of a file or concatting color codes.
86  * Otherwise, the buffer size would have to be increased.
87  *
88  */
89 static char *concat(const char *str1, const char *str2) {
90         static char concatbuf[32];
91         (void)snprintf(concatbuf, sizeof(concatbuf), "%s%s", str1, str2);
92         return concatbuf;
93 }
94
95 /*
96  * Cleans wmii's /rbar directory by deleting all regular files
97  *
98  */
99 static void cleanup_rbar_dir() {
100         struct dirent *ent;
101         DIR *dir;
102         char pathbuf[strlen(wmii_path)+256+1];
103
104         if ((dir = opendir(wmii_path)) == NULL)
105                 exit(EXIT_FAILURE);
106
107         while ((ent = readdir(dir)) != NULL) {
108                 if (ent->d_type == DT_REG) {
109                         (void)snprintf(pathbuf, sizeof(pathbuf), "%s%s", wmii_path, ent->d_name);
110                         if (unlink(pathbuf) == -1)
111                                 exit(EXIT_FAILURE);
112                 }
113         }
114
115         (void)closedir(dir);
116 }
117
118 /*
119  * Creates the specified file in wmii's /rbar directory with
120  * correct modes and initializes colors if colormode is enabled
121  *
122  */
123 static void create_file(const char *name) {
124         char pathbuf[strlen(wmii_path)+256+1];
125         int fd;
126         int flags = O_CREAT | O_WRONLY;
127         struct stat statbuf;
128
129         (void)snprintf(pathbuf, sizeof(pathbuf), "%s%s", wmii_path, name);
130
131         /* Overwrite file's contents if it exists */
132         if (stat(pathbuf, &statbuf) >= 0)
133                 flags |= O_TRUNC;
134
135         if ((fd = open(pathbuf, flags, S_IRUSR | S_IWUSR)) < 0)
136                 exit(EXIT_FAILURE);
137         if (use_colors) {
138                 char *tmp = concat("#888888 ", wmii_normcolors);
139                 if (write(fd, tmp, strlen(tmp)) != (ssize_t)strlen(tmp))
140                         exit(EXIT_FAILURE);
141         }
142         (void)close(fd);
143 }
144
145 /*
146  * Waits until wmii_path/rbar exists (= the filesystem gets mounted),
147  * cleans up all files and creates the needed files
148  *
149  */
150 static void setup(void) {
151         unsigned int i;
152         struct stat statbuf;
153         char pathbuf[512];
154
155         /* Wait until wmii_path/rbar exists */
156         for (; stat(wmii_path, &statbuf) < 0; sleep(interval));
157
158         cleanup_rbar_dir();
159         if (wlan_interface)
160                 create_file(concat(order[ORDER_WLAN],"wlan"));
161         if (eth_interface)
162                 create_file(concat(order[ORDER_ETH],"eth"));
163         if (battery_path)
164                 create_file(concat(order[ORDER_BATTERY],"battery"));
165         create_file(concat(order[ORDER_LOAD],"load"));
166         if (time_format)
167                 create_file(concat(order[ORDER_TIME],"time"));
168         for (i = 0; i < num_run_watches; i += 2) {
169                 snprintf(pathbuf, sizeof(pathbuf), "%s%s", order[ORDER_RUN], run_watches[i]);
170                 create_file(pathbuf);
171         }
172 }
173
174 /*
175  * Writes the given message in the corresponding file in wmii's /rbar directory
176  *
177  */
178 static void write_to_statusbar(const char *name, const char *message) {
179         char pathbuf[strlen(wmii_path)+256+1];
180         int fd;
181
182         (void)snprintf(pathbuf, sizeof(pathbuf), "%s%s", wmii_path, name);
183         if ((fd = open(pathbuf, O_RDWR)) == -1) {
184                 /* Try to re-setup stuff and just continue */
185                 setup();
186                 return;
187         }
188         if (write(fd, message, strlen(message)) != (ssize_t)strlen(message))
189                 exit(EXIT_FAILURE);
190         (void)close(fd);
191 }
192
193 /*
194  * Writes an errormessage to statusbar
195  *
196  */
197 static void write_error_to_statusbar(const char *message) {
198         cleanup_rbar_dir();
199         create_file("error");
200         write_to_statusbar("error", message);
201 }
202
203 /*
204  * Write errormessage to statusbar and exit
205  *
206  */
207 void die(const char *fmt, ...) {
208         if (wmii_path != NULL) {
209                 char buffer[512];
210                 va_list ap;
211                 va_start(ap, fmt);
212                 (void)vsnprintf(buffer, sizeof(buffer), fmt, ap);
213                 va_end(ap);
214
215                 write_error_to_statusbar(buffer);
216         }
217         exit(EXIT_FAILURE);
218 }
219
220 /*
221  * Skip the given character for exactly 'amount' times, returns
222  * a pointer to the first non-'character' character in 'input'.
223  *
224  */
225 static char *skip_character(char *input, char character, int amount) {
226         char *walk;
227         size_t len = strlen(input);
228         int blanks = 0;
229
230         for (walk = input; ((size_t)(walk - input) < len) && (blanks < amount); walk++)
231                 if (*walk == character)
232                         blanks++;
233
234         return (walk == input ? walk : walk-1);
235 }
236
237 /*
238  * Get battery information from /sys. Note that it uses the design capacity to
239  * calculate the percentage, not the last full capacity, so you can see how
240  * worn off your battery is.
241  *
242  */
243 static char *get_battery_info() {
244         char buf[1024];
245         static char part[512];
246         char *walk, *last;
247         int fd;
248         int full_design = -1,
249             remaining = -1,
250             present_rate = -1;
251         charging_status_t status = CS_DISCHARGING;
252
253         if ((fd = open(battery_path, O_RDONLY)) == -1)
254                 return "No battery found";
255
256         memset(part, 0, sizeof(part));
257         (void)read(fd, buf, sizeof(buf));
258         for (walk = buf, last = buf; (walk-buf) < 1024; walk++)
259                 if (*walk == '=') {
260                         if (BEGINS_WITH(last, "POWER_SUPPLY_ENERGY_FULL_DESIGN") ||
261                             BEGINS_WITH(last, "POWER_SUPPLY_CHARGE_FULL_DESIGN"))
262                                 full_design = atoi(walk+1);
263                         else if (BEGINS_WITH(last, "POWER_SUPPLY_ENERGY_NOW") ||
264                                  BEGINS_WITH(last, "POWER_SUPPLY_CHARGE_NOW"))
265                                 remaining = atoi(walk+1);
266                         else if (BEGINS_WITH(last, "POWER_SUPPLY_CURRENT_NOW"))
267                                 present_rate = atoi(walk+1);
268                         else if (BEGINS_WITH(last, "POWER_SUPPLY_STATUS=Charging"))
269                                 status = CS_CHARGING;
270                         else if (BEGINS_WITH(last, "POWER_SUPPLY_STATUS=Full"))
271                                 status = CS_FULL;
272                 } else if (*walk == '\n')
273                         last = walk+1;
274         (void)close(fd);
275
276         if ((full_design != -1) && (remaining != -1) && (present_rate != -1)) {
277                 float remaining_time;
278                 int seconds, hours, minutes;
279                 if (status == CS_CHARGING)
280                         remaining_time = ((float)full_design - (float)remaining) / (float)present_rate;
281                 else if (status == CS_DISCHARGING)
282                         remaining_time = ((float)remaining / (float)present_rate);
283                 else remaining_time = 0;
284
285                 seconds = (int)(remaining_time * 3600.0);
286                 hours = seconds / 3600;
287                 seconds -= (hours * 3600);
288                 minutes = seconds / 60;
289                 seconds -= (minutes * 60);
290
291                 (void)snprintf(part, sizeof(part), "%s %.02f%% %02d:%02d:%02d",
292                         (status == CS_CHARGING ? "CHR" :
293                          (status == CS_DISCHARGING ? "BAT" : "FULL")),
294                         (((float)remaining / (float)full_design) * 100),
295                         hours, minutes, seconds);
296         }
297         return part;
298 }
299
300 /*
301  * Return the IP address for the given interface or "no IP" if the
302  * interface is up and running but hasn't got an IP address yet
303  *
304  */
305 static const char *get_ip_address(const char *interface) {
306         static char part[512];
307         struct ifreq ifr;
308         struct sockaddr_in addr;
309         socklen_t len = sizeof(struct sockaddr_in);
310         memset(part, 0, sizeof(part));
311
312         (void)strcpy(ifr.ifr_name, interface);
313         ifr.ifr_addr.sa_family = AF_INET;
314         if (ioctl(general_socket, SIOCGIFADDR, &ifr) < 0)
315                 return NULL;
316
317         memcpy(&addr, &ifr.ifr_addr, len);
318         (void)inet_ntop(AF_INET, &addr.sin_addr.s_addr, part, len);
319         if (strlen(part) == 0)
320                 (void)snprintf(part, sizeof(part), "no IP");
321
322         return part;
323 }
324
325 /*
326  * Just parses /proc/net/wireless looking for lines beginning with
327  * wlan_interface, extracting the quality of the link and adding the
328  * current IP address of wlan_interface.
329  *
330  */
331 static char *get_wireless_info() {
332         char buf[1024];
333         static char part[512];
334         char *interfaces;
335         int fd;
336         memset(buf, 0, sizeof(buf));
337         memset(part, 0, sizeof(part));
338
339         if ((fd = open("/proc/net/wireless", O_RDONLY)) == -1)
340                 die("Could not open /proc/net/wireless\n");
341         (void)read(fd, buf, sizeof(buf));
342         (void)close(fd);
343
344         interfaces = skip_character(buf, '\n', 1) + 1;
345         while ((interfaces = skip_character(interfaces, '\n', 1)+1) < buf+strlen(buf)) {
346                 while (isspace((int)*interfaces))
347                         interfaces++;
348                 if (!BEGINS_WITH(interfaces, wlan_interface))
349                         continue;
350                 int quality;
351                 if (sscanf(interfaces, "%*[^:]: 0000 %d", &quality) != 1)
352                         continue;
353                 if ((quality == UCHAR_MAX) || (quality == 0)) {
354                         if (use_colors)
355                                 (void)snprintf(part, sizeof(part), "%s%s",
356                                         concat("#FF0000 ", wmii_normcolors), " W: down");
357                         else (void)snprintf(part, sizeof(part), "W: down");
358                 } else (void)snprintf(part, sizeof(part), "W: (%03d%%) %s",
359                                 quality, get_ip_address(wlan_interface));
360                 return part;
361         }
362
363         return part;
364 }
365
366 /*
367  * Combines ethernet IP addresses and speed (if requested) for displaying
368  *
369  */
370 static char *get_eth_info() {
371         static char part[512];
372         const char *ip_address = get_ip_address(eth_interface);
373         int ethspeed = 0;
374
375         if (get_ethspeed) {
376 #ifdef LINUX
377                 /* This code path requires root privileges */
378                 struct ifreq ifr;
379                 struct ethtool_cmd ecmd;
380
381                 ecmd.cmd = ETHTOOL_GSET;
382                 (void)memset(&ifr, 0, sizeof(ifr));
383                 ifr.ifr_data = (caddr_t)&ecmd;
384                 (void)strcpy(ifr.ifr_name, eth_interface);
385                 if (ioctl(general_socket, SIOCETHTOOL, &ifr) == 0)
386                         ethspeed = (ecmd.speed == USHRT_MAX ? 0 : ecmd.speed);
387                 else get_ethspeed = false;
388 #endif
389         }
390
391         if (ip_address == NULL)
392                 (void)snprintf(part, sizeof(part), "E: down");
393         else {
394                 if (get_ethspeed)
395                         (void)snprintf(part, sizeof(part), "E: %s (%d Mbit/s)", ip_address, ethspeed);
396                 else (void)snprintf(part, sizeof(part), "E: %s", ip_address);
397         }
398
399         return part;
400 }
401
402 /*
403  * Checks if the PID in path is still valid by checking:
404  *  (Linux) if /proc/<pid> exists
405  *  (NetBSD) if sysctl returns process infos for this pid
406  *
407  */
408 static bool process_runs(const char *path) {
409         char pidbuf[16];
410         static glob_t globbuf;
411         int fd;
412         memset(pidbuf, 0, sizeof(pidbuf));
413
414         if (glob(path, GLOB_NOCHECK | GLOB_TILDE, NULL, &globbuf) < 0)
415                 die("glob() failed\n");
416         fd = open((globbuf.gl_pathc > 0 ? globbuf.gl_pathv[0] : path), O_RDONLY);
417         globfree(&globbuf);
418         if (fd < 0)
419                 return false;
420         (void)read(fd, pidbuf, sizeof(pidbuf));
421         (void)close(fd);
422
423 #ifdef LINUX
424         struct stat statbuf;
425         char procbuf[512];
426         (void)snprintf(procbuf, sizeof(procbuf), "/proc/%ld", strtol(pidbuf, NULL, 10));
427         return (stat(procbuf, &statbuf) >= 0);
428 #else
429         /* TODO: correctly check for NetBSD. Evaluate if this runs on OpenBSD/FreeBSD */
430         struct kinfo_proc info;
431         size_t length = sizeof(struct kinfo_proc);
432         int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, strtol(pidbuf, NULL, 10) };
433         if (sysctl(mib, 4, &info, &length, NULL, 0) < 0)
434                 return false;
435         return (length != 0);
436 #endif
437 }
438
439 /*
440  * Reads the configuration from the given file
441  *
442  */
443 static int load_configuration(const char *configfile) {
444         #define OPT(x) else if (strcasecmp(dest_name, x) == 0)
445
446         /* check if the file exists */
447         struct stat buf;
448         if (stat(configfile, &buf) < 0)
449                 return -1;
450
451         int result = 0;
452         FILE *handle = fopen(configfile, "r");
453         if (handle == NULL)
454                 die("Could not open configfile\n");
455         char dest_name[512], dest_value[512], whole_buffer[1026];
456         struct stat stbuf;
457         while (!feof(handle)) {
458                 char *ret;
459                 if ((ret = fgets(whole_buffer, 1024, handle)) == whole_buffer) {
460                         /* sscanf implicitly strips whitespace */
461                         if (sscanf(whole_buffer, "%s %[^\n]", dest_name, dest_value) < 1)
462                                 continue;
463                 } else if (ret != NULL)
464                         die("Could not read line in configuration file\n");
465
466                 /* skip comments and empty lines */
467                 if (dest_name[0] == '#' || strlen(dest_name) < 3)
468                         continue;
469
470                 OPT("wlan")
471                         wlan_interface = strdup(dest_value);
472                 OPT("eth")
473                         eth_interface = strdup(dest_value);
474                 OPT("time_format")
475                         time_format = strdup(dest_value);
476                 OPT("battery_path")
477                         battery_path = strdup(dest_value);
478                 OPT("color")
479                         use_colors = true;
480                 OPT("get_ethspeed")
481                         get_ethspeed = true;
482                 OPT("normcolors")
483                         wmii_normcolors = strdup(dest_value);
484                 OPT("interval")
485                         interval = atoi(dest_value);
486                 OPT("wmii_path")
487                 {
488                         static glob_t globbuf;
489                         if (glob(dest_value, GLOB_NOCHECK | GLOB_TILDE, NULL, &globbuf) < 0)
490                                 die("glob() failed\n");
491                         wmii_path = strdup(globbuf.gl_pathc > 0 ? globbuf.gl_pathv[0] : dest_value);
492                         globfree(&globbuf);
493
494                         if ((stat(wmii_path, &stbuf)) == -1) {
495                                 fprintf(stderr, "Warning: wmii_path contains an invalid path\n");
496                                 free(wmii_path);
497                                 wmii_path = strdup(dest_value);
498                         }
499                         if (wmii_path[strlen(wmii_path)-1] != '/')
500                                 die("wmii_path is not terminated by /\n");
501                 }
502                 OPT("run_watch")
503                 {
504                         char *name = strdup(dest_value);
505                         char *path = name;
506                         while (*path != ' ')
507                                 path++;
508                         *(path++) = '\0';
509                         num_run_watches += 2;
510                         run_watches = realloc(run_watches, sizeof(char*) * num_run_watches);
511                         run_watches[num_run_watches-2] = name;
512                         run_watches[num_run_watches-1] = path;
513                 }
514                 OPT("order")
515                 {
516                         #define SET_ORDER(opt, idx) { if (strcasecmp(token, opt) == 0) sprintf(order[idx], "%d", c++); }
517                         char *walk, *token;
518                         int c = 0;
519                         walk = token = dest_value;
520                         while (*walk != '\0') {
521                                 while ((*walk != ',') && (*walk != '\0'))
522                                         walk++;
523                                 *(walk++) = '\0';
524                                 SET_ORDER("run", ORDER_RUN);
525                                 SET_ORDER("wlan", ORDER_WLAN);
526                                 SET_ORDER("eth", ORDER_ETH);
527                                 SET_ORDER("battery", ORDER_BATTERY);
528                                 SET_ORDER("load", ORDER_LOAD);
529                                 SET_ORDER("time", ORDER_TIME);
530                                 token = walk;
531                                 while (isspace((int)(*token)))
532                                         token++;
533                         }
534                 }
535                 else
536                 {
537                         result = -2;
538                         die("Unknown configfile option: %s\n", dest_name);
539                 }
540         }
541         fclose(handle);
542
543         if (wmii_path == NULL)
544                 exit(EXIT_FAILURE);
545
546         return result;
547 }
548
549 int main(int argc, char *argv[]) {
550         char part[512],
551              pathbuf[512];
552         unsigned int i;
553
554         char *configfile = PREFIX "/etc/wmiistatus.conf";
555         int o, option_index = 0;
556         struct option long_options[] = {
557                 {"config", required_argument, 0, 'c'},
558                 {"help", no_argument, 0, 'h'},
559                 {0, 0, 0, 0}
560         };
561
562         while ((o = getopt_long(argc, argv, "c:h", long_options, &option_index)) != -1)
563                 if ((char)o == 'c')
564                         configfile = optarg;
565                 else if ((char)o == 'h') {
566                         printf("wmiistatus (c) 2008-2009 Michael Stapelberg\n"
567                                 "Syntax: %s [-c <configfile>]\n", argv[0]);
568                         return 0;
569                 }
570
571         if (load_configuration(configfile) < 0)
572                 return EXIT_FAILURE;
573
574         setup();
575
576         if ((general_socket = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
577                 die("Could not create socket\n");
578
579         while (1) {
580                 for (i = 0; i < num_run_watches; i += 2) {
581                         bool running = process_runs(run_watches[i+1]);
582                         if (use_colors)
583                                 snprintf(part, sizeof(part), "%s %s: %s",
584                                         (running ?
585                                                 concat("#00FF00 ", wmii_normcolors) :
586                                                 concat("#FF0000 ", wmii_normcolors)),
587                                         run_watches[i],
588                                         (running ? "yes" : "no"));
589                         else snprintf(part, sizeof(part), "%s: %s", run_watches[i], (running ? "yes" : "no"));
590                         snprintf(pathbuf, sizeof(pathbuf), "%s%s", order[ORDER_RUN], run_watches[i]);
591                         write_to_statusbar(pathbuf, part);
592                 }
593
594                 if (wlan_interface)
595                         write_to_statusbar(concat(order[ORDER_WLAN], "wlan"), get_wireless_info());
596                 if (eth_interface)
597                         write_to_statusbar(concat(order[ORDER_ETH], "eth"), get_eth_info());
598                 if (battery_path)
599                         write_to_statusbar(concat(order[ORDER_BATTERY], "battery"), get_battery_info());
600
601                 /* Get load */
602 #ifdef LINUX
603                 int load_avg;
604                 if ((load_avg = open("/proc/loadavg", O_RDONLY)) == -1)
605                         die("Could not open /proc/loadavg\n");
606                 (void)read(load_avg, part, sizeof(part));
607                 (void)close(load_avg);
608                 *skip_character(part, ' ', 3) = '\0';
609 #else
610                 /* TODO: correctly check for NetBSD, check if it works the same on *BSD */
611                 struct loadavg load;
612                 size_t length = sizeof(struct loadavg);
613                 int mib[2] = { CTL_VM, VM_LOADAVG };
614                 if (sysctl(mib, 2, &load, &length, NULL, 0) < 0)
615                         die("Could not sysctl({ CTL_VM, VM_LOADAVG })\n");
616                 double scale = load.fscale;
617                 (void)snprintf(part, sizeof(part), "%.02f %.02f %.02f",
618                                 (double)load.ldavg[0] / scale,
619                                 (double)load.ldavg[1] / scale,
620                                 (double)load.ldavg[2] / scale);
621 #endif
622                 write_to_statusbar(concat(order[ORDER_LOAD], "load"), part);
623
624                 if (time_format) {
625                         /* Get date & time */
626                         time_t current_time = time(NULL);
627                         struct tm *current_tm = localtime(&current_time);
628                         (void)strftime(part, sizeof(part), time_format, current_tm);
629                         write_to_statusbar(concat(order[ORDER_TIME], "time"), part);
630                 }
631
632                 sleep(interval);
633         }
634 }