Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - AP_ops

#1
General Support / Maintenance column in db after upgrade
November 15, 2018, 03:36:16 PM
Hello,

Last week i did an upgrade to version 2.2.10

We used to had a daily report through a db query that we check for systems that are in maintenance mode.

the query is this one:

USE netxms_db

DECLARE @OBJECT_ID INT, @NAME VARCHAR(63), @ITEM_ID INT, @DESCRIPTION VARCHAR(255)
SET @OBJECT_ID = 0
SET @ITEM_ID = 0

DECLARE @UNMANAGED_SYSTEMS TABLE(
    System VARCHAR(63)
)

WHILE (1 = 1)
BEGIN 

    SELECT TOP 1 @OBJECT_ID = object_id
    ,@NAME = name
    FROM netXMS.object_properties
    WHERE object_id > @OBJECT_ID AND maint_mode=1
    ORDER BY object_id

/* Exit loop if no more entries */
IF @@ROWCOUNT = 0 BREAK;

INSERT INTO @UNMANAGED_SYSTEMS SELECT @NAME AS System FROM [netxms_db].[netxms].[items] WHERE node_id = @OBJECT_ID

END

SELECT * FROM @UNMANAGED_SYSTEMS GROUP BY System ORDER BY System ASC


After the upgrade the query is not working. I see some changes in the names but i cannot find a value for the maint_mode.
Have you move it to different table?

thanks
#2
Hi Victor,

Thanks! Sounds really nice. We will upgrade as soon as we find time :)

Kind regards,
AP_ops

#3
Hi Victor

That would be a nice option. Thanks in advance! Please let us now when you have implemented this option.

Best regards,
AP_ops
#4
Hi Victor,

I know now how I could reformat all message texts to handover by commandline. But the option to avoid all /t /n characters is not the way with the least work as I use the formatted message texts mostly for messages by mail. Do you have any idea if it's possible to parse this characters in the script or if there is a way to solve this problem without building every message from scretch?

thanks for help
AP_ops
#5
Hi,

I just found the reason...now its not NetXMS. One should know how to execute powershell from cmd environment. If you call a ps1 script fom cmd environment or in this case NetXMS you have to use "powershell -file -para "bla" -para2 "bla" " if no -file is used..just the first word is taken. It has to do with a security "feature"..

thanks for your help!

#6
Hi,

Alright I made the recommended changes: I removed all \n and \t characters. The Batchfile works now. After this success I just checked with a simple powerShell script:

param(
       [String]$msg = $(throw "-msg is required.")
);

$error_log_path = "C:\log.txt"
"$(get-date) - "+ $msg | Out-File -Append $error_log_path


I Just receive: "Zone:Comp" instead of
"Zone:Comp XX NMS - 172.20.1.0/24System:[VM]Time:[22-Sep-2014 12:19:46]Severity:[Critical][TEST]isstopped!"

The Line above is created through "Zone:%[get_first_parent]System:[%n]Time:[%t]Severity:[%S][%2]isstopped!" event config.


Do you have any idea what could be the reason for that? Is is possible that the output is not a single string? Or the string is splitted in each space?

Best regards,
AP_ops
#7
Hello Victor

Thx for your reply. I just tested if your test with the batch-file works in my configuration. It is exactly the same behaviour as with the powershell script... if I configure the action as:
c:\\temp\\test.cmd parameter_1 "%m" it won't get executed. If I remove the "" from the %m (c:\\temp\\test.cmd parameter_1 %m) it gets executed but I just receive the first word. In my case "Zone:"

Message form the event is configured as: Zone:\t%[get_first_parent]\nSystem:\t%n\nTime:\t\t%t\nSeverity:\t%S\n\n%2 is stopped!

We have the version 1.2.13 running.

Thx for help & best regards
Ap_ops
#8
Hi

I'm struggeling to get the Action Configuration "execute command on management server" working as it should. I'd like to have the %m Message forwarded as a String to my script. What happens is that only the first word gets forwarded.

My command:
powershell C:\\NetXMS\\send_sms.ps1 \-recipients "00417xxxxxxxx" \-msg %m

if i use "%m" nothing works also if i use single quotes. But if I use ' [%[get_first_parent]][%n] [%S]: [%[get_event_name]] ' it gets forwarded..

The same behavior was discussed in the topic in 2011 but not solved:
https://www.netxms.org/forum/configuration/parameters-with-spaces-on-execute-command-on-management-server/

Where is my mistake?

Thanks for your help!

#9
General Support / Re: Advanced Schedule
April 26, 2013, 11:27:35 AM
Hello,

That's work fine but only with 5 fields (* * * * *)! With 6 fields it has problem and the schedule doesnt work!
So i added the same schedules like this:

*/5 0 * * *
*/5 7-23 * * *

Thanks & Regards,
Andreas
#10
General Support / Advanced Schedule
April 10, 2013, 11:58:40 AM
Hello,

I want to configure a custom file.count schedule (to check a specific folder daily between 7:00 AM to 1:00 AM  every 5 minutes) and i want this folder to be empty (0 files) between the specific period and if i have file to trigger an alarm (only between this period).

So i tried several combinations and it doesn`t work.
Here is my examples that i tried

1st.
*/5 7-1 * * * *

it doesn`t work

2nd. (combination of 2 schedules)
* 7-1 * * * *
*/5 * * * * *

it works every 5 minutes but i get an alert all the time

3rd. (combination of 3 schedules)
* 7-0 * * * *
* 0-1 * * * *
*/5 * * * * *

