- case 0:
- if (!(hosts[i].flags & 0x01))
- syslog (LOG_WARNING, "ping %s: Connection timed out.", hosts[i].name);
- hosts[i].flags |= 0x01;
- break;
-
- case -1:
- if (!(hosts[i].flags & 0x02))
- syslog (LOG_WARNING, "ping %s: Host or service is not reachable.", hosts[i].name);
- hosts[i].flags |= 0x02;
- break;
-
- case -2:
- syslog (LOG_ERR, "ping %s: Socket error. Ping will be disabled for %i iteration(s).",
- hosts[i].name, hosts[i].backoff);
- hosts[i].disable = hosts[i].backoff;
- if (hosts[i].backoff < 8192) /* 22 3/4 hours */
- hosts[i].backoff *= 2;
- hosts[i].flags |= 0x10;
- break;
-
- case -3:
- if (!(hosts[i].flags & 0x04))
- syslog (LOG_WARNING, "ping %s: Connection refused.", hosts[i].name);
- hosts[i].flags |= 0x04;
- break;
-
- default:
- if (hosts[i].flags != 0x00)
- syslog (LOG_NOTICE, "ping %s: Back to normal: %ims.", hosts[i].name, ping);
- hosts[i].flags = 0x00;
- hosts[i].backoff = 1;
- ping_submit (ping, hosts[i].name);
- } /* switch (ping) */
- } /* for (i = 0; i < num_pinghosts; i++) */
-}
+ WARNING ("ping plugin: ping_iterator_get_info (%s, "
+ "PING_INFO_LATENCY) failed.", host);
+ continue;
+ }
+
+ DEBUG ("ping plugin: host = %s, latency = %f", host, latency);
+ ping_submit (host, latency);
+ number_of_hosts++;
+ }
+
+ if ((number_of_hosts == 0) && (getuid () != 0))
+ {
+ ERROR ("ping plugin: All hosts failed. Try starting collectd as root.");
+ }
+
+ return (number_of_hosts == 0 ? -1 : 0);
+} /* int ping_read */