What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

How can I monitor free disk space of connected iSCSI shares on Xen servers?

Votes:

0

I use the SSH disk free sensor to monitor the free disk space of mounted devices on a Xen server. This works perfectly with NFS shares, but how can I read out the free disk space of iSCSI connected drives?

free-disk-space iscsi linux prtg script sensor ssh xen

Created on May 8, 2013 2:26:43 PM by  Gerald Schoch [Paessler Support]



11 Replies

Accepted Answer

Votes:

0

This article applies to PRTG Network Monitor 13 or later

Monitoring Free Disk Space of iSCSI Shares on Xen Servers

iSCSI mounts are not integrated as regular volumes. Because of this, they are not visible for the standard SSH Disk Free Sensor. However, PRTG’s SSH Script Sensor makes it possible to retrieve the desired information.

In order to monitor free disk space on a connected iSCSI device, create a small script file in combination with an SSH Script sensor. This custom sensor will return the utilization of the share in percent. You are also able to improve and adjust the script to your monitoring needs.

Please follow the steps below.

Steps to Go

  1. Open a text editor.
  2. Copy the script (see below) and paste it into the editor.
  3. Save the created script file and place it in the following path on your Xen server: var/prtg/scripts
  4. Ensure that the script file has executable rights and is accessible for the user defined in PRTG.
  5. Add a new SSH Script sensor to the corresponding device in PRTG, e.g., via Add Sensor… in the device’s context menu.
  6. Choose the created script from the dropdown list in the add sensor dialog (in section Script).
  7. In the field Parameters, provide the Universally Unique Identifier (UUID) of the connected iSCSI share. For example, 222ac029-3970-9e8b-060b-5e3870bc1302
    Note: You can get a list of all UUIDs available on your system using the following command: xe sr-list | grep -B2 -A3 iSCSI
  8. Select Float in section Value Type. Note: The percentage output of the example script in this article is a float value. If you use an adjusted or another script, make sure that you choose the correct value type here!
  9. Click on Continue.

The created sensor will start to monitor the free disk space immediately. This sensor works for all volume types which are available on a Xen server, even for Network File Systems (NFS) or local devices.


Script

Please use the following script:

#!/bin/bash

xe sr-list uuid=$1 params=physical-utilisation,physical-size | awk '{if (NR == 1) {pu = $NF}; if (NR == 2) {ps = $NF; print "0:" pu/ps*100 ":OK"}}' 

The script works like this:

  • xe: command to administrate the Xen kernel
  • sr-list: ‘storage-list’ to get all available storage systems on Xen Without additional parameters you will get an unfiltered list of all storages. In order to get specific values for a defined storage use the parameters below:
  • uuid: calls a specific storage, defined in the parameters field of the SSH Script sensor settings.
  • params: retrieves the desired values.

awk and the following statement calculates the utilization of the disk and returns a PRTG compatible output.

Created on May 8, 2013 2:40:19 PM by  Gerald Schoch [Paessler Support]

Last change on Nov 8, 2013 4:48:16 PM by  Gerald Schoch [Paessler Support]



Votes:

0

"Ensure that the script file has executable rights and is accessible for the user defined in PRTG."

Hello everyone, i wanted to ask what rights do i have to give to my Test-User "oper1"?

He already has this Privileges:

(ALL) NOPASSWD: /var/prtg/scripts/storage (storage is the name of the script)

The ls -l command in /var/prtg/scripts returns this: -rwxrwxrwx 1 oper1 root 161 Jun 12 18:54 storage

And the user can run this Script with sudo /var/prtg/scripts/storage, without entering a password. So I basically have ALL the rights possible to run this script as a user. But the sensor doesn't work. Does it have something to with the following line i've found?

echo PAESSH_START;/var/prtg/scripts/storage 3f981f15-5724-xxxx-xxxx-b3xxxxxxxcd;echo;echo PAESSH_END

I would be really Glad if someone could help,

Created on Jun 12, 2020 5:59:15 PM



Votes:

0

Hi,

Can you test if a domain admin is able to execute the script?

Created on Jun 15, 2020 5:39:36 AM by  Marijan Horsky [Paessler Support]



Votes:

0

Hello Marijan Horsky,

the root user can run the script withouth any problems. For Security reasons I wanted to establish a User (oper1) that is just privileged for this particular Script so the SSH Script-Sensor doesn't need an admin/root. After that i make the Script just executable and not writable for this particular User. But first of all it has to be executed by the non root user. The User being an Admin in any form would not be my goal of choice. If the User is compromised, he could change the Script and do whatever he wants on the system.

If it makes the communication easier, i also speak German fluently. Thank you in advance.

Created on Jun 15, 2020 7:29:56 AM



Votes:

0

Hi,

If you can execute the script via the Probe system with the desired user you should be able to use the desired user. If you cannot execute the script you need to check the permissions for this user. Please note that we recommend to use a user which has full access rights on the target system.

Created on Jun 15, 2020 9:12:49 AM by  Marijan Horsky [Paessler Support]



Votes:

0

Hello Marijan Horsky,

Sorry i have forgot to tell you that running the Script locally on the Server works. With the settings mentioned above i can run the Script with the following Codes and my Testuser {{{cd /var/prtg/scripts

  1. in this direcetory, the Script named storage ist the desired Script to execute
  2. so I type in:

sudo ./ storage

  1. And the Script runs without asking for a Password from my Testuser oper1}}} But as I mentioned with the SSH Script Sensor it will not work. I guess that the needed sudo infront of the command is not implemented in the Code, sended from PRTG to the XenServer with SSH. Can I alter the Code or even see what PRTG actually sends? Maybe it is a different Code and i need to edit the sudoers again.

Thank you very much for your effort!

Created on Jun 15, 2020 12:14:27 PM

Last change on Jun 15, 2020 8:58:37 PM by  Sebastian Kniege [Paessler Support]



Votes:

0

Hi,

Can you execute the script directly on the remote probe system? Maybe via Powershell? Please let me know about the result.

Created on Jun 15, 2020 12:36:25 PM by  Marijan Horsky [Paessler Support]



Votes:

0

To visualize it, i have changed the Script testwise to echo "Hello World" and I can run it from the remote probe system with an SSH session, Testuser oper1 and even without sudo.

I can directly run the script without entering the Password. If i change the script back to what it was i can only run it with sudo in front of the execution command. Without sudo it shows me that Authentication failed. And sudo doesn't need a password, because i have set oper1 as a sudoer for exactly that script.

Created on Jun 15, 2020 2:47:48 PM



Votes:

0

Hi Leon,

What will happen when you enter the credentials of this user into the script? Does it work than?

Created on Jun 16, 2020 6:10:23 AM by  Marijan Horsky [Paessler Support]



Votes:

0

Hello Marijan Horsky,

thank you for your help i really appreciate it.

I have to apologize that i am not an Unix expert, how do I exactly put in the credentials correctly into the script?

Let's say if the user is testuser and the password is testpassword

Created on Jun 17, 2020 8:44:47 AM



Votes:

0

Hi,

As this is a custom script you need to contact a colleague in your department and ask them how to enter the credentials into the script. We cannot help you to change your script.

Created on Jun 18, 2020 5:11:58 AM by  Marijan Horsky [Paessler Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.