# Check command "linux memory" does not exist

**URL:** <https://community.icinga.com/t/check-command-linux-memory-does-not-exist/693>\
**Category:** Service Monitoring\
**Created:** [March 25, 2019, 8:10am UTC](https://community.icinga.com/t/check-command-linux-memory-does-not-exist/693 "2019-03-25T08:10:33Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![remoschmitter](https://community.icinga.com/letter_avatar_proxy/v4/letter/r/9fc29f/32.png) [@remoschmitter](https://community.icinga.com/u/remoschmitter)\
**Post date:** [March 25, 2019, 8:10am UTC](https://community.icinga.com/t/check-command-linux-memory-does-not-exist/693/1 "2019-03-25T08:10:33Z")

</div>

Hello Dear Community

I’m having trouble with the nagios plugin “linux memory” for checking the ram usage on a debian server machine over the agent.

I have installed the nagios plugin on both the master and on the server with the agent running.

This is the service on the master:

```
// Memory Usage
apply Service "linux_memory" {
  import "generic-service"
  check_command = "linux_memory"
  vars.linux_memory_warning = "20"
  vars.linux_memory_critical = "10"
  vars.linux_memory_divider = "M"
  command_endpoint = host.vars.client_endpoint
  assign where host.vars.client_endpoint
}

```

Where do I have do define this check\_command? I’ve already tried to enter this check\_command in **conf.d/commands.conf** or **conf.d/services.conf** Or what else am I missing? Since there’s the following error showing up at validation:

`critical/config: Error: Validation failed for object 'xy-server!linux_memory' of type 'Service'; Attribute 'check_command': Object 'linux_memory' of type 'CheckCommand' does not exist.`

Thank you very much for your help!

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [March 25, 2019, 8:19am UTC](https://community.icinga.com/t/check-command-linux-memory-does-not-exist/693/3 "2019-03-25T08:19:50Z")

</div>

Hi,

both endpoints need to be aware of the command: The master in order to resolve the given command argument parameters, and the client to really calculate the command line being executed. The client may use a different local command to ignore certain passed parameters (for security reasons, but it is not general best practice).

Therefore, it is advised to put the CheckCommand into a global zone, namely `global-templates` which already comes pre-defined in the `node wizard` setups in recent versions.

```auto
mkdir -p /etc/icinga2/zones.d/global-templates
vim /etc/icinga2/zones.d/global-templates/commands.conf

...

systemctl restart icinga2

```

Cheers,  
Michael

---

<div class="post-metadata">

**Author:** ![remoschmitter](https://community.icinga.com/letter_avatar_proxy/v4/letter/r/9fc29f/32.png) [@remoschmitter](https://community.icinga.com/u/remoschmitter)\
**Post date:** [March 25, 2019, 8:48am UTC](https://community.icinga.com/t/check-command-linux-memory-does-not-exist/693/4 "2019-03-25T08:48:29Z")

</div>

Thank you very much! Service is now showing up!  
But I’m getting the following message on icingaweb2:

`/usr/lib/nagios/plugins/check_linux_memory: 8: /usr/lib/nagios/plugins/check_linux_memory: Syntax error: newline unexpected`

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [March 25, 2019, 8:50am UTC](https://community.icinga.com/t/check-command-linux-memory-does-not-exist/693/5 "2019-03-25T08:50:38Z")

</div>

Hi,

that’s coming from the plugin’s execution itself. I don’t know which source you did use, nor how the check command itself looks like, nor the executed command line. Please share that 🙂

Cheers,  
Michael

---

<div class="post-metadata">

**Author:** ![remoschmitter](https://community.icinga.com/letter_avatar_proxy/v4/letter/r/9fc29f/32.png) [@remoschmitter](https://community.icinga.com/u/remoschmitter)\
**Post date:** [March 25, 2019, 8:53am UTC](https://community.icinga.com/t/check-command-linux-memory-does-not-exist/693/6 "2019-03-25T08:53:44Z")

</div>

I have noticed that my nagios plugins are in **/usr/lib64/nagios/plugins** and not in **/usr/lib/nagios/plugins** , probably because of CentOS…  
So it’s might looking in the wrong place?

I’ve used the following source:  
wget [https://github.com/osklil/nagios-misc/blob/master/check\_linux\_memory/check\_linux\_memory](https://github.com/osklil/nagios-misc/blob/master/check_linux_memory/check_linux_memory)

Thanks:blush:

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [March 25, 2019, 8:55am UTC](https://community.icinga.com/t/check-command-linux-memory-does-not-exist/693/7 "2019-03-25T08:55:50Z")

</div>

The plugin is executed already, so it shouldn’t be a location problem. To me, this sounds more like a missing code, wrong indent or interpreter, or whatever else. Time is limited so please provide the requested things 🙂

Cheers,  
Michael

---

<div class="post-metadata">

**Author:** ![remoschmitter](https://community.icinga.com/letter_avatar_proxy/v4/letter/r/9fc29f/32.png) [@remoschmitter](https://community.icinga.com/u/remoschmitter)\
**Post date:** [March 25, 2019, 9:02am UTC](https://community.icinga.com/t/check-command-linux-memory-does-not-exist/693/8 "2019-03-25T09:02:06Z")

</div>

Plugin Source:

> <https://github.com/osklil/nagios-misc/blob/master/check_linux_memory/check_linux_memory>

Service:  
// Memory Usage  
apply Service “linux\_memory” {  
import “generic-service”  
check\_command = “linux\_memory”  
vars.linux\_memory\_warning = “20”  
vars.linux\_memory\_critical = “10”  
vars.linux\_memory\_divider = “M”  
command\_endpoint = host.vars.client\_endpoint  
assign where host.vars.client\_endpoint  
}

global-template:  
/\* Linux Memory Command \*/  
object CheckCommand “linux\_memory” {  
command = [PluginDir + “/check\_linux\_memory”]  
arguments ={  
“-w” = “$linux\_memory\_warning$”  
“-c” = “$linux\_memory\_critical$”  
“-d” = “$linux\_memory\_divider$”  
}  
}

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [March 25, 2019, 9:18am UTC](https://community.icinga.com/t/check-command-linux-memory-does-not-exist/693/9 "2019-03-25T09:18:58Z")

</div>

Ok, and the [executed command line](https://icinga.com/docs/icinga2/latest/doc/15-troubleshooting/#executed-command-for-checks) on the agent? Once you’ll have it, run the following on the agent:

```auto
sudo -u icinga <insert command here>

```

Cheers,  
Michael

---

<div class="post-metadata">

**Author:** ![remoschmitter](https://community.icinga.com/letter_avatar_proxy/v4/letter/r/9fc29f/32.png) [@remoschmitter](https://community.icinga.com/u/remoschmitter)\
**Post date:** [March 25, 2019, 9:58am UTC](https://community.icinga.com/t/check-command-linux-memory-does-not-exist/693/10 "2019-03-25T09:58:52Z")

</div>

I’m not sure if this is what you’re looking for, sorry…

```
sudo -i /usr/lib/nagios/plugins/check_linux_memory:

    /usr/lib/nagios/plugins/check_linux_memory: Zeile 7: Syntaxfehler beim unerwarteten Wort `newline'
    /usr/lib/nagios/plugins/check_linux_memory: Zeile 7: `<!DOCTYPE html>'
```

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [March 25, 2019, 10:12am UTC](https://community.icinga.com/t/check-command-linux-memory-does-not-exist/693/11 "2019-03-25T10:12:46Z")

</div>

Ah. Seems you’ve downloaded an HTTP page instead of the actual plugin 😉

Lemme guess, you’re using

```auto
wget https://github.com/osklil/nagios-misc/blob/master/check_linux_memory/check_linux_memory

```

… instead, you’ll need the raw file to download 😉

![55](https://community.icinga.com/uploads/default/original/1X/7e2f57924f5722fb56bd11722af5b8baef148e41.png)

```auto
wget https://raw.githubusercontent.com/osklil/nagios-misc/master/check_linux_memory/check_linux_memory

```

Cheers,  
Michael

---

<div class="post-metadata">

**Author:** ![remoschmitter](https://community.icinga.com/letter_avatar_proxy/v4/letter/r/9fc29f/32.png) [@remoschmitter](https://community.icinga.com/u/remoschmitter)\
**Post date:** [March 25, 2019, 10:39am UTC](https://community.icinga.com/t/check-command-linux-memory-does-not-exist/693/12 "2019-03-25T10:39:00Z")

</div>

You are absolutely correct! I’ve downloaded the HTTP page 😅  
We are one step further now:

```
Can't locate Nagios/Plugin.pm in @INC (you may need to install the Nagios::Plugin module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.24.1 /usr/local/share/perl/5.24.1 /usr/lib/x86_64-linux-gnu/perl5/5.24 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.24 /usr/share/perl/5.24 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/lib/nagios/plugins/check_linux_memory line 28.

BEGIN failed--compilation aborted at /usr/lib/nagios/plugins/check_linux_memory line 28.

```

I suspect, **“perl-Nagios-Plugin”** is missing?  
The equivalent for debian would be **“libnagios-plugin-perl”** right?

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [March 25, 2019, 12:15pm UTC](https://community.icinga.com/t/check-command-linux-memory-does-not-exist/693/13 "2019-03-25T12:15:22Z")

</div>

Hi,

depending on your distribution, you may either find this packaged already as Perl library, or you’ll manually install Nagios::Plugin from CPAN.

```auto
apt-get install libnagios-plugin-perl

yum install perl-Nagios-Plugin

```

CentOS requires the EPEL repository up front.

```auto
yum -y install epel-release
yum makecache

```

Cheers,  
Michael

---

<div class="post-metadata">

**Author:** ![log1c](https://community.icinga.com/user_avatar/community.icinga.com/log1c/32/2071_2.png) [@log1c](https://community.icinga.com/u/log1c)\
**Post date:** [March 25, 2019, 12:33pm UTC](https://community.icinga.com/t/check-command-linux-memory-does-not-exist/693/14 "2019-03-25T12:33:44Z")

</div>

Side note for Ubuntu 18.04 (and maybe other new debian-based systems):  
On Ubuntu 18.04 you can install the package called `libmonitoring-plugin-perl`.  
Downside is you have to change `Nagios::Plugin` to `Monitoring::Plugin` in the depending scripts.  
For example with `vim` command line and `%s/Nagios::Plugin/Monitoring::Plugin/g`

---

<div class="post-metadata">

**Author:** ![remoschmitter](https://community.icinga.com/letter_avatar_proxy/v4/letter/r/9fc29f/32.png) [@remoschmitter](https://community.icinga.com/u/remoschmitter)\
**Post date:** [March 25, 2019, 12:35pm UTC](https://community.icinga.com/t/check-command-linux-memory-does-not-exist/693/15 "2019-03-25T12:35:33Z")

</div>

Thank you!

Unfortunately, **apt-get install libnagios-plugin-perl** does not seem to work on my debian 9 server:

```
Paketlisten werden gelesen... Fertig
Abhängigkeitsbaum wird aufgebaut.
Statusinformationen werden eingelesen.... Fertig
Paket libnagios-plugin-perl ist nicht verfügbar, wird aber von einem anderen Paket
referenziert. Das kann heißen, dass das Paket fehlt, dass es abgelöst
wurde oder nur aus einer anderen Quelle verfügbar ist.

E: Für Paket »libnagios-plugin-perl« existiert kein Installationskandidat.

```

I was able to install **apt-get install libmonitoring-plugin-perl** , but that’s not going to do the trick, right?

---

<div class="post-metadata">

**Author:** ![log1c](https://community.icinga.com/user_avatar/community.icinga.com/log1c/32/2071_2.png) [@log1c](https://community.icinga.com/u/log1c)\
**Post date:** [March 25, 2019, 1:35pm UTC](https://community.icinga.com/t/check-command-linux-memory-does-not-exist/693/16 "2019-03-25T13:35:45Z")

</div>

Open your script with `vim`. When the file is open enter a `:` to enter the command line of `vim`.  
On the command line just paste the command `%s/Nagios::Plugin/Monitoring::Plugin/g` and hit enter.  
Now all occurrences of `Nagios::Plugin` are replaced by `Monitoring::Plugin`  
Now just enter `:x!`or `:wq` to save the file. After this you should be able to run the script.

---

<div class="post-metadata">

**Author:** ![remoschmitter](https://community.icinga.com/letter_avatar_proxy/v4/letter/r/9fc29f/32.png) [@remoschmitter](https://community.icinga.com/u/remoschmitter)\
**Post date:** [March 25, 2019, 1:48pm UTC](https://community.icinga.com/t/check-command-linux-memory-does-not-exist/693/17 "2019-03-25T13:48:58Z")

</div>

I’ve edited the **check\_linux\_memory** file in /usr/lib/nagios/plugins.  
Now I’m not getting an error anymore, but the check is now purple in IcingaWeb2 with the following text:

`Unknown option: d`

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [March 25, 2019, 2:01pm UTC](https://community.icinga.com/t/check-command-linux-memory-does-not-exist/693/18 "2019-03-25T14:01:10Z")

</div>

How would a manual CLI run of this plugin look like? 🙂

---

<div class="post-metadata">

**Author:** ![remoschmitter](https://community.icinga.com/letter_avatar_proxy/v4/letter/r/9fc29f/32.png) [@remoschmitter](https://community.icinga.com/u/remoschmitter)\
**Post date:** [March 25, 2019, 2:10pm UTC](https://community.icinga.com/t/check-command-linux-memory-does-not-exist/693/19 "2019-03-25T14:10:33Z")

</div>

`./check_linux_memory`

`check_linux_memory OK - Memory used: 7.8G/15.6G (50%), Swap used: 734M/1.7G (43%) | memused=8389021696B;;;0;16784388096 memused%=50%;;;0;100 swapused=769118208B;;;0;1795153920 swapused%=43%;;;0;100`

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [March 25, 2019, 2:40pm UTC](https://community.icinga.com/t/check-command-linux-memory-does-not-exist/693/20 "2019-03-25T14:40:58Z")

</div>

So the plugin script doesn’t accept any threshold parameters?

---

<div class="post-metadata">

**Author:** ![remoschmitter](https://community.icinga.com/letter_avatar_proxy/v4/letter/r/9fc29f/32.png) [@remoschmitter](https://community.icinga.com/u/remoschmitter)\
**Post date:** [March 25, 2019, 2:45pm UTC](https://community.icinga.com/t/check-command-linux-memory-does-not-exist/693/21 "2019-03-25T14:45:09Z")

</div>

I commented them out for now. It’s running perfectly without any threshold values.  
I’m gonna try a few things and I’ll see if I’ll get it to work with threshold parameters. But thats not too important right now. Thanks very much for your help guys!! 😄

[Next page](https://community.icinga.com/t/check-command-linux-memory-does-not-exist/693.md?page=2)