it works every 5 minutes but i get an alert all the time


Can you please someone advice/help me with the correct schedule that i have to specify?

Thanks in advance

Regards,
Andreas
#11
Hi

I recognized that the length of ExternalParametersProvider values have to be less or equal the default width of cmd.exe because the line wraps and your value can be cut off in the end.
this is not much of an issue, you can simply change the default console width of cmd.exe, but maybe you find a better solution to it. In larger environments it could b a pain if you, for whatever reason, need to have a larger return value.

regards
#12
Hi

We recognized, that the default Parameters that come with the NetXMS Agent have a certain Data Type and Description which makes it easy to create to DCIs.
When using Values from a ExternalParametersProvider you always have to check both but they are always the same.
maybe you could add this information to the return value
before:
ParameterName=Value
after:
ParameterName:DataType:Description=Value

what do you think?

regards
#13
Hi

just tried to run the agent from the commandline:
"C:\NetXMS\bin\nxagentd.exe" -c "C:\NetXMS\etc\nxagentd.conf" -n "NetXMSAgentdW32" -e "NetXMS Win32 Agent" -D 0

now it works!
what's the difference?

usually the agent runs as a windows service using Active Directory user credentials to be able to access network ressources. the user i did run it from the commandline.
#14
confirmed, server version 1.2.4 fixes the problem
#15
Hi

Windows Batch Scripts executed by the ExternalParametersProvider seem to have issues when they execute other applications. In Powershell Scripts only xcopy.exe doesn't work.
We are using Windows 2008 R2 as Server and Agent.
NetXMS Server and Agent is on 1.2.4

in cmd.exe scripts it seems like it stops executing after the first exe-application was started. this only happens when run by NetXMS Agent, when run manually in cmd.exe it always runs through

@echo off
echo ---- MARK >> d:\log_files\netxms_rpc_debug_cmd.log 2>&1
c:\WINDOWS\System32\ping.exe localhost -n 1 >> d:\log_files\netxms_rpc_debug_cmd.log 2>&1
c:\WINDOWS\System32\findstr.exe csax d:\csaxtext?.txt >> d:\log_files\netxms_rpc_debug_cmd.log 2>&1
c:\WINDOWS\System32\robocopy.exe d:\ c:\ csaxtext3.txt /NJH /NP >> d:\log_files\netxms_rpc_debug_cmd.log 2>&1
c:\WINDOWS\System32\xcopy.exe d:\csaxtext3.txt c:\ /Y >> d:\log_files\netxms_rpc_debug_cmd.log 2>&1
echo DEBUG_CMD=SOMEVALUE >> d:\log_files\netxms_rpc_debug_cmd.log 2>&1

when you change order of commands, the first one is executed with proper output, the rest is not.
interestingly, xcopy does not work at all, no output, no copy but still stops execution
the output of the above script is:
Quote
---- MARK 

Pinging localhost [127.0.0.1] with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128

Ping statistics for 127.0.0.1:
    Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

in powershell all but xcopy work. xcopy won't stop the execution of the hole script but it doesn't do anything and does not show any output. If run manually, it works as expected.
"---- MARK" | ac d:\log_files\netxms_rpc_debug_ps.log
c:\WINDOWS\System32\ping.exe localhost -n 1 | ac d:\log_files\netxms_rpc_debug_ps.log
c:\WINDOWS\System32\xcopy.exe d:\csaxtext3.txt c:\ /Y | ac d:\log_files\netxms_rpc_debug_ps.log
c:\WINDOWS\System32\findstr.exe csax d:\csaxtext?.txt | ac d:\log_files\netxms_rpc_debug_ps.log
c:\WINDOWS\System32\robocopy.exe d:\ c:\ csaxtext3.txt /NJH /NP | ac d:\log_files\netxms_rpc_debug_ps.log
"DEBUG_PS=SOMEVALUE"| ac d:\log_files\netxms_rpc_debug_ps.log


output
Quote---- MARK

Pinging app01.intra.arcplace.ch [127.0.0.1] with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128

Ping statistics for 127.0.0.1:
    Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms
d:\csaxtext3.txt:csax-test

                      1   d:\

------------------------------------------------------------------------------

               Total    Copied   Skipped  Mismatch    FAILED    Extras
    Dirs :         1         0         1         0         0         0
   Files :         1         0         1         0         0         0
   Bytes :        11         0        11         0         0         0
   Times :   0:00:00   0:00:00                       0:00:00   0:00:00

   Ended : Wed Nov 14 15:58:30 2012
DEBUG_PS=SOMEVALUE

Agent Config:

LogFile = D:\log_files\netxms_agent.log
DebugLevel = 9
FileStore = C:\NetXMS\var
SubAgent = ecs.nsm
SubAgent = ping.nsm
SubAgent = logwatch.nsm
SubAgent = portcheck.nsm
SubAgent = winperf.nsm
SubAgent = wmi.nsm
ExternalParametersProvider=powershell.exe d:\cmd_files\netxms_rpc_debug.ps1:5
ExternalParametersProvider=d:\cmd_files\netxms_rpc_debug.cmd:5


In the Agent Debug(level 9) logs i was unable to find detailed information about the execution of ExternalParamtersProvider only the DCIs requesting their parameters.
i tested this on two Windows 2008 R2 systems with same agent version. one is part of a domain, the other is not.

i appreciate any ideas.
in the end, i need the xcopy in powershell to generate a list of remote files older than a specific date (xcopy /L /D:DATE)