Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apcups plugin polling issues when non-default interval used #15

Closed
octo opened this issue Feb 21, 2012 · 0 comments
Closed

apcups plugin polling issues when non-default interval used #15

octo opened this issue Feb 21, 2012 · 0 comments
Labels
Bug A genuine bug Patch
Milestone

Comments

@octo
Copy link
Member

octo commented Feb 21, 2012

From: Edwin (Mantis #38)

Description: Using collectd 4.10.1-2 (Ubuntu 10.10 Maverick repo)

When changing the collectd interval to 30, apcups plugin always fails polling after the initial poll succeeds. This causes the plugin to be paused and stats not collected.

Syslog entries will look something like:

Jun 15 14:55:28 codis collectd[2607]: apcups plugin: Writing to the socket failed.
Jun 15 14:55:28 codis collectd[2607]: read-function of plugin `apcups' failed. Will suspend it for 60 seconds.
Jun 15 14:56:58 codis collectd[2607]: apcups plugin: Writing to the socket failed.
Jun 15 14:56:58 codis collectd[2607]: read-function of plugin `apcups' failed. Will suspend it for 60 seconds.

Steps To Reproduce: Change collectd interval to 30

Additional Information: This appears to be due to attempting to reuse the network socket and not handling any failures. Workaround is to open a new socket each time.

Patch attached to close the socket everytime. Cleaner patch should probably attempt to reuse the socket if possible and then open a new one on error.

--- apcups.c.orig       2011-06-16 09:56:52.231552800 -0400
+++ apcups.c    2011-06-16 09:56:56.690889806 -0400
@@ -323,6 +323,18 @@
                return (-1);
        }

+       uint16_t packet_size = 0;
+        if (global_sockfd < 0)
+                return (0);
+
+        DEBUG ("Gracefully shutting down socket %i.", global_sockfd);
+
+        /* send EOF sentinel */
+        swrite (global_sockfd, (void *) &packet_size, sizeof (packet_size));
+
+        close (global_sockfd);
+        global_sockfd = -1;
+
        return (0);
 }
octo added a commit that referenced this issue Apr 16, 2012
While they are correctly encoded, e.g. as "&#15;", browsers will
complain about invalid XML and not render the page. Ignore all control
characters other than whitespace.
octo added a commit that referenced this issue Sep 13, 2012
If that fails more than twice in the first 10 iterations, gracefully shut
down the socket in all future iterations.

This should fix Github issue #15.
@octo octo closed this as completed Sep 13, 2012
abays added a commit to abays/collectd that referenced this issue Apr 19, 2018
Use nested notification meta (connectivity)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A genuine bug Patch
Projects
None yet
Development

No branches or pull requests

1 participant