[Request]Network Status check
 

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

[Request]Network Status check

Started by Snooze, 25 March, 2004, 15:15:42

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Snooze

hey guys,

I once saw a small script that would check if a network hub were online, and if not it would send a PM to all Ops, Master or what ever .. The thing is that im not sure it were for ptokax ...

I've searched this forum with no luck :( So if anyone know this script, please let me know ..

Should you think that its a kewl idea and have a nice way to script this, please do so

**Snooze
-Still searching..

kepp

mmm... hmmm

Ok, It's not a good a idea to use this as it will freeze your hub for a few seconds...
But as i am new to sockets in lua i couln't resist!!

sBot = "Test"
Hub_Adress = "dware.com"
HubPort = "411"

function DataArrival(user, data)
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
	if cmd=="+disp" then
		s = connect(Hub_Adress,HubPort)
		if s == nil then
			user:SendData(sBot,"Hub is Offline")
		else
			user:SendData(sBot,"hub is Online")
			s:close() return 1
		end
	end
end

Don't say i didn't warn you... It's on your own responsibility!
Guarding    

Snooze

Thanks kepp :))

Though as reading your warning i have to ask ... Is there a better way to do this ?


**Snooze

kepp

i don't think so, unless it's in another langugae, such as VB, C++ or something.
hmm, Well, maybe...

If you use a client which support LUA scripts such as BCDC, then you can ask in the Client section of this forum, im sure they can help you..
Guarding    

??????Hawk??????

#4
hmmm  very interesting..

this script done client side would be great..
activated by pm command

if you really want to freeze your hub up try this....


sBot = "Test"
Hub_Adress = { 
"hub1.no-ip.org", 
"hub2.dynu.com", 
"hub3.no-ip.org", 
"hub4.servemp3.com", 
"hub5.no-ip.org", 
"hub6.servemp3.com", 
"hub7.no-ip.com", 

 }
HubPort = "411"

function DataArrival(user, data)
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
	if cmd=="+netstat" then
		for h=1,getn(Hub_Adress) do
			a = connect(Hub_Adress[h],HubPort)
			if a == nil then
				user:SendData(sBot,Hub_Adress[h].."   Hub is Offline")
			else
				user:SendData(sBot,Hub_Adress[h].."   hub is Online  ")
				a:close() 
			end
		end
	end
end

Snooze

I jsut tested it with 7 of our network hubs

12 secs of silence :P

as this will only be running in an Ops Hub a few secs of "stall" wont do no harm ... but 10+ secs wont work.
Any chance of setting this on a timer so it will do the seach with 5 min interval .. as in check hub1 then wait 5 min, then seach hub2 etc etc ?


**Snooze

kepp

sBot = "Test"

Hub_Adress = { 
"hub1.no-ip.org", 
"hub2.dynu.com", 
"hub3.no-ip.org", 
"hub4.servemp3.com", 
"hub5.no-ip.org", 
"hub6.servemp3.com", 
"hub7.no-ip.com", 

 }
HubPort = "411"

sSearch = 0

function Main()
	SetTimer(50000)
	StartTimer()
end

function OnTimer()
	if sSearch == 0 then
		Connect(rawget(1),HubPort)
		sSearch = sSearch + 1

	elseif sSearch == 1 then
		Connect(rawget(2),HubPort)
		sSearch = sSearch + 1

	elseif sSearch == 2 then
		Connect(rawget(3),HubPort)
		sSearch = sSearch + 1

	elseif sSearch == 3 then
		Connect(rawget(4),HubPort)
		sSearch = sSearch + 1

	elseif sSearch == 4 then
		Connect(rawget(5),HubPort)
		sSearch = sSearch + 1

	elseif sSearch == 5 then
		Connect(rawget(6),HubPort)
		sSearch = sSearch + 1

	elseif sSearch == 6 then
		Connect(rawget(7),HubPort)
		sSearch = sSearch + 1
	end
end


function Connect(IP,PORT)

a = connect(IP,PORT)
	if a == nil then
		SendToOps(sBot,IP.." Is Currently Offline.")
	else
		SendToOps(sBot,IP.." Is Currently Online.")
		a:close()
	end
end
Guarding    

Snooze

yeps ..something like that :)) - though "Syntax Error: bad argument #1 to `rawget' (table expected, got number)" :(

Help me out, please :)


*Snooze

kepp

sBot = "Test"

