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.

Eggdrop stops working and dies

General support and discussion of Eggdrop bots.
Post Reply
C
CP1832
Halfop
Posts: 68
Joined: Thu Oct 09, 2014 4:03 pm

Eggdrop stops working and dies

Post by CP1832 »

For a few weeks my bot has been getting stoned every once in a while, like each two days, so I'm using this script to kill the pid when it gets stoned. The script works flawlessly, but I want to know which script could be causing my eggdrop to get stoned. How can I check that? The log file shows absolutely nothing useful. What else could I do? And how (I'm not very Linux savvy)?

Thanks in advance.
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Try without any loaded mods or scripts and then load one by one?
Once the game is over, the king and the pawn go back in the same box.
C
CP1832
Halfop
Posts: 68
Joined: Thu Oct 09, 2014 4:03 pm

Post by CP1832 »

That crossed my mind, but I have some 30 scripts loaded and they worked fine until recently (haven't modified them in a long while), so I have no clues where to start. Is there any debugging tool available for this kind of issues?
w
willyw
Revered One
Posts: 1196
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

CP1832 wrote: ... but I have some 30 scripts loaded and they worked fine until recently
But in your first post, you indicated that you felt that the problem IS a script.
(haven't modified them in a long while), so I have no clues where to start. Is there any debugging tool available for this kind of issues?
How about if it isn't a script at all? That much, you could find out within a couple days. Simply unload ALL scripts. Be sure they are unloaded. All of them. Then let bot run for a couple days. If it happens again, you know it is not a script.

I'm saying this, because you seem to be saying that you have changed nothing, yet this behavior started. So something changed. If not you and your bot, then what's left? The shell it is on - could the admin there have changed something? And... the irc server that your bot connects to.... could the admin there have changed something?

I'm just kicking around ideas....
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
C
CP1832
Halfop
Posts: 68
Joined: Thu Oct 09, 2014 4:03 pm

Post by CP1832 »

I thought the problem had to be a script, it was my first guess. As you mentioned, many other things can be causing this. I'll unload all the scripts and give it a shot.
w
willyw
Revered One
Posts: 1196
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

Good.
I assume that in a couple days you'll be letting us know what you discovered. It will be info that is one more piece to your puzzle.

If it stops, and thus you feel more assured that it is IS a script, then I'm with caesar - load them back, one at a time, until you find the one that is causing it. Sorry, but without something logged or appearing in the partyline, I don't know a better method. If anybody else does, perhaps they will speak up now.

Note - neither your nor I mentioned loaded modules. Caesar did though.

If it continues, with no scripts loaded - ... I'm not sure how to proceed then.
Maybe somebody else will be along by then, to help you deal with that new info.

Let us know how it goes.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

30 scripts? Oh my!

Sadly there's no easy way to figure out the culprit, so you are stuck with unloading all the scripts and modules (if added any special ones) and see if there's any improvements. Do you have a high CPU / RAM usage?
Once the game is over, the king and the pawn go back in the same box.
C
CP1832
Halfop
Posts: 68
Joined: Thu Oct 09, 2014 4:03 pm

Post by CP1832 »

Hi guys:

Regarding this, I think that I found the script that's causing issues. Here it is:

Code: Select all

##############################################################################################
##  ##     rssreader.tcl for eggdrop by Ford_Lawnmower irc.geekshed.net #Script-Help    ##  ##
##############################################################################################
## .rss in the party line for commands and syntax. Example Feed Add Below:                  ##
##.rss add #Hawkee hawkee Hawkee http://www.hawkee.com/comment.rss.php?tool_type=snippet_id ##
##############################################################################################
##      ____                __                 ###########################################  ##
##     / __/___ _ ___ _ ___/ /____ ___   ___   ###########################################  ##
##    / _/ / _ `// _ `// _  // __// _ \ / _ \  ###########################################  ##
##   /___/ \_, / \_, / \_,_//_/   \___// .__/  ###########################################  ##
##        /___/ /___/                 /_/      ###########################################  ##
##                                             ###########################################  ##
##############################################################################################
##  ##                             Start Setup.                                         ##  ##
##############################################################################################
namespace eval rssreader {
## Edit textf to change the color/state of the text shown                               ##  ##
  variable textf "\017\00304"
## Edit linkf to change the color/state of the links                                    ##  ##
  variable linkf "\017\037"
## Change usetiny to shorten links with tinyurl. 1 = on , 0 = off                       ##  ## 
  variable usetiny 0
## Change useisgd to shorten links with is.gd. 1 = on , 0 = off                         ##  ## 
  variable useisgd 0
## Edit maxresults to the amount of results you want per query. This will not cause     ##  ##
## You to lose results. It will only spread them out over several querys.               ##  ##
  variable maxresults 1
## Edit checkdelay to change the frequency feed pages are checked. Delay is in minutes. ##  ##
  variable checkdelay 30
## Edit startupdelay to add delay to startup/restart. Delay is in minutes.              ##  ##
  variable startupdelay 0
##############################################################################################
##  ##                           End Setup.                                              ## ##
############################################################################################## 
  
foreach bind [binds rssreader::settings] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
foreach bind [binds rssreader::loadhash] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
foreach bind [binds rssreader::load_hash] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}

  bind pub - !rss rssreader::settings
  bind evnt -|- init-server rssreader::loadhash
  bind evnt -|- prerehash rssreader::loadhash
  bind time - "00 * * * *" rssreader::load_hash

  proc settings {nick uhost hand chan text} {
     set choice [lindex $text 0]; set name [lindex $text 1]; set logo [lindex $text 2]; set link [lindex $text 3]
     if {[string equal -nocase "add" $choice] && $link != ""} {
     set deleteinfo [string map {\[ ? \] ?} [hget "rssreader" $name]]
     if {[set idx [lsearch -glob [timers] "*$deleteinfo*"]] != -1 && $deleteinfo != "0"} {
       killtimer [lindex [lindex [timers] $idx] 2]
     }
     hadd "rssreader" "$name" "rssreader::type2 {$chan $logo $link}"
     savehash
     puthelp "PRIVMSG $chan :Feed $name added to $chan as $logo $link"
     rssreader::type2 "$chan $logo $link"
   } elseif {[string equal -nocase "list" $choice]} {
     puthelp "PRIVMSG $chan :\[Feeds list\]"
     set count [hfind "rssreader" "*" 0]; set counter 1
     while {$count >= $counter} {
       puthelp "PRIVMSG $chan :[hfind "rssreader" "*" $counter]"
      incr counter
     }
     puthelp "PRIVMSG $chan :\[End of feeds list\]"
   } elseif {[string equal -nocase "info" $choice] && $name != ""} {
     set info [string map {\[ ? \] ?} [hget "rssreader" $name]]
    if {[set idx [lsearch -glob [timers] "*$info*"]] != -1 && $info != "0"} {
      puthelp "PRIVMSG $chan :[hget "rssreader" $name]"
     } else {
       puthelp "PRIVMSG $chan :Feed $name not found. Too see the feeds list, check !rss list"
     }
   } elseif {[string equal -nocase "delete" $choice] && $name != ""} {
     set deleteinfo [string map {\[ ? \] ?} [hget "rssreader" $name]]
     hdel "rssreader" $name
     savehash
     if {[set idx [lsearch -glob [timers] "*$deleteinfo*"]] != -1 && $deleteinfo != "0"} {
       killtimer [lindex [lindex [timers] $idx] 2]
      puthelp "PRIVMSG $chan :Feed $name deleted"
     } else {
       puthelp "PRIVMSG $chan :Feed $name not found. Too see the feeds list, check !rss list"
     }
   } elseif {[string equal -nocase "timers" $choice]} {
     putlog [timers]
   } elseif {[string equal -nocase "rehash" $choice]} {
     puthelp "PRIVMSG $chan :Rehashing feeds..."
     hfree rsstempold
     hfree rsstempnew
     puthelp "PRIVMSG $chan :Done, feeds rehashed"
   } else {
     puthelp "PRIVMSG $chan :\[RSS sintaxis\]"
     puthelp "PRIVMSG $chan :Usage: !rss add <name> <logo> <link> - Add feed"
     puthelp "PRIVMSG $chan :Usage: !rss delete <name> - Delete feed"
     puthelp "PRIVMSG $chan :Usage: !rss info <name> - Feed information"
     puthelp "PRIVMSG $chan :Usage: !rss list - Feeds list"
     puthelp "PRIVMSG $chan :Usage: !rss rehash - Rehash feeds"
     puthelp "PRIVMSG $chan :\[RSS sintaxis\]"
    }
  return 1
  }

  proc main {text} {
    set chan [lindex $text 0]; set logo [lindex $text 1]; set linker [lindex $text 2]
    set title ""; set link ""; set description ""; set maxcount 1; set json ""
    if {[set idx [lsearch -glob [timers] "*rssreader::main {$chan [string map {\[ ? \] ?} $logo] ${linker}}*"]] != -1} {
      killtimer [lindex [lindex [timers] $idx] 2]
    }
    timer $rssreader::checkdelay "rssreader::main {$chan $logo $linker}"
    set rssreaderurl "/ajax/services/feed/load?v=1.0&num=$rssreader::maxresults&q=${linker}"
    set rssreadersite "ajax.googleapis.com"; set rssout ""
    set url ""
    append url "http://" $rssreadersite $rssreaderurl
    if {[catch {http::geturl $url -timeout 5000} sockerr]} {
			putlog "RSS error: $sockerr"
			return 1
		} elseif {[http::ncode $sockerr] != 200 || ![string equal [http::status $sockerr] "ok"]} {
			putlog "RSS error: [http::ncode $sockerr] -> [http::status $sockerr]"
			http::cleanup $sockerr
			return 1
		} else {
      if {![catch {set rssreadersock [socket -async $rssreadersite 80]; fconfigure $RacSock -blocking off;}]} { 
      puts $rssreadersock "GET $rssreaderurl HTTP/1.0"
      puts $rssreadersock "Host: $rssreadersite"
      puts $rssreadersock "User-Agent: Opera 9.6"
      puts $rssreadersock "Connection: close"
      puts $rssreadersock ""
      flush $rssreadersock
      while {![eof $rssreadersock]} {
        set rssreadervar " [string map {<![CDATA[ "" ]]> "" \$ \002\$\002 \[ \( \] \)} [gets $rssreadersock]] "
      if {[regexp {\"responseStatus\":\s?400} $rssreadervar]} {
        if {[set idx [lsearch -glob [timers] "*rssreader::main {$chan $logo ${linker}}*"]] != -1} {
            killtimer [lindex [lindex [timers] $idx] 2]
          }
        type2 "$chan $logo $linker"
        close $rssreadersock
        return
      } else {
        regexp {\:\[(\{.*)$} $rssreadervar match rssout
        set rssout [regexp -all -inline {\{(.*?)\}} $rssout]
        if {$rssout != ""} {
          set count 0
          foreach {match matched} $rssout {
           incr count
            set matched [regexp -all -inline {(".*?":".*?"\,)} $match]
              foreach {innermatch innermatched} $matched {
             regexp  {\"(.*?)\":\".*?\"\,} $innermatch match varname
                regexp  {\".*?\":\"(.*?)\"\,} $innermatch match value
            set value [string map {\$ \002\$\002 \] \002\]\002 \[ \002\[\002} $value]
             set $varname $value
           }
           if {[hfindexact "rsstempold" "${link}" 1] != $link} {
             if {$title == ""} { set title $description }
            set linked $link
            if {$rssreader::usetiny} { set linked [string trimright [tiny $link]] }
            if {$rssreader::useisgd} { set linked [string trimright [isgd $link]] }
            if {$maxcount <= $rssreader::maxresults} {
               puthelp "PRIVMSG $chan :${logo} ${rssreader::textf}[dehex $title] ${rssreader::linkf}[dehex $linked]"
               incr maxcount
              hadd "rsstempnew" $link 1
            }
           }
            }
          hfree rsstempold
          hcopy rsstempnew rsstempold
         rssreader::savetemphash
          }
      }
      }
     close $rssreadersock
    }
  }
  }

  proc type2 {text} {
    set chan [lindex $text 0]; set logo [lindex $text 1]; set linker [lindex $text 2]
    set title ""; set link ""; set description ""
    if {[set idx [lsearch -glob [timers] "*rssreader::type2 {$chan [string map {\[ ? \] ?} $logo] ${linker}}*"]] != -1} {
      killtimer [lindex [lindex [timers] $idx] 2]
    }
    timer $rssreader::checkdelay "rssreader::type2 {$chan $logo $linker}"
   regexp -- {https?\:\/\/(.*?)(\/.*)$} $linker wholematch rsstype2site rsstype2url
   set itemfound 0 ; set maxcount 1
   set readerurl ""
    append readerurl "http://" $rsstype2site $rsstype2url
    if {[catch {http::geturl $readerurl -timeout 5000} sockerr]} {
			putlog "RSS error: $sockerr"
			return 1
		} elseif {[http::ncode $sockerr] != 200 || ![string equal [http::status $sockerr] "ok"]} {
			putlog "RSS error: [http::ncode $sockerr] -> [http::status $sockerr]"
			http::cleanup $sockerr
			return 1
		} else {
      if {![catch {set rssreadersock [socket -async $rssreadersite 80]; fconfigure $RacSock -blocking off;}]} { 
      puts $rsstype2sock "GET $rsstype2url HTTP/1.0"
      puts $rsstype2sock "Host: $rsstype2site"
      puts $rsstype2sock "User-Agent: Opera 9.6"
     puts $rsstype2sock "Connection: close"
      puts $rsstype2sock ""
      flush $rsstype2sock
      while {![eof $rsstype2sock]} {
        set rsstype2var " [string map {<![CDATA[ "" ]]> "" \$ \002\$\002 \[ \( \] \)} [gets $rsstype2sock]] "   
        if {[string match {*<item>*} $rsstype2var]} { set itemfound 1 }
      if {[regexp {<title>(.*?)(?:<\/title>|$)} $rsstype2var match title]} { }
      if {[regexp {<link>(.*?)(?:<\/link>|$)} $rsstype2var match link]} {
        if {[hfindexact "rsstempold" "${link}" 1] != $link} {
         if {$itemfound} {
           if {$maxcount <= $rssreader::maxresults} {
             set linked $link
            if {$rssreader::usetiny} { set linked [string trimright [tiny $link]] }
            if {$rssreader::useisgd} { set linked [string trimright [isgd $link]] }
             puthelp "PRIVMSG $chan :${logo} ${rssreader::textf}[dehex $title] ${rssreader::linkf}[dehex $linked]"
            incr maxcount
            hadd "rsstempnew" $link 1
           }
         }
        }
      }
      }
     set itemfound 0
      hfree rsstempold
     hcopy rsstempnew rsstempold
     rssreader::savetemphash
     close $rsstype2sock
    }
  }
  }

  proc tiny {link} {
    set tinyurl http://tinyurl.com/api-create.php?url=[urlencode ${link}]
    if {[catch {http::geturl $tinyurl -timeout 5000} sockerr]} {
			putlog "tinyurl error: $sockerr"
			return 1
		} elseif {[http::ncode $sockerr] != 200 || ![string equal [http::status $sockerr] "ok"]} {
			putlog "tinyurl error: [http::ncode $sockerr] -> [http::status $sockerr]"
			http::cleanup $sockerr
			return 1
		} else {
			set tinyvar [http::data $sockerr]
			http::cleanup $sockerr
        if {[regexp {(http:\/\/.*)} $tinyvar match tinyresult]} {
          return [string map {http:// https://} $tinyresult]
        }
      }
      return $link
    }

  proc isgd {link} {
    set isgdurl http://is.gd/create.php?format=simple&url=[urlencode ${link}]
    if {[catch {http::geturl $isgdurl -timeout 5000} sockerr]} {
			putlog "isgd error: $sockerr"
			return 1
		} elseif {[http::ncode $sockerr] != 200 || ![string equal [http::status $sockerr] "ok"]} {
			putlog "isgd error: [http::ncode $sockerr] -> [http::status $sockerr]"
			http::cleanup $sockerr
			return 1
		} else {
			set isgdvar [http::data $sockerr]
			http::cleanup $sockerr
        if {[regexp {(http:\/\/.*)} $isgdvar match isgdresult]} {
          return $isgdresult
        }
      }
      return $link
    }
  
  proc hex {decimal} { return [format %x $decimal] }
  proc decimal {hex} { return [expr 0x$hex] }
  proc dehex {string} {
    regsub -all {[\[]} $string "\(" string
    regsub -all {[\]]} $string "\)" string
    regsub -all {^\{|\}$} $string "" string
    set string [subst [regsub -nocase -all {\\u([a-f0-9]{4})} $string {[format %c [decimal \1]]}]]
    set string [subst [regsub -nocase -all {\%([a-f0-9]{2})} $string {[format %c [decimal \1]]}]]
    set string [subst [regsub -nocase -all {\&#([0-9]{2});} $string {[format %c \1]}]]
    set string [subst [regsub -nocase -all {\&#x([0-9]{2});} $string {[format %c [decimal \1]]}]]
    set string [string map {" \" · · & & <b> \002 </b> \002 – – » \
    » « « Ü Ü ü ü Á Á á á É É é é Í Í í \
    í Ó Ó ó ó Ñ Ñ ñ ñ Ú Ú ú ú æ æ   " " &apos; \' \
   \( \002\(\002 \) \002\)\002 \{ \002\{\002 \} \002\}\002} $string]
    return $string
  }
  proc urlencode {string} {
    regsub -all {^\{|\}$} $string "" string
    return [subst [regsub -nocase -all {([^a-z0-9\+])} $string {%[format %x [scan "\\&" %c]]}]]
  }
  proc hadd {hashname hashitem hashdata } {
    global $hashname
    set ${hashname}($hashitem) $hashdata
  }
  proc hget {hashname hashitem} {
    upvar #0 $hashname hgethashname
   if {[info exists hgethashname($hashitem)]} {
     return $hgethashname($hashitem)
   } else {
     return 0
   }
  }
  proc hfind {hashname search value} {
    upvar #0 $hashname hfindhashname
   if {[array exists hfindhashname]} {
     if {$value == 0} {
       return [llength [array names hfindhashname $search]]
      } else {
        set value [expr $value - 1]
       return [lindex [array names hfindhashname $search] $value]
     }
   }
  }
  proc hfindexact {hashname search value} {
    upvar #0 $hashname hfindhashname
   if {[array exists hfindhashname]} {
     if {$value == 0} {
       return [llength [array names hfindhashname -exact $search]]
      } else {
        set value [expr $value - 1]
       return [lindex [array names hfindhashname -exact $search] $value]
     }
   }
  }
  proc hsave {hashname filename} {
    upvar #0 $hashname hsavehashname
   if {[array exists hsavehashname]} {
     fconfigure [set hsavefile [open $filename w]] -encoding binary
     foreach {key value} [array get hsavehashname] {
       puts $hsavefile "${key}=${value}"
     }
     close $hsavefile
   }
  }
  proc hload {hashname filename} {
    upvar #0 $hashname hloadhashname
   hfree $hashname
   fconfigure [set hloadfile [open $filename]] -encoding binary
   set linenum 0
   while {[gets $hloadfile line] >= 0} {
     if {[regexp -- {([^\s]+)=(.*)$} $line wholematch item data]} {
       set hloadhashname($item) $data
     }
    }
   close $hloadfile
  }
  proc hfree {hashname} {
    upvar #0 $hashname hfreehashname
   if {[array exists hfreehashname]} {
      foreach key [array names hfreehashname] {
       unset hfreehashname($key)
     }
   }
  }
  proc hdel {hashname hashitem} {
    upvar #0 $hashname hdelhashname
   if {[info exists hdelhashname($hashitem)]} {
     unset hdelhashname($hashitem)
   }
  }
  proc hcopy {hashfrom hashto} {
   upvar #0 $hashfrom hashfromlocal $hashto hashtolocal
   array set hashtolocal [array get hashfromlocal]
  }
  proc savetemphash {} {
    hsave "rsstempnew" "${::network}rsstemp.hsh"
  }
  proc savehash {} {
    hsave "rssreader" "${::network}rssreader.hsh"
  }
  proc load_hash {min hour day month year} {
  rssreader::loadhash 1
  }
  proc loadhash {type} {
    if {[file exists "${::network}rssreader.hsh"]} {
     rssreader::hload "rssreader" "${::network}rssreader.hsh"
   }
   if {[file exists "${::network}rsstemp.hsh"]} {
     rssreader::hload "rsstempnew" "${::network}rsstemp.hsh"
      rssreader::hload "rsstempold" "${::network}rsstemp.hsh"    
   }
    set count $rssreader::startupdelay
    foreach {key value} [array get ::rssreader] {
      if {[set idx [lsearch -glob [timers] "*$value*"]] != -1} {
       killtimer [lindex [lindex [timers] $idx] 2]
      }
      timer $count $value
      incr count
    }
  } 
}

putlog "\002*Loaded* \017\00304\002RSS Reader\017 \002by \
Ford_Lawnmower irc.GeekShed.net #Script-Help .rss for help"
My guess is that this the HTTP socket gets closed or quit somehow and that is hanging the bot:

Code: Select all

if {![catch {set rssreadersock [socket -async $rssreadersite 80]; fconfigure $RacSock -blocking off;}]}
Do you guys know how to improve this? Thanks in advance.
C
CP1832
Halfop
Posts: 68
Joined: Thu Oct 09, 2014 4:03 pm

Post by CP1832 »

CP1832 wrote:My guess is that this the HTTP socket gets closed or quit somehow and that is hanging the bot:

Code: Select all

if {![catch {set rssreadersock [socket -async $rssreadersite 80]; fconfigure $RacSock -blocking off;}]}
Do you guys know how to improve this? Thanks in advance.
Sorry I didn't post this before, but after a while, I figured out the problem was that there had been an update on the shell's TCL, so I had to recompile my bot and the problem was solved.
w
willyw
Revered One
Posts: 1196
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

CP1832 wrote: ...
Sorry I didn't post this before, but after a while, I figured out the problem was that there had been an update on the shell's TCL, so I had to recompile my bot and the problem was solved.
Well, I was on the right track, in that _something_ changed. :) I just didn't think of that that possibility to mention it to you.

Glad you figured it out, and glad you posted the solution here. It might help somebody else someday.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
Post Reply