check_memory
Checks the memory usage on the host.
You can check these memory types:
- physical: physical memory
- swap: swap memory (pagefile on Windows)
- committed: committed memory as shown in the Windows task manager (Windows only, physical + swap)
- virtual: available Windows virtual address space (Windows only)
Read more about Windows virtual address space.
Implementation
| Windows | Linux | FreeBSD | macOS |
|---|---|---|---|
| ✅ | ✅ | ✅ | ✅ |
Argument Defaults
| Argument | Default Value |
|---|---|
| warning | used > 80% |
| critical | used > 90% |
| empty-state | 0 (OK) |
| empty-syntax | |
| top-syntax | %(status) - %(list) |
| ok-syntax | |
| detail-syntax | %(type) = %(used)/%(size) (%(used_pct | fmt=%.1f )%) |
Check Specific Arguments
| Argument | Description |
|---|---|
| n|procs-to-show | Number of top resource-consuming processes to show |
| show-args | Show arguments for the top N processes |
| type | Memory types to check. Default: physical,committed (Windows) or physical,swap (other systems) |
| use-free | Calculate used physical memory as total minus free (instead of available) memory |
Attributes
Filter Keywords
Use these attributes in filters and thresholds, along with the default attributes:
| Attribute | Description |
|---|---|
| Used bytes with the type as key | |
| type | Checked type, either ‘physical’ or ‘committed’, ‘swap’ or ‘virtual’ (Windows only) |
| used | Used memory in human readable bytes (IEC) |
| used_bytes | Used memory in bytes (IEC) |
| used_pct | Used memory in percent |
| free | Free memory in human readable bytes (IEC) |
| free_bytes | Free memory in bytes (IEC) |
| free_pct | Free memory in percent |
| size | Total memory in human readable bytes (IEC) |
| size_bytes | Total memory in bytes (IEC) |
| caches | Memory used by the page cache in human readable bytes (IEC, physical type only) |
| caches_bytes | Memory used by the page cache in bytes (IEC, physical type only) |
| caches_pct | Memory used by the page cache in percent (physical type only) |
Examples
Default Check
check_memory
OK - physical = 6.98 GiB, committed = 719.32 MiB|...
Change the output template to show more information:
check_memory 'top-syntax=%(list)' 'detail-syntax=%(type) free: %(free) used: %(used) size: %(size)'
physical free: 35.00 B used: 7.01 GiB size: 31.09 GiB, committed free: 27.00 B used: 705.57 MiB size: 977.00 MiB |...
Subtract free memory from total memory. Report the four counters in decimal KB:
check_memory type=physical --use-free \
'detail-syntax=%(used_pct | fmt=%.1f)% (%(used)) used.' \
"perf-config=size_bytes(unit:KB;magic:0.001;suffix:TOTAL) used_bytes(unit:KB;magic:0.001;suffix:USED) \
free_bytes(unit:KB;magic:0.001;suffix:FREE) caches_bytes(unit:KB;magic:0.001;suffix:CACHES) *(ignore:yes)"
Example using check_snclient and Naemon
Naemon Config
define command{
command_name check_snclient
command_line $USER1$/check_snclient -k -p 'your-password' -u 'https://$HOSTADDRESS$:8443' $ARG1$ $ARG2$
}
define service {
host_name testhost
service_description check_memory
use generic-service
check_command check_snclient!check_memory!'warn=used > 80%' 'crit=used > 90%'
}