This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Uptime

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
S
Snorly
Voice
Posts: 25
Joined: Mon Apr 17, 2006 2:44 pm

Uptime

Post by Snorly »

I want to know if it is possible with this script to display uptime on local shell and in other shells. if it is please tell me how

Code: Select all

# uptime.tcl v1.08 [11 November 2000] 
# Copyright (C) 1999-2000 Teemu Hjelt <temex@iki.fi>
#
# Latest version can be found from http://www.iki.fi/temex/eggdrop/
# 
# If you have any suggestions, questions or you want to report 
# bugs, please feel free to send me email to temex@iki.fi
#
# This script shows the uptime of the bot's maschine.
#
# Current DCC Commands:
#    .utime [option]
#
# Current MSG Commands:
#    uptime/utime [option]
#
# Current Channel Commands:
#    uptime/utime [option]
#
# Tested on eggdrop1.4.4 with TCL 7.6
#
# Version history:
# v1.00 - The very first version!
# v1.01 - Added little cosmetic things.
# v1.02 - There were few 'return 0' strings too much.
# v1.03 - Fixed few bugs, removed few params from uptime command and  
#         modified .uptime to .utime because .uptime was already in use. 
# v1.04 - Renamed the procs, fixed little bug in ut_douptime proc and added msg commands.
# v1.05 - Fixed few little bugs and typos.
# v1.06 - Little bug fixed in msg command.
# v1.07 - Some cosmetic changes.
# v1.08 - Changed few minor things.

### Settings ###

## [0/1] Enable Channel Command?
set ut_enablepublic 1

## [0/1] Enable MSG Command?
set ut_enablemsg 1

## [0/1] Enable DCC Command?
set ut_enabledcc 1

## What command prefix do you want to use for channel commands?
set ut_cmdpfix "!"

## What users can use the uptime command?
set ut_flag1 "-"

## What users can start/stop the timer and show uptime on the channel/partyline?
set ut_flag2 "o"

## Send the uptime via NOTICE or PRIVMSG?
set ut_method "PRIVMSG"

## [0/1] Enable timer which shows uptime on the channel(s) or on partyline?
set ut_enabletimer 1

## What is the interval for the timer (mins)?
set ut_interval 60

## [0/1] Show uptime on partyline?
set ut_showdcc 1

## [0/1] Show uptime on channel(s)?
set ut_showchannel 1

## On what channels do you want to show the uptime?
# Note: Set this to "" to show the uptime on all channels.
set ut_chans "#si-shell"

###### You don't need to edit below this ######

### Misc Things ###

set ut_ver "1.08"

### Bindings ###

## Channel Command
if {$ut_enablepublic} {
	bind pub - ${ut_cmdpfix}uptime pub:ut_uptime
	bind pub - ${ut_cmdpfix}utime pub:ut_uptime
}

## MSG Command
if {$ut_enablemsg} {
	bind msg - uptime msg:ut_uptime
	bind msg - utime msg:ut_uptime
}

## DCC Command
if {$ut_enabledcc} {
	bind dcc - utime dcc:ut_uptime
}

### Channel Command ###

proc pub:ut_uptime {nick uhost hand chan arg} {
global ut_cmdpfix ut_flag1 ut_flag2 ut_interval ut_showdcc ut_showchannel ut_method ut_ver
set option [string tolower [lindex [split $arg] 0]]
	if {[matchattr $hand $ut_flag2]} {
		if {($option != "") && ($option != "-p") && ($option != "-start") && ($option != "-stop")} {
			putserv "PRIVMSG $nick :uptime.tcl v$ut_ver commands:"
			putserv "PRIVMSG $nick :   ${ut_cmdpfix}uptime        - Shows uptime for you." 
			putserv "PRIVMSG $nick :   ${ut_cmdpfix}uptime -p     - Shows uptime on $chan."
			putserv "PRIVMSG $nick :   ${ut_cmdpfix}uptime -start - Starts timer."
			putserv "PRIVMSG $nick :   ${ut_cmdpfix}uptime -stop  - Stops timer."
		} else {
			if {$option == ""} {
				putserv "$ut_method $nick :[ut_douptime]"
			} elseif {$option == "-p"} { 
				putserv "$ut_method $chan :[ut_douptime]" 
			} elseif {$option == "-start"} {
				ut_stoptimer
				ut_starttimer  
				putserv "NOTICE $nick :Timer started! Interval: $ut_interval mins" 
			} elseif {$option == "-stop"} { 
				ut_stoptimer 
				putserv "NOTICE $nick :Timer stopped!" 
			}
		}
	} elseif {[matchattr $hand $ut_flag1]} {
		putserv "$ut_method $nick :[ut_douptime]"
	}
return 1
}