Hub_Adress = { 
"hub1.no-ip.org", 
"hub2.dynu.com", 
"hub3.no-ip.org", 
"hub4.servemp3.com", 
"hub5.no-ip.org", 
"hub6.servemp3.com", 
"hub7.no-ip.com", 

 }
HubPort = "411"

sSearch = 0

function Main()
	SetTimer(50000)
	StartTimer()
end

function OnTimer()
	if sSearch == 0 then
		Connect(Hub_Adress[1],HubPort)
		sSearch = sSearch + 1

	elseif sSearch == 1 then
		Connect(Hub_Adress[2],HubPort)
		sSearch = sSearch + 1

	elseif sSearch == 2 then
		Connect(Hub_Adress[3],HubPort)
		sSearch = sSearch + 1

	elseif sSearch == 3 then
		Connect(Hub_Adress[4],HubPort)
		sSearch = sSearch + 1

	elseif sSearch == 4 then
		Connect(Hub_Adress[5],HubPort)
		sSearch = sSearch + 1

	elseif sSearch == 5 then
		Connect(Hub_Adress[6],HubPort)
		sSearch = sSearch + 1

	elseif sSearch == 6 then
		Connect(Hub_Adress[7],HubPort)
		sSearch = sSearch + 1
	end
end


function Connect(IP,PORT)

a = connect(IP,PORT)
	if a == nil then
		SendToOps(sBot,IP.." Is Currently Offline.")
	else
		SendToOps(sBot,IP.." Is Currently Online.")
		a:close()
	end
end

And this?
Guarding    

Snooze

Works perfectly - thanks m8 :)))



**Snooze
- still learning..

??????Hawk??????

try this  

+neton  -- turns it on
+netoff  -- turns it off




sBot = "Network-online-check-  "
Hub_Adress = { 
"hub1.no-ip.org", 
"hub2.dynu.com", 
"hub3.no-ip.org", 
"hub4.servemp3.com", 
"hub5.no-ip.org", 
"hub6.servemp3.com", 
"hub7.no-ip.com",

 }
HubPort = "411"
curenthub = 1
mins = 1
function Main()
	hubcount = getn(Hub_Adress)
	SetTimer(1000 * 60 * mins)

end

function DataArrival(user, data)
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
	if cmd=="+neton" then
		SendToOps(sBot," netstats enabled ")
		StartTimer()
	elseif cmd=="+netoff" then
		SendToOps(sBot," netstats disabled ")
		  StopTimer()
	end
end

function OnTimer()
	displayhub(curenthub)
		if curenthub == hubcount then
			curenthub = 0
		end		
curenthub = curenthub + 1
end


function displayhub(curenthub)
	a = connect(Hub_Adress[curenthub],HubPort)
	if a == nil then
		SendToOps(sBot,Hub_Adress[curenthub].."   Hub is Offline")
	else
		SendToOps(sBot,Hub_Adress[curenthub].."   hub is Online  ")
		a:close() 
	end
end

kepp

Yep indeed, i thought to fast :) lol
Guarding    

Snooze

All it needs to be perfect is a port setting as not all hubs is running on port 411 ;)

Thanks goes to both of you for your help :))


**Snooze

Typhoon

heres one by [ES]latinmusic

