Monitoring disk space on server with multiple drives

Hello.
I am new to Icinga. can you please help me get this point:

  • How does Icinga monitor disk space on Server with multiple drives.
    do I have to write a script for each drive, an will get an alarm for each one, that would not be practical for us cause we dont want to get notified because of just one drive while the other are not full.
    or it s possible to set a trigger for the total amount of disk space.
    Thanks

Hi and welcome to the community!

Please have a look at check_disk in the icinga template library (ITL).
https://icinga.com/docs/icinga2/latest/doc/10-icinga-template-library/#disk

You can use a dictonary for each drive in your service.

Example:

Service

apply Service for (disk => config in host.vars.disks) {
import “generic service”
check_command = “disk”
vars += config
}

use the config in your host:

vars.disk [“disk /”] = {
disk_partitions = “/”
disk_wfree = “10%”
disk_cfree = “5%”
}

1 Like

Hello,

I want to do the same.
I would like to do it as you recommend. Could you please let me know where exactly I can find the config files on a Linux system which I can edit? Please tell me the exact path to the config files for the host and the service.

Thanks in advance.

HI @tom2,

This is a very old topic I am afraid. And the answer is given but not marked as the solution.

The example above but with 2 disks:

   vars.disks["disk /data"] = {
     disk_partitions = "/data"
   }
   vars.disks["disk /"] = {
     disk_partitions = "/"
   }

For more see:

And official documentation:

Hello William,
thank you so much for quick answer.
Honestly I have general problem with posts in the icinga communtiy and documentations. There are always many excerpts from scripts, config files or views from the Icinga director. But where exactly these files or views are? I can’t find anything. In this specific case, I also don’t see any paths in the entry for which I asked the question, nor in your answer, and I don’t see any paths in the links you sent me either.

Yes there are no paths, because every setup is different. Generally you put the disk configuration in the agent.conf file in the zone where it lives (/etc/icinga2/zondes.d/zone_name/agent.conf) This is genrally explaned in the “how-to” guides in the documentation

the

apply Service for (disk => config in host.vars.disks) {
import “generic service”
check_command = “disk”
vars += config
}

Is generally placed in the global-templates directory as this can be applicable to all hosts in all zones

Thanks for your answer.
In our system there are no further foulder or files in this path which you gave me.

/etc/icinga2/zones.d# ll
total 12
drwxr-x— 2 nagios nagios 4096 Nov 6 15:04 ./
drwxr-x— 9 nagios nagios 4096 Nov 6 15:04 …/
-rw-r–r-- 1 nagios nagios 119 Nov 6 15:04 README
root@

the

apply …
Is generly…

Sorry I do not understand what file and where is the global-templates directory.

If read the monitoring basics

I see many excerpts from scripts, config files or views from the Icinga director but I don’t know is this the icinga director, is this a config file or what ever.
When I read this documentations its just theoretical for me I don’t know how it works in the documentation nor our Icinga system.

For example, this is from the documentation

Zone ¶

Zone objects are used to specify which Icinga 2 instances are located in a zone. Please read the distributed monitoring chapter for additional details. Example:

object Zone “master” {
endpoints = [ “icinga2-master1.localdomain”, “icinga2-master2.localdomain” ]

}

object Zone “satellite” {
endpoints = [ “icinga2-satellite1.localdomain” ]
parent = “master”
}

I don’t know is this extract above?
A view in the director?
A config file?
If so, where could the config file be?

I understand that every Icinga System is different. But is there not a basic configuration which is equal to others?

I know how to work with Iciniga director but I don’t know about the file structure on the Server.
Could you please send me a link where I can find the “how-to” guides in the documentation?

Hi @tom2,

Zone objects need to be specified in the zone configuration file /etc/icinga2/zones.conf
Icinga installs in a basic manner on all linux systems.

See this for example: (purpose of all the linux directories)

https://www.tecmint.com/linux-directory-structure-and-important-files-paths-explained/#:~:text=A%20standard%20Linux%20distribution%20follows,below%20with%20Diagram%20and%20explanation.&text=Each%20of%20the%20above%20directory,drivers%2C%20configuration%20files%2C%20etc.

If you need more linux knowledge there is a good free course available here:

This is the basic icinga installation:

This is for the web part of it:

Here for the configuration part:

Everything you are searching for is available in the documentation if you look hard enough.

Thanks for the Links.

I didn’t ask for knowled about Linux Directory Structure and Important Files Paths.
I need the Icinga Directory Structure and Important Files Paths Explained.

In the Configuration - Icinga are some paths but then it stops also. And in all other Documentations there is also not explained where or what are this extracts!
And I have the same problem which I explained several times.

I asked clear questions but know answers to this.
I should examples but know response to this.

/etc/icinga2/zones.conf

/*

  • Generated by Icinga 2 node setup commands
  • on 2017-03-06 15:17:16 +0100
    */

object Endpoint NodeName {
}

object Zone ZoneName {
endpoints = [ NodeName ]
}

object Zone “director-global” {
global = true
}

Back to my original question:

Could you please let me know where exactly I can find the config files where I can setup multiple drives?

Hi @tom2

As I already told you:

put

apply Service for (disk => config in host.vars.disks) {
import “generic service”
check_command = “disk”
vars += config
}

in a file here:
/etc/icinga2/zones.d/global-templates
As this will then apply to all hosts which have

   vars.disks["disk /data"] = {
     disk_partitions = "/data"
   }
   vars.disks["disk /"] = {
     disk_partitions = "/"
   }

Configurred in a file here:
/etc/icinga2/zones.d/{{ zone_name }}/agent.conf

This only works without the director.

Thanks for the answer with path.
(Also with control F the computer could not find that you sent already)

/etc/icinga2/zones.d# ll
total 12
drwxr-x— 2 nagios nagios 4096 Nov 27 14:23 ./
drwxr-x— 9 nagios nagios 4096 Nov 27 14:22 …/
-rw-r–r-- 1 nagios nagios 119 Nov 6 15:04 README

The code was already in a other file.
Tobias found a solution in icinga director and with a apply rule.