flexmetric 0.1.2__tar.gz → 0.1.4__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.
- {flexmetric-0.1.2 → flexmetric-0.1.4}/PKG-INFO +1 -1
- {flexmetric-0.1.2 → flexmetric-0.1.4}/flexmetric/metric_process/prometheus_agent.py +5 -2
- {flexmetric-0.1.2 → flexmetric-0.1.4}/flexmetric.egg-info/PKG-INFO +1 -1
- {flexmetric-0.1.2 → flexmetric-0.1.4}/flexmetric.egg-info/SOURCES.txt +0 -1
- {flexmetric-0.1.2 → flexmetric-0.1.4}/setup.py +2 -2
- flexmetric-0.1.2/flexmetric/metric_process/process_commands.py +0 -73
- {flexmetric-0.1.2 → flexmetric-0.1.4}/README.md +0 -0
- {flexmetric-0.1.2 → flexmetric-0.1.4}/flexmetric/__init__.py +0 -0
- {flexmetric-0.1.2 → flexmetric-0.1.4}/flexmetric/config/__init__.py +0 -0
- {flexmetric-0.1.2 → flexmetric-0.1.4}/flexmetric/config/configuration.py +0 -0
- {flexmetric-0.1.2 → flexmetric-0.1.4}/flexmetric/file_recognition/__init__.py +0 -0
- {flexmetric-0.1.2 → flexmetric-0.1.4}/flexmetric/file_recognition/exec_file.py +0 -0
- {flexmetric-0.1.2 → flexmetric-0.1.4}/flexmetric/logging_module/__init__.py +0 -0
- {flexmetric-0.1.2 → flexmetric-0.1.4}/flexmetric/logging_module/logger.py +0 -0
- {flexmetric-0.1.2 → flexmetric-0.1.4}/flexmetric/metric_process/__init__.py +0 -0
- {flexmetric-0.1.2 → flexmetric-0.1.4}/flexmetric/metric_process/database_processing.py +0 -0
- {flexmetric-0.1.2 → flexmetric-0.1.4}/flexmetric.egg-info/dependency_links.txt +0 -0
- {flexmetric-0.1.2 → flexmetric-0.1.4}/flexmetric.egg-info/entry_points.txt +0 -0
- {flexmetric-0.1.2 → flexmetric-0.1.4}/flexmetric.egg-info/requires.txt +0 -0
- {flexmetric-0.1.2 → flexmetric-0.1.4}/flexmetric.egg-info/top_level.txt +0 -0
- {flexmetric-0.1.2 → flexmetric-0.1.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: flexmetric
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.4
|
4
4
|
Summary: A flexible Prometheus exporter for commands, databases, functions, and scripts.
|
5
5
|
Home-page: https://github.com/nikhillingadhal1999/custom_prometheus_agent
|
6
6
|
Author: Nikhil Lingadhal
|
@@ -96,7 +96,8 @@ def measure(init_flag,args):
|
|
96
96
|
exec_result.extend(function_results)
|
97
97
|
if args.commands:
|
98
98
|
cmd_results = process_commands(args.commands_config)
|
99
|
-
|
99
|
+
if cmd_results != None:
|
100
|
+
exec_result.extend(cmd_results)
|
100
101
|
# exec_result = process_commands('commands.yaml')
|
101
102
|
# print(exec_result)
|
102
103
|
global gauges
|
@@ -123,7 +124,8 @@ def measure(init_flag,args):
|
|
123
124
|
label_dict = dict(zip(labels, result['label']))
|
124
125
|
gauge.labels(**label_dict).set(convert_to_data_type(result['value']))
|
125
126
|
|
126
|
-
|
127
|
+
|
128
|
+
def main():
|
127
129
|
args = arguments()
|
128
130
|
print("Validating configuration...")
|
129
131
|
if not validate_all_modes(args):
|
@@ -138,3 +140,4 @@ if __name__ == "__main__":
|
|
138
140
|
measure(flag,args)
|
139
141
|
flag = False
|
140
142
|
time.sleep(5)
|
143
|
+
main()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: flexmetric
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.4
|
4
4
|
Summary: A flexible Prometheus exporter for commands, databases, functions, and scripts.
|
5
5
|
Home-page: https://github.com/nikhillingadhal1999/custom_prometheus_agent
|
6
6
|
Author: Nikhil Lingadhal
|
@@ -2,14 +2,14 @@ from setuptools import setup, find_packages
|
|
2
2
|
|
3
3
|
setup(
|
4
4
|
name="flexmetric",
|
5
|
-
version="0.1.
|
5
|
+
version="0.1.4",
|
6
6
|
author="Nikhil Lingadhal",
|
7
7
|
description="A flexible Prometheus exporter for commands, databases, functions, and scripts.",
|
8
8
|
long_description=open("README.md").read(),
|
9
9
|
long_description_content_type="text/markdown",
|
10
10
|
url="https://github.com/nikhillingadhal1999/custom_prometheus_agent",
|
11
11
|
license="MIT",
|
12
|
-
packages=find_packages(),
|
12
|
+
packages=find_packages(),
|
13
13
|
install_requires=[
|
14
14
|
"prometheus_client",
|
15
15
|
"PyYAML",
|
@@ -1,73 +0,0 @@
|
|
1
|
-
import subprocess
|
2
|
-
import yaml
|
3
|
-
import re
|
4
|
-
|
5
|
-
# 1. Read YAML commands
|
6
|
-
def read_commands_from_yaml(file_path):
|
7
|
-
with open(file_path, 'r') as f:
|
8
|
-
config = yaml.safe_load(f)
|
9
|
-
return config.get('commands', [])
|
10
|
-
|
11
|
-
# 2. Execute command with timeout
|
12
|
-
def execute_command_with_timeout(command, timeout):
|
13
|
-
try:
|
14
|
-
result = subprocess.run(command, shell=True, capture_output=True, text=True, timeout=timeout)
|
15
|
-
if result.returncode != 0:
|
16
|
-
return ''
|
17
|
-
return result.stdout.strip()
|
18
|
-
except subprocess.TimeoutExpired:
|
19
|
-
return ''
|
20
|
-
|
21
|
-
def process_commands(config_file):
|
22
|
-
commands = read_commands_from_yaml(config_file)
|
23
|
-
all_results = []
|
24
|
-
|
25
|
-
for cmd_info in commands:
|
26
|
-
command = cmd_info['command']
|
27
|
-
label_name = cmd_info['label']
|
28
|
-
timeout = cmd_info.get('timeout_seconds', 30)
|
29
|
-
label_column = cmd_info.get('label_column', -1)
|
30
|
-
value_column = cmd_info.get('value_column', 0)
|
31
|
-
fixed_label_value = cmd_info.get('label_value')
|
32
|
-
|
33
|
-
raw_output = execute_command_with_timeout(command, timeout)
|
34
|
-
lines = raw_output.strip().splitlines()
|
35
|
-
|
36
|
-
result_list = []
|
37
|
-
|
38
|
-
for line in lines:
|
39
|
-
parts = line.strip().split()
|
40
|
-
if not parts:
|
41
|
-
continue
|
42
|
-
if label_column == 'fixed':
|
43
|
-
label = fixed_label_value or 'label'
|
44
|
-
else:
|
45
|
-
try:
|
46
|
-
label = parts[label_column]
|
47
|
-
except IndexError:
|
48
|
-
label = 'unknown'
|
49
|
-
try:
|
50
|
-
raw_value = parts[value_column]
|
51
|
-
cleaned_value = re.sub(r'[^\d\.\-]', '', raw_value)
|
52
|
-
value = float(cleaned_value) if cleaned_value else 1
|
53
|
-
except (IndexError, ValueError):
|
54
|
-
value = 1
|
55
|
-
|
56
|
-
result_list.append({
|
57
|
-
'label': label,
|
58
|
-
'value': value
|
59
|
-
})
|
60
|
-
|
61
|
-
formatted = {
|
62
|
-
'result': result_list,
|
63
|
-
'labels': [label_name]
|
64
|
-
}
|
65
|
-
all_results.append(formatted)
|
66
|
-
|
67
|
-
return all_results
|
68
|
-
|
69
|
-
|
70
|
-
# # Example usage:
|
71
|
-
# if __name__ == "__main__":
|
72
|
-
# results = process_commands('/Users/nlingadh/code/custom_prometheus_agent/src/commands.yaml')
|
73
|
-
# print(results)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|