-------------------------------------------------------------------------------------------------------
-- ![NetStatus]!? script - v1.1 - Created by [ES]latinmusic __/04/2003
-- Powered by ARACNIDOS.NET?  -  No Rights Reserved
-- Thanks go out to all people from LUA Board, old and new one
-- Some of the original code was developed by some one i don't remember
-- If you were envolving in this code, tell me and you will be added into credits
-- Multilanguage Version (Spanish & English)
--  ***************************************************************************
*************************
-- This Script: Show if the hubs listed inside the array are online or offline in real time
-- Could be usefull if you are running a net of hubs or you wanna see if your friends hubs are online
-- Command for this script '-netstat'
-- To set up this script working under your needs, read the help inside the code
-- Enjoy...
-------------------------------------------------------------------------------------------------------
------- Main function -------
function Main()
botName="![NetStatus]!?" --//Help: Name of the bot.
--frmHub:RegBot(botName) --//Help: This line is not requiered, is only a comment for Ptacek.
CoolLine=strrep("-",250) --//Help: This line could be nosense for the upcoming release in test of PtokaX since code about PMs have been change, in this case remove it from the script.
waitmessage=strrep(" ...WAIT...ESPERE... ",6) --//Help: Same of above. If you delete those lines, also you have to delete the variables related from the script in messages part
--------- HubsArrayHelp --------
-------Formating the array------
-- HubAddress = {
-- ["Hub{0} Name Of The Hub] =			Change 'Name Of The Hub' to the real hub name
-- address= "Address Of The Hub",		Change 'Address Of The Hub' to the real hub address
-- port = Port Of The Current Hub,		Change 'Port Of The Current Hub' to the real hub port
-- },						For examples take a look into the following lines
--------- HubsArrayHelp --------
HubAddress = {
["Hub{0} ?ARACNIDOS?-=MAIN SERVER=-?"] = { --//Help: Put here the real name of the HUB
address= "aracnidos.no-ip.com", --//Help: Put here the real address  of the HUB
port = 411, --//Help: Put here the real port of the HUB
},
["Hub{1} ?ARACNIDOS#1?-=SUPPORT SERVER=-?"] = { --//Help: Put here the real name of the HUB
address= "aracnidos1.no-ip.com", --//Help: Put here the real address of the HUB
port = 411, --//Help: Put here the real port of the HUB
},
["Hub{2} ?ARACNIDOS#2?-=SUPPORT SERVER=-?"] = { --//Help: Put here the real name of the HUB
address= "aracnidos2.no-ip.com", --//Help: Put here the real address of the HUB
port = 411, --//Help: Put here the real port of the HUB
},
["Hub{3} ?ARACNIDOS#3?-=SUPPORT SERVER=-?"] = { --//Help: Put here the real name of the HUB
address= "aracnidos3.no-ip.com", --//Help: Put here the real address of the HUB
port = 411, --//Help: Put here the real port of the HUB
},
["Hub{4} ?ARACNIDOS#4?-=SUPPORT SERVER=-?"] = { --//Help: Put here the real name of the HUB
address= "aracnidos4.no-ip.com", --//Help: Put here the real address of the HUB
port = 411, --//Help: Put here the real port of the HUB
}
} 
end
function DataArrival(user, data) 
	if( strsub(data, 1, 1) == "<" ) then
		-- get the msg only using regular expression
		s,e,message = strfind(data, "%b<> (.*)")
		--remove pipe
		message = strsub(message,1,strlen(message)-1) 
		s,e,cmd=strfind(message,"(%S+)")
		if (cmd=="-netstat")then 
			for i,v in HubAddress do
				user:SendPM(botName,"\r\nRequesting Net Information for "..i.."\r\nPlease "..waitmessage.."\r\n")
				local socket, err = connect(v["address"], v["port"])
				if not err then socket:close()
					status = "<----------------------------> {{**ONLINE**}}"
				else
					status = "<----------------------------> {{**OFFLINE**}}   :-("
				end
				user:SendPM(botName,"\r\n"..CoolLine.."\r\n"..i.."\r\n<> Address: "..v["address"].."\r\n<> Port:"..v["port"].."\r\n<> Status: "..status.."\r\n"..CoolLine.."\r\n")
			end
			user:SendPM(botName,"The request for Online/Offline Hubs have been completed [El chequeo de HUBs Conectados/Desconectados ha concluido]\r\n")
		end
	end
end
--function OnExit() --//Help: This line is not requiered, is only a comment for Ptacek.
--	frmHub:UnregBot(botName) --//Help: This line is not requiered, is only a comment for Ptacek.
--end --//Help: This line is not requiered, is only a comment for Ptacek.



kepp

Well well well, ^^ there you have one :)
Guarding    

??????Hawk??????

sBot = "Network-online-check-  "
Hub_Adress = { 
"hub1.no-ip.org", 
"411", 
"hub2.no-ip.org", 
"456", 
"hub3.no-ip.org", 
"485", 
"hub4.no-ip.com",
"645",
"hub5.no-ip.com",
"645",
"hub6.no-ip.com",
"645",
"hub7.no-ip.com",
"412",

 }
HubPort = "411"
curenthub = 1
curentport = 2
mins = 1
function Main()
	hubcount = getn(Hub_Adress)
	SetTimer(1000 * 60 * mins)

end

function DataArrival(user, data)
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
	if cmd=="+neton" then
		SendToOps(sBot," netstats enabled ")
		StartTimer()
	elseif cmd=="+netoff" then
		SendToOps(sBot," netstats disabled ")
		  StopTimer()
	end
end

