1 diff -ur apinger-0.6.1.orig//src/apinger.c apinger-0.6.1/src/apinger.c
2 --- apinger-0.6.1.orig//src/apinger.c 2012-07-26 11:10:07.608188198 +0000
3 +++ apinger-0.6.1/src/apinger.c 2012-07-26 11:09:49.216188301 +0000
8 - fprintf(f,"%s\n",ctime(&tm));
9 + if(!config->status_format) fprintf(f,"%s\n",ctime(&tm));
10 for(t=targets;t;t=t->next){
11 - fprintf(f,"Target: %s\n",t->name);
12 - fprintf(f,"Source IP: %s\n",t->config->srcip);
13 - fprintf(f,"Description: %s\n",t->description);
14 - fprintf(f,"Last reply received: #%i %s",t->last_received,
15 - ctime(&t->last_received_tv.tv_sec));
16 - fprintf(f,"Average delay: %0.3fms\n",AVG_DELAY(t));
17 + if(config->status_format){
18 + fprintf(f,"%s|%s|%s|%i|%i|%u|",t->name, t->config->srcip, t->description, t->last_sent+1,
19 + t->received, t->last_received_tv.tv_sec);
20 + fprintf(f,"%0.3fms|", AVG_DELAY(t));
23 + fprintf(f,"Target: %s\n",t->name);
24 + fprintf(f,"Source IP: %s\n",t->config->srcip);
25 + fprintf(f,"Description: %s\n",t->description);
26 + fprintf(f,"Last reply received: #%i %s",t->last_received,
27 + ctime(&t->last_received_tv.tv_sec));
28 + fprintf(f,"Average delay: %0.3fms\n",AVG_DELAY(t));
30 if (AVG_LOSS_KNOWN(t)){
31 - fprintf(f,"Average packet loss: %0.1f%%\n",AVG_LOSS(t));
32 + if(config->status_format){
33 + fprintf(f,"%0.1f%%",AVG_LOSS(t));
36 + fprintf(f,"Average packet loss: %0.1f%%\n",AVG_LOSS(t));
39 + if(config->status_format){
43 + fprintf(f,"Active alarms:");
45 - fprintf(f,"Active alarms:");
46 if (t->active_alarms){
47 for(al=t->active_alarms;al;al=al->next){
49 - fprintf(f," \"%s\"",a->name);
50 + if(config->status_format){
51 + fprintf(f,"%s",a->name);
54 + fprintf(f," \"%s\"",a->name);
58 + if(!config->status_format) fprintf(f,"\n");
60 - else fprintf(f," None\n");
61 + else fprintf(f," none");
62 + if(!config->status_format) fprintf(f,"\n");
64 buf1=NEW(char,t->config->avg_loss_delay_samples+1);
65 buf2=NEW(char,t->config->avg_loss_samples+1);
66 diff -ur apinger-0.6.1.orig//src/apinger.conf apinger-0.6.1/src/apinger.conf
67 --- apinger-0.6.1.orig//src/apinger.conf 2012-07-26 11:24:35.000000000 +0000
68 +++ apinger-0.6.1/src/apinger.conf 2012-07-26 11:30:33.352064094 +0000
70 # ## Interval between file updates
71 # ## when 0 or not set, file is written only when SIGUSR1 is received
74 +# ## Create status file in script parseable format (on) or human
75 +# ## readable format (off)
79 ########################################
80 diff -ur apinger-0.6.1.orig//src/cfgparser1.y apinger-0.6.1/src/cfgparser1.y
81 --- apinger-0.6.1.orig//src/cfgparser1.y 2012-07-26 10:15:23.000000000 +0000
82 +++ apinger-0.6.1/src/cfgparser1.y 2012-07-26 10:35:18.153063319 +0000
84 %token AVG_LOSS_DELAY_SAMPLES
92 { cur_config.status_interval=$2; }
94 { cur_config.status_interval=$2; }
95 + | SCRIPTFORMAT boolean
96 + { cur_config.status_format=$2; }
97 | statuscfg separator statuscfg
100 diff -ur apinger-0.6.1.orig//src/cfgparser2.l apinger-0.6.1/src/cfgparser2.l
101 --- apinger-0.6.1.orig//src/cfgparser2.l 2012-07-26 10:15:23.000000000 +0000
102 +++ apinger-0.6.1/src/cfgparser2.l 2012-07-26 10:31:46.408063728 +0000
104 down { LOC; LOCINC; return DOWN; }
105 false { LOC; LOCINC; return FALSE; }
106 file { LOC; LOCINC; return FILE_; }
107 +scriptformat { LOC; LOCINC; return SCRIPTFORMAT; }
108 group { LOC; LOCINC; return GROUP; }
109 interval { LOC; LOCINC; return INTERVAL; }
110 loss { LOC; LOCINC; return LOSS; }
111 diff -ur apinger-0.6.1.orig//src/conf.h apinger-0.6.1/src/conf.h
112 --- apinger-0.6.1.orig//src/conf.h 2012-07-26 10:15:23.000000000 +0000
113 +++ apinger-0.6.1/src/conf.h 2012-07-26 10:33:09.770251230 +0000
119 char *timestamp_format;
122 diff -ur apinger-0.6.1.orig//src/main.c apinger-0.6.1/src/main.c
123 --- apinger-0.6.1.orig//src/main.c 2012-07-26 10:15:23.000000000 +0000
124 +++ apinger-0.6.1/src/main.c 2012-07-26 11:13:52.643188408 +0000
126 "/var/run/apinger.pid", /* pid file */
127 NULL, /* status file */
128 0, /* status interval */
129 + 0, /* status format */
130 "%b %d %H:%M:%S" /* timestamp format */