Browsing this Thread:   1 Anonymous Users






xmpp 推送服务器报警
#1
Quite a regular
Quite a regular


See User information
#!/usr/bin/env python3


import os

MAX_LOAD  
0.2

def topmsg
():
    
topmsg os.popen("top -b -n 1").readlines()[0:5]
    return 
topmsg

def osload
(loadstr):
    
load_num loadstr.split('load average: ')[1].split(", ")[0]
    return 
floatload_num ) > MAX_LOAD

def sendmsg
(msg_list):
    
msg_list.insert(0"cpu load alert rnrn")
    return 
"".join(msg_list)



def sendtoxmpp(msg):
    
command_str " xmpp-message    --jabberid  ryi@jabber.fr  --password  psdpsd  --receiver rayzhitch.org --message '" msg.replace("'""'") + "'"
    
tomsg os.popen(command_str).read()
    return 
tomsg



if __name__ == '__main__':
    
msg topmsg()
    if 
osload(msg[0]) :
       print( 
sendtoxmppsendmsg(msg) ))
    else :
        print(
"it's nothing")

Posted on: 7/6 18:10
Top








Themes

(2 themes)
Login
Username:

Password:


Lost Password?
Register now!
Categories