Page 1 of 2

Why Nagios shows more memory than the real?

Posted: Tue May 12, 2015 5:58 am
by xerez
I have a host with 1.25 GB RAM, but Nagios shows that this host has 2668,87 Mb. I tried with other host and the result also was greater than real memory. Why? How solve it?

Thanks.

Re: Why Nagios shows more memory than the real?

Posted: Tue May 12, 2015 6:02 am
by rhassing
Which plugin are you using to check the memory?

Re: Why Nagios shows more memory than the real?

Posted: Tue May 12, 2015 6:26 am
by xerez
I use check_nt v2.0 (nagios-plugins 2.0):

Code: Select all

check_command           check_nt!MEMUSE!-w 80 -c 90

Re: Why Nagios shows more memory than the real?

Posted: Tue May 12, 2015 7:28 am
by rhassing
I'm currently using the following script:
http://nagios.manubulon.com/snmp_storage.html

This is using the information via snmp instead of running software on all servers.

Code: Select all

check_snmp_storage.pl -C public -H 10.10.10.1 -m ^[P] -w 97 -c 98

Re: Why Nagios shows more memory than the real?

Posted: Tue May 12, 2015 7:40 am
by xerez
Mmm I execute this:

Code: Select all

./check_snmp_storage.pl -C public -H <host ip> -m ^C: -w 97 -c 98
And the output is:

Code: Select all

Argument "v6.0.1" isn't numeric in numeric lt (<) at ./check_snmp_storage.pl line 420.
ERROR: Description/Type table : No response from remote host "<host ip>".

Re: Why Nagios shows more memory than the real?

Posted: Tue May 12, 2015 7:45 am
by rhassing
What happens if you do:

Code: Select all

snmpwalk -v2c -c public <host ip> 1.3.6.1.2.1.25.2.3.1

Re: Why Nagios shows more memory than the real?

Posted: Tue May 12, 2015 10:12 am
by lmiltchev
@xerez

This is a known issue with NSClient++ and check_nt with MEMUSE. Try using check_nrpe instead.

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -p 5666 -c CheckMEM -a MaxWarn=80% MaxCrit=90% ShowAll type=physical
OK: physical: Total: 15.958GB - Used: 7.027GB (44%) - Free: 8.931GB (55%)|'physical'=7.02726GB;12.76632;14.36211;0;15.9579 'physical %'=44%;80;90;0;100
If you define an alias in the nsclient.ini under [/settings/external scripts/alias], for example:

Code: Select all

physical_memory = CheckMEM MaxWarn=80% MaxCrit=90% ShowAll type=physical
you could just run (from Nagios)

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -p 5666 -c physical_memory
OK: physical: Total: 15.958GB - Used: 7.087GB (44%) - Free: 8.871GB (55%)|'physical'=7.08733GB;12.76632;14.36211;0;15.9579 'physical %'=44%;80;90;0;100

Re: Why Nagios shows more memory than the real?

Posted: Wed May 13, 2015 3:16 am
by xerez
@rhassing:

Code: Select all

nagios@localhost:/usr/local/nagios/libexec$ snmpwalk -v2c -c public <host ip> 1.3.6.1.2.1.25.2.3.1
Timeout: No Response from <host ip>
@lmiltchev

Code: Select all

nagios@localhost:/usr/local/nagios/libexec$ check_nrpe -H <host ip> -p 5666 -c CheckMEM -a MaxWarn=80% MaxCrit=90% ShowAll type=physical
CHECK_NRPE: Error - Could not complete SSL handshake.
I read it could be a problem in the configuration of NSClient++. I followed this instructions: https://assets.nagios.com/downloads/nag ... ios-XI.pdf

My version of NSClient++ is 0.4.3.131.

My nsclient.ini:

Code: Select all

# If you want to fill this file with all avalible options run the following command:
#   nscp settings --generate --add-defaults --load-all
# If you want to activate a module and bring in all its options use:
#   nscp settings --activate-module <MODULE NAME> --add-defaults
# For details run: nscp settings --help


; Undocumented section
[/settings/default]

; PASSWORD - Password used to authenticate against server
password = <password>

; ALLOWED HOSTS - A comaseparated list of allowed hosts. You can use netmasks (/ syntax) or * to create ranges.
allowed hosts = <host ip>


; Undocumented section
[/settings/NRPE/server]

; ENABLE SSL ENCRYPTION - This option controls if SSL should be enabled.
use ssl = true

; PORT NUMBER - Port to use for NRPE.
port = 5666