### MSG Command ###

proc msg:ut_uptime {nick uhost hand arg} {
global ut_cmdpfix ut_flag1 ut_flag2 ut_interval ut_showdcc ut_showchannel ut_method ut_ver
set option [string tolower [lindex [split $arg] 0]]
	if {[matchattr $hand $ut_flag2]} {
		if {($option != "") && ($option != "-start") && ($option != "-stop")} {
			putserv "PRIVMSG $nick :uptime.tcl v$ut_ver commands:"
			putserv "PRIVMSG $nick :   uptime        - Shows uptime for you." 
			putserv "PRIVMSG $nick :   uptime -start - Starts timer."
			putserv "PRIVMSG $nick :   uptime -stop  - Stops timer."
		} else {
			if {$option == ""} { 
				putserv "$ut_method $nick :[ut_douptime]" 
			} elseif {$option == "-start"} {
				ut_stoptimer
				ut_starttimer  
				putserv "NOTICE $nick :Timer started! Interval: $ut_interval mins" 
			} elseif {$option == "-stop"} { 
				ut_stoptimer 
				putserv "NOTICE $nick :Timer stopped!" 
			}
		}
	} elseif {[matchattr $hand $ut_flag1]} {
		putserv "$ut_method $nick :[ut_douptime]"
	}
return 1
}

### DCC Command ###

proc dcc:ut_uptime {hand idx arg} {
global ut_cmdpfix ut_flag1 ut_flag2 ut_interval ut_showdcc ut_showchannel ut_method ut_ver
set option [string tolower [lindex [split $arg] 0]]
	putcmdlog "#$hand# utime $arg"
	if {[matchattr $hand $ut_flag2]} {
		if {($option != "") && ($option != "-p") && ($option != "-start") && ($option != "-stop")} {
			putidx $idx "uptime.tcl v$ut_ver commands:"
			putidx $idx "   .utime        - Shows uptime for you." 
			putidx $idx "   .utime -p     - Shows uptime on partyline."
			putidx $idx "   .utime -start - Starts timer."
			putidx $idx "   .utime -stop  - Stops timer."
		} else {
			if {$option == ""} { 
				putidx $idx "[ut_douptime]" 
			} elseif {$option == "-p"} { 
				putlog "[ut_douptime]" 
			} elseif {$option == "-start"} { 
				ut_stoptimer
				ut_starttimer  
				putidx $idx "Timer started! Interval: $ut_interval mins." 
			} elseif {$option == "-stop"} { 
				ut_stoptimer  
				putidx $idx "Timer stopped!" 
			}
		}
	} elseif {[matchattr $hand $ut_flag1]} {
		putidx $idx "[ut_douptime]"
	}
}

### Other Procs ###

proc ut_showuptime { } {
global botnick ut_chans ut_showchannel ut_showdcc ut_method 
	if {$ut_showchannel} {
		foreach chan [channels] {
			if {($ut_chans != "") && ([lsearch -exact [split [string tolower $ut_chans]] [string tolower $chan]] == -1)} { continue }
			if {([validchan $chan]) && ([onchan $botnick $chan])} { 
				putserv "$ut_method $chan :[ut_douptime]" 
			}
		}
	}
	if {$ut_showdcc} {
		putlog "uptime: [ut_douptime]"
	}
	ut_starttimer
}

proc ut_douptime { } {
	if {[catch {exec uptime} uptime]} { set uptime "Uptime is unavailable." }
	if {[catch {exec uname -sr} machine]} { set machine [unames] }
	if {[catch {exec hostname} hostname]} {	set hostname [info hostname] }
	return "Uptime for $hostname ($machine): $uptime"
}

proc ut_starttimer { } {
global ut_interval
	if {![string match "*ut_showuptime*" [timers]]} {
		timer $ut_interval ut_showuptime
	}
}

proc ut_stoptimer { } {
	foreach timer [timers] {
		if {[string match "*ut_showuptime*" $timer]} { 
			killtimer [lindex $timer 2]
		}
	}
}

### End ###

if {$ut_enabletimer} { ut_starttimer }

putlog "TCL loaded: uptime.tcl v$ut_ver by Sup <temex@iki.fi>" 
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

If I understand you correctly:
# This script shows the uptime of the bot's maschine.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
S
Snorly
Voice
Posts: 25
Joined: Mon Apr 17, 2006 2:44 pm

Post by Snorly »

yes :)
and i want it to show for 2 more maschines :P if it is possible
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

use rconsole

it shows the uptime of each host on your botnet (and allows you to control it remotely without having to log into each bot, too)
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
Post Reply