Check Uptime as service


I added a new service to Icinga 2, to monitor the uptime of the machine. So far it is working but, the default plugin check unit is in minutes. The plugin itself supports an argument, with which you can change the unit to (seconds | minutes | hours | days).

Now my question is, how can I add arguments to the service? I tried the following, without success:

apply Service "uptime" {
  import "generic-service"

  check_command = "uptime"

  vars.uptime_arguments = [ "-u", "days" ]

  assign where == NodeName

I guess I misunderstood the configuration documentation and have done something wrong but I can’t figure out what it could be.

Does anyone know how I could add the following arguments to that service or if there is another way of doing it?


-u (seconds | minutes | hours | days)
-w Warning Threshold (i.e. 280)
-c Critical Threshold (i.e 300)

Thank you in advance

Service is the wrong place for this modification, you need to edit the related CheckCommand.
The problem is that uptime is part of the ITL (icinga template library, it’s basically default configuration provided with icinga), so i wouldn’t advise you to directly edit its definition since your modification can be erased by a future update.

So, what you can do instead is a wrapper check command, basically, define your check command uptime_custom and import uptime command in it in this way :

object CheckCommand "uptime_custom" {
    import "uptime"
        arguments += {
                "-u" = {
                        set_if = "$uptime_arguments$"
                        value = "$uptime_arguments$"
                        description = "custom description"

        vars.uptime_arguments = "days"

Also, you need to change your target check_command in your service.

I didn’t tested it but it should do the trick.

1 Like


Thank you for the hint, as that helped me to sort the problem. This is how I have done it now and it works for us:


object CheckCommand "uptime_custom" {
    import "uptime"
        arguments += {
        "-u" = "$uptime_unit$"
        "-w" = "$uptime_warning$"
        "-c" = "$uptime_critical$"


apply Service "uptime" {
  import "generic-service"

  check_command = "uptime_custom"

  vars.uptime_unit = "days"
  vars.uptime_warning = "280"
  vars.uptime_critical = "300"

  assign where == NodeName

Hello HigH-Hawk
I am looking for this check and I was trying to implement this one, but unfortunetely its not working for me. I get the following error:

execvpe(/usr/lib64/nagios/plugins/check_uptime) failed: No such file or directory

can anyone help me where do i ge the check_uptime file?

thank you in advance

kind regards

Hello Pia,

what operating system are you on?

The error message execvpe(/usr/lib64/nagios/plugins/check_uptime) failed: No such file or directory says that the file is not available, which might be due to the plugin not being installed.

But if you tell us what operating system this is on, we can surely help you installing the required plugin.

Good Morning,

my OS System is Linux. I was lookin for the check_uptime file its not in my plugin folder, where do I get it from ? I tried so many different uptime plugins but can’t find a working one. So I hope the one you are using will help.

thank you

That depends on your distribution. For Debian/Ubuntu you need to install nagios-plugins-contrib.

and for GNU or CENTOS? is there something i need to install?

On CentOS you should be able to do:

#: yum install nagios-plugins-uptime

thank you. It works but somehow just for the icinga host not for other hosts? I thought I can check every host with this check? did I get it wrong?

The plugins, or service checks, need to be installed on the machine/s you want
to check.