Re: yet another python qa failure (pmrep)
"Marko Myllynen" <[email protected]> Wed, 15 Feb 2017 21:59:36 +0200
| Newsgroups | gmane.comp.sysutils.pcp |
|---|---|
| Organization | Red Hat |
| Message-ID | <[email protected]> |
Hi,
On 2017-02-15 03:48, Nathan Scott wrote:
>
> ----- Original Message -----
>> This time qa/1068 on vm28 (RHEL Server 6.8)
>>
>> --- pmrep stderr --
>> Traceback (most recent call last):
>> File "/usr/bin/pmrep", line 1622, in <module>
>> P.execute()
>> File "/usr/bin/pmrep", line 1008, in execute
>> self.report(self.pmfg_ts())
>> File "/usr/bin/pmrep", line 1029, in report
>> self.write_zabbix(tstamp)
>> File "/usr/bin/pmrep", line 1568, in write_zabbix
>> ts = (self.pmfg_ts() - datetime.fromtimestamp(0)).total_seconds()
>> AttributeError: 'datetime.timedelta' object has no attribute 'total_seconds'
>
> Looks like total_seconds() is new in python 2.7, and RHEL6 contains
> an earlier version. https://docs.python.org/2/library/datetime.html
> We could do the calculation by hand I guess?
Yeah, this should do it:
---
src/pmrep/pmrep.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/pmrep/pmrep.py b/src/pmrep/pmrep.py
index fd2fb8c..8910444 100755
--- a/src/pmrep/pmrep.py
+++ b/src/pmrep/pmrep.py
@@ -1565,7 +1565,8 @@ class PMReporter(object):
return
# Collect the results
- ts = (self.pmfg_ts() - datetime.fromtimestamp(0)).total_seconds()
+ td = self.pmfg_ts() - datetime.fromtimestamp(0)
+ ts = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6
if self.zabbix_prevsend == None:
self.zabbix_prevsend = ts
for i, metric in enumerate(self.metrics):
Thanks,
--
Marko Myllynen
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links:
You receive all messages sent to this group.
View/Reply Online (#15181): https://groups.io/g/pcp/message/15181
View All Messages In Topic (2): https://groups.io/g/pcp/topic/4367510
Mute This Topic: https://groups.io/mt/4367510?uid=174580
New Topic: https://groups.io/g/pcp/post
-=-=-
pcp mailing list
[email protected]
https://groups.io/g/pcp/messages
-=-=-
Change Your Subscription: https://groups.io/g/pcp/editsub?uid=174580
Group Home: https://groups.io/g/pcp
Contact Group Owner: [email protected]
Terms of Service: https://groups.io/static/tos
Unsubscribe: https://groups.io/g/pcp/leave/354243/563757577/xyzzy
-=-=-=-=-=-=-=-=-=-=-=-