I added following UserParameter.
Prettified version of awk script..
I tested this as following.
But, when I test this by zabbix_agentd -t, it isn't working.
I can't understand why this is not working...
1. How can I solve this problem?
2. Are there any debugging tool or logging to debug UserParameter command?
Thank you so much!
Code:
UserParameter=icmp.ping.loss[*],fping $1 -C 5 -q 2>&1 | awk '{loss=0; cnt=0; for (i=3; i<3+5; i++) { if (length($i)>1) { cnt ++; } else { loss++; }} if (cnt > 0) { print 100*loss/5; } else { print 100; }}'
Code:
{
loss = 0;
cnt = 0;
for (i = 3; i < 3 + 5; i++) {
if (length($i) > 1) {
cnt++;
} else {
loss++;
}
}
if (cnt > 0) {
print 100 * loss / 5;
} else {
print 100;
}
}
I tested this as following.
Code:
# fping 127.0.0.1 -C 5 -q 2>&1 | awk '{loss=0; cnt=0; for (i=3; i<3+5; i++) { if (length($i)>1) { cnt ++; } else { loss++; }} if (cnt > 0) { print 100*loss/5; } else { print 100; }}'
0
# echo "54.248.208.246 : 41.89 40.80 42.49 46.02 -" | awk '{loss=0; cnt=0; for (i=3; i<3+5; i++) { if (length($i)>1) { cnt ++; } else { loss++; }} if (cnt > 0) { print 100*loss/5; } else { print 100; }}'
20
Code:
# zabbix_agentd -t icmp.ping.loss[127.0.0.1] icmp.ping.loss[127.0.0.1] [m|ZBX_NOTSUPPORTED]
I can't understand why this is not working...
1. How can I solve this problem?
2. Are there any debugging tool or logging to debug UserParameter command?
Thank you so much!
Comment