Knowledge Base

Creating a Custom Sensor EXE for IPCheck Server Monitor using Delphi

Diese Seite steht leider noch nicht auf Deutsch zur Verfügung. Wir bitten um Ihr Verständnis!

This custom sensor for IPCheck Server Monitor reads the available diskspace of a local drive and gives back a result.

This file (disksensorexe.dpr) serves as a sample for am EXE based custom sensor created using Delphi.

The sensor requires one parameter, which is the character of the drive to check (e.g. "c").

The source and the binaries can be found in the following subfolder of your IPCheck Server Monitor installation folder:

custom\sample\delphi\exe 

Instructions:

  • (if necessary: edit the dpr and recompile it using Delphi)
  • Copy the EXE into your CUSTOM directory
  • Restart the IPCheck web server process (to scan the folder for new files)
  • Create a new CUSTOM sensor
  • For the Sensor setting choose your EXE file
  • For Parameters enter one character for the drive to check, e.g. "c"

disksensorexe.dpr

program disksensorexe;
		uses SysUtils;
		var drive:string; driveid:byte; freespace:integer; m:string; code:integer;
		begin try //read the parameter from the command line drive:=ansilowercase(paramstr(1)); //convert drive letter to id driveid:=ord(drive[1])-ord('a')+1; //read the free space in kb freespace:=DiskFree(driveid) div 1024; //check the free space and set result values if freespace<1 then begin code:=3; m:='Disk full'; end else if freespace<1024 then begin code:=1; m:='Only 1MB left'; end else begin code:=0; m:='Everything OK'; end; except //on exception return a error freespace:=0; code:=2; m:='Error reading free space.'; end; //send result to standard out writeln(inttostr(freespace)+':'+m); //set exit code halt(code)
		end.