home *** CD-ROM | disk | FTP | other *** search
- {
- This script provides extended possibilites to split hostlist on sublists
- By default it splits it by subnet mask 255.255.0.0
- This can be changed by editing GetSublistName function
- }
- program ExtendedSubnetAutosplit;
- const RethinkInterval=300;//in seconds
-
- function GetSublistName(hst:TNVHost):string;
- var ret,ip:string;
- i,j:integer;
- begin
- ret:='';
- ip:=hst.hip;
- if length(ip)<>0 then
- begin
- j:=0;
- for i:=1 to length(ip) do
- begin
- if j<2 then ret:=ret+ip[i];
- if ip[i]='.' then j:=j+1;
- end;
- ret:=ret+'x.x';
- end;
- Result:=ret;
- end;
-
- var hst:TNVHost;
- v,v1,v2:integer;
- newlist,oldlist:string;
- begin
- hst:=TNVHost.create;
- SetTimer(RethinkInterval*1000);
- repeat
- v:=WaitEvent(v1,v2);
- if(v=8)then
- begin
- hst.nextid:=0;
- repeat
- hst.GetHost(hst.nextid,0);
- if(hst.id<>0)then
- begin
- oldlist:=hst.GetMetaVar('map');
- newlist:=GetSublistName(hst);
- if (oldlist<>newlist) and (length(newlist)<>0) then
- begin
- hst.SetMetaVar('map',newlist);
- Action(NVACTION_SETSTATE,hst.id);
- end;
- end;
- until hst.nextid=0;
- end;
- until v=0;
- SetTimer(0);
- hst.Free;
- end.
-
-