Index: /branches/amp_3_7_2/src/webui/webui/htdocs/new/src/djproject/urls.py
===================================================================
--- /branches/amp_3_7_2/src/webui/webui/htdocs/new/src/djproject/urls.py	(revision 2749)
+++ /branches/amp_3_7_2/src/webui/webui/htdocs/new/src/djproject/urls.py	(working copy)
@@ -16,6 +16,8 @@
 from hive.report.generate_report import handle_report_generation
 from hive.controller.backup_controller import handle_backup_req
 from hive.controller.restore_controller import handle_restore_req
+from hive.controller.snmpv3_controller import handle_snmpv3_req
+from hive.controller.telegraf_controller import handle_telegraf_req
 
 js_info_dict = {
     #'packages': ('your.app.package',),
@@ -67,6 +69,8 @@
     url(r'^log/(?P<app>\w+)$', handle_log_location_app),
     url(r'^backup/(?P<path>.*)$', handle_backup_req),
     url(r'^restore/(?P<path>.*)$', handle_restore_req),
+    url(r'^snmpv3/(?P<path>.*)$', handle_snmpv3_req),
+    url(r'^telegraf/(?P<path>.*)$', handle_telegraf_req),
     url(r'^real_service$', real_service),
     url(r'^rs_block$', rs_block),
     url(r'^rs_block_import$', rs_block_import),
Index: /branches/amp_3_7_2/src/webui/webui/htdocs/new/src/hive/controller/snmpv3_controller.py
===================================================================
--- /branches/amp_3_7_2/src/webui/webui/htdocs/new/src/hive/controller/snmpv3_controller.py	(nonexistent)
+++ /branches/amp_3_7_2/src/webui/webui/htdocs/new/src/hive/controller/snmpv3_controller.py	(working copy)
@@ -0,0 +1,80 @@
+import json
+from django.http import HttpResponse, HttpResponseBadRequest
+from hive.util.utils import json_response
+from hive.services.snmpv3_service import (enable_snmp_v3, disable_snmp_v3, save_user_details, add_snmpv3_user_to_conf,
+                                          restart_snmp_service, get_snmp_v3_users)
+
+
+def handle_snmpv3_req(request, path=None):
+    if request.method == 'POST':
+        if path == 'enable':
+            return enable_snmpv3()
+        elif path == 'disable':
+            return disable_snmpv3()
+        elif path == 'configure':
+            return configure_snmpv3(request)
+    elif request.method == 'GET':
+        if path == 'users':
+            return get_snmpv3_users()
+    return json_response({
+        'error': 400,
+        'message': "Invalid HTTP method"
+    }, status=400)
+
+
+def enable_snmpv3():
+
+    try:
+        success, message = enable_snmp_v3()
+
+    except Exception as e:
+        return json_response({"error": "Failed to enable/start snmpd"}, status=400)
+
+    if success:
+        return json_response({"message": message}, status=200)
+    return json_response({"error": message}, status=500)
+
+
+def disable_snmpv3():
+    try:
+        success, message = disable_snmp_v3()
+
+    except Exception as e:
+        return json_response({"error": "Failed to stop/disable snmpd"}), 500
+
+    if success:
+        return json_response({"message": message}, status=200)
+    return json_response({"error": message}, status=500)
+
+
+def configure_snmpv3(request):
+    try:
+        data = json.loads(request.body)
+    except Exception as e:
+        return json_response({"error": "Invalid JSON: %s" % str(e)}, status=400)
+
+    required = ['username', 'auth_pass', 'priv_pass', 'auth_protocol', 'priv_protocol']
+    if not all(k in data for k in required):
+        return json_response({"error": "Missing required fields"}, status=400)
+
+    username = data['username']
+    auth_pass = data['auth_pass']
+    priv_pass = data['priv_pass']
+    auth_protocol = data['auth_protocol']
+    priv_protocol = data['priv_protocol']
+
+    try:
+        save_user_details(username, auth_pass, priv_pass, auth_protocol, priv_protocol)
+        add_snmpv3_user_to_conf(username, auth_pass, priv_pass, auth_protocol, priv_protocol)
+        ok, err = restart_snmp_service()
+        if not ok:
+            return json_response({"error": "Failed to restart snmpd: %s" % err}, status=500)
+    except Exception as e:
+        return json_response({"error": str(e)}, status=500)
+
+    return json_response({"message": "SNMPv3 configured and service restarted"}, status=200)
+
+
+def get_snmpv3_users():
+    users = get_snmp_v3_users()
+    return json_response(users)
\ No newline at end of file
Index: /branches/amp_3_7_2/src/webui/webui/htdocs/new/src/hive/controller/telegraf_controller.py
===================================================================
--- /branches/amp_3_7_2/src/webui/webui/htdocs/new/src/hive/controller/telegraf_controller.py	(nonexistent)
+++ /branches/amp_3_7_2/src/webui/webui/htdocs/new/src/hive/controller/telegraf_controller.py	(working copy)
@@ -0,0 +1,52 @@
+import json
+from hive.util.utils import json_response
+from hive.utils import andebug
+from hive.services.telegraf_service import configure_telegraf_snmp, save_device_details
+
+
+def handle_telegraf_req(request, path=None):
+
+    if request.method == 'POST':
+        if path == "device/add":
+            return add_device_details(request)
+        if path == 'configure':
+            return configure_telegraf()
+    return json_response({
+        'error': 400,
+        'message': "Invalid HTTP method or path"
+    }, status=400)
+
+
+def configure_telegraf():
+    """Trigger Telegraf SNMP input configuration."""
+    try:
+        success, message = configure_telegraf_snmp()
+        if success:
+            return json_response({"message": message}, status=200)
+        return json_response({"error": message}, status=500)
+    except Exception as e:
+        return json_response({"error": str(e)}, status=500)
+
+
+def add_device_details(request):
+    try:
+        data = json.loads(request.body)
+    except Exception as e:
+        return json_response({"error": "Invalid JSON: %s" % str(e)}, status=400)
+
+    try:
+        required = ['agent', 'username', 'enabled']
+        if not all(k in data for k in required):
+            return json_response({"error": "Missing required fields"}, status=400)
+
+        agent = data['agent']
+        username = data['username']
+        enabled = data['enabled']
+
+        success, message = save_device_details(agent, username, enabled)
+        if success:
+            return json_response({"message": message}, status=200)
+        return json_response({"error": message}, status=500)
+    except Exception as e:
+        return json_response({"error": str(e)}, status=500)
+
Index: /branches/amp_3_7_2/src/webui/webui/htdocs/new/src/hive/services/snmpv3_service.py
===================================================================
--- /branches/amp_3_7_2/src/webui/webui/htdocs/new/src/hive/services/snmpv3_service.py	(nonexistent)
+++ /branches/amp_3_7_2/src/webui/webui/htdocs/new/src/hive/services/snmpv3_service.py	(working copy)
@@ -0,0 +1,126 @@
+import os
+import json
+import subprocess
+from hive.util.utils import json_response
+from cm.lib.libbasic_operation import oper_log
+
+SNMP_CONF_PATH = "/etc/snmp/snmpd.conf"
+SNMP_USERS_PATH = "/var/lib/snmp/snmpv3_users.json"
+
+
+def enable_snmp_v3():
+    """Enable and start snmpd service (SNMP v3)."""
+    try:
+        subprocess.check_call(["systemctl", "enable", "snmpd"])
+        subprocess.check_call(["systemctl", "start", "snmpd"])
+        msg = "SNMPv3 service enabled and started successfully."
+        oper_log('info', 'system', msg)
+        return True, msg
+
+    except subprocess.CalledProcessError as e:
+        msg = "Failed to enable/start snmpd: %s" % str(e)
+        oper_log('error', 'system', msg)
+        return False, msg
+
+    except Exception as e:
+        msg = "Unexpected error while enabling SNMPv3: %s" % str(e)
+        oper_log('error', 'system', msg)
+        return False, msg
+
+
+def disable_snmp_v3():
+    """Stop and disable snmpd service (SNMP v3)."""
+    try:
+        subprocess.check_call(["systemctl", "stop", "snmpd"])
+        subprocess.check_call(["systemctl", "disable", "snmpd"])
+        msg = "SNMPv3 service stopped and disabled successfully."
+        oper_log('info', 'system', msg)
+        return True, msg
+
+    except subprocess.CalledProcessError as e:
+        msg = "Failed to stop/disable snmpd: %s" % str(e)
+        oper_log('error', 'system', msg)
+        return False, msg
+
+    except Exception as e:
+        msg = "Unexpected error while disabling SNMPv3: %s" % str(e)
+        oper_log('error', 'system', msg)
+        return False, msg
+
+
+def save_user_details(username, auth_pass, priv_pass, auth_protocol, priv_protocol):
+    """Save SNMPv3 user details to local JSON file."""
+    try:
+        # Ensure parent directory exists
+        directory = os.path.dirname(SNMP_USERS_PATH)
+        if not os.path.exists(directory):
+            try:
+                os.makedirs(directory)
+            except OSError:
+                if not os.path.exists(directory):
+                    raise  # Re-raise if creation actually failed
+
+        # If file doesn't exist, initialize it with an empty list
+        if not os.path.exists(SNMP_USERS_PATH):
+            with open(SNMP_USERS_PATH, 'w') as f:
+                json.dump([], f)
+
+        # Load existing users
+        with open(SNMP_USERS_PATH, 'r') as f:
+            try:
+                users = json.load(f)
+            except ValueError:
+                users = []
+
+        # Add or update user
+        user_data = {
+            "username": username,
+            "auth_pass": auth_pass,
+            "priv_pass": priv_pass,
+            "auth_protocol": auth_protocol,
+            "priv_protocol": priv_protocol
+        }
+
+        # Replace existing if user exists
+        for i, u in enumerate(users):
+            if u.get("username") == username:
+                users[i] = user_data
+                break
+        else:
+            users.append(user_data)
+
+        # Save updated list
+        with open(SNMP_USERS_PATH, 'w') as f:
+            json.dump(users, f, indent=4)
+
+        return True, "SNMPv3 user details saved successfully"
+
+    except Exception as e:
+        return False, str(e)
+
+
+def add_snmpv3_user_to_conf(username, auth_pass, priv_pass, auth_protocol, priv_protocol):
+    snmpd_conf_entry = (
+                           "createUser %s %s \"%s\" %s \"%s\"\n"
+                           "rouser %s authPriv\n"
+                       ) % (
+                           username, auth_protocol, auth_pass, priv_protocol, priv_pass, username
+                       )
+    with open(SNMP_CONF_PATH, "a") as conf_file:
+        conf_file.write(snmpd_conf_entry)
+
+
+def restart_snmp_service():
+    try:
+        subprocess.call(["systemctl", "restart", "snmpd"])
+        return True, ""
+    except Exception as e:
+        return False, str(e)
+
+
+def get_snmp_v3_users():
+    if not os.path.exists(SNMP_USERS_PATH):
+        return []
+    with open(SNMP_USERS_PATH) as f:
+        users = json.load(f)
+    return users
\ No newline at end of file
Index: /branches/amp_3_7_2/src/webui/webui/htdocs/new/src/hive/services/telegraf_service.py
===================================================================
--- /branches/amp_3_7_2/src/webui/webui/htdocs/new/src/hive/services/telegraf_service.py	(nonexistent)
+++ /branches/amp_3_7_2/src/webui/webui/htdocs/new/src/hive/services/telegraf_service.py	(working copy)
@@ -0,0 +1,170 @@
+# -*- coding: utf-8 -*-
+import json
+import os
+import time
+import subprocess
+from hive.utils import andebug
+from cm.lib.libbasic_operation import oper_log
+
+SNMP_USERS_PATH = "/var/lib/snmp/snmpv3_users.json"
+DEVICES_PATH = "/var/lib/snmp/snmp_devices.json"
+COMPOSER_TELEGRAF_CONF = "/usr/local/etc/composer/composer_tele.conf"
+
+
+def save_device_details(agent, username, enabled=True):
+    """
+    Save or update SNMP device information, linking it to a specific SNMPv3 user.
+    """
+    try:
+        directory = os.path.dirname(DEVICES_PATH)
+        if not os.path.exists(directory):
+            os.makedirs(directory)
+
+        if not os.path.exists(DEVICES_PATH):
+            with open(DEVICES_PATH, "w") as f:
+                json.dump([], f)
+
+        with open(DEVICES_PATH, "r") as f:
+            try:
+                devices = json.load(f)
+            except ValueError:
+                devices = []
+
+        # Add or update entry
+        updated = False
+        for i, d in enumerate(devices):
+            if d.get("agent") == agent:
+                devices[i] = {"agent": agent, "username": username, "enabled": enabled}
+                updated = True
+                break
+        if not updated:
+            devices.append({"agent": agent, "username": username, "enabled": enabled})
+
+        with open(DEVICES_PATH, "w") as f:
+            json.dump(devices, f, indent=4)
+
+        return True, "Device details saved successfully"
+    except Exception as e:
+        return False, str(e)
+
+
+def configure_telegraf_snmp():
+    """
+    Append SNMPv3 input blocks to composer_tele.conf based on saved user/device info.
+    Keeps SNMPv2 blocks intact.
+    """
+    try:
+        # --- Load SNMPv3 Users ---
+        if not os.path.exists(SNMP_USERS_PATH):
+            return False, "No SNMPv3 users found."
+
+        with open(SNMP_USERS_PATH, "r") as f:
+            try:
+                users = json.load(f)
+            except ValueError:
+                users = []
+
+        if not users:
+            return False, "No SNMPv3 users defined."
+
+        # Build a username -> user map
+        user_map = {u["username"]: u for u in users if "username" in u}
+
+        # --- Load Devices ---
+        if not os.path.exists(DEVICES_PATH):
+            return False, "No SNMP devices configured."
+
+        with open(DEVICES_PATH, "r") as f:
+            try:
+                devices = json.load(f)
+            except ValueError:
+                devices = []
+
+        if not devices:
+            return False, "No SNMP devices defined."
+
+        # --- Build SNMPv3 blocks ---
+        lines = []
+
+        for device in devices:
+            if not device.get("enabled", True):
+                continue
+
+            agent_ip = device.get("agent")
+            username = device.get("username")
+
+            if not agent_ip or not username:
+                continue
+
+            user = user_map.get(username)
+            if not user:
+                oper_log('error', 'system',
+                         "No SNMPv3 user found for device {} (username={})".format(agent_ip, username))
+                continue
+
+            lines.extend([
+                '[[inputs.snmp]]',
+                '  agents = ["%s:161"]' % agent_ip,
+                '  version = 3',
+                '  name = "snmpv3_metrics_%s"' % agent_ip.replace('.', '_'),
+                '  timeout = "2s"',
+                '  sec_name = "%s"' % username,
+                '  auth_protocol = "%s"' % user.get("auth_protocol", "SHA"),
+                '  auth_password = "%s"' % user.get("auth_pass", ""),
+                '  priv_protocol = "%s"' % user.get("priv_protocol", "AES"),
+                '  priv_password = "%s"' % user.get("priv_pass", ""),
+                '  sec_level = "authPriv"',
+                '',
+                '  [[inputs.snmp.field]]',
+                '    name = "cpu_usage"',
+                '    oid = ".1.3.6.1.4.1.7564.30.1.0"',
+                '',
+                '  [[inputs.snmp.field]]',
+                '    name = "mem_usage"',
+                '    oid = ".1.3.6.1.4.1.7564.4.5.0"',
+                ''
+            ])
+
+        if not lines:
+            return False, "No valid SNMPv3 devices found for configuration."
+
+        # --- Ensure composer_tele.conf exists ---
+        if not os.path.exists(COMPOSER_TELEGRAF_CONF):
+            with open(COMPOSER_TELEGRAF_CONF, "w") as f:
+                f.write("[agent]\ninterval = \"10s\"\n\n")
+
+        # --- Preserve SNMPv2 blocks ---
+        with open(COMPOSER_TELEGRAF_CONF, "r") as f:
+            existing = f.read()
+
+        start_marker = "# BEGIN SNMPv3 AUTOGEN"
+        end_marker = "# END SNMPv3 AUTOGEN"
+
+        # Replace or append SNMPv3 section
+        if start_marker in existing and end_marker in existing:
+            pre = existing.split(start_marker)[0]
+            post = existing.split(end_marker)[-1]
+            new_conf = pre + start_marker + "\n" + "\n".join(lines) + "\n" + end_marker + post
+        else:
+            new_conf = existing.strip() + "\n\n" + start_marker + "\n" + "\n".join(lines) + "\n" + end_marker + "\n"
+
+        # --- Write updated config ---
+        with open(COMPOSER_TELEGRAF_CONF, "w") as f:
+            f.write(new_conf)
+
+        # --- Restart composer_tele safely ---
+        subprocess.call(["pkill", "-f", "composer_tele"])
+        subprocess.Popen([
+            "/ca/extensions/auditing/syslogd/composer_tele",
+            "--config", COMPOSER_TELEGRAF_CONF
+        ], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+        time.sleep(5)
+        ps_check = subprocess.call(["pgrep", "-f", "composer_tele"])
+        if ps_check != 0:
+            oper_log('error', 'system', "composer_tele did not start properly")
+
+        return True, "SNMPv3 configuration added to composer_tele.conf"
+
+    except Exception as e:
+        return False, str(e)
Index: /branches/amp_3_7_2/src/webui/webui/htdocs/new/src/hive/util/utils.py
===================================================================
--- /branches/amp_3_7_2/src/webui/webui/htdocs/new/src/hive/util/utils.py	(nonexistent)
+++ /branches/amp_3_7_2/src/webui/webui/htdocs/new/src/hive/util/utils.py	(working copy)
@@ -0,0 +1,6 @@
+import json
+from django.http import HttpResponse
+
+
+def json_response(data, status=200):
+    return HttpResponse(json.dumps(data), content_type="application/json", status=status)
\ No newline at end of file
