Browsing this Thread:   1 Anonymous Users






xmpp 推送服务器报警
#1
Just can't stay away
Just can't stay away


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: 2022/7/6 18:10
Top








friend links
Themes

(2 themes)
Login
Username:

Password:


Lost Password?
Register now!
Categories
Xoops (11)
--Modules (2)
--Themes (0)
Article (8)