File: status.py

package info (click to toggle)
pyrad 2.5.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 932 kB
  • sloc: python: 4,021; makefile: 15
file content (26 lines) | stat: -rw-r--r-- 724 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/python
from pyrad.client import Client
from pyrad.dictionary import Dictionary
import socket
import sys
import pyrad.packet

srv = Client(server="localhost", authport=18121, secret=b"test", dict=Dictionary("dictionary"))

req = srv.CreateAuthPacket(code=pyrad.packet.StatusServer)
req["FreeRADIUS-Statistics-Type"] = "All"
req.add_message_authenticator()

try:
    print("Sending FreeRADIUS status request")
    reply = srv.SendPacket(req)
except pyrad.client.Timeout:
    print("RADIUS server does not reply")
    sys.exit(1)
except socket.error as error:
    print("Network error: " + error[1])
    sys.exit(1)

print("Attributes returned by server:")
for i in reply.keys():
    print("%s: %s" % (i, reply[i]))