监控es,执行python脚本出错

执行:python monitor_es.py
Traceback (most recent call last):
  File "monitor_es.py", line 7, in <module>
    parm=sys.argv[1]
IndexError: list index out of range

源码:

import requests,json
import sys
headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/72.0.3626.109Safari/537.36"}
response=requests.get("http://10.0.111.13:9200/_cluster/health",headers=headers)
s=json.loads(response.content.decode())
parm=sys.argv[1]

itemlist=["cluster_name","status","time_out","number_of_nodes","number_of_data_nodes","active_primary_shards","active_shards","relocating_shards","initializing_shards","unassigned_shards","delayed_unassigned_shards","number_of_pending_tasks","number_of_in_flight_fetch","task_max_waiting_in_queue_millis","active_shards_percent_as_number"]

if parm not in itemlist:
        print("parm failed")
        sys.exit(1)
else:
        print(s[parm])

 

你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答

本次提问扣除的有问必答次数,将会以问答VIP体验卡(1次有问必答机会、商城购买实体图书享受95折优惠)的形式为您补发到账户。

​​​​因为有问必答VIP体验卡有效期仅有1天,您在需要使用的时候【私信】联系我,我会为您补发。