- 28 Dec 2021
- 1 Minute to read
-
Print
-
DarkLight
Snapt Aria Framework API Documentation
- Updated on 28 Dec 2021
- 1 Minute to read
-
Print
-
DarkLight
Please ensure you have read the beginners guide in order to understand the commands below.
OS Module
The OS module provides various OS functions, all of which you can request using the system.listMethods call to the /os API. Below are some examples of common commands.
IP/Network Related Commands
print(str(proxy.os.getInterfaces()));
['lo', 'eth0']
print(str(proxy.os.getIPs()));
{'1': '192.168.1.231', '0': '192.168.1.240', '2': '127.0.0.1'}
System Related Commands
print(str(proxy.os.getCPUUsage()));
11
print(str(proxy.os.getMemoryUsage()));
{'Used': 455.65234375, 'Free': 1551.4921875}
A full listing is available with the system.listMethods call:
['system.listMethods', 'system.methodHelp', 'system.methodSignature', 'system.multicall', 'os.getInterfaces', 'os.getIPs', 'os.getDiskUsage', 'os.getLoadAverages', 'os.getMemoryUsage', 'os.getProgramMemoryUsage', 'os.getProgramCPUUsage', 'os.getCPUUsage', 'os.getOs', 'os.top', 'os.ps', 'os.dmesg', 'os.uname', 'os.writeSysctls']
Activity and Notices Modules
The activity module handles activity logging on the system, and the notices module handles alerts. They both function in the same fashion.
proxy = xmlrpclib.ServerProxy("http://localhost:8080/api/key/secret/activity");
print(str(proxy.activity.getLogs(10)));
[{'action': 'Snapt blacklist automatically updated [fail2ban].', 'userid': '0', 'tstamp': '2015-02-25 12:01'}, {'action': 'Snapt blacklist automatically updated [bogon].', 'userid': '0', 'tstamp': '2015-02-25 12:00'}, {'action': 'Snapt blacklist automatically updated [threats].', 'userid': '0', 'tstamp': '2015-02-25 12:00'}, {'action': 'Snapt blacklist automatically updated [spam].', 'userid': '0', 'tstamp': '2015-02-25 12:00'}, {'action': 'Snapt blacklist automatically updated [scanners].', 'userid': '0', 'tstamp': '2015-02-25 12:00'}, {'action': "Automatic directory creation: '/var/snapt/backups/haproxy'", 'userid': '-1', 'tstamp': '2015-02-25 11:59'}, {'action': "Automatic directory creation: '/var/snapt/backups/haproxy'", 'userid': '-1', 'tstamp': '2015-02-25 11:57'}, {'action': "Automatic directory creation: '/var/snapt/backups/haproxy'", 'userid': '-1', 'tstamp': '2015-02-25 11:55'}, {'action': "Automatic directory creation: '/var/snapt/backups/haproxy'", 'userid': '1', 'tstamp': '2015-02-25 11:24'}, {'action': 'A frontend (<strong>test</strong>) was edited in Balancer.', 'userid': '1', 'tstamp': '2015-02-25 11:24'}]
proxy = xmlrpclib.ServerProxy("http://localhost:8080/api/key/secret/notices");
print(str(proxy.notices.getUnread(10)));
[{'msg': 'A monitored process was not running! Restart attempted.', 'type': 'e', 'id': '5982', 'tstamp': '2020-03-07 22:17:27'}, {'msg': 'A monitored process was not running! Restart attempted.', 'type': 'e', 'id': '5979', 'tstamp': '2020-02-15 19:54:48'}, {'msg': 'A monitored process (nginx) was not running! Restart attempted.', 'type': 'e', 'id': '5978', 'tstamp': '2020-02-15 19:54:32'}]
Please also refer to the developers section of this site for further documentation.