; COMMAND ARGUMENT PROCESSING - This option determines whether or not the we will allow clients to specify arguments to commands that are executed.
allow arguments = true

; COMMAND ALLOW NASTY META CHARS - This option determines whether or not the we will allow clients to specify nasty (as in |`&><'"\[]{}) characters in arguments.
allow nasty characters = true


; ALLOW INSECURE CHIPHERS and ENCRYPTION - Only enable this if you are using legacy check_nrpe client.
insecure = false

; VERIFY MODE - Comma separated list of verification flags to set on the SSL socket.  none	The server will not send a client certificate request to the client, so the client will not send a certificate. peer	The server sends a client certificate request to the client and the certificate returned (if any) is checked. fail-if-no-cert	if the client did not return a certificate, the TLS/SSL handshake is immediately terminated. This flag must be used together with peer. peer-cert	Alias for peer and fail-if-no-cert. workarounds	Various bug workarounds. single	Always create a new key when using tmp_dh parameters. client-once	Only request a client certificate on the initial TLS/SSL handshake. This flag must be used together with verify-peer   
verify mode = peer-cert

; VERIFY MODE - Comma separated list of verification flags to set on the SSL socket.  default-workarounds	Various workarounds for what I understand to be broken ssl implementations no-sslv2	Do not use the SSLv2 protocol. no-sslv3	Do not use the SSLv3 protocol. no-tlsv1	Do not use the TLSv1 protocol. single-dh-use	Always create a new key when using temporary/ephemeral DH parameters. This option must be used to prevent small subgroup attacks, when the DH parameters were not generated using "strong" primes (e.g. when using DSA-parameters).   
ssl options = no-sslv2,no-sslv3


; Undocumented section
[/modules]

; CheckExternalScripts - Execute external scripts
CheckExternalScripts = 1

; CheckHelpers - Various helper function to extend other checks.
CheckHelpers = 1

; NSClientServer - A server that listens for incoming check_nt connection and processes incoming requests.
NSClientServer = 1

; CheckNSCP - Use this module to check the healt and status of NSClient++ it self
CheckNSCP = 1

; NRPEServer - A server that listens for incoming NRPE connection and processes incoming requests.
NRPEServer = 1

; CheckSystem - Various system related checks, such as CPU load, process state, service state memory usage and PDH counters.
CheckSystem = 1

; CheckDisk - CheckDisk can check various file and disk related things.
CheckDisk = 1

; CheckEventLog - Check for errors and warnings in the event log.
CheckEventLog = 1


; A list of templates for wrapped scripts.
%SCRIPT% will be replaced by the actual script an %ARGS% will be replaced by any given arguments.
[/settings/external scripts/wrappings]

; POWERSHELL WRAPPING - 
ps1 = cmd /c echo scripts\\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -

; VISUAL BASIC WRAPPING - 
vbs = cscript.exe //T:30 //NoLogo scripts\\lib\\wrapper.vbs %SCRIPT% %ARGS%

; BATCH FILE WRAPPING - 
bat = scripts\\%SCRIPT% %ARGS%


; A list of aliases available.
An alias is an internal command that has been predefined to provide a single command without arguments. Be careful so you don't create loops (ie check_loop=check_a, check_a=check_loop)
[/settings/external scripts/alias]

; alias_up - Alias for alias_up. To configure this item add a section called: /settings/external scripts/alias/alias_up
alias_up = check_uptime

; alias_service_ex - Alias for alias_service_ex. To configure this item add a section called: /settings/external scripts/alias/alias_service_ex
alias_service_ex = check_service "exclude=Net Driver HPZ12" "exclude=Pml Driver HPZ12" exclude=stisvc

; alias_service - Alias for alias_service. To configure this item add a section called: /settings/external scripts/alias/alias_service
alias_service = check_service

; alias_process_hung - Alias for alias_process_hung. To configure this item add a section called: /settings/external scripts/alias/alias_process_hung
alias_process_hung = check_process "filter=is_hung" "crit=count>0"

; alias_process - Alias for alias_process. To configure this item add a section called: /settings/external scripts/alias/alias_process
alias_process = check_process "process=$ARG1$" "crit=state != 'started'"

; alias_cpu_ex - Alias for alias_cpu_ex. To configure this item add a section called: /settings/external scripts/alias/alias_cpu_ex
alias_cpu_ex = check_cpu "warn=load > $ARG1$" "crit=load > $ARG2$" time=5m time=1m time=30s

; alias_event_log - Alias for alias_event_log. To configure this item add a section called: /settings/external scripts/alias/alias_event_log
alias_event_log = check_eventlog

; alias_cpu - Alias for alias_cpu. To configure this item add a section called: /settings/external scripts/alias/alias_cpu
alias_cpu = check_cpu

; alias_disk_loose - Alias for alias_disk_loose. To configure this item add a section called: /settings/external scripts/alias/alias_disk_loose
alias_disk_loose = check_drivesize

; alias_mem - Alias for alias_mem. To configure this item add a section called: /settings/external scripts/alias/alias_mem
alias_mem = check_memory

; alias_disk - Alias for alias_disk. To configure this item add a section called: /settings/external scripts/alias/alias_disk
alias_disk = check_drivesize

; alias_file_size - Alias for alias_file_size. To configure this item add a section called: /settings/external scripts/alias/alias_file_size
alias_file_size = check_files "path=$ARG1$" "crit=size > $ARG2$" "top-syntax=${list}" "detail-syntax=${filename] ${size}" max-dir-depth=10

; alias_sched_task - Alias for alias_sched_task. To configure this item add a section called: /settings/external scripts/alias/alias_sched_task
alias_sched_task = check_tasksched show-all "filter=title eq '$ARG1$'" "detail-syntax=${title} (${exit_code})" "crit=exit_code ne 0"

; alias_process_stopped - Alias for alias_process_stopped. To configure this item add a section called: /settings/external scripts/alias/alias_process_stopped
alias_process_stopped = check_process "process=$ARG1$" "crit=state != 'stopped'"

; alias_process_count - Alias for alias_process_count. To configure this item add a section called: /settings/external scripts/alias/alias_process_count
alias_process_count = check_process "process=$ARG1$" "warn=count > $ARG2$" "crit=count > $ARG3$"

; alias_sched_long - Alias for alias_sched_long. To configure this item add a section called: /settings/external scripts/alias/alias_sched_long
alias_sched_long = check_tasksched "filter=status = 'running'" "detail-syntax=${title} (${most_recent_run_time})" "crit=most_recent_run_time < -$ARG1$"

; alias_file_age - Alias for alias_file_age. To configure this item add a section called: /settings/external scripts/alias/alias_file_age
alias_file_age = check_files "path=$ARG1$" "crit=written > $ARG2$" "top-syntax=${list}" "detail-syntax=${filename] ${written}" max-dir-depth=10

; alias_volumes_loose - Alias for alias_volumes_loose. To configure this item add a section called: /settings/external scripts/alias/alias_volumes_loose
alias_volumes_loose = check_drivesize

; alias_volumes - Alias for alias_volumes. To configure this item add a section called: /settings/external scripts/alias/alias_volumes
alias_volumes = check_drivesize

; alias_sched_all - Alias for alias_sched_all. To configure this item add a section called: /settings/external scripts/alias/alias_sched_all
alias_sched_all = check_tasksched show-all "syntax=${title}: ${exit_code}" "crit=exit_code ne 0"

Re: Why Nagios shows more memory than the real?

Posted: Wed May 13, 2015 3:39 am
by rhassing
First you should allow your Nagios server to do snmp queries to the host.

Re: Why Nagios shows more memory than the real?

Posted: Wed May 13, 2015 6:33 am
by xerez
Thanks!! Works!!

Anyway, I will like do it with nrpe too.

Edit:

In the commands.cfg I put:

Code: Select all

# 'check_mem_win' command definition
define command{
        command_name    check_mem_win
        command_line    $USER1$/check_snmp_storage.pl -H $HOSTADDRESS$ -C public -m "^Physical Memory$" -w 90 -c 95
        }
And in windows.cfg I put:

Code: Select all

define service{
        use                     generic-service
        host_name               <host name>
        service_description     Memory Usage
#       check_command           check_nt!MEMUSE!-w 90 -c 95
        check_command           check_mem_win
        }
And all work fine! But if I try to define the command with arguments doesn't work:

commands.cfg:

Code: Select all

# 'check_mem_win' command definition
define command{
        command_name    check_mem_win
        command_line    $USER1$/check_snmp_storage.pl -H $HOSTADDRESS$ -C public -m "^Physical Memory$" -w $ARG1$ -c $ARG2$
        }
windows.cfg:

Code: Select all

define service{
        use                     generic-service
        host_name               <host name>
        service_description     Memory Usage
#       check_command           check_nt!MEMUSE!-w 90 -c 95
        check_command           check_mem_win!90!95
        }
Why? What is wrong?

Thanks!