Skip to content

Utility module to get remote server file system disk space usage

Notifications You must be signed in to change notification settings

nirajKpanda/linux-disk-usage-util

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Project Summary

In our app environment, we don’t allow developers to SSH into servers without leadership approval. Therefore, it is critical that our team provide tools to allow developers to debug problems using our monitoring tools.

For example, when we get an alert that a disk is getting full, you would want to know what files are using up all of the space.

Development tools

  1. Python
  2. Ubuntu (16.x or later) or similar distribution
  3. SSH enabled servers

Prerequisites

Prerequisite Version
Python ~ ^2.7

Updating to the latest releases is recommended.

If python and ssh is already installed in your machine, run the following commands to validate the versions:

python -v
ssh -h

If your versions are lower than the prerequisite versions, you should update.

Cloning Repository

  1. Open a Terminal / Command Line / Bash Shell in your projects directory (i.e.: /yourprojectdirectory/)
  2. Clone the linix-disk-usage-util repository
$ git clone https://github.com/nirajKpanda/linux-disk-usage-util.git

This will download the entire linix-disk-usage-util repo to your project directory.

Setup Your Upstream

  1. Change directory to the new linix-disk-usage-util directory (cd linix-disk-usage-util)

Congratulations, you now have a local copy of the linix-disk-usage-util project!

Setup linix-disk-usage-util enviornment

Once you have linix-disk-usage-util cloned, before you start the application, you first need to install all of the dependencies:

pip install -r requirements.txt

Script Usage

[niraj@niraj]$python get_diskusage.py --help
usage: get_diskusage.py [-h] [-i HOST] [-u USER] [-p PASSWORD] [-f FILENAME]
-m MOUNTPOINT

optional arguments:
-h, --help show this help message and exit
-i HOST, --host HOST The hostname or IP address of the server to connect
-u USER, --user USER The remote server username preferably a sudo user
-p PASSWORD, --password PASSWORD
The password of the remote server user
-f FILENAME, --filename FILENAME
Load server credentials from configuration file,
provide absolute path of the config file
-m MOUNTPOINT, --mountpoint MOUNTPOINT
Mount point of the server directory structure
[niraj@niraj]$

Run in local server

[niraj@niraj]$python get_diskusage.py -i localhost -m /tmp
INFO:User requested to fetch local server file disk usage.....
Mount point is : /tmp
{
"/tmp/unity_support_test/tmp0": 0,
"/tmp/e3546f11-84f5-4c95-90e9a5af-36eeff8e/tmpdmp": 221248,
"/tmp/config-err-0PdOED": 0,
"/tmp//tmporg/tmpchromium/tmpChromium/tmpMNLHuI/Skype1_5/tmppng": 652,
"/tmp/a": 349,
"/tmp//tmpX0-lock": 11
}
[niraj@niraj]$

Run in remote server

[niraj@niraj]python get_diskusage.py -i -u -p -m

Load server credetnitals from config file

[niraj@nira]$python get_diskusage.py -f server.config -m /tmp

About

Utility module to get remote server file system disk space usage

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages