Skip to content

Commit 61094a1

Browse files
committed
update Python script examples to python3
1 parent 60590d0 commit 61094a1

File tree

5 files changed

+13
-14
lines changed

5 files changed

+13
-14
lines changed

src/Linux/scripts/rtflow.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
# command-line utility to send JSON-encoded rtflow records through hsflowd.
4-
# requires "jsonPort=36343" in hsflowd.conf.
4+
# requires "json { udpport=36343 }" in hsflowd.conf.
55

66
import argparse
77
import json
@@ -42,4 +42,4 @@
4242

4343
msg = {"rtflow":metrics}
4444
sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
45-
sock.sendto(json.dumps(msg),("127.0.0.1",36343))
45+
sock.sendto(json.dumps(msg).encode(),("127.0.0.1",36343))

src/Linux/scripts/rtmetric.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
# command-line utility to send JSON-encoded rtmetric values through hsflowd.
4-
# requires "jsonPort=36343" in hsflowd.conf.
4+
# requires "json { udpport=36343 }" in hsflowd.conf.
55

66
import argparse
77
import json

src/Linux/scripts/rtmetric_cpu.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
# Send JSON-encoded rtmetric messages through hsflowd to provide
44
# separate moniting of every CPU.
55

6-
# Requires "jsonPort=36343" in hsflowd.conf.
6+
# Requires "json { udpport=36343 }" in hsflowd.conf.
77

88
# This should be executed periodically e.g. by cron(1)
99
# or like this at the shell prompt for testing:
@@ -31,5 +31,5 @@
3131
'cpu_x_sintr': { "type":"counter32", "value": int(toks[7]) }
3232
}
3333
}
34-
sock.sendto(json.dumps(msg), ('127.0.0.1', 36343))
34+
sock.sendto(json.dumps(msg).encode(), ('127.0.0.1', 36343))
3535
inputfile.close()

src/Linux/scripts/rtmetric_disk.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
# Send JSON-encoded rtmetric through hsflowd to provide
44
# separate moniting of every local disk partition.
55

6-
# Requires "jsonPort=36343" in hsflowd.conf.
6+
# Requires "json {udpport=36343 }" in hsflowd.conf.
77

88
# This should be executed periodically e.g. by cron(1)
99
# or like this at the shell prompt for testing:
@@ -14,10 +14,9 @@
1414
import time
1515
import os
1616
import re
17-
from string import maketrans
1817

1918
# we are going to translate '/' to '_' in the mount point names
20-
transtab = maketrans("/", "_")
19+
transtab = str.maketrans("/", "_")
2120

2221
# match the subset of mount points that we want to report on
2322
pattern = re.compile('^/$|^/tmp|^/usr/')
@@ -43,5 +42,5 @@
4342
}
4443
}
4544
# print json.dumps(msg)
46-
sock.sendto(json.dumps(msg), ('127.0.0.1', 36343))
45+
sock.sendto(json.dumps(msg).encode(), ('127.0.0.1', 36343))
4746
p.close()

src/Linux/scripts/telemetry.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python3
1+
#!/usr/bin/env python3
22
import dbus
33
bus = dbus.SystemBus()
44

0 commit comments

Comments
 (0)