collectd/collectd — pull request #644 by manuelluis (2014-06-18 22:46:14+00:00)
Title: Fix the conversion of time option in PUTNOTIF from timestamp to cdtime_t

The time parsed in PUTNOTIF, a timestamp, is not converted to cdtime_t.

Reported in the mailing list by George B:

Hello,

I have configured a simple test notification using the Exec plugin. This works, however, the Time value in the notification message is changed into something strange (1.307) - can anyone suggest why this is happening?

----
root@croaker:~# cat /etc/collectd/collectd.conf
LoadPlugin exec

NotificationExec "www-data" "/srv/www/notify.sh"
Exec "www-data" "/srv/www/test.sh"

----

----
root@croaker:~# cat /srv/www/test.sh
#!/bin/bash

MESSAGE="Some random text"
SEVERITY="warning"
TIME=`date +%s`

LINE="PUTNOTIF message=\"$MESSAGE\" severity=$SEVERITY time=$TIME"

echo "$LINE" >> /tmp/out.txt

echo "$LINE"
----

----
root@croaker:~# cat /srv/www/notify.sh
#!/bin/bash

echo "$(cat)" >> /tmp/out.txt
----

----
root@croaker:~# tail -n 5 /tmp/out.txt
PUTNOTIF message="Some random text" severity=warning time=1403113649
Severity: WARNING
Time: 1.307

Some random text
----

I am running collectd 5.1.0 (Debian Wheezy).

Thanks,

George