CPU consumption?
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

CPU consumption?

Started by Shurlock, 24 July, 2004, 02:47:56

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Shurlock

Hi all,

I would very much like to write a script that creates (or appends to an existing) complete  logfile for each entering user.

The file will contain facts like logon, logoff, kicks & bans (with reason), etc.

Once created, the file will be accessable to OP's and higher levels.
These checks however will obviously not be as numerous as the actual creations (or appendings) themselves.
It should however give a complete view of the user in question.

Reason? I very much dislike registering people that we know nothing about!
This could give an answer to that question of a period of time.
(Meaning: you can request registration after a month or so)

Before I start working on this, there's but 1 simple question I know no answer to:
How consuming is the command: writeto(filename)   for the CPU  ???

If this would pull down hub activities too much, I'll just not start trying!  :)

Thanks for any explanations.

Regards,
Shurlock.

[PS: CPU = PIII/1000Mhz   Memory=512Mb  Users=appr. 350]
If it's raining and your roof leaks, fix the roof. DON'T try to stop the rain!!

plop

last time i checked it took 0.05 seconds 2 write a 55KB file 2 disk.
this was on a p2 266 with 128MB running freebsd with a scsi-2 hdd (20MB/s).
it's not a real mather of cpu power (this is where DMA cuts in), specialy when the file fits into the cache of the hdd.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

nErBoS

Hi,

About saving info from users try out the major scripts, like:  RoboCop, ChannelBot, NXS, Brain-Master, etc (this is the bots that i remenber with offline info.)

Best regards, nErBoS
--## nErBoS Spot ##--

D-J Valhala

#3
Try that one great script  :D
========================================
-- Simple Offline Info by NightLitch
-- Commands is sent in Main-Chat
-- Create folder UserInfo

-- BotName --
BotName = "BOT_NAME_HERE"
-- Prefix --
Prefix = "+"

--Command--
cmd1 = "off"
-- Tables --
Temp = {}
Info = {}
-- Info Path --
InfoLog = "UserInfo/"

-- New User Connected --
function NewUserConnected(curUser,data)
	LogInfo(curUser)
end
-- Data Arrival --
function DataArrival(curUser, data)
	if strsub(data, 1, 1) == "<" then
		data = strsub(data,1,strlen(data)-1)
		if (GetCom(curUser,data) == 1) then
			return 1
		else
			return 0
		end
	end
end
-- Get Command --
function GetCom(curUser,data)
	local _,_,cmd = strfind(data,"^%b<>%s+%"..Prefix.."(%S+)")
	if cmd then
		if IPCommand[cmd] and curUser.iProfile==0 then
			local Com = IPCommand[cmd](curUser,data)
			return 1
		end
	end
end
-- Commands --
IPCommand = {
[cmd1] = function(curUser,data)
			local _,_,nick = strfind( data,"%b<>%s+%S+%s+(%S+)")
			if (nick == nil or nick == "") then 
				curUser:SendData(BotName,"Syntax: "..Prefix..cmd1.." ")
				return 1
			end
			local IP, Profile, MyInfo = GetInfo(nick)
			if IP==0 and Profile==0 and MyInfo==0 then
				curUser:SendData(BotName,"User not found.")
				return 1
			end
			ClientTAG = {
			{ "","MS++V" },
			{ "","MS++V" },{ "","Phantom DC++" },}
			local _,_,Nick = strfind( MyInfo, "^%$MyINFO %$ALL (%S+)%s*")
			local _,_,Speed,Share = strfind( MyInfo, "^%$MyINFO %$ALL [^ ]+ [^$]*%$ $([^$]+)[^$]%$[^$]*%$%s*(%d+)%$" )
			local _,_,Slots = strfind( MyInfo, "S:(%d+)")
			local _,_, Ver,Mode = strfind(MyInfo,"V:(%S+),M:([S,A,P])")
			local	_,_, Hubs = strfind(MyInfo,"H:(%x+)")
			local Client = "Unknown"
			for i = 1,getn(ClientTAG) do
				if strfind(MyInfo,ClientTAG[i][1]) then
					Client = ClientTAG[i][2]
				end
			end
			local line = "\r\n"
			line = line .. "\r\n	User Info on: "..Nick
			line = line .. "\r\n --------------------------------------------------------------------"
			line = line .. "\r\n --------------------------------------------------------------------"
			line = line .. "\r\n	IP: "..IP
			line = line .. "\r\n	Client: "..Client
			line = line .. "\r\n	Version: "..Ver
			line = line .. "\r\n	Mode: "..Mode
			line = line .. "\r\n	Hubs: "..Hubs
			line = line .. "\r\n	Slots: "..Slots
			line = line .. "\r\n	Speed: "..Speed
			line = line .. "\r\n	Share: "..format("%.2f",Share/1024/1024/1024)
			line = line .. "\r\n --------------------------------------------------------------------"
			line = line .. "\r\n --------------------------------------------------------------------"
			curUser:SendData(BotName,line)
		end,

}

-- Log Users Info --
function LogInfo(curUser)
	Info[strlower(curUser.sName)] = {["IP"]=curUser.sIP,["PROFILE"]=curUser.iProfile,["MYINFO"]=curUser.sMyInfoString,}
	SaveToFile(InfoLog..strlower(curUser.sName)..".dat" , Info , "Info")
	Info = nil
	Info = {}
	collectgarbage()
	flush()
	return 1
end
-- Get Info --
function GetInfo(nick)
	LoadFromFile(InfoLog..strlower(nick)..".dat")
	local usr = Info[strlower(nick)]
	if usr then
		IP = usr["IP"]
		Profile = usr["PROFILE"]
		MyInfo = usr["MYINFO"]
		return IP,Profile, MyInfo
	else
		return 0,0,0
	end
end
-- Serialize --
function Serialize(tTable, sTableName, hFile, sTab)
	assert(tTable, "tTable equals nil");
	assert(sTableName, "sTableName equals nil");
	assert(hFile, "hFile equals nil");

	assert(type(tTable) == "table", "tTable must be a table!");
	assert(type(sTableName) == "string", "sTableName must be a string!");

	sTab = sTab or "";

	write(hFile, sTab..sTableName.." = {\n" );

	for key, value in tTable do
		local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

		if(type(value) == "table") then
			Serialize(value, sKey, hFile, sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			write(hFile, sTab.."\t"..sKey.." = "..sValue);
		end

		write(hFile, ",\n");
	end

	write(hFile, sTab.."}");
end
-- Save Table to File --
function SaveToFile(file , table , tablename)
	local hFile = openfile(file, "w");
	Serialize(table, tablename, hFile);
	closefile(hFile);
end
-- Load Table From File --
function LoadFromFile (file)
	assert(readfrom(file),file.." is not found.Generating new "..file..". All is fine. Don't panic.")
	dostring(read("*all"))
	readfrom()
end
:D  it's a good one  :P have fun mate
My PsyIsrael Network
==================
--=[PsyIsrael DC Hub]=--
--=[PsyIsrael Website]=--
==================

SMF spam blocked by CleanTalk