403Webshell
Server IP : 103.88.176.108  /  Your IP : 216.73.216.211
Web Server : Apache/2.4.41 (Ubuntu)
System : Linux webserver 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64
User : www-data ( 33)
PHP Version : 7.4.3-4ubuntu2.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /bin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /bin/cagent_tools
#!/usr/local/qcloud/monitor/python26/bin/python
# -*- coding: utf-8 -*-
__author__ = 'samhuang'

# *********************************************************************
# Description       : cloud monitor agent tool 
#										 	 									
# Input parameters  : 
#                      					
# Output Parameters : #					 
# created by        : samhuang, 2014-Feb-13
# return state value: null  
# note              : 
#                    
# modified by       : hetiulin, 2014-Oct-27
# *********************************************************************

import sys
import urllib2, time, json, os

realPath = os.path.dirname(os.path.realpath(__file__)) + '/../comm/'
sys.path.append(realPath)
import cutils
import constant


class AlarmSender:
    def __init__(self):
        self.__config = cutils.generate_config(constant.PLUGIN_CONFIG_PATH, self.__class__.__name__)

    def sendData(self, data, policy_id):
        try:
            data['localip'] = cutils.local_ip()
            data['clientKey'] = cutils.get_client_key()
            data['localtime'] = int(time.time())
            with open('/etc/uuid', 'r') as f:
                uuid = f.read().split('=')[1].replace('"', '').replace('\'', '').strip()
            data['uuid'] = uuid
            if policy_id is not None:
                data['policyId'] = policy_id
            url = cutils.get_url('AlarmSender','new_alarm_url','alarm_url')
            timeout = float(self.__config['alarm_timeout']) / 1000

            http_ret = urllib2.urlopen(url, json.dumps(data), timeout)
            response = http_ret.read()
            try:
                json_resp = json.loads(response)
                retcode = int(json_resp["returnCode"])
                if retcode != 0:
                    error_msg = json_resp["msg"]

                    (retcode, retinfo) = (constant.ErrorCode.HTTP_RESPONSE_ERROR, error_msg)
                else:
                    (retcode, retinfo) = (constant.ErrorCode.SUCC, "OK")

            except ValueError, e:
                (retcode, retinfo) = (constant.ErrorCode.HTTP_RESPONSE_ERROR, "server return an invalid data")

        except urllib2.URLError, e:
            (retcode, retinfo) = (constant.ErrorCode.HTTP_SEND_ERROR, "send to server failed")

        return (retcode, retinfo)


def help():
    print 'usage: %s  <subcommand> args' % sys.argv[0]
    print '\tsubcommand list as:'
    print '\talarm alarmString policyId' +\
          '\n\t\texample:%s alarm "hello world" cm-ah7hc3md (policyId can be acquired from the cloud monitor console)' % sys.argv[0]
    exit(0)


# const variable definitions
MAX_ALARM_LEN = 1024

# ------ program start here ------------
if len(sys.argv) < 3 or len(sys.argv) > 4:
    help()

subCmd = sys.argv[1]
if cmp(subCmd, 'alarm') == 0:
    if len(sys.argv[2]) > MAX_ALARM_LEN:
        print "alarm string's length is over the max length %d, please shorten it" % MAX_ALARM_LEN
        exit(1)
    alarm_str = {'alarmString': sys.argv[2]}
    policy_id = sys.argv[3] if len(sys.argv) == 4 else None
    alarmObj = AlarmSender()
    ret_code, ret_msg = alarmObj.sendData(alarm_str, policy_id)
    if ret_code == 0:
        print "send alarm string OK!"
    else:
        print "fail to send alarm string as " + ret_msg + ", please try again!"
    exit(ret_code)
else:
    help()

Youez - 2016 - github.com/yon3zu
LinuXploit