Permalink
Browse files

Rename the functions which became part of public interface

  • Loading branch information...
1 parent 991eadd commit 0cda558791666f45347e3b0b4b3505d9db42e5d2 @romanbsd committed Apr 18, 2012
Showing with 16 additions and 15 deletions.
  1. +4 −4 statsd-client.c
  2. +2 −2 statsd-client.h
  3. +10 −9 uptimed.c
View
@@ -101,7 +101,7 @@ static int should_send(float sample_rate)
}
}
-void send_to_socket(const char *message)
+void statsd_send(const char *message)
{
int slen = sizeof(server);
@@ -117,11 +117,11 @@ static void send_stat(char *stat, size_t value, const char *type, float sample_r
return;
}
- prepare_stat(stat, value, type, sample_rate, message, MAX_MSG_LEN, 0);
- send_to_socket(message);
+ statsd_prepare(stat, value, type, sample_rate, message, MAX_MSG_LEN, 0);
+ statsd_send(message);
}
-void prepare_stat(char *stat, size_t value, const char *type, float sample_rate, char *message, size_t buflen, int lf)
+void statsd_prepare(char *stat, size_t value, const char *type, float sample_rate, char *message, size_t buflen, int lf)
{
cleanup(stat);
if (sample_rate == 1.0) {
View
@@ -11,9 +11,9 @@ void statsd_finalize(void);
type can be "c", "g" or "ms"
lf - whether line feed needs to be added
*/
-void prepare_stat(char *stat, size_t value, const char *type, float sample_rate, char *buf, size_t buflen, int lf);
+void statsd_prepare(char *stat, size_t value, const char *type, float sample_rate, char *buf, size_t buflen, int lf);
/* manually send a message, which might be composed of several lines. Must be null-terminated */
-void send_to_socket(const char *message);
+void statsd_send(const char *message);
void statsd_inc(char *stat, float sample_rate);
void statsd_dec(char *stat, float sample_rate);
View
@@ -89,21 +89,21 @@ int main(int argc, char *argv[])
pkt[0] = 0;
sysinfo(&si);
- prepare_stat("load", 100*si.loads[0]/0x10000, "g", 1.0, tmp, MAX_LINE_LEN, 1);
+ statsd_prepare("load", 100*si.loads[0]/0x10000, "g", 1.0, tmp, MAX_LINE_LEN, 1);
strcat(pkt, tmp);
- prepare_stat("freemem", si.freeram/1024, "g", 1.0, tmp, MAX_LINE_LEN, 1);
+ statsd_prepare("freemem", si.freeram/1024, "g", 1.0, tmp, MAX_LINE_LEN, 1);
strcat(pkt, tmp);
/*
- prepare_stat("freeswap", si.freeswap/1024, "g", 1.0, tmp, MAX_LINE_LEN, 1);
+ statsd_prepare("freeswap", si.freeswap/1024, "g", 1.0, tmp, MAX_LINE_LEN, 1);
strcat(pkt, tmp);
*/
- prepare_stat("procs", si.procs, "g", 1.0, tmp, MAX_LINE_LEN, 1);
+ statsd_prepare("procs", si.procs, "g", 1.0, tmp, MAX_LINE_LEN, 1);
strcat(pkt, tmp);
- prepare_stat("uptime", si.uptime, "c", 1.0, tmp, MAX_LINE_LEN, 1);
+ statsd_prepare("uptime", si.uptime, "c", 1.0, tmp, MAX_LINE_LEN, 1);
strcat(pkt, tmp);
rewind(net);
@@ -116,10 +116,10 @@ int main(int argc, char *argv[])
for (i = 0, p = strtok_r(line, " ", &lasts); p;
p = strtok_r(NULL, " ", &lasts), i++) {
if (i == 1) {
- prepare_stat("if-rx", atoi(p), "c", 1.0, tmp, MAX_LINE_LEN, 1);
+ statsd_prepare("if-rx", atoi(p), "c", 1.0, tmp, MAX_LINE_LEN, 1);
strcat(pkt, tmp);
} else if (i == 9) {
- prepare_stat("if-tx", atoi(p), "c", 1.0, tmp, MAX_LINE_LEN, 1);
+ statsd_prepare("if-tx", atoi(p), "c", 1.0, tmp, MAX_LINE_LEN, 1);
strcat(pkt, tmp);
break;
}
@@ -133,11 +133,11 @@ int main(int argc, char *argv[])
total = user + sys + idle;
busy = user + sys;
- prepare_stat("cpu", 100 * (busy - old_busy)/(total - old_total), "g", 1.0, tmp, MAX_LINE_LEN, 0);
+ statsd_prepare("cpu", 100 * (busy - old_busy)/(total - old_total), "g", 1.0, tmp, MAX_LINE_LEN, 0);
strcat(pkt, tmp);
// printf("pkt:\n%s\n\n", pkt);
- send_to_socket(pkt);
+ statsd_send(pkt);
old_total = total;
old_busy = busy;
@@ -146,6 +146,7 @@ int main(int argc, char *argv[])
fclose(net);
fclose(stat);
+ statsd_finalize();
exit(0);
}

0 comments on commit 0cda558

Please sign in to comment.