Ptokax uptime logger (request)
 

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

Ptokax uptime logger (request)

Started by qaz, 24 June, 2005, 02:58:07

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

qaz

Hello and sorry to bother again so soon. Is there possible to make script what saves uptime in log file like this

[Best Uptime]
Ptokax Uptime 17days 23hours

[Current Uptime]
Ptokax Uptime 12days 22hours

and option to see it with command !showuptime

time arrival for saving info supposed to be every 30min or 1hour

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(off topic)

I dont use, terminator or robocop because i dont need so many option, i wanna that my hub has only those things what it really need.

Currently these scripts:
--Anti rmDC++ script for PtokaX 0.3.3.0 Lua 5.0.2 by PPK
--ADDED: Anti strongDC++ by Pothead

--Advertise Crusher by blackwings
--v1.0 LUA 5

-- Simple TXT / file viewer by TTB
-- Requested by Pingelmonster
-- Made: 06-05-05 (couplee of these)

-- QDM (quick-and-dirty mass) by bastya_elvtars
-:: Northwind a.k.a qaz ::-

bastya_elvtars

#1
This is a body, I currently use timer for this, but it is not prepared for use. Please ask someone to make it for you. I go offline for 2.5 months.

-- Hubstats body by bstya_elvtars, based on DarkMind's appropriate part by Tuben.
-- also some code by RabidWombat and [NL]Pur.
-- Please make the arrivals, and the timer, I go offline for 2.5 months.

function GetUpTime()	
  local diff =  frmHub:GetUpTime()/(1440*60)
  local hours, mins= math.floor(diff) * 24 + math.floor(frac(diff) * 24), math.floor(frac(frac(diff)*24)*60)
  local hubuptime=hours*60+mins -- converting to minutes, that's to make days too
  local days = math.floor(hubuptime/1440)
  local hrs = math.floor((hubuptime-(days*1440))/60)
  local min = math.floor((hubuptime-(days*1440)-(hrs*60)))
  return frmHub:GetUpTime()/60, days, hrs, mins
end

function frac(num)
	return num - math.floor(num);
end

function parsestats()
  local hubuptime,_,_,_=GetUpTime()
  if Stats.Share < frmHub:GetCurrentShareAmount() then
    Stats.Share=frmHub:GetCurrentShareAmount()
    Stats.ShareDate = "Time: "..os.date("%A").." the "..os.date("%d").."th of "..os.date("%B")..", "..os.date("%T").." Year "..os.date("%Y").."" 
    SendToAll(Bot,"Alltime peak share total is now ( "..string.format("%0.2f",(frmHub:GetCurrentShareAmount()/1024^4)).." TB ).")
    WriteHubStats()
  end
  if Stats.Peak < frmHub:GetUsersCount() then
    Stats.Peak=frmHub:GetUsersCount() 
    Stats.PeakDate = "Time: "..os.date("%A").." the "..os.date("%d").."th of "..os.date("%B")..", "..os.date("%T").." Year "..os.date("%Y")..""
    SendToAll(Bot,"Alltime peak users is now ( "..Stats.Peak.." ).")
    WriteHubStats()
  end
  if Stats.Memory < gcinfo() then
    Stats.Memory=gcinfo()
    Stats.MemoryDate = "Time: "..os.date("%A").." the "..os.date("%d").."th of "..os.date("%B")..", "..os.date("%T").." Year "..os.date("%Y")..""	
    SendToOps(Bot,"Alltime peak memory use is now ( "..Stats.Memory.." Kb ).")
    WriteHubStats()	
  end	
  if Stats.HubUptime < hubuptime  then
    Stats.HubUptime = hubuptime
    WriteHubStats()
  end
end

