Jabbernachricht beim Boot eines Debianservers

Sockets, TCP/IP, (XML-)RPC und ähnliche Themen gehören in dieses Forum
Antworten
p90
User
Beiträge: 198
Registriert: Donnerstag 22. Juli 2010, 17:30

Hi,

folgendes Problem.
Wenn mein Server hochfährt möchte ich mir dies per Jabber mitteilen lassen.
Ich verwende dazu dieses Programm:

Code: Alles auswählen

#!/usr/bin/env python
import sys,os,xmpp

if not os.path.exists("/tmp/jabbermessagesend"):

        jid=xmpp.protocol.JID('meinname')
        cl=xmpp.Client(jid.getDomain())
        cl.connect()
        cl.auth(jid.getNode(),'meinpw')
        cl.send(xmpp.protocol.Message("meinpc","Router rebooted! Mount drives please!"))

        FILE = open("/tmp/jabbermessagesend","w")
        FILE.close()

die Datei jabbermessagesend wird auf /tmp abgelegt und dadurch bei jedem boot gelöscht.
Ich führe das Script immer aus wenn meine PPPoE Verbindung hochkommt (also über /etc/ppp/up-ip.d/), ich sollte also eine Internetverbindung haben. Trotzdem kommt keine Nachricht an.
Führe ich das Script per Hand aus geht alles.
Es wird aber auch beim boot ausgeführt (jabbermessagesend wird angelegt)

Hat irgendeiner ne Idee was hier schief läuft?
Leonidas
Python-Forum Veteran
Beiträge: 16025
Registriert: Freitag 20. Juni 2003, 16:30
Kontaktdaten:

Du kannst die Ausgaben ja in Syslog schreiben lassen und sie dort rauslesen. Ansonsten, schon geschaut ob die Netzwerkverbindung steht und alles?
My god, it's full of CARs! | Leonidasvoice vs (former) Modvoice
Paramount
User
Beiträge: 5
Registriert: Mittwoch 2. Februar 2011, 21:06

hi,

liegt das python file direkt in ip-up.d? Du könntest mal versuchen das python script über ein bash script zu starten un daran explizit nochmal die bash.bashrc sourcen.

Code: Alles auswählen

#!/bin/bash
. /etc/bash.bashrc
/usr/bin/env python /usr/local/bla/jabber.py
Vielleicht hilft das.

Grüße
p90
User
Beiträge: 198
Registriert: Donnerstag 22. Juli 2010, 17:30

Hi,

also erstmal, ja liegt direkt im ip-up.d
Ich habe aber oben ein #!/usr/bin/env python drin.
Und per ./notifyatboot.py geht es auch.
Halt nur nicht im Bootvorgang.
Da ein

Code: Alles auswählen

