pandoraPlugintools-basic 1.0.3__tar.gz → 1.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pandoraplugintools_basic-1.0.3/pandoraPlugintools_basic.egg-info → pandoraplugintools_basic-1.1.1}/PKG-INFO +3 -1
- {pandoraplugintools_basic-1.0.3 → pandoraplugintools_basic-1.1.1}/README.md +2 -0
- {pandoraplugintools_basic-1.0.3 → pandoraplugintools_basic-1.1.1}/pandoraPlugintools/__init__.py +2 -1
- {pandoraplugintools_basic-1.0.3 → pandoraplugintools_basic-1.1.1}/pandoraPlugintools/discovery.py +1 -1
- {pandoraplugintools_basic-1.0.3 → pandoraplugintools_basic-1.1.1}/pandoraPlugintools/general.py +3 -3
- {pandoraplugintools_basic-1.0.3 → pandoraplugintools_basic-1.1.1}/pandoraPlugintools/modules.py +10 -1
- pandoraplugintools_basic-1.1.1/pandoraPlugintools/monitoring.py +86 -0
- {pandoraplugintools_basic-1.0.3 → pandoraplugintools_basic-1.1.1/pandoraPlugintools_basic.egg-info}/PKG-INFO +3 -1
- {pandoraplugintools_basic-1.0.3 → pandoraplugintools_basic-1.1.1}/pandoraPlugintools_basic.egg-info/SOURCES.txt +1 -0
- {pandoraplugintools_basic-1.0.3 → pandoraplugintools_basic-1.1.1}/setup.cfg +1 -1
- {pandoraplugintools_basic-1.0.3 → pandoraplugintools_basic-1.1.1}/setup.py +1 -1
- pandoraplugintools_basic-1.1.1/tests/test_basic.py +12 -0
- pandoraplugintools_basic-1.0.3/tests/test_basic.py +0 -2
- {pandoraplugintools_basic-1.0.3 → pandoraplugintools_basic-1.1.1}/LICENSE +0 -0
- {pandoraplugintools_basic-1.0.3 → pandoraplugintools_basic-1.1.1}/pandoraPlugintools/agents.py +0 -0
- {pandoraplugintools_basic-1.0.3 → pandoraplugintools_basic-1.1.1}/pandoraPlugintools/output.py +0 -0
- {pandoraplugintools_basic-1.0.3 → pandoraplugintools_basic-1.1.1}/pandoraPlugintools/threads.py +0 -0
- {pandoraplugintools_basic-1.0.3 → pandoraplugintools_basic-1.1.1}/pandoraPlugintools/transfer.py +0 -0
- {pandoraplugintools_basic-1.0.3 → pandoraplugintools_basic-1.1.1}/pandoraPlugintools_basic.egg-info/dependency_links.txt +0 -0
- {pandoraplugintools_basic-1.0.3 → pandoraplugintools_basic-1.1.1}/pandoraPlugintools_basic.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pandoraPlugintools-basic
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.1
|
|
4
4
|
Summary: A plugin tool set of basic functions for pandorafms
|
|
5
5
|
Home-page: https://github.com/pandorafms/pandoraPlugintoolsBasic
|
|
6
6
|
Author: PandoraFMS projects department
|
|
@@ -55,6 +55,8 @@ The package exports the following modules:
|
|
|
55
55
|
Reference documentation:
|
|
56
56
|
[PluginTools Reference Documentation](https://pandorafms.com/guides/public/books/plugintools)
|
|
57
57
|
|
|
58
|
+
For a full, runnable example per function, see [docs/examples.md](docs/examples.md).
|
|
59
|
+
|
|
58
60
|
## Most used functions
|
|
59
61
|
|
|
60
62
|
The README stays focused on the quick path. For a complete function list and full details, use the reference documentation link above.
|
|
@@ -38,6 +38,8 @@ The package exports the following modules:
|
|
|
38
38
|
Reference documentation:
|
|
39
39
|
[PluginTools Reference Documentation](https://pandorafms.com/guides/public/books/plugintools)
|
|
40
40
|
|
|
41
|
+
For a full, runnable example per function, see [docs/examples.md](docs/examples.md).
|
|
42
|
+
|
|
41
43
|
## Most used functions
|
|
42
44
|
|
|
43
45
|
The README stays focused on the quick path. For a complete function list and full details, use the reference documentation link above.
|
{pandoraplugintools_basic-1.0.3 → pandoraplugintools_basic-1.1.1}/pandoraPlugintools/general.py
RENAMED
|
@@ -315,13 +315,13 @@ def _print_debug(var="", print_errors: bool = False):
|
|
|
315
315
|
#########################################################################################
|
|
316
316
|
def safe_input(input_string: str = "") -> str:
|
|
317
317
|
"""
|
|
318
|
-
Convert an input string
|
|
318
|
+
Convert special characters in an input string to their corresponding HTML entities.
|
|
319
319
|
|
|
320
320
|
Args:
|
|
321
|
-
input_string (str): The input string
|
|
321
|
+
input_string (str): The input string containing characters to encode.
|
|
322
322
|
|
|
323
323
|
Returns:
|
|
324
|
-
str: The
|
|
324
|
+
str: The encoded string with special characters replaced by HTML entities.
|
|
325
325
|
"""
|
|
326
326
|
if not input_string:
|
|
327
327
|
return ""
|
{pandoraplugintools_basic-1.0.3 → pandoraplugintools_basic-1.1.1}/pandoraPlugintools/modules.py
RENAMED
|
@@ -86,6 +86,13 @@ def init_module(
|
|
|
86
86
|
if key in module:
|
|
87
87
|
module[key] = value
|
|
88
88
|
|
|
89
|
+
# Compatibility alias: whichever of 'data'/'value' the caller explicitly
|
|
90
|
+
# set, mirror it onto the other one if that other one was not also set.
|
|
91
|
+
if "data" in default_values and "value" not in default_values:
|
|
92
|
+
module["value"] = module["data"]
|
|
93
|
+
elif "value" in default_values and "data" not in default_values:
|
|
94
|
+
module["data"] = module["value"]
|
|
95
|
+
|
|
89
96
|
return module
|
|
90
97
|
|
|
91
98
|
####
|
|
@@ -115,7 +122,9 @@ def print_module(
|
|
|
115
122
|
if "description" in data:
|
|
116
123
|
data["desc"] = data["description"]
|
|
117
124
|
|
|
118
|
-
|
|
125
|
+
# Modules built by hand (bypassing init_module()) often only set
|
|
126
|
+
# 'data', not 'value' -- fall back to 'data' when 'value' is missing.
|
|
127
|
+
if "value" not in data and "data" in data:
|
|
119
128
|
data["value"] = data["data"]
|
|
120
129
|
|
|
121
130
|
module_xml = ("<module>\n"
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
####
|
|
4
|
+
# Define some global variables
|
|
5
|
+
#########################################################################################
|
|
6
|
+
|
|
7
|
+
_MONITORING_ITEMS = []
|
|
8
|
+
|
|
9
|
+
####
|
|
10
|
+
# Set fixed list of monitoring items
|
|
11
|
+
#########################################################################################
|
|
12
|
+
def set_monitoring_items(data: list = []) -> None:
|
|
13
|
+
"""
|
|
14
|
+
Sets the monitoring items list to the specified value.
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
data (list): A list of monitoring item dicts, each with 'agent_data'
|
|
18
|
+
and 'module_data' keys, as accepted by the '/monitoring' API endpoint.
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
None
|
|
22
|
+
"""
|
|
23
|
+
global _MONITORING_ITEMS
|
|
24
|
+
|
|
25
|
+
_MONITORING_ITEMS = data
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
####
|
|
29
|
+
# Add one monitoring item (agent_data + module_data)
|
|
30
|
+
#########################################################################################
|
|
31
|
+
def add_monitoring_item(agent_data: dict = {}, module_data: list = []) -> None:
|
|
32
|
+
"""
|
|
33
|
+
Adds one monitoring item to the internal monitoring items list.
|
|
34
|
+
|
|
35
|
+
Builds a single entry of the '/monitoring' API payload array from an
|
|
36
|
+
agent dict and a list of module dicts. Both are plain dicts the caller
|
|
37
|
+
already built (e.g. via 'init_agent()'/'init_module()' or by hand);
|
|
38
|
+
this function does not validate or transform their shape.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
agent_data (dict): A dictionary containing agent configuration.
|
|
42
|
+
module_data (list): A list of dictionaries representing modules.
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
None
|
|
46
|
+
"""
|
|
47
|
+
global _MONITORING_ITEMS
|
|
48
|
+
|
|
49
|
+
_MONITORING_ITEMS.append({"agent_data": agent_data, "module_data": module_data})
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
####
|
|
53
|
+
# Get monitoring items
|
|
54
|
+
#########################################################################################
|
|
55
|
+
def get_monitoring_items() -> list:
|
|
56
|
+
"""
|
|
57
|
+
Retrieves the current monitoring items list.
|
|
58
|
+
|
|
59
|
+
Returns:
|
|
60
|
+
list: The list of monitoring items accumulated so far.
|
|
61
|
+
"""
|
|
62
|
+
return _MONITORING_ITEMS
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
####
|
|
66
|
+
# Build (and optionally print) the monitoring API payload as JSON
|
|
67
|
+
#########################################################################################
|
|
68
|
+
def print_monitoring_payload(print_flag: bool = False) -> str:
|
|
69
|
+
"""
|
|
70
|
+
Build the JSON array ready to be sent as the request body to the
|
|
71
|
+
'/monitoring' API endpoint, optionally printing it.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
print_flag (bool): A flag indicating whether to print the JSON payload.
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
str: The JSON representation of the monitoring items list.
|
|
78
|
+
"""
|
|
79
|
+
json_string = json.dumps(_MONITORING_ITEMS)
|
|
80
|
+
|
|
81
|
+
if print_flag:
|
|
82
|
+
from .output import print_stdout
|
|
83
|
+
|
|
84
|
+
print_stdout(json_string)
|
|
85
|
+
|
|
86
|
+
return json_string
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pandoraPlugintools-basic
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.1
|
|
4
4
|
Summary: A plugin tool set of basic functions for pandorafms
|
|
5
5
|
Home-page: https://github.com/pandorafms/pandoraPlugintoolsBasic
|
|
6
6
|
Author: PandoraFMS projects department
|
|
@@ -55,6 +55,8 @@ The package exports the following modules:
|
|
|
55
55
|
Reference documentation:
|
|
56
56
|
[PluginTools Reference Documentation](https://pandorafms.com/guides/public/books/plugintools)
|
|
57
57
|
|
|
58
|
+
For a full, runnable example per function, see [docs/examples.md](docs/examples.md).
|
|
59
|
+
|
|
58
60
|
## Most used functions
|
|
59
61
|
|
|
60
62
|
The README stays focused on the quick path. For a complete function list and full details, use the reference documentation link above.
|
|
@@ -8,7 +8,7 @@ with open("README.md", mode="r", encoding="utf-8") as f:
|
|
|
8
8
|
|
|
9
9
|
setup(
|
|
10
10
|
name="pandoraPlugintools-basic",
|
|
11
|
-
version="1.
|
|
11
|
+
version="1.1.1",
|
|
12
12
|
author="PandoraFMS projects department",
|
|
13
13
|
author_email="<info@pandorafms.com>",
|
|
14
14
|
description="A plugin tool set of basic functions for pandorafms",
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import pandoraPlugintools as ppt
|
|
2
|
+
|
|
3
|
+
m = ppt.init_module({"name": "x", "value": "10"})
|
|
4
|
+
assert "<data><![CDATA[10]]></data>" in ppt.print_module(m)
|
|
5
|
+
|
|
6
|
+
ppt.set_monitoring_items([])
|
|
7
|
+
ppt.add_monitoring_item({"agent_name": "host1"}, [{"name": "CPU", "type": "generic_data", "data": 30}])
|
|
8
|
+
payload = ppt.print_monitoring_payload()
|
|
9
|
+
assert '"agent_data"' in payload and '"module_data"' in payload
|
|
10
|
+
ppt.set_monitoring_items([])
|
|
11
|
+
|
|
12
|
+
print("ok")
|
|
File without changes
|
{pandoraplugintools_basic-1.0.3 → pandoraplugintools_basic-1.1.1}/pandoraPlugintools/agents.py
RENAMED
|
File without changes
|
{pandoraplugintools_basic-1.0.3 → pandoraplugintools_basic-1.1.1}/pandoraPlugintools/output.py
RENAMED
|
File without changes
|
{pandoraplugintools_basic-1.0.3 → pandoraplugintools_basic-1.1.1}/pandoraPlugintools/threads.py
RENAMED
|
File without changes
|
{pandoraplugintools_basic-1.0.3 → pandoraplugintools_basic-1.1.1}/pandoraPlugintools/transfer.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|