Page 1 of 1

Check Linux Disk Space

Posted: Mon Apr 22, 2024 9:36 am
by AngeloMileto
I've been searching for some time now and can't find anything - my search skills aren't great - so I figured I'd try to ask here and you can point me to what I'm missing.

New position and they have an XI instance running. It hasn't been configured much - just a couple of hosts added by the basic wizards run - and I'm trying to expand on the configurations. We have a mixed windows/linux environment - as do most I assume - and I'm trying to do some basic disk space checks.

The basic implementation here is to use ncpa having the agent installed on both windows and linux and a single token for both. Basic checks are working so I know the installations are good. What I can't get is a way to check all local linux partitions (or windows for that matter). I did find the basic check_ncpa.py metric='disk/logical/' but there seems to be no way to tell it to look at all local - non-network mountpoints - disks at the same time.

Is there a way? Is there a way of writing a bash script to be on all the linux hosts that does that based on whatever local partitions are defined (thinking output of df or lsblk or something)? I'm sure there was a check_disk plugin I've used in core before that did exactly that but can't figure out if ncpa is capable.

Re: Check Linux Disk Space

Posted: Mon Apr 22, 2024 9:54 am
by sgardil
AngeloMileto wrote: Mon Apr 22, 2024 9:36 am I've been searching for some time now and can't find anything - my search skills aren't great - so I figured I'd try to ask here and you can point me to what I'm missing.

New position and they have an XI instance running. It hasn't been configured much - just a couple of hosts added by the basic wizards run - and I'm trying to expand on the configurations. We have a mixed windows/linux environment - as do most I assume - and I'm trying to do some basic disk space checks.

The basic implementation here is to use ncpa having the agent installed on both windows and linux and a single token for both. Basic checks are working so I know the installations are good. What I can't get is a way to check all local linux partitions (or windows for that matter). I did find the basic check_ncpa.py metric='disk/logical/' but there seems to be no way to tell it to look at all local - non-network mountpoints - disks at the same time.

Is there a way? Is there a way of writing a bash script to be on all the linux hosts that does that based on whatever local partitions are defined (thinking output of df or lsblk or something)? I'm sure there was a check_disk plugin I've used in core before that did exactly that but can't figure out if ncpa is capable.
Do you know what version of NCPA you have installed on the linux and windows systems? We currently released NCPA 3, I need to check if we added the ability to do this with NCPA with 3 first but here is a thread going over a similar topic. I'll get back to you on if this functionality was added,

Re: Check Linux Disk Space

Posted: Tue Apr 23, 2024 7:13 am
by AngeloMileto
I appreciate it! I did find that thread but kinda got lost in the whole using ncpa to call another plugin. I was going to try to figure out how to use check_disk as it has an option for --all and --local which should work for both windows and linux.

As for ncpa, /usr/local/ncpa/ncpa_listener --version = 2.4.1.

I'm hoping that it's not an upgrade thing that's needed as this is a completely disconnected system so getting updates in is a pain!

Appreciate the help!

Re: Check Linux Disk Space

Posted: Wed Apr 24, 2024 10:42 am
by bbahn
Hello @AngeloMileto,

The disk node should return all local disks, but if you want a bash script to do this, you should be able to add a plugin like this:

Code: Select all

#!/bin/bash

df -h --output=source,pcent,target | grep -vE 'tmpfs|udev' | while read line; do
  echo "$line"
done
and use check_ncpa with metric='plugins/myplugin.sh'

You can check the following link for more information on using plugins with NCPA and check_ncpa.py:
NCPA Help Reference Documentation - Plugins
check_ncpa.py - Running Plugins with Arguments - and go to the section Running plugins with Arguments

Re: Check Linux Disk Space

Posted: Thu Apr 25, 2024 8:49 am
by AngeloMileto
bbahn wrote: Wed Apr 24, 2024 10:42 am The disk node should return all local disks, ...
But from what I've read, executing check_ncpa.py --hostname=xxx --port=5693 --token=jklfdskj --metric='disk' by itself fails. Also, you can't do metric='disk/used_percent' as that fails. The only way to use metric='disk' is to put a path in there --metric='disk/logical/|data/used_percent'.

I get your suggestion on using df to get a list of all the local disks but I'm not sure how that could be called and returned to Nagios via the ncpa call to evaluate against some percentage number to give a warning/critical indication.

The other challenge is that this is a completely disconnected system so I can't just go and download plugins so I have to create my own. I appreciate the help and sorry for being so ignorant of this as I have a programming background but just can't seem to understand how to get this to work.

Re: Check Linux Disk Space

Posted: Mon Apr 29, 2024 10:14 am
by bbahn
It would seem you're running into some kind of error regarding your disk check. You can definitely use a custom plugin in place of the failing disk check. Just create a plugin that grabs the disk information you're looking for, put it in /usr/local/ncpa/plugins and now you can access that plugin as a check through the API, which is what check_ncpa.py does. You will be using --metric='plugins/myplugin.sh' instead of --metric='disk/'.