Solved

Problem with script check

  • 27 April 2022
  • 4 replies
  • 303 views

Badge +6

Dear centreon users,

i’m currently facing an issue where script check run by centreon engine do not work properly.

Script are used to check disk with wmi. Running script from command line return expected behavior (ie return code 0 or 1 or 2 depending results).

While running via centreon, it not works an always return “unknown state”.

Those script are working correctly from another centreon server w/ same version.

Can someone help ?

Here some debug output from centengine.debug :

** Running async check of service 'rik-check-wmi-disk_C' on host 'server.domain.local'...
[1651075486] [1950] check_service_check_viability()
[1651075486] [1950] Making callbacks (type 13)...
[1651075486] [1950] Callback #1 (type 13) return (code = 0)
[1651075486] [1950] Checking service 'rik-check-wmi-disk_C' on host 'server.domain.local'...
[1651075486] [1950] get_raw_command_line_r()
[1651075486] [1950] Raw Command Input: $ERICAPLUGINS$/check_wmi_disk.sh -H $HOSTADDRESS$ -U '$DOMAINUSER$' -P '$DOMAINPWD$' -c $_SERVICECRITICAL$ -w $_SERVICEWARNING$ -d $_SERVICEVOLUME$ -D
[1651075486] [1950] Expanded Command Output: $RIKPLUGINS$/check_wmi_disk.sh -H $HOSTADDRESS$ -U '$DOMAINUSER$' -P '$DOMAINPWD$' -c $_SERVICECRITICAL$ -w $_SERVICEWARNING$ -d $_SERVICEVOLUME$ -D
[1651075486] [1950] Current running service checks: 1
[1651075486] [1950] process_macros_r()
[1651075486] [1950] Making callbacks (type 13)...
[1651075486] [1950] Callback #1 (type 13) return (code = 0)
[1651075486] [1950] raw::run: cmd='/usr/lib/rik/plugins/check_wmi_disk.sh -H server.domain.local -U 'admincentreon@domain.local' -P 'mysecretpassword' -c 10 -w 20 -d C -D', timeout=60
[1651075486] [1950] raw::run: id=50, process=0x286ccf0
[1651075486] [1950] raw::run: start process success: id=50
[1651075486] [1950] Making callbacks (type 8)...
[1651075486] [1950] raw::finished: process=0x286ccf0
[1651075486] [1950] raw::finished: id=50
[1651075486] [1950] raw::finished: id=50, start_time=1651075486677, end_time=1651075486855, exit_code=3, exit_status=0, output=''
[1651075486] [1950] checker::finished: res=0x7f406ce95380
[1651075487] [1950] handle_timed_event()
[1651075487] [1950] Making callbacks (type 8)...
[1651075487] [1950] Making callbacks (type 24)...
[1651075487] [1950] check_for_external_commands()
[1651075487] [1950] Callback #1 (type 24) return (code = 0)
[1651075487] [1950] Callback #2 (type 24) return (code = 0)
[1651075487] [1950] reschedule_event()
[1651075487] [1950] add_event()
[1651075487] [1950] Making callbacks (type 8)...
[1651075487] [1950] Making callbacks (type 8)...
[1651075488] [1950] handle_timed_event()
[1651075488] [1950] Making callbacks (type 8)...
[1651075488] [1950] Making callbacks (type 24)...
[1651075488] [1950] check_for_external_commands()
[1651075488] [1950] Callback #1 (type 24) return (code = 0)
[1651075488] [1950] Callback #2 (type 24) return (code = 0)
[1651075488] [1950] reschedule_event()
[1651075488] [1950] add_event()
[1651075488] [1950] Making callbacks (type 8)...
[1651075488] [1950] Making callbacks (type 8)...
[1651075489] [1950] handle_timed_event()
[1651075489] [1950] Making callbacks (type 8)...
[1651075489] [1950] Making callbacks (type 24)...
[1651075489] [1950] check_for_external_commands()
[1651075489] [1950] Callback #1 (type 24) return (code = 0)
[1651075489] [1950] Callback #2 (type 24) return (code = 0)
[1651075489] [1950] reschedule_event()
[1651075489] [1950] add_event()
[1651075489] [1950] Making callbacks (type 8)...
[1651075489] [1950] Making callbacks (type 8)...
[1651075490] [1950] handle_timed_event()
[1651075490] [1950] Making callbacks (type 8)...
[1651075490] [1950] checker::reap
[1651075490] [1950] Starting to reap check results.
[1651075490] [1950] Found a check result (#1) to handle...
[1651075490] [1950] Handling check result for service 35/263...
[1651075490] [1950] handle_async_service_check_result()
[1651075490] [1950] ** Handling check result for service 'rik-check-wmi-disk_C' on host 'server.domain.local'...
[1651075490] [1950] HOST: server.domain.local, SERVICE: rik-check-wmi-disk_C, CHECK TYPE: Active, OPTIONS: 1, RESCHEDULE: Yes, EXITED OK: Yes, EXEC TIME: 0.178340, return CODE: 3, OUTPUT:
[1651075490] [1950] Parsing check output...
[1651075490] [1950] Short Output:
[1651075490] [1950] (No output returned from plugin)
[1651075490] [1950] Long Output:
[1651075490] [1950] NULL
[1651075490] [1950] Perf Data:
[1651075490] [1950] NULL
[1651075490] [1950] ST: SOFT CA: 2 MA: 3 CS: 3 LS: 3 LHS: 0
[1651075490] [1950] Service is in a non-OK state!
[1651075490] [1950] Host is currently UP, so we'll recheck its state to make sure...
[......]
[1651075490] [1950] SERVICE ALERT: server.domain.local;rik-check-wmi-disk_C;UNKNOWN;SOFT;2;(No output returned from plugin)

And running directly it from  shell :

[root@srv-centreon2 plugins]# /usr/lib/rik/plugins/check_wmi_disk.sh -H server.domain.local -U 'admincentreon@domain.local' -P 'myspass' -c 10 -w 20 -d C -D
DEBUG :
wmiclient --delimiter=, -U admincentreon@domain.local%mypass //server.domain.local SELECT size,freespace FROM win32_logicaldisk WHERE deviceID='C:'
DEBUG :
WMIC outpout:
CLASS: Win32_LogicalDisk
DeviceID,FreeSpace,Size
C:,15920844800,42423283712
DEBUG :
result: C:,15920844800,42423283712
volume=C:
totalsize=42.42G
freespace=15.92G
used=26.50G
freespacePercent=37.52%
usedspacePercent=62.47%
warning=less than 20% free (8GB)
critical=less than 10% free (4GB)
OK : volume C: 37.52% left (15.92G) | 'size(GB)'=42.42GB 'freespace(GB)'=15.92GB;8;4;0;42.42
[root@srv-centreon2 plugins]# echo $?
0

 

Note that I try many tests like adding quote/double quote to script args. and try to use MAcro instead of ressource.

I’m out of idea !

Does someone already have this behaviour ?

bye.

GC

icon

Best answer by GCHARDIN 28 April 2022, 21:41

View original

4 replies

Userlevel 5
Badge +16

Have you tried with centreon-engine user (centengine is not launched by root user) ?

Badge +6

Hi,

running as centreon-user  point me at a file security issue (mod 744 instead of 755)

Userlevel 5
Badge +16

The script should executable by centreon-engine user.

Badge +6

Sorry my reply was not clear. Problem was solved.

 

Reply