From 722cbcd679d94847d97aa0821ae091b3e83cf23c Mon Sep 17 00:00:00 2001 From: Junichi Satoh Date: Sun, 16 Nov 2014 12:30:31 +0900 Subject: [PATCH] Added sample setting of 'agent_name_cmd' and sample external command. (cherry picked from commit d6f33811aa59a3895115d531bcafb29498bd1cc6) --- pandora_agents/win32/bin/pandora_agent.conf | 7 ++++- pandora_agents/win32/bin/util/agentname.vbs | 31 +++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 pandora_agents/win32/bin/util/agentname.vbs diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index f75fd15368..4afe21d61c 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -1,6 +1,6 @@ # Base config file for Pandora FMS Windows Agent # (c) 2006-2014 Artica Soluciones Tecnologicas -# Version 5.1SP1 +# Version 5.1SP1 # This program is Free Software, you can redistribute it and/or modify it # under the terms of the GNU General Public Licence as published by the Free Software @@ -30,6 +30,11 @@ temporal "$AgentTemp$" # agent_name My_Custom_Agent_name +# To define agent name by specific command, define 'agent_name_cmd'. +# If agent_name_cmd is defined, agent_name is ignored. +# (In the following example, agent name is 'hostname_IP') +#agent_name_cmd cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\agentname.vbs" + #Parent agent_name #parent_agent_name caprica diff --git a/pandora_agents/win32/bin/util/agentname.vbs b/pandora_agents/win32/bin/util/agentname.vbs new file mode 100644 index 0000000000..99661664a2 --- /dev/null +++ b/pandora_agents/win32/bin/util/agentname.vbs @@ -0,0 +1,31 @@ +' agentname.vbs +' +' Pandora FMS external command sample for 'agent_name_cmd' token. +' This script returns agent name like 'hostname_IPaddress'. +' (c) 2014 Junichi Satoh +' ------------------------------------------ + +Option Explicit + +Dim objNetWork +Dim oClassSet +Dim oClass +Dim oLocator +Dim oService + +Set objNetWork = WScript.CreateObject("WScript.Network") + +Set oLocator = WScript.CreateObject("WbemScripting.SWbemLocator") +Set oService = oLocator.ConnectServer +Set oClassSet = oService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration") + +For Each oClass In oClassSet + +If oClass.IPEnabled = True Then + +Wscript.StdOut.WriteLine objNetWork.ComputerName & "_" & oClass.IPAddress(0) +Exit For + +End If + +Next