Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update zabbix_item_add.py #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions zabbix_item_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ def get_options():
parser.add_option("-d","--delay",action="store",type="int",\
dest="delay",default="120",help="(REQUIRED,Default:120)Update interval of the item in seconds.")
parser.add_option("-i","--interfaceid",action="store",type="string",\
dest="interfaceid",default="",help="(REQUIRED,Default:"")ID of the item's host interface. Used only for host items. Optional for Zabbix agent (active), Zabbix internal, Zabbix trapper, Zabbix aggregate, database monitor and calculated items.")
dest="interfaceid",default="",help="(REQUIRED,Default:"")ID of the item's host interface. Used only for host items. Optional for Zabbix agent (active), Zabbix internal, Zabbix trapper, Zabbix aggregate, database monitor and calculated items.")
parser.add_option("--trends",action="store",type="int",\
dest="trends",default="365",help="(Default:365)Number of days to keep item's trends data. Default:365.")
parser.add_option("--history",action="store",type="int",\
dest="history",default="7",help="(Default:7)Number of days to keep item's history data. Default:7.")
dest="history",default="7",help="(Default:7)Number of days to keep item's history data. Default:7.")
parser.add_option("--units",action="store",type="string",\
dest="units",default="",help="(Default:"")Value units.")
parser.add_option("-t","--type",action="store",type="int",\
Expand Down Expand Up @@ -126,6 +128,7 @@ def errmsg(msg):
delay = options.delay
interfaceid = options.interfaceid
history = options.history
trends = options.trends
units = options.units
delta = options.delta
params = options.params
Expand Down Expand Up @@ -162,9 +165,9 @@ def errmsg(msg):
print "hostname is not exist."
try:
if "applicationid" in dir():
print zapi.item.create({"name":name,"key_":key,"hostid":hostid,"type":(type),"interfaceid":interfaceid,"value_type":value_type,"delay":delay,"history":history,"delta":delta,"units":units,"params":params,"applications":[applicationid]})
print zapi.item.create({"name":name,"key_":key,"hostid":hostid,"type":(type),"interfaceid":interfaceid,"value_type":value_type,"delay":delay,"history":history,"trends":trends,"delta":delta,"units":units,"params":params,"applications":[applicationid]})
else:
print zapi.item.create({"name":name,"key_":key,"hostid":hostid,"type":(type),"interfaceid":interfaceid,"value_type":value_type,"delay":delay,"history":history,"delta":delta,"units":units,"params":params})
print zapi.item.create({"name":name,"key_":key,"hostid":hostid,"type":(type),"interfaceid":interfaceid,"value_type":value_type,"delay":delay,"history":history,"trends":trends,"delta":delta,"units":units,"params":params})
except Exception as e:
print str(e)
else:
Expand All @@ -179,8 +182,8 @@ def errmsg(msg):
applicationid = json.loads(json.dumps(_application))["applicationid"]
try:
if 'applicationid' in dir():
print zapi.item.create({"name":name,"key_":key,"hostid":hostid,"type":(type),"interfaceid":interfaceid,"value_type":value_type,"delay":delay,"history":history,"delta":delta,"units":units,"params":params,"applications":[applicationid]})
print zapi.item.create({"name":name,"key_":key,"hostid":hostid,"type":(type),"interfaceid":interfaceid,"value_type":value_type,"delay":delay,"history":history,"trends":trends,"delta":delta,"units":units,"params":params,"applications":[applicationid]})
else:
print zapi.item.create({"name":name,"key_":key,"hostid":hostid,"type":(type),"interfaceid":interfaceid,"value_type":value_type,"delay":delay,"history":history,"delta":delta,"units":units,"params":params})
print zapi.item.create({"name":name,"key_":key,"hostid":hostid,"type":(type),"interfaceid":interfaceid,"value_type":value_type,"delay":delay,"history":history,"trends":trends,"delta":delta,"units":units,"params":params})
except Exception as e:
print str(e)