function OnTimer()
	if curentport == hubcount + 2 then
		curenthub = 1
		curentport = 2
	end
	displayhub(curenthub,curentport)
	curenthub = curenthub + 2
	curentport = curenthub + 1
end

function displayhub(curenthub,curentport)
	a = connect(Hub_Adress[curenthub],Hub_Adress[curentport])
	if a == nil then
		SendToOps(sBot,Hub_Adress[curenthub]..":"..Hub_Adress[curentport].."   Hub is Offline")
	else
		SendToOps(sBot,Hub_Adress[curenthub]..":"..Hub_Adress[curentport].."   hub is Online  ")
		a:close() 
	end
end

Snooze

#16
This script is still working perfectly, but i had a good idea ...

This script is now running in 6 hubs checking on all hubs and making sure that the redirect chain isnt broken by sending a msg to ops if an hub is down.
My idea is that the script should auto change the redirect if the next hub in line is down.

The redirect chain goes as the same way as the address' is listed..

PRedir = frmHub:GetRedirectAddress()

So if "Hub_Adress[curenthub]..":"..Hub_Adress[curentport].." is down it should auto update like:

frmHub:SetRedirectAddress(NextRedirInline)

and update this to temp.PRedir.

Then on next check if PRedir is online it should set that as redirect and delete the temp.PRedir. If PRedir is not online it should keep the temp.PRedir etc  etc ..
------------------------

Please let me know if its not explained well enough...

I know it can be done, just dont have the skill for it yet .. so please help me out :))


**Snooze

plop

kepp this sounds like a nice thing for your client, doing it on bcdc should be avoided @ any cost.
bcdc with luasockets has the bad side effect that it picks a random port without checking if it's free.
sooner or later it's gone pick a port which is in use, and the trouble starts.

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 <----<<

G?M

#18
This is just another way checking server status, is there a way someone could make a table with all the network hubs in it?
can the info once checked be parsed?
also is there a way to clear the file portstat.txt after the check is over?
any insight would be greatly appreaciated!

Enjoy! :)

-- Network Status Checker By G?M?
-- Requested by Snooze
-- Requirements: PortQuery you can get it at
-- [URL]http://www.microsoft.com/downloads/details.aspx?familyid=89811747-C74B-4638-A2D5-AC828BDC6983&displaylang=en[/URL]
-- once downloaded unzip it to the %Windir%/system32 directory
-- also the folder C:\NetCheck needs to be created
-- Thanks to Gamefreak for showing me PortQuery
-- PLEASE NOTE  PORT QUERY WILL ONLY WORK ON NT,2K AND XP!

Bot = "Netchecker"
dir = "C:\\NetCheck\\"

function Main()
frmHub:RegBot(Bot)
end

function DataArrival(user,data)
    if strsub(data, 1, 1) == "<" then
		data=strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data,"%b<>%s+(%S+)")

		if cmd == "!netcheck" then
        check()
        end
    end
end


function check()
-- portqry usage
-- -n servertocheck.com  < remote server to check
-- -e 411                < remote port to check


execute("portqry -n server.no-ip.com -e 411 > "..dir.."portstat.txt")
readfrom(dir.."portstat.txt");

local line = read("*a");
    if(line) then
    line = gsub(line, "\n", "\r\n");
    SendToAll(Bot, "\r\n"..line);
    end
end
The more I drink, the more I realize I like to Drink.
                                                                          -G?M

[G-T-E]Gate?

Just did my daily read thru on whats been happening and found this thread, Interesting I must say .
 Now to the script and Server Querying,
Installed the script and PortQryV2. Ran the command and got the followiong responce,
wonder if its not meant to the responce to Netchecker Bot,
Would appreciate it , plus a question on "unknown service" last line. Why "unknown service" ?
Thanks  and what a nice way to start the morning :D



Querying target system called:

 sod.homedns.org.

Attempting to resolve name to IP address...


Name resolved to 81.229.30.244

querying...

TCP port 411 (unknown service): LISTENING

G?M

#20
i'm not sure what services it can identify, more than likely its just the basic
telnet 23
ftp 21
http 80
etc
that is why the unknown service comes up in response to checking port 411.
The more I drink, the more I realize I like to Drink.
                                                                          -G?M

kepp

yea, good idea plop, I think i have 9 - 12 diferent Client projects im working on!! But yea, I like the idea..
and thank you, i got another idea :D
Guarding    

SMF spam blocked by CleanTalk