Daily diskspace alerts using OCS Inventory NG

Being proactive about managing system capacity is always a good idea. If you happen to use the OCS Inventory NG tool then here is a way for you to automatically have reports emailed to you (or various people) regarding systems with disk capacity below a threshold you set in a configuration file. This solution is geared towards Windows Servers, but you can easily change the select statement and use a different criteria (change where osname like ‘%server%’ to suit yourself). The results are sent as an attached CSV file, so you can easily view it in Excel or Open Office or even using vi if that is suits your fancy.

The percentage free space threshold, along with email addresses and domain names (aka workgroup names) are configured in a file named ocsdiff_conf.php. I run this (and other reports which I may post later) from a new subdirectory named reports that I created under /var/www/html/ocsreports. Be sure to set the same ownership and permissions on files in this directory as the other files under ocsreports. Here is what the file looks like:

> ocsdiff_conf.php

The file is named like this because the first report I wrote was to generate reports on hardware changes (RAM and disk in particular). I know reports like this can be implemented using GLPI integration – but we already have a helpdesk/ticketing system and I just can’t justify the effort to setup GLPI when writing one’s own reports is just not that hard.

The report itself is contained in the code below, I named the file diskreport.php and I scheduled it to run everyday using cron. I run my cron jobs for OCS-NG reports under the apache account.

> diskreport.php

Be sure to change the From and Reply To addresses in at the top of the file to suit yourself. If I have time I will move this to the configuration file.

My version of OCS-NG displays 4020 on the screen, I believe this equates to V1.0 (I know 1.01 is released, but just haven’t had the time to upgrade yet). I am running on RHEL 4.

Use the link below to download a zip file of both of these files. If you have any comments or questions post a comment on this post and I will reply.

Download OCS-NG Diskspace Report Version 1.0

12 Responses to “Daily diskspace alerts using OCS Inventory NG”

  1. Mark Egghead ISRAEL Windows XP Mozilla Firefox 2.0.0.14 says:

    SAManage is a leading provider of on-demand IT Asset Management services built using OCS-NG technology. Our service helps companies of all sizes effectively manage IT Assets, organize software licenses and detect risks and license compliance gaps. With no software or servers required, SAManage’s on-demand service can be easily deployed across multiple locations within minutes and provide visibility into complex IT infrastructures to ensure optimized IT asset utilization. For more information or to sign-up for a free 30-Days Trial, visit http://www.samanage.com or call 1-888-250-8971.

  2. sarfraz INDIA RedHat Linux Mozilla Firefox 1.5.0.9 says:

    We are installing both in RHEL5 we got the alert but when we changing any hardware we didi not got alert can you help us.

  3. Mike UNITED STATES Windows Vista Mozilla Firefox 3.0 says:

    Hi sarfraz,

    What do you mean by changing hardware? Are you altering the hardware to simulate a low % of free disk space? Or were you expecting this utility to generate alerts on ahrdware changes?

  4. sarfraz INDIA RedHat Linux Mozilla Firefox 1.5.0.9 says:

    I means, we are using this script for change management we can use it if not tel us and also we are getting alert but in attachment only we got this line
    “Computer Name,Drive Letter,Type,Filesystem,Total,Free,Free %”

    PLEASE HELP US.

  5. Marcelo BRAZIL Windows XP Mozilla Firefox 2.0.0.15 says:

    Hi Mike!

    i’m using ocsreport and i am search a tool that show me the changes in the machine with ocs-agent… this script(diskreport.php) show me the the disk-space but i don’t understand with put in the code! :S

    can you help me?

  6. Raman Pillai INDIA Windows XP Mozilla Firefox 3.0.4 says:

    Hi,
    It was great to have a script to check disk space. It would be great if you could send me the OCSdiff script which sends mail of the difference to the hardware changes in the system.

    Thanks in Advance.

    Raman

  7. [...] the OCS NG database.  This script is implemented much like the daily disk reports from OCS (see this).  Sorry there is no better documentation for this, I just have not had the time and soon will no [...]

  8. Gabriel Sepulveda CHILE Windows XP Mozilla Firefox 3.0.10 says:

    in which folder on the ocsreports should I put these files?, or how do I use it?

  9. Gabriel Sepulveda CHILE Windows XP Mozilla Firefox 3.0.10 says:

    dont worry, I just got the case closed. Thank you for these scripts.

  10. Mike UNITED STATES Windows Vista Mozilla Firefox 3.0.10 says:

    Glad you figured it out Gabriel

  11. Anonymous TAIWAN Ubuntu Linux Mozilla Firefox 3.5.8 says:

    Good job there are work on 1.3 too.

Leave a Reply