foo = open("/verbose", "w")
os.sysout = foo
os.syserr = foo
leider nicht dazu führt, das ich den Kram den es schreibt auch dahin geschrieben bekomme.
Habe dann in der debug.py von xmpppy was in der Richtung eingefügt.
Ergebnis:
DEBUG: socket start Plugging <xmpp.transports.TCPsocket instance at 0x898ceec> into <xmpp.client.Client instance at 0x898ce8c>
DEBUG: socket start Successfully connected to remote host ('jabberd.jabber.ccc.de.', 80)
DEBUG: dispatcher start Plugging <xmpp.dispatcher.Dispatcher instance at 0x899aa6c> into <xmpp.client.Client instance at 0x898ce8c>
DEBUG: dispatcher info Registering namespace "unknown"
DEBUG: dispatcher info Registering protocol "unknown" as xmpp.protocol.Protocol(unknown)
DEBUG: dispatcher info Registering protocol "default" as xmpp.protocol.Protocol(unknown)
DEBUG: dispatcher info Registering namespace "http://etherx.jabber.org/streams"
DEBUG: dispatcher info Registering protocol "unknown" as xmpp.protocol.Protocol(http://etherx.jabber.org/streams)
DEBUG: dispatcher info Registering protocol "default" as xmpp.protocol.Protocol(http://etherx.jabber.org/streams)
DEBUG: dispatcher info Registering namespace "jabber:client"
DEBUG: dispatcher info Registering protocol "unknown" as xmpp.protocol.Protocol(jabber:client)
DEBUG: dispatcher info Registering protocol "default" as xmpp.protocol.Protocol(jabber:client)
DEBUG: dispatcher info Registering protocol "iq" as xmpp.protocol.Iq(jabber:client)
DEBUG: dispatcher info Registering protocol "presence" as xmpp.protocol.Presence(jabber:client)
DEBUG: dispatcher info Registering protocol "message" as xmpp.protocol.Message(jabber:client)
DEBUG: dispatcher info Registering handler <bound method Dispatcher.streamErrorHandler of <xmpp.dispatcher.Dispatcher instance at 0x899aa6c>> for "error" type-> ns->(http://etherx.jabber.org/streams)
DEBUG: dispatcher warn Registering protocol "error" as xmpp.protocol.Protocol(http://etherx.jabber.org/streams)
DEBUG: socket sent <?xml version='1.0'?>
<stream:stream xmlns="jabber:client" to="jabber.ccc.de" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" >
DEBUG: socket got <?xml version='1.0'?>
<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='306484825' from='jabber.ccc.de' version='1.0' xml:lang='en'>
DEBUG: socket got <stream:features>
<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
<mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
<mechanism>PLAIN</mechanism>
<mechanism>DIGEST-MD5</mechanism>
</mechanisms>
<c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='TeHoUYyKw5MAbWN339k8noZFt2Q='/>
<register xmlns='http://jabber.org/features/iq-register'/>
</stream:features>
DEBUG: dispatcher warn Unknown stanza: features
DEBUG: dispatcher ok Dispatching unknown stanza with type-> props->[u'urn:ietf:params:xml:ns:xmpp-tls', u'urn:ietf:params:xml:ns:xmpp-sasl', u'http://jabber.org/protocol/caps', u'http://jabber.org/features/iq-register'] id->None
DEBUG: tls start Plugging <xmpp.transports.TLS instance at 0x899ab2c> into <xmpp.client.Client instance at 0x898ce8c>
DEBUG: tls ok TLS supported by remote server. Requesting TLS start.
DEBUG: dispatcher info Registering handler <bound method TLS.StartTLSHandler of <xmpp.transports.TLS instance at 0x899ab2c>> for "proceed" type-> ns->(urn:ietf:params:xml:ns:xmpp-tls)
DEBUG: dispatcher warn Registering namespace "urn:ietf:params:xml:ns:xmpp-tls"
DEBUG: dispatcher info Registering protocol "unknown" as xmpp.protocol.Protocol(urn:ietf:params:xml:ns:xmpp-tls)
DEBUG: dispatcher info Registering protocol "default" as xmpp.protocol.Protocol(urn:ietf:params:xml:ns:xmpp-tls)
DEBUG: dispatcher warn Registering protocol "proceed" as xmpp.protocol.Protocol(urn:ietf:params:xml:ns:xmpp-tls)
DEBUG: dispatcher info Registering handler <bound method TLS.StartTLSHandler of <xmpp.transports.TLS instance at 0x899ab2c>> for "failure" type-> ns->(urn:ietf:params:xml:ns:xmpp-tls)
DEBUG: dispatcher warn Registering protocol "failure" as xmpp.protocol.Protocol(urn:ietf:params:xml:ns:xmpp-tls)
DEBUG: socket sent <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>
DEBUG: socket got <proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
DEBUG: dispatcher ok Got urn:ietf:params:xml:ns:xmpp-tls/proceed stanza
DEBUG: dispatcher ok Dispatching proceed stanza with type-> props->[] id->None
DEBUG: tls ok Got starttls proceed response. Switching to TLS/SSL...
DEBUG: dispatcher stop Plugging <xmpp.dispatcher.Dispatcher instance at 0x899aa6c> out of <xmpp.client.Client instance at 0x898ce8c>.
DEBUG: dispatcher start Plugging <xmpp.dispatcher.Dispatcher instance at 0x89b284c> into <xmpp.client.Client instance at 0x898ce8c>
DEBUG: dispatcher info Registering namespace "unknown"
DEBUG: dispatcher info Registering protocol "unknown" as xmpp.protocol.Protocol(unknown)
DEBUG: dispatcher info Registering protocol "default" as xmpp.protocol.Protocol(unknown)
DEBUG: dispatcher info Registering namespace "http://etherx.jabber.org/streams"
DEBUG: dispatcher info Registering protocol "unknown" as xmpp.protocol.Protocol(http://etherx.jabber.org/streams)
DEBUG: dispatcher info Registering protocol "default" as xmpp.protocol.Protocol(http://etherx.jabber.org/streams)
DEBUG: dispatcher info Registering namespace "jabber:client"
DEBUG: dispatcher info Registering protocol "unknown" as xmpp.protocol.Protocol(jabber:client)
DEBUG: dispatcher info Registering protocol "default" as xmpp.protocol.Protocol(jabber:client)
DEBUG: dispatcher info Registering protocol "iq" as xmpp.protocol.Iq(jabber:client)
DEBUG: dispatcher info Registering protocol "presence" as xmpp.protocol.Presence(jabber:client)
DEBUG: dispatcher info Registering protocol "message" as xmpp.protocol.Message(jabber:client)
DEBUG: dispatcher info Registering handler <bound method Dispatcher.streamErrorHandler of <xmpp.dispatcher.Dispatcher instance at 0x89b284c>> for "error" type-> ns->(http://etherx.jabber.org/streams)
DEBUG: dispatcher warn Registering protocol "error" as xmpp.protocol.Protocol(http://etherx.jabber.org/streams)
DEBUG: socket sent <?xml version='1.0'?>
<stream:stream xmlns="jabber:client" to="jabber.ccc.de" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" >
DEBUG: socket got <?xml version='1.0'?>
<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='4280561112' from='jabber.ccc.de' version='1.0' xml:lang='en'>
DEBUG: socket got <stream:features>
<mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
<mechanism>PLAIN</mechanism>
<mechanism>DIGEST-MD5</mechanism>
</mechanisms>
<c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='TeHoUYyKw5MAbWN339k8noZFt2Q='/>
<register xmlns='http://jabber.org/features/iq-register'/>
</stream:features>
DEBUG: dispatcher warn Unknown stanza: features
DEBUG: dispatcher ok Dispatching unknown stanza with type-> props->[u'urn:ietf:params:xml:ns:xmpp-sasl', u'http://jabber.org/protocol/caps', u'http://jabber.org/features/iq-register'] id->None
DEBUG: sasl start Plugging <xmpp.auth.SASL instance at 0x89b2c4c> into <xmpp.client.Client instance at 0x898ce8c>
DEBUG: dispatcher info Registering handler <bound method SASL.SASLHandler of <xmpp.auth.SASL instance at 0x89b2c4c>> for "challenge" type-> ns->(urn:ietf:params:xml:ns:xmpp-sasl)
DEBUG: dispatcher warn Registering namespace "urn:ietf:params:xml:ns:xmpp-sasl"
DEBUG: dispatcher info Registering protocol "unknown" as xmpp.protocol.Protocol(urn:ietf:params:xml:ns:xmpp-sasl)
DEBUG: dispatcher info Registering protocol "default" as xmpp.protocol.Protocol(urn:ietf:params:xml:ns:xmpp-sasl)
DEBUG: dispatcher warn Registering protocol "challenge" as xmpp.protocol.Protocol(urn:ietf:params:xml:ns:xmpp-sasl)
DEBUG: dispatcher info Registering handler <bound method SASL.SASLHandler of <xmpp.auth.SASL instance at 0x89b2c4c>> for "failure" type-> ns->(urn:ietf:params:xml:ns:xmpp-sasl)
DEBUG: dispatcher warn Registering protocol "failure" as xmpp.protocol.Protocol(urn:ietf:params:xml:ns:xmpp-sasl)
DEBUG: dispatcher info Registering handler <bound method SASL.SASLHandler of <xmpp.auth.SASL instance at 0x89b2c4c>> for "success" type-> ns->(urn:ietf:params:xml:ns:xmpp-sasl)
DEBUG: dispatcher warn Registering protocol "success" as xmpp.protocol.Protocol(urn:ietf:params:xml:ns:xmpp-sasl)
DEBUG: socket sent <auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="DIGEST-MD5" />
DEBUG: socket got <challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>bm9uY2U9IjExNTk2MDA4MjUiLHFvcD0iYXV0aCIsY2hhcnNldD11dGYtOCxhbGdvcml0aG09bWQ1LXNlc3M=</challenge>
DEBUG: dispatcher ok Got urn:ietf:params:xml:ns:xmpp-sasl/challenge stanza
DEBUG: dispatcher ok Dispatching challenge stanza with type-> props->[] id->None
DEBUG: sasl ok Got challenge:nonce="1159600825",qop="auth",charset=utf-8,algorithm=md5-sess
DEBUG: socket sent <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">Y2hhcnNldD11dGYtOCx1c2VybmFtZT0icm91dGVycDkwIixyZWFsbT0iamFiYmVyLmNjYy5kZSIsbm9uY2U9IjExNTk2MDA4MjUiLG5jPTAwMDAwMDAxLGNub25jZT0iOWNhZjE0Y2E5ZTIxNWIyZmVhNzM1YTM2ZDFkYTg3ZjlmOGQ0MDk5MmJkYzFiMjhjMyIsZGlnZXN0LXVyaT0ieG1wcC9qYWJiZXIuY2NjLmRlIixyZXNwb25zZT05Y2E1MDcxZGY0MDBiZTU3NWQ2OGJlYzZlMDE0NWQ3MSxxb3A9YXV0aA==</response>
DEBUG: socket got <challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>cnNwYXV0aD02YmZhZWE2M2ZkNmMzZDZjMDRjYTM2NmU2MjA4YTA1Yg==</challenge>
DEBUG: dispatcher ok Got urn:ietf:params:xml:ns:xmpp-sasl/challenge stanza
DEBUG: dispatcher ok Dispatching challenge stanza with type-> props->[] id->None
DEBUG: sasl ok Got challenge:rspauth=6bfaea63fd6c3d6c04ca366e6208a05b
DEBUG: socket sent <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl" />
DEBUG: socket got <success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>
DEBUG: dispatcher ok Got urn:ietf:params:xml:ns:xmpp-sasl/success stanza
DEBUG: dispatcher ok Dispatching success stanza with type-> props->[] id->None
DEBUG: sasl ok Successfully authenticated with remote server.
DEBUG: dispatcher stop Plugging <xmpp.dispatcher.Dispatcher instance at 0x89b284c> out of <xmpp.client.Client instance at 0x898ce8c>.
DEBUG: dispatcher start Plugging <xmpp.dispatcher.Dispatcher instance at 0x89b2eac> into <xmpp.client.Client instance at 0x898ce8c>
DEBUG: dispatcher info Registering namespace "unknown"
DEBUG: dispatcher info Registering protocol "unknown" as xmpp.protocol.Protocol(unknown)
DEBUG: dispatcher info Registering protocol "default" as xmpp.protocol.Protocol(unknown)
DEBUG: dispatcher info Registering namespace "http://etherx.jabber.org/streams"
DEBUG: dispatcher info Registering protocol "unknown" as xmpp.protocol.Protocol(http://etherx.jabber.org/streams)
DEBUG: dispatcher info Registering protocol "default" as xmpp.protocol.Protocol(http://etherx.jabber.org/streams)
DEBUG: dispatcher info Registering namespace "jabber:client"
DEBUG: dispatcher info Registering protocol "unknown" as xmpp.protocol.Protocol(jabber:client)
DEBUG: dispatcher info Registering protocol "default" as xmpp.protocol.Protocol(jabber:client)
DEBUG: dispatcher info Registering protocol "iq" as xmpp.protocol.Iq(jabber:client)
DEBUG: dispatcher info Registering protocol "presence" as xmpp.protocol.Presence(jabber:client)
DEBUG: dispatcher info Registering protocol "message" as xmpp.protocol.Message(jabber:client)
DEBUG: dispatcher info Registering handler <bound method Dispatcher.streamErrorHandler of <xmpp.dispatcher.Dispatcher instance at 0x89b2eac>> for "error" type-> ns->(http://etherx.jabber.org/streams)
DEBUG: dispatcher warn Registering protocol "error" as xmpp.protocol.Protocol(http://etherx.jabber.org/streams)
DEBUG: socket sent <?xml version='1.0'?>
<stream:stream xmlns="jabber:client" to="jabber.ccc.de" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" >
DEBUG: bind start Plugging <xmpp.auth.Bind instance at 0x89b2dcc> into <xmpp.client.Client instance at 0x898ce8c>
DEBUG: dispatcher info Registering handler <bound method Bind.FeaturesHandler of <xmpp.auth.Bind instance at 0x89b2dcc>> for "features" type-> ns->(http://etherx.jabber.org/streams)
DEBUG: dispatcher warn Registering protocol "features" as xmpp.protocol.Protocol(http://etherx.jabber.org/streams)
DEBUG: socket got <?xml version='1.0'?>
<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='1731564503' from='jabber.ccc.de' version='1.0' xml:lang='en'>
DEBUG: socket got <stream:features>
<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/>
<session xmlns='urn:ietf:params:xml:ns:xmpp-session'/>
<c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='TeHoUYyKw5MAbWN339k8noZFt2Q='/>
<register xmlns='http://jabber.org/features/iq-register'/>
</stream:features>
DEBUG: dispatcher ok Got http://etherx.jabber.org/streams/features stanza
DEBUG: dispatcher ok Dispatching features stanza with type-> props->[u'urn:ietf:params:xml:ns:xmpp-bind', u'urn:ietf:params:xml:ns:xmpp-session', u'http://jabber.org/protocol/caps', u'http://jabber.org/features/iq-register'] id->None
DEBUG: socket sent <iq type="set" id="1">
<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind" />
</iq>
DEBUG: dispatcher wait Waiting for ID:1 with timeout 25...
DEBUG: socket got <iq id='1' type='result'>
<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
<jid>servername/6710251051298882568835758</jid>
</bind>
</iq>
DEBUG: dispatcher ok Got jabber:client/iq stanza
DEBUG: dispatcher ok Dispatching iq stanza with type->result props->[u'urn:ietf:params:xml:ns:xmpp-bind'] id->1
DEBUG: dispatcher ok Expected stanza arrived!
DEBUG: bind ok Successfully bound sername/6710251051298882568835758.
DEBUG: socket sent <iq type="set" id="2">
<session xmlns="urn:ietf:params:xml:ns:xmpp-session" />
</iq>
DEBUG: dispatcher wait Waiting for ID:2 with timeout 25...
DEBUG: socket got <iq type='result' id='2'>
<session xmlns='urn:ietf:params:xml:ns:xmpp-session'/>
</iq>
DEBUG: dispatcher ok Got jabber:client/iq stanza
DEBUG: dispatcher ok Dispatching iq stanza with type->result props->[u'urn:ietf:params:xml:ns:xmpp-session'] id->2
DEBUG: dispatcher ok Expected stanza arrived!
DEBUG: bind ok Successfully opened session.
DEBUG: socket sent <message to="meineid" id="3">
<body>Router rebooted! Mount drives please!</body>
</message>

Also für mich sieht das so aus als würde er die Nachricht absetzen
Antworten