function WriteHubStats()
	local f=io.open("lawmaker/inifiles/hubstats.ini","w+")
	Temp = ""
	Temp = Temp.."Stats = {\n\tPeak="..Stats.Peak..",\n\tPeakDate=\""..
			Stats.PeakDate.."\",\n\tShare="..Stats.Share..",\n\tShareDate=\""..
			Stats.ShareDate.."\",\n\tMemory="..Stats.Memory..",\n\tMemoryDate=\""..
			Stats.MemoryDate.."\",\n\tHubUptime="..Stats.HubUptime..
			"\n\t}\n -- For heaven's sake, do not change this!"
	f:write(Temp)
	f:close()
end

function showuptime(user,env)
			local _,days, hrs, mins=GetUpTime()
			if days>=1 then
				user:SendData(parseenv(user,env,Bot).."Current hub uptime is: "..days.." days, "..hrs.." hours, "..mins.." minutes.")
			else
				if hrs>=1 then
					user:SendData(parseenv(user,env,Bot).."Current hub uptime is: "..hrs.." hours, "..mins.." minutes.")
				else
				user:SendData(parseenv(user,env,Bot).."Current hub uptime is: "..mins.." minutes.")
				end
			end
end

function showhubstats(user,env)
			parsestats()
			local msg="\r\n\r\n\t\t\t\t\t\t\tHUB STATISTICS\r\n=================================================================================================================================\r\n\r\n"..
			"Alltime peak share total : "..string.format("%0.2f",(Stats.Share/1024^4)).." Tb. ("..Stats.ShareDate..")\r\n\r\n"..
			"Alltime peak user count : "..Stats.Peak.." users. ("..Stats.PeakDate..")\r\n\r\n"
			local days = math.floor(Stats.HubUptime/1440)
			local hrs = math.floor((Stats.HubUptime-(days*1440))/60)
			local min = math.floor((Stats.HubUptime-(days*1440)-(hrs*60)))
			if days>=1 then
				msg=msg.."The uptime record is : "..days.." days, "..hrs.." hours, "..min.." minutes.\r\n"
			else
				if hrs>=1 then
					msg=msg.."The uptime record is : "..hrs.." hours, "..min.." minutes.\r\n"
				else
					msg=msg.."The uptime record is : "..min.." minutes.\r\n"
				end
			end
			if user.bOperator then
				msg=msg.."\r\nAlltime peak memory use was : "..Stats.Memory.." kBytes. ("..Stats.MemoryDate..")\r\n"
			end
			msg=msg.."\r\n================================================================================================================================="
			user:SendPM(Bot,msg)
end
Everything could have been anything else and it would have just as much meaning.

qaz

Please can somebody finish this awesome script from bastya...  :D
-:: Northwind a.k.a qaz ::-

UwV

#3
how can i ignore two nice pleases in one thread ?
  :0)
here you go,..
-- Hubstats body by bstya_elvtars, based on DarkMind's appropriate part by Tuben.

-- also some code by RabidWombat and [NL]Pur.

-- Please make the arrivals, and the timer, I go offline for 2.5 months.

-- done Thursday, November 10, 2005 9:14:03 PM 
-- hope you come back soon to optimise it ..  UwV

----------------------------------------------------------------------------------
TopStatsFile = frmHub:GetPtokaXLocation().."scripts/topstats.dsn"

interval = "30"
Command = "!topstats"
Bot = "-=Holly=-" -- yeyeye
--------------------------------------------------------------------------------------

function ChatArrival(user, data)
	s,e,cmd = string.find(data, "%b<>%s+(%S+)|$")
	if (cmd==Command) then
		showhubstats(user, pm)
		return 1
	end
end	
function Main()
	SetTimer(interval * 60000)
	StartTimer()
	if loadfile(TopStatsFile) ~= nil then 
		dofile(TopStatsFile)
	else
		Stats = {
			Peak=1,
			PeakDate="scriptstart",
			Share=1,
			ShareDate="scriptstart",
			Memory=1,
			MemoryDate="scriptstart",
			HubUptime=1
		}
	end
	parsestats()
end

function OnTimer()
	parsestats()
end

