Adrian Perez [Mon, 8 Aug 2011 14:01:11 +0000 (16:01 +0200)]
drlog: Handle the INT signal gracefully
Sending an interrupt signal to a drlog process will make it exit gracefully,
flushing buffers to disk if needed.
Adrian Perez [Mon, 8 Aug 2011 13:57:54 +0000 (15:57 +0200)]
dlog: Remove unneded "running" variable
The variable controlling the main loop is never reset, so it can be removed.
Adrian Perez [Mon, 8 Aug 2011 13:53:37 +0000 (15:53 +0200)]
dlog: Handle INT, TERM and HUP signals gracefully
* Sending a HUP signal to a dlog process will flush the log file and re-open
it. This allows e.g. for external rotation of files.
* Sending a TERM or INT signal to a dlog process will close the log file and
exit gracefully.
Adrian Perez [Mon, 25 Jul 2011 08:14:53 +0000 (11:14 +0300)]
Version 0.4.1
Adrian Perez [Mon, 25 Jul 2011 08:13:24 +0000 (11:13 +0300)]
Update Debian packaging for version 0.4.1
Adrian Perez [Tue, 12 Jul 2011 23:16:32 +0000 (02:16 +0300)]
Define _GNU_SOURCE to get the definition of ULLONG_MAX
System headers with new GCC versions will not include a definition for
ULLONG_MAX, unless C99 mode is turned on, or GNU extensions requested.
As there is no common option for compilers to enable C99 mode, it is
actually easier to define _GNU_SOURCE.
Adrian Perez [Tue, 12 Jul 2011 23:03:51 +0000 (02:03 +0300)]
Improve error messages from drlog
Adrian Perez [Tue, 12 Jul 2011 22:48:55 +0000 (01:48 +0300)]
Unify all file-like size parsing in util.c
* New common functions storage_size_to_bytes() and storage_size_option()
--for use with w_opt_t-- in util.{h,c}
* Make drlog use the common functions.
Adrian Perez [Tue, 12 Jul 2011 22:34:41 +0000 (01:34 +0300)]
Unify all time-period parsing in util.c
* New common functions time_period_to_seconds() and time_period_option()
--for use with w_opt_t-- in util.{h,c}
* Make dmon and drlog use the common functions.
Adrian Perez [Tue, 12 Jul 2011 21:46:17 +0000 (00:46 +0300)]
Use memory handling functions from libwheel
Removes the usage of the memory handling functions defined in util.{h,c}
and uses the corresponding functions from libwheel where needed.
Adrian Perez [Tue, 12 Jul 2011 21:42:54 +0000 (00:42 +0300)]
Remove unneeded die() declaration from util.h
Adrian Perez [Tue, 12 Jul 2011 21:42:36 +0000 (00:42 +0300)]
Remove unused include from multicall.c
Adrian Perez [Tue, 12 Jul 2011 21:41:13 +0000 (00:41 +0300)]
Change MULTICALL preprocessor define to NO_MULTICALL
Now that building a multicall binary is the default, it looks sensible to
remove the -DMULTICALL from the compiler command line while building, and
adding -DNO_MULTICALL when standalone binaries are requested.
Adrian Perez [Tue, 12 Jul 2011 15:11:14 +0000 (18:11 +0300)]
Link dmon to libwheel.a instead all of its object files
This will make the linker discard unused symbols from the static library,
instead of munging together all the libwheel .o object files. Generated
binary size in x86-64 is ~3 kB smaller.
Adrian Perez [Tue, 12 Jul 2011 15:10:04 +0000 (18:10 +0300)]
Use $(LD) for libnofork instead of hardcoding gcc command
Adrian Perez [Tue, 12 Jul 2011 14:40:45 +0000 (17:40 +0300)]
drlog: Better error formatting
Make error output more consistent with that of dlog and dslog.
Adrian Perez [Tue, 12 Jul 2011 14:32:08 +0000 (17:32 +0300)]
drlog: Remove die() macro, use w_die(NULL) instead
Adrian Perez [Tue, 12 Jul 2011 14:23:33 +0000 (17:23 +0300)]
drlog: Better output directory errors
Show different messages if the output path does not exists and
if it is a directory, instead of having a single error message
for both cases.
Adrian Perez [Mon, 11 Jul 2011 11:25:02 +0000 (14:25 +0300)]
Build a multicall binary by default
In general there is no gain in building separate binaries for each tool, so
it sounds reasonable to assume that by default everybody would like to build
a multicall binary. Still, it is possible to build standalone tools passing
MULTICALL=0 in the Make command line. The README is updated accordingly.
Adrian Perez [Mon, 11 Jul 2011 11:20:57 +0000 (14:20 +0300)]
Update libwheel and disable its stdio usage
Adrian Perez [Mon, 11 Jul 2011 11:19:59 +0000 (14:19 +0300)]
Use w_io_t instead of libc's stdio
Adrian Perez [Wed, 29 Jun 2011 22:58:05 +0000 (01:58 +0300)]
Completely replace assert() with w_assert()
Adrian Perez [Thu, 16 Jun 2011 09:27:07 +0000 (12:27 +0300)]
Version 0.4
Adrian Perez [Thu, 16 Jun 2011 09:26:48 +0000 (12:26 +0300)]
Update Debian packaging for version 0.4
Adrian Perez [Thu, 16 Jun 2011 09:19:02 +0000 (12:19 +0300)]
Same help message in dlog/drlog for -b flag
Make dlog and drlog use the same help message for the -b/--buffered
command line option, avoiding references to fsync(), which is in
fact a technical detail that the user would not care about.
Adrian Perez [Thu, 16 Jun 2011 09:16:20 +0000 (12:16 +0300)]
Add -b/--buffered option to drlog
Now drlog works the same as dlog: it flushes data to disk after
each line. Optionally buffered operation can be enabled by passing
-b or --buffered in the command line.
Adrian Perez [Thu, 16 Jun 2011 09:01:38 +0000 (12:01 +0300)]
Fix option name in drlog manpage
Option "-t" was used for both both timestamp and max-time,
so changed max-time to "-T", following the actual implementation.
Adrian Perez [Thu, 16 Jun 2011 09:00:15 +0000 (12:00 +0300)]
Point to all DMon articles in README file
Instead of linking to a single post in Adrian's blog about
DMon, change the link to point to all the articles on DMon
available.
Adrian Perez [Thu, 16 Jun 2011 08:42:41 +0000 (11:42 +0300)]
Do not make non-optimized debug builds by default
Adrian Perez [Thu, 16 Jun 2011 08:42:15 +0000 (11:42 +0300)]
Remove usage invalid of optarg
For reporting errors related to opening the status file/fifo,
optarg was being used (a leftover from the pre-wheel era), so
changed it to properly report the path.
Adrian Perez [Thu, 16 Jun 2011 07:56:22 +0000 (10:56 +0300)]
Removed section in README about externally adding rotlog
As rotlog is now included in dmon (as drlog), it no longer makes sense
to keep the section in the README file.
Adrian Perez [Thu, 16 Jun 2011 07:53:11 +0000 (10:53 +0300)]
Add drlog in Git ignore rules
Adrian Perez [Thu, 16 Jun 2011 06:40:52 +0000 (09:40 +0300)]
Import new drlog tool, based on rotlog
Adrian Perez [Wed, 15 Jun 2011 21:35:14 +0000 (00:35 +0300)]
Update libwheel submodule to v0.1
Adrian Perez [Wed, 15 Jun 2011 21:08:18 +0000 (00:08 +0300)]
Properly detect pid-file command line argument
The option parser was using a global variable, whilst the code
was checking a local one. Removed the local and kept the other.
Adrian Perez [Wed, 15 Jun 2011 20:56:24 +0000 (23:56 +0300)]
Use _DEBUG_PRINT for enabling debug output
Adrian Perez [Wed, 1 Jun 2011 23:41:44 +0000 (01:41 +0200)]
Remove iolib.{h,c} and use w_io_t functions instead
Adrian Perez [Sun, 22 May 2011 10:24:22 +0000 (12:24 +0200)]
Improve help output by passing cmdline syntax to w_opt_parse
Adrian Perez [Sun, 22 May 2011 10:23:49 +0000 (12:23 +0200)]
Update libwheel
Adrian Perez [Sun, 15 May 2011 23:22:59 +0000 (02:22 +0300)]
Use w_die wherever possible
Adrian Perez [Sun, 15 May 2011 13:23:36 +0000 (16:23 +0300)]
Disable pthread support from libwheel
Adrian Perez [Sun, 15 May 2011 12:32:17 +0000 (15:32 +0300)]
Fix file name in comment header
Adrian Perez [Sun, 15 May 2011 12:32:02 +0000 (15:32 +0300)]
Update code to build with latest libwheel
Adrian Perez [Mon, 8 Nov 2010 21:30:39 +0000 (23:30 +0200)]
Use w_lengthof instead of length_of
The libwheel library already includes a macro that calculates array lengths,
so use that instead of dmon's
Adrian Perez [Wed, 27 Oct 2010 09:29:00 +0000 (12:29 +0300)]
Update libwheel to latest Git head
Adrian Perez [Fri, 15 Oct 2010 08:50:55 +0000 (11:50 +0300)]
Change dslog to use w_opt_parse() from libwheel
Adrian Perez [Fri, 15 Oct 2010 08:21:27 +0000 (11:21 +0300)]
Change dlog to use w_opt_parse() from libwheel
Adrian Perez [Fri, 15 Oct 2010 08:12:27 +0000 (11:12 +0300)]
Remove unused parse_float_arg() function
Since we are using w_opt_parse() in dmon, this function is no longer needed.
Adrian Perez [Fri, 15 Oct 2010 08:06:33 +0000 (11:06 +0300)]
Parse config file with w_opt_parse_file()
Instead of replacing argc/argv (which is hackish), use a proper parser
resuing the long command line options using libwheel's w_opt_parse_file().
Adrian Perez [Fri, 15 Oct 2010 06:58:27 +0000 (09:58 +0300)]
Change dmon to use w_opt_parse
Adrian Perez [Thu, 14 Oct 2010 07:09:09 +0000 (10:09 +0300)]
Rules in Makefile to build with libwheel
Adrian Perez [Thu, 14 Oct 2010 07:05:46 +0000 (10:05 +0300)]
Add Git wheel submodule
Adrian Perez [Wed, 6 Oct 2010 00:11:32 +0000 (02:11 +0200)]
Document "-I" option and status file format
This modifies the manual page to have a section on the format used for the
status file updates (picked from the commit message of edf2718), and the
"-I" option to pass the path where to write status updates.
Adrian Perez [Wed, 6 Oct 2010 00:01:41 +0000 (02:01 +0200)]
Better debugging message including signal number
Adrian Perez [Tue, 5 Oct 2010 23:54:00 +0000 (01:54 +0200)]
Implementing writing process status to file
This makes dmon print lines with status changes to a given file-like
entity (e.g. FIFOs do work). Possible formats for lines are:
- Processes are started or stopped by dmon:
cmd start <pid>
log start <pid>
cmd stop <pid>
log stop <pid>
- Process has exited by its own means, or was terminated by the other means
different than dmon itself:
cmd exit <pid> <status>
log exit <pid> <status>
The <status> field is numeric, and must be interpreted the same as the
"status" argument to waitpid(2) system call. Most of the time this is
the expected integer code passed to exit(2), but this may not be true if
the process exits forcibly. Likely, this should be changed at some point.
- Signals are being sent to processes:
cmd signal <pid> <signal>
log signal <pid> <signal>
- The main process timed out (-t):
cmd timeout <pid>
- Process was paused or resumed due to system load constraints (-l/-L):
cmd pause <pid>
cmd resume <pid>
Adrian Perez [Mon, 4 Oct 2010 22:56:21 +0000 (00:56 +0200)]
Sanity-check for printable characters in replace_args_cb()
When reading non-printable characters, assume that binary data is being
read, return an error flag and set "errno" to some sensible value (for
systems which have it defined, EINVAL is used) to signal the error to
the user.
Adrian Perez [Mon, 4 Oct 2010 22:48:55 +0000 (00:48 +0200)]
Handle errors when reading file passed to "-C"
In some situations, the file passed with "-C file" may not be readable so
this adds the code to handle such situations.
Adrian Perez [Mon, 4 Oct 2010 22:42:42 +0000 (00:42 +0200)]
Document "-C file" commnand line option in manpage
Adrian Perez [Mon, 4 Oct 2010 22:39:08 +0000 (00:39 +0200)]
Fix typo (double double-dash) in manual page
In the examples section, one of them contained two double-dash arguments,
which is not a valid combination.
Adrian Perez [Mon, 4 Oct 2010 22:26:34 +0000 (00:26 +0200)]
Support reading options from files with "-C file"
This implements very basic support for reading options from files.
Note that this reads "options from files", it does not read "proper
configuration files", so implementation is somewhat dodgy -- but it
the most we can do with the less possible code. It works this way:
- If "-C" is exactly the first argument and there are at least two
arguments, the second one is expected to be a file name.
- Arguments are shifted two positions to the left.
- Contents from the file are placed in the argv array by using
replace_args_file().
- Contents of the file will be happily "parsed" by getopt().
This is similar to what is done with the contents of the DMON_OPTIONS
environment variable.
Adrian Perez [Mon, 4 Oct 2010 14:31:16 +0000 (16:31 +0200)]
Release v0.3.7
Adrian Perez [Mon, 4 Oct 2010 14:27:31 +0000 (16:27 +0200)]
Ignore shared libraries (*.so) in Git
Adrian Perez [Mon, 4 Oct 2010 14:23:26 +0000 (16:23 +0200)]
Fix muilticall builds without rotlog
When builing like this (without "ROTLOG=..."):
make MULTICALL=1
caused linking to fail because of an undefined symbol. This patch fixes
that kind of builds.
Adrian Perez [Mon, 4 Oct 2010 14:21:10 +0000 (16:21 +0200)]
Describe option "-E" in manual page
Add a description in the manual page regarding usage of the "-E" option used
to manipulate the environment variables.
Adrian Perez [Mon, 4 Oct 2010 14:15:40 +0000 (16:15 +0200)]
Implement modifying environment variables with "-E"
- Using "-E foo" clears a variable *and* removes it from the environment.
- Using "-E foo=" clears a variable, but it is left in the environment (with
an empty value, of course)
- Using "-E foo=bar" defines a variable and its value.
Adrian Perez [Mon, 4 Oct 2010 02:33:59 +0000 (04:33 +0200)]
Add libnofork.so and support its building
When passing LIBNOFORK=1 to Make:
- nofork.c will be compiled to libnofork.so
- libnofork.so will be installed to $(prefix)/lib
This small library is intended to be used with LD_PRELOAD to prevent
processes from forking.
Adrian Perez [Mon, 4 Oct 2010 02:11:32 +0000 (04:11 +0200)]
Update manual pages with notes on environment vars
Add notes in manual pages stating that tools honor the corresponding
environment variables for additional options.
Adrian Perez [Mon, 4 Oct 2010 02:06:38 +0000 (04:06 +0200)]
Honor DSLOG_OPTIONS environment variable
If DSLOG_OPTIONS is defined in the environment, it will be used to pick up
additional command line arguments.
Adrian Perez [Mon, 4 Oct 2010 02:04:48 +0000 (04:04 +0200)]
Honor DLOG_OPTIONS environment variable
If DLOG_OPTIONS is defined in the environment, it will be used to pick up
additional command line arguments.
Adrian Perez [Mon, 4 Oct 2010 02:03:21 +0000 (04:03 +0200)]
Honor DMON_OPTIONS environment variable
If DMON_OPTIONS is defined in the environment, it will be used to pick
additional command line arguments.
Adrian Perez [Mon, 4 Oct 2010 01:55:42 +0000 (03:55 +0200)]
Memory and arg-replacing utility functions
Provides additions to util.[hc], first the memory functions:
- xxalloc(), which handles allocation, resizing and freeing. Plus utility
macros: xmalloc(), xrealloc(), xfree().
- xalloc() and xresize(), which work for typed dynamic arrays of elements.
A type is passed to the macros.
Then, for replacing (argc, argv) from different sources:
- A generic replace_args_cb() which replaces by reading characters from
a callback function.
- Convenience functions: replace_args_fd(), from an open file descriptor;
replace_args_file(), from a given file by name; replace_args_string(),
which reads characters from the passed string.
All arg-replacing functions leave the original argv[0] at position zero, the
read arguments next, and then the original elements at the end.
Adrian Perez [Fri, 1 Oct 2010 14:21:20 +0000 (16:21 +0200)]
Support in Makefile to build multicall binary with rotlog
This is a bit hackish, but allows building "rotlog" inside the "dmon"
multicall binary. To use it, pass the "ROTLOG=path/to/rotlog/source"
variable when building.
Adrian Perez [Thu, 30 Sep 2010 01:27:17 +0000 (03:27 +0200)]
Release v0.3.6
Adrian Perez [Thu, 30 Sep 2010 01:23:40 +0000 (03:23 +0200)]
Update manual page with "-r" option
Add section on the manual page describing the option for setting process
limits to keep it up to date with the implementation.
Adrian Perez [Thu, 30 Sep 2010 01:15:57 +0000 (03:15 +0200)]
Build by default optimized for size (-Os)
Adrian Perez [Thu, 30 Sep 2010 01:13:07 +0000 (03:13 +0200)]
Make safe_setrlimit() print limit names on failure
This uses limit_name() to make error messages more meaningful.
Adrian Perez [Thu, 30 Sep 2010 01:00:25 +0000 (03:00 +0200)]
Implement setting process limits
This is done by using parse_limit_arg(), saving items to arrays, and doing
limit setup in the child once it was spawned, but before file redirection,
and other tweaks done before execvp().
Adrian Perez [Thu, 30 Sep 2010 00:24:41 +0000 (02:24 +0200)]
Implement parse_limit_arg() and limit_name()
Convenience functions to parse "limit=value" arguments, as passed to the
"-r" command line flag. As a bonus, limit_name() can be used to get the name
of a limit given its numeric value.
Adrian Perez [Thu, 30 Sep 2010 00:24:07 +0000 (02:24 +0200)]
Add length_of macro to util.h
Adrian Perez [Wed, 29 Sep 2010 22:42:43 +0000 (00:42 +0200)]
New safe_setrlimit() function
Hides using "struct rlimit", and aborts program execution when errors occur.
This is a convenience function which will be used to control process limits.
Adrian Perez [Mon, 27 Sep 2010 00:32:47 +0000 (02:32 +0200)]
Release v0.3.5
Adrian Perez [Mon, 27 Sep 2010 00:22:10 +0000 (02:22 +0200)]
Add "-i" and remove "-?" in manual page
Updates the manual page to state the current behavior of dmon. The "-i"
option was added, along with a clarification about how to specify time
intervals using suffixes. The "-?" option is no longer valid.
Adrian Perez [Mon, 27 Sep 2010 00:13:58 +0000 (02:13 +0200)]
Remove "-?" as valid command line flag
The getopt() uses the "?" as character for signalling an invalid command
line option, so dmon must not use it by itself.
Adrian Perez [Mon, 27 Sep 2010 00:12:03 +0000 (02:12 +0200)]
Move "-1" in help message to exec constraints section
The option controls process execution, so it belongs to the "process
execution constraints" epigraph in the help text.
Adrian Perez [Mon, 27 Sep 2010 00:08:02 +0000 (02:08 +0200)]
Implement sleeping an interval between succesful runs
Add a new "-i" flag, which is passed a time interval. When the process exits
with a zero return code, then the wait is done before the next run. This can
be used to make dmon behave as el-cheapo cron daemon. As it makes no sense
using this option along with "-1", an error is given back to the user when
both options are passed in the command line.
Adrian Perez [Sun, 26 Sep 2010 23:02:15 +0000 (01:02 +0200)]
Refactored code for better reusability of functions
- Move parse_float_arg() and parse_time_arg() to util.[hc]
- Move become_daemon() to util.[hc]
- Moved safe_sleep() to util.[hc]
- Factor out task_t handling code to task.[hc]
Adrian Perez [Mon, 13 Sep 2010 22:56:08 +0000 (00:56 +0200)]
Explictly ignore return value of write() in iolib
When building with -D_FORTIFY_SOURCE=1 the compiler will complain about the
return value for write() --inside the die() macro-- being ignored. In this
particular case we want it to be actually ignored because it is unknown
whether the call would succeed, and also we do not care because the program
will abort execution afterwards.
Adrian Perez [Mon, 13 Sep 2010 22:54:32 +0000 (00:54 +0200)]
Avoid warning about signed vs. unsigned comparisons
Second argument to format_ulong() and format_ullong() was declared as "int",
when in fact those functions are never called with negative values. By
changing the declaration to use "unsigned" instead will make the compiler
not complain.
Adrian Perez [Mon, 13 Sep 2010 22:52:58 +0000 (00:52 +0200)]
Handle errors when creating command<->log pipes
When calling pipe() to create the pipe put in between the main process and
the logging process, the return value was not being taken into account. This
makes dmon die() in failure.
Adrian Perez [Wed, 8 Sep 2010 02:12:35 +0000 (04:12 +0200)]
New "strip" target in Makefile
Allows for "make strip". Also works properly with "make MULTICALL=1 strip".
Adrian Perez [Mon, 6 Sep 2010 12:24:36 +0000 (14:24 +0200)]
Support building all tools as a multicall binary
This enables building all tools into a single executable, being the tools
chosen by inspecting argv[0]. This is good to save space i.e. in embedded
devices and also some memory because of sharability of the text segment.
To make such a build, just pass MULTICALL=1 to Make.
Adrian Perez [Sun, 5 Sep 2010 17:10:43 +0000 (19:10 +0200)]
Release v0.3.4
Adrian Perez [Sun, 5 Sep 2010 17:06:15 +0000 (19:06 +0200)]
util: Use primary group for the user
Changed name_to_uid() to be name_to_uidgid(), so we get the primary group to
which we do setgid() from the password database entry, this way we ensure
that the group always exists and that it is the primary group of the user.
Apart from removing the potential flaw of a group named exactly like the
specified user, this behavior is more predictable and it is likely that
users would expect dmon to work like this.
Adrian Perez [Sun, 5 Sep 2010 16:31:04 +0000 (18:31 +0200)]
Release v0.3.3
Adrian Perez [Sun, 5 Sep 2010 16:27:50 +0000 (18:27 +0200)]
Set additional groups prior to execution
Implements setting additional groups passed to -u/-U as a colon-separated
list. This is done using setgroups(2) before dropping privileges.
Adrian Perez [Sun, 5 Sep 2010 16:17:19 +0000 (18:17 +0200)]
Update manual pages for -u/-U
Keep manual page up-to-date with the latest change to how parsing is done
for -u/-U.
Adrian Perez [Sun, 5 Sep 2010 16:12:44 +0000 (18:12 +0200)]
Do -u/-U in terms of parse_uidgids() removing -g/-G
This used parse_uidgids() to get the user and group list for the -u and -U
options. This makes -g and -G unnecessary because now groups are specified
as a colon-separated list to -u/-U.
Adrian Perez [Sun, 5 Sep 2010 15:49:05 +0000 (17:49 +0200)]
util: Add function to parse uid[:gid[:gid...]] lists
This adds a function parse_uidgids() which will parse lists with an UID and
any number of GIDs separated by colons.
Adrian Perez [Fri, 3 Sep 2010 09:12:37 +0000 (11:12 +0200)]
Release v0.3.2
Adrian Perez [Fri, 3 Sep 2010 09:01:10 +0000 (11:01 +0200)]
Added COPYING and (simple) README
The README for the moment refers to the DMon blog post and the manual pages.
That should suffice for now.