#552 closed defect (worksforme)
Argument processing in NSClient v0.4
| Reported by: | azipheral | Owned by: | mickem |
|---|---|---|---|
| Priority: | 1 | Milestone: | 0.4.0 |
| Component: | NRPE | Version: | 0.4.0 |
| Severity: | Bugs | Keywords: | arguments |
| Cc: |
Description
We currently use OpsView? to monitor our servers but the version of NSClient that they have bundled with their system was old (0.3.x) and was throwing errors with check like CheckProcState.
So I decided to try and upgrade the client testing errors as I go.
In the OpsView? all the alias checks are
nsc_checkdrivesize=inject CheckDriveSize $ARG1$ nsc_checkfilesize=inject CheckFileSize $ARG1$ nsc_checkfile=inject CheckFile $ARG1$ nsc_checkeventlog=inject CheckEventLog $ARG1$
and the checks have all the arguments bundled into the first $ARG1$ which seems to work quite nicely
check_nrpe -H HOSTNAME -c nsc_checkdrivesize -a 'warn=90 crit=95 time=10m time=1m ShowAll=long'
So I setup an alias in the new NSClient version (under scripts/alias) in a similar fashion to 0.3 to end up something like this
alias_check_cpu = checkCPU $ARG1$
and ran the following command
check_nrpe -H HOSTNAME -c alias_check_cpu -a 'warn=80 crit=90 time=5m'
But I get the following error back from the client
l ce\simple_client.hpp:32 Enter command to inject or exit to terminate... d pe\server\server.cpp:95 Accepting connection from: ::ffff:10.88.3.144 d r\ssl_connection.cpp:27 starting secure data connection d erver\connection.cpp:37 starting data connection d ver\handler_impl.cpp:34 Running command: alias_check_cpu d rvice\NSClient++.cpp:923 Injecting: alias_check_cpu... d kExternalScripts.cpp:256 Arguments: warn=80 crit=90 time=5m d rvice\NSClient++.cpp:923 Injecting: checkcpu... c i_plugin_wrapper.hpp:245 Exception in: NSHandleCommand: bad lexical cast: source type value could not be interpreted as target d rvice\NSClient++.cpp:948 Result checkcpu: WARNING d rvice\NSClient++.cpp:948 Result alias_check_cpu: WARNING d ver\handler_impl.cpp:36 Running command: alias_check_cpu = d erver\connection.cpp:51 Timeout reading: 1024 d erver\connection.cpp:106 Wrote data: 1036
So while I imagine that its just bundling it all into the first argument and failing to parse it, I want to avoid creating a series of checks like the following just to get around having checks to allow different amounts of arguments
alias_check_cpu_1 = checkCPU $ARG1$ alias_check_cpu_2 = checkCPU $ARG1$ $ARG2$ ... alias_check_cpu_9 = checkCPU $ARG1$ $ARG2$ $ARG3$ $ARG4$ $ARG5$ $ARG6$ $ARG7$ $ARG8$ $ARG9$ alias_check_cpu_10 = checkCPU $ARG1$ $ARG2$ $ARG3$ $ARG4$ $ARG5$ $ARG6$ $ARG7$ $ARG8$ $ARG9$ $ARG10$
Is there any way around this? I have tried both of the following without luck
alias_cpu2 = checkCPU \"$ARG1$\" alias_cpu3 = checkCPU args=%ARGS%
Any help would be appreciated
Change History (3)
comment:1 Changed 10 months ago by mickem
comment:2 Changed 10 months ago by azipheral
- Resolution set to worksforme
- Status changed from new to closed
Hi Michael,
I wasn't aware that I could call the functions directly like that from check_nrpe. Looking at the NRPE Handlers section of the OpsView? NSC.ini my assumption (wrongly it seems) had been that you had to alias the functions to pass the arguments to them!
Thanks for the help!!!
Cheers,
Chris
comment:3 Changed 10 months ago by mickem
- Milestone changed from 0.4.1 to 0.4.0
No, the idea with aliases is that you can create a "check_mem" command which only takes a single argument (and have all the cofiguration done client side)...
If you disable all aliases and restart you will get a set of "default aliases" which are exactly like that i.e.:
alias_cpu=checkCPU warn=80 crit=90 time=5m time=1m time=30s
alias_cpu_ex=checkCPU warn=$ARG1$ crit=$ARG2$ time=5m time=1m time=30s
alias_mem=checkMem MaxWarn=80% MaxCrit=90% ShowAll=long type=physical type=virtual type=paged type=page
alias_up=checkUpTime MinWarn=1d MinWarn=1h
alias_disk=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED
alias_disk_loose=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED ignore-unreadable
alias_volumes=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll=volumes FilterType=FIXED
alias_volumes_loose=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll=volumes FilterType=FIXED ignore-unreadable
alias_service=checkServiceState CheckAll
alias_service_ex=checkServiceState CheckAll "exclude=Net Driver HPZ12" "exclude=Pml Driver HPZ12" exclude=stisvc
alias_process=checkProcState "$ARG1$=started"
alias_process_stopped=checkProcState "$ARG1$=stopped"
alias_process_count=checkProcState MaxWarnCount=$ARG2$ MaxCritCount=$ARG3$ "$ARG1$=started"
alias_process_hung=checkProcState MaxWarnCount=1 MaxCritCount=1 "$ARG1$=hung"
alias_event_log=CheckEventLog file=application file=system MaxWarn=1 MaxCrit=1 "filter=generated gt -2d AND severity NOT IN ('success', 'informational') AND source != 'SideBySide'" truncate=800 unique descriptions "syntax=%severity%: %source%: %message% (%count%)"
alias_file_size=CheckFiles "filter=size > $ARG2$" "path=$ARG1$" MaxWarn=1 MaxCrit=1 "syntax=%filename% %size%" max-dir-depth=10
alias_file_age=checkFile2 filter=out "file=$ARG1$" filter-written=>1d MaxWarn=1 MaxCrit=1 "syntax=%filename% %write%"
alias_sched_all=CheckTaskSched "filter=exit_code ne 0" "syntax=%title%: %exit_code%" warn=>0
alias_sched_long=CheckTaskSched "filter=status = 'running' AND most_recent_run_time < -$ARG1$" "syntax=%title% (%most_recent_run_time%)" warn=>0
alias_sched_task=CheckTaskSched "filter=title eq '$ARG1$' AND exit_code ne 0" "syntax=%title% (%most_recent_run_time%)" warn=>0
alias_updates=check_updates -warning 0 -critical 0
check_ok=CheckOK Everything is fine!
Thus you can use (without arguments):
check_nrpe ... -c alias_cpu
Thus you can use (with simple arguments):
check_nrpe ... -c alias_cpu_ex -a 80 90
Michael Medin









I am a bit confused.
If you don't want to use aliases why use aliases?
The idea with aliases is really to allow configuration "client-side". If you just want to run commands you do not need aliases.
You could just as easily do:
And not use any aliases at all?
Anyways I can confirm the current behavior which is to parse aliases at "startup" and not runtime.
So the alias will be split into "tokens" before you replace things so what you are trying will not work. But I guess it would be possible, the down side would be a slight over haed in the form of parsing the string...
Michael Medin