Information May Be Out-of-Date
This page about licensing and maintenance is shown for reference purposes only. Information on this page is not maintained and may no longer be valid.
For recent information, please visit our Frequently Asked Questions (FAQs) page.
Creating a Custom Sensor EXE for IPCheck Server Monitor using Delphi
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.