frontend: Reset the current command length on CONNECTION_IDLE.
frontend: Clear the error buffer when initializing a new command.
utils strbuf: Don't copy more than needed in sdb_strbuf_skip().
strbuf_test: Added some more test-cases for sdb_strbuf_skip().
frontend: Always store errors in the error buffer.
This allows to access the error from other parts of the code.
This allows to access the error from other parts of the code.
frontend: Always reset the current command after handling it.
That is, also reset it after an authentication error.
That is, also reset it after an authentication error.
frontend: Clear current command on authentication error.
store_lookup_test: Dereference objects returned from the store.
parser: Don't leak memory when building nested matchers.
backends: Destroy dbi/unixsock clients on shutdown.
This would also be cleaned up when destroying the registered user data objects
but doing so on shutdown in much cleaner.
This would also be cleaned up when destroying the registered user data objects
but doing so on shutdown in much cleaner.
store: Free old attribute values before storing an updated value.
collectd::unixsock plugin: Free temporarily allocated memory.
frontend: Free strdup()'ed username when destroying a connection.
sysdbd: Free up the config item returned from the parser as well.
oconfig_free() does not do that because it does not correctly keep track of
what the top-level config item is and it cannot free items which are the child
of another.
oconfig_free() does not do that because it does not correctly keep track of
what the top-level config item is and it cannot free items which are the child
of another.
sysdbd: Shut down all plugins before exiting.
plugin: Added sdb_plugin_shutdown_all().
This function calls all registered "shutdown" callbacks.
This function calls all registered "shutdown" callbacks.
Make clang-analyze happy in two irrelevant cases.
sysdbd: Keep connections open during reconfiguration.
By using the new sdb_fe_sock_clear_listeners(), the list of active listeners
may be reconfigured without affecting any open connections.
By using the new sdb_fe_sock_clear_listeners(), the list of active listeners
may be reconfigured without affecting any open connections.
frontend: Added sdb_fe_sock_clear_listeners().
This function may be used to shut down and clear all listeners associated with
a socket object without affecting any open connections.
This function may be used to shut down and clear all listeners associated with
a socket object without affecting any open connections.
sysdbd: Free the config parse tree after finishing config work.
sysdbd: Reconfigure the daemon on SIGHUP.
The current approach shuts down the backend collector thread and the frontend.
Then, the config file is parsed again and libsysdb's reconfiguration mechanism
is used to reconfigure all plugins.
The current approach shuts down the backend collector thread and the frontend.
Then, the config file is parsed again and libsysdb's reconfiguration mechanism
is used to reconfigure all plugins.
sysdbd: Added daemon_free_listen_addresses().
This is a helper function for handling config settings.
This is a helper function for handling config settings.
Make all plugins ready for reconfiguration support.
That is, handle NULL arguments passed to the config and module init functions
during reconfiguration.
That is, handle NULL arguments passed to the config and module init functions
during reconfiguration.
plugin: Added support for reconfiguring the system on the fly.
Reconfiguring all plugins happens in multiple steps:
First, call sdb_plugin_reconfigure_init() to deconfigure all plugins by
calling their config callbacks with a NULL config tree and unregistering all
registered callbacks.
Then, sdb_plugin_configure() and other functions may be used to provide the
new configuration or load new plugins. For all plugins which were already
loaded before, sdb_module_init() will be called with a NULL argument when
reloading them.
Finally, sdb_plugin_reconfigure_finish() will clean up leftover pieces, like
unloading plugins which are no longer in use.
Reconfiguring all plugins happens in multiple steps:
First, call sdb_plugin_reconfigure_init() to deconfigure all plugins by
calling their config callbacks with a NULL config tree and unregistering all
registered callbacks.
Then, sdb_plugin_configure() and other functions may be used to provide the
new configuration or load new plugins. For all plugins which were already
loaded before, sdb_module_init() will be called with a NULL argument when
reloading them.
Finally, sdb_plugin_reconfigure_finish() will clean up leftover pieces, like
unloading plugins which are no longer in use.
utils llist: Added sdb_llist_clear().
This function clears the list by removing all elements and releasing the
included objects. It's similar to destroy() but does not actually release the
list object itself.
This function clears the list by removing all elements and releasing the
included objects. It's similar to destroy() but does not actually release the
list object itself.
utils llist: Removed sdb_ prefix from private functions.
For consistency!
For consistency!
plugin: Do not expect all callbacks to have a plugin context assigned.
For callbacks not registered from a plugin, we don't have a context. For
example, the frontend's connection logger callback does not have a context.
For callbacks not registered from a plugin, we don't have a context. For
example, the frontend's connection logger callback does not have a context.
plugin: Unset the plugin context before unregistering a plugin.
Else, the context is still considered to be in use and, thus, won't be removed
from the global plugin (context) list.
Else, the context is still considered to be in use and, thus, won't be removed
from the global plugin (context) list.
plugin: Log to stderr if no logger has been registered.
Check the length of the list rather than replying on it being uninitialized.
Check the length of the list rather than replying on it being uninitialized.
plugin: Let ctx_create() use ctx_set().
This ensures consistent handling of reference counts.
This ensures consistent handling of reference counts.
plugin: Split sdb_plugin_load() into multiple functions.
… to make it easier to reuse parts of the function.
… to make it easier to reuse parts of the function.
plugin: Fixed detection of plugins loaded twice.
This was missing in commit fdfe2a68ba1838cdb1c34d3275d129fb217fbd9d.
This was missing in commit fdfe2a68ba1838cdb1c34d3275d129fb217fbd9d.
plugin: Keep a global reference of a plugin context if it's still in use.
D'oh!
D'oh!
plugin: Increment ref-count for a context stored in the TSD.
… and release it when removing it from the TSD. While this shouldn't matter
when everything is done right, this ensures that memory management is done
right.
… and release it when removing it from the TSD. While this shouldn't matter
when everything is done right, this ensures that memory management is done
right.
plugin: Only log a message when actually unloading a module.
plugin: Unload (dlclose) a plugin when it's no longer used.
Do so, if the init callback failed.
Do so, if the init callback failed.
plugin: Name the plugin context after the actual module name.
That is, the name as specified by the user without '::' replaced by '/'.
The latter is only used for loading the shared object by file-name.
That is, the name as specified by the user without '::' replaced by '/'.
The latter is only used for loading the shared object by file-name.
sysdbd: Fixed a config parser error message.
plugin: Keep a usage counter for each plugin.
Also, let plugin_load return early if the plugin is already loaded.
This is mostly in preparation for future improvements around plugin handling.
Also, let plugin_load return early if the plugin is already loaded.
This is mostly in preparation for future improvements around plugin handling.
sysdbd: Moved main loop handling into a separate function.
This will allow for easier restart of the main loop.
This will allow for easier restart of the main loop.
llist_test: Removed "llist" from all test names.
No need to use overly long names.
No need to use overly long names.
llist utils: Added sdb_llist_remove_by_name().
This function removes the first entry with the specified name.
This function removes the first entry with the specified name.
llist_test: Removed "sdb" from test names.
frontend: Force-close the connection in sdb_connection_close().
Previously, it would still be kept open if someone else referenced the object.
Previously, it would still be kept open if someone else referenced the object.
Frontend: Improve debug log when destroying a connection.
The file-descriptor associated with the connection might not be open any more
and, thus, be -1. Instead of using that in the message, use the connection's
object name which includes the file-descriptor as used when accepting the
connection.
The file-descriptor associated with the connection might not be open any more
and, thus, be -1. Instead of using that in the message, use the connection's
object name which includes the file-descriptor as used when accepting the
connection.
frontend: Fixed a memory leak in the connection context handler.
Previously, the ownership was not taken away from the thread-specific data
aftter removing the connection from the current context, thus leaking each
connection object.
Previously, the ownership was not taken away from the thread-specific data
aftter removing the connection from the current context, thus leaking each
connection object.
Merged branch 'master' of git://git.tokkee.org/sysdb.
sysdbd: Ignore SIGPIPE (e.g. when a client connection was aborted).
frontend: Be more robust in case of failed connections.
Make sure not to write to a failed connection, most notably, don't try to log
to a failed connection.
Make sure not to write to a failed connection, most notably, don't try to log
to a failed connection.
frontend: Close a connection when receiving an exception of the fd.
sysdb: Added support for the -c <cmd> option.
This option (which may be specified multiple times) may be used to send
commands to the server in a non-interactive way. After handling the reply from
the last command, the process exits.
This option (which may be specified multiple times) may be used to send
commands to the server in a non-interactive way. After handling the reply from
the last command, the process exits.
sock.h: Fixed documentation of sdb_client_send() return values.
core: Allow objects to have the same size as sdb_object_t.
That is, allow minimalistic objects which only have a name.
That is, allow minimalistic objects which only have a name.
sysdb: Let sdb_command_print_reply() accept client instead of input objects.
This is more flexible.
This is more flexible.
Travis: Only run coveralls when using gcc.
We don't have any gcov information in any other case.
We don't have any gcov information in any other case.
Travis: Don't use 'coveralls --verbose'.
coveralls reports work fine now, so we don't need this anymore.
coveralls reports work fine now, so we don't need this anymore.
README: Added links to travis-ci and coveralls.
sysdbd(1): Fixed typo.
Added sysdb(1) manpage and updated sysdb help output.
Travis: Don't use --use-mirrors with pip.
It's been deprecated and I think we don't need it ;-)
It's been deprecated and I think we don't need it ;-)
Travis; Pass --build-root to coveralls.
Else, it cannot find the right source files.
Else, it cannot find the right source files.
Travis: Display information about cpp-coveralls after installing it.
t/coverage.sh: Restore t/cibuild.sh in the temp directory.
This is to avoid the version being marked as dirty.
This is to avoid the version being marked as dirty.
store_lookup_test: Added a more complex parser/lookup test.
store_lookup: Added "tostring" methods for matcher objects.
This is meant for logging and debugging. For now, it's used in tests to check
parsed and compiled matchers.
This is meant for logging and debugging. For now, it's used in tests to check
parsed and compiled matchers.
store_lookup_test: Fixed user-data passed to the lookup callback.
parser: Make sure that each comparator matcher is a host matcher.
So far, 'NOT (service|attribute).<attr> <cmp> <value>' matches did not work
correctly, because the object matcher was not correctly wrapped into a host
matcher. Since we do not currently support querying any object types besides
hosts, this was wrong.
The respective code has been moved into sdb_store_matcher_parse_cmp() which
also implements and checks the restriction on matching host objects only.
A new set of tests has been introduced which exposed this problem and which
(roughly) verifies the result of a lookup using a parsed matcher.
So far, 'NOT (service|attribute).<attr> <cmp> <value>' matches did not work
correctly, because the object matcher was not correctly wrapped into a host
matcher. Since we do not currently support querying any object types besides
hosts, this was wrong.
The respective code has been moved into sdb_store_matcher_parse_cmp() which
also implements and checks the restriction on matching host objects only.
A new set of tests has been introduced which exposed this problem and which
(roughly) verifies the result of a lookup using a parsed matcher.
frontend/parser_test: Cover more basic expressions.
plugin: Removed obsolete TODO note.
frontend: Actually implement support for the NOT operator.
core, frontend: Added !=, !~, and NOT operators.
store_lookup: Added sdb_store_inv_matcher().
This creates a matcher objects which matches the inverse (logical NOT) of the
specified matcher.
This creates a matcher objects which matches the inverse (logical NOT) of the
specified matcher.
frontend: Let the parser support brackets in matcher expressions.
frontend: Fixed memory holes in the parser.
store: Don't change the interval if the new interval is zero.
If the interval is zero, multiple updates happened at the same time. This does
not affect the interval at which the object is updated in the backend, though.
If the interval is zero, multiple updates happened at the same time. This does
not affect the interval at which the object is updated in the backend, though.
parser_test: Check operator precedence.
parser_test: Check matcher type returned by sdb_fe_parse_matcher().
frontend parser: Added support for AND and OR matchers.
frontend: Updated unit-tests for expression related parsing.
frontend: Accept compare matchers as expressions.
… replacing the current placeholder.
For now, this is specific to '=' (equal) and '=~' (regex) comparison.
… replacing the current placeholder.
For now, this is specific to '=' (equal) and '=~' (regex) comparison.
frontend: Don't ignore single characters in the scanner.
This would lead to those characters be silently ignored at any place in the
input stream.
This would lead to those characters be silently ignored at any place in the
input stream.
store: Added sdb_store_matcher_parse_cmp().
This function parses simple matcher compare expressions (<obj_type>.<attr>
<op> <value>).
This function parses simple matcher compare expressions (<obj_type>.<attr>
<op> <value>).
store: Moved matcher types to store-private.h.
collectd::unixsock backend: Simplified host updates.
Also, don't do duplicate updates in a single iteration. This caused bad
startup effects for the interval calculation.
Later, we should make the core more robust in that respect, I guess.
Also, don't do duplicate updates in a single iteration. This caused bad
startup effects for the interval calculation.
Later, we should make the core more robust in that respect, I guess.
store_test: Added a test for interval calculation.
store: Include update interval in the JSON serialization.
core/time: Added sdb_strfinterval().
This function formats a time interval using the format 1Y2M3D4h5m6.7s.
This function formats a time interval using the format 1Y2M3D4h5m6.7s.
store: Fixed a conversion warning reported by GCC.
store: Calculate and store each objects update interval.
The interval is calculated as the moving average of the incoming update
intervals. This should also work fine for out-of-order updates or updates from
multiple sources.
The interval is calculated as the moving average of the incoming update
intervals. This should also work fine for out-of-order updates or updates from
multiple sources.
frontend: Let LIST not include details.
Now that we have FETCH and LOOKUP, list should only provide basic information
(name and last_update).
Now that we have FETCH and LOOKUP, list should only provide basic information
(name and last_update).
parser_test: Added simple LOOKUP parser tests.
frontend: Added LOOKUP support to the connection handler.
For now, the wire format is: <CONNECTION_LOOKUP>;<len>;<expression>
For now, the wire format is: <CONNECTION_LOOKUP>;<len>;<expression>
frontend: Added simple 'LOOKUP <type> WHERE <expression>' query.
This query command may be used to retrieve a list of detailed host information
for each host matching the specified expression. For now, querying hosts is
supported only.
This query command may be used to retrieve a list of detailed host information
for each host matching the specified expression. For now, querying hosts is
supported only.
store: Let sdb_store_matcher_matches return true if it matches.
Rather than using 0 for matches and -1 else.
Rather than using 0 for matches and -1 else.
store: Added sdb_store_lookup().
This function looks up objects from the store which match a user-specified
matcher. For each such object, a user-specified callback is executed.
This function looks up objects from the store which match a user-specified
matcher. For each such object, a user-specified callback is executed.
store: Added sdb_store_iterate().
This function iterates over all (host, for now) objects in the store and calls
a user-specified callback for each.
This function iterates over all (host, for now) objects in the store and calls
a user-specified callback for each.
grammar.y: Added some (very) short documentation for each statement.
parser_test: Fixed a sign-compare warning/error on GCC.
frontend: Require strings instead of identifiers.
… for host names and name matchers. Identifiers were used as an early
work-around but they are not valid in those places.
… for host names and name matchers. Identifiers were used as an early
work-around but they are not valid in those places.
frontend: Added very simple single-quoted string support.
No escape sequences whatsoever are supported so far but except for that any
single-quoted strings which do not contain single quotes, can be used.
FETCH now supports host names specified as strings as well.
No escape sequences whatsoever are supported so far but except for that any
single-quoted strings which do not contain single quotes, can be used.
FETCH now supports host names specified as strings as well.