function OnExit()
	parsestats()
end

function GetUpTime()
	local diff =  frmHub:GetUpTime()/(1440*60)
	local hours, mins= math.floor(diff) * 24 + math.floor(frac(diff) * 24), math.floor(frac(frac(diff)*24)*60)
	local hubuptime=hours*60+mins -- converting to minutes, that's to make days too
	local days = math.floor(hubuptime/1440)
	local hrs = math.floor((hubuptime-(days*1440))/60)
	local min = math.floor((hubuptime-(days*1440)-(hrs*60)))
	return frmHub:GetUpTime()/60, days, hrs, mins
end
	
function ShowUptime()	
	local days = math.floor(Stats.HubUptime/1440)
	local hrs = math.floor((Stats.HubUptime-(days*1440))/60)
	local mins = math.floor((Stats.HubUptime-(days*1440)-(hrs*60)))
	if days>=1 then
		return days.." days, "..hrs.." hours, and "..mins.." minutes."
	else
		if hrs>=1 then
			return hrs.." hours, and "..mins.." minutes."
		else
			return mins.." minutes."
		end
	end
end

function frac(num)
	return num - math.floor(num);
end

function WriteHubStats()
	local f=io.open(TopStatsFile,"w+")
	Temp = ""
	Temp = Temp.."Stats = {\n\tPeak="..Stats.Peak..",\n\tPeakDate=\""..
			Stats.PeakDate.."\",\n\tShare="..Stats.Share..",\n\tShareDate=\""..
			Stats.ShareDate.."\",\n\tMemory="..Stats.Memory..",\n\tMemoryDate=\""..
			Stats.MemoryDate.."\",\n\tHubUptime="..Stats.HubUptime..
			"\n\t}\n -- For heaven's sake, do not change this!"
	f:write(Temp)
	f:close()
end

function parsestats()
	local hubuptime,_,_,_=GetUpTime()
	if Stats.Share < frmHub:GetCurrentShareAmount() then
		Stats.Share=frmHub:GetCurrentShareAmount()
		Stats.ShareDate = "Time: "..os.date("%A").." the "..os.date("%d").."th of "..os.date("%B")..", "..os.date("%T").." Year "..os.date("%Y")..""     
		SendToAll(Bot,"ZakaaAaa \r\n_-*-__-*-__-*-__-*-__-*-__-*-__-*-__-*-__-*-__-*-__-*-__\r\n\t\tAlltime share record has been broken !! \r\n\t\t  New record  is : "..cShare("CurShare")..".\r\n\t\t????????????????????????????????????????????????????????")
--		SendToAll(Bot,"Alltime share record is now : "..string.format("%0.2f",(frmHub:GetCurrentShareAmount()/1024^4)).." TB ).")
		WriteHubStats()
	end
	if Stats.Peak < frmHub:GetUsersCount() then
		Stats.Peak=frmHub:GetUsersCount() 
		Stats.PeakDate = "Time: "..os.date("%A").." the "..os.date("%d").."th of "..os.date("%B")..", "..os.date("%T").." Year "..os.date("%Y")..""
		SendToAll(Bot,"Zakaa\r\n_-*-__-*-__-*-__-*-__-*-__-*-__-*-__-*-__-*-__-*-__-*-__\r\n\t\tAlltime Antennae Online record has been broken !!\r\n\t\t  New record  is : "..Stats.Peak.."  :o) .")
		WriteHubStats()
	end
	if Stats.Memory < gcinfo() then
		Stats.Memory=gcinfo()
		Stats.MemoryDate = "Time: "..os.date("%A").." the "..os.date("%d").."th of "..os.date("%B")..", "..os.date("%T").." Year "..os.date("%Y")..""	    
		SendToOps(Bot,"Ooops \r\n????????????????????????????????????????????????????\r\n\t Alltime Memory use record has been broken and is now : "..Stats.Memory.." kBytes.  :oS \r\n????????????????????????????????????????????????????")
		WriteHubStats()	
	end	
	if Stats.HubUptime < hubuptime  then
		Stats.HubUptime = hubuptime
		WriteHubStats()
	end
end

function cShare(val)                   --- get and format
	if val == "CurShare" then
		Amount = frmHub:GetCurrentShareAmount()
		Nr = tonumber(Amount)
	elseif val == "TopShare" then
		Amount = Stats.Share -- or "1042"
		Nr = tonumber(Amount)
	end
	if Nr > 1125899906842624 then
		fAmount = string.format("%.2f PB", Amount/1024/1024/1024/1024/1024) --- dream on ;0)
	elseif  Nr > 1099511627776 then
		fAmount = string.format("%.2f TB", Amount/1024/1024/1024/1024) -- i wish ..
	elseif  Nr > 1073741824 then 
		fAmount = string.format("%.2f GB", Amount/1024/1024/1024)
	 elseif Nr > 1048576 then
		fAmount = string.format("%.2f MB", Amount/1024/1024)
	elseif Nr > 1024 then
		fAmount = string.format("%.2f KB", Amount/1024)
	else
		fAmount = string.format("%.2f Bytes", Amount)
	end
	return fAmount
end

function showhubstats(user,env)  
	parsestats()
	local msg="\r\n\r\n\t\t\t\t\t\t\tHUB  TOP STATISTICS\r\n\============================================================\r\n\r\n"..
	"\tAlltime peak share total : "..cShare("TopShare").." ("..Stats.ShareDate..")\r\n\r\n"..
--	"\tAlltime peak share total : "..string.format("%0.2f",(Stats.Share/1024^4)).." Tb. ("..Stats.ShareDate..")\r\n\r\n"..
	"\tAlltime peak user count : "..Stats.Peak.." users. ("..Stats.PeakDate..")\r\n\r\n"
	local days = math.floor(Stats.HubUptime/1440)
	local hrs = math.floor((Stats.HubUptime-(days*1440))/60)
	local mins = math.floor((Stats.HubUptime-(days*1440)-(hrs*60)))
	if days>=1 then
		msg=msg.."\tThe uptime record is : "..days.." days, "..hrs.." hours, "..mins.." minutes.\r\n"
	else
		if hrs>=1 then
			msg=msg.."\tThe uptime record is : "..hrs.." hours, "..mins.." minutes.\r\n"
		else
			msg=msg.."\tThe uptime record is : "..mins.." minutes.\r\n"
		end
	end
	if user.bOperator then
		msg=msg.."\r\n\t& the Alltime peak memory use was : "..Stats.Memory.." kBytes. ("..Stats.MemoryDate..")\r\n"
	end
msg=msg.."\r\n============================================================"
	user:SendPM(Bot,msg)
end
\NL   The knowledge and skills you have achieved are meant to be forgotten so you can float comfortably in emptiness, without obstruction.
" Holly loves me,...  . "      ;o)

& don't forget, the motto is :
  -- SUPPORT YOUR LOCAL DJ'S --

UwV

25.06.2005, 18:28
.
only now i see yu posted this a while ago .. well hope you still want it .. and i guess BE is back soon .. hehe :D  :D
\NL   The knowledge and skills you have achieved are meant to be forgotten so you can float comfortably in emptiness, without obstruction.
" Holly loves me,...  . "      ;o)

& don't forget, the motto is :
  -- SUPPORT YOUR LOCAL DJ'S --

Northwind

BIG thanks to you UwV

i changed my nick while ago to my dc world nick and i've been waited that somebody will make this script ready. Again hundred thanks to you...


UwV

np you are welcome ..
\NL   The knowledge and skills you have achieved are meant to be forgotten so you can float comfortably in emptiness, without obstruction.
" Holly loves me,...  . "      ;o)

& don't forget, the motto is :
  -- SUPPORT YOUR LOCAL DJ'S --

SMF spam blocked by CleanTalk