Skip to content

Commit

Permalink
Add New command to show zabbix-cli configuration parameters [Issue: #13]
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelma committed Nov 18, 2016
1 parent 70dd922 commit f35162c
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 4 deletions.
6 changes: 3 additions & 3 deletions etc/zabbix-cli.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; Authors:
; rafael@postgresql.org.es / http://www.postgresql.org.es/
;
; Copyright (c) 2014-2015 USIT-University of Oslo
; Copyright (c) 2014-2016 USIT-University of Oslo
;
; This file is part of Zabbix-CLI
; https://github.com/rafaelma/zabbix-cli
Expand Down Expand Up @@ -83,8 +83,8 @@ default_notification_users_usergroup=All-notification-users

; Default export format.
; default_export_format: JSON, XML
; Default: JSON
; default_export_format=JSON
; Default: XML
; default_export_format=XML
;
; We deactivate this parameter until
; https://support.zabbix.com/browse/ZBX-10607 gets fixed.
Expand Down
91 changes: 90 additions & 1 deletion zabbix_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,95 @@ def do_show_maintenance_periods(self,args):
ALL)


# ############################################
# Method show_zabbixcli_config
# ############################################

def do_show_zabbixcli_config(self,args):
'''
DESCRIPTION:
This command shows information about the
configuration used by this zabbix-cli instance.
COMMAND:
show_zabbixcli_config
'''

result_columns = {}
result_columns_key = 0


# Generate information of the configuration files that are
# active and exist in this host.
#
# This is the priority list of configuration files that can
# exist in the system. Files close to the top of the list will
# have priority to define configuration parameters in the
# system.
#
# 1. /usr/share/zabbix-cli/zabbix-cli.fixed.conf
# 2. /etc/zabbix-cli/zabbix-cli.fixed.conf
# 3. Configuration file defined with the parameter -c / --config when executing zabbix-cli
# 4. $HOME/.zabbix-cli/zabbix-cli.conf
# 5. /etc/zabbix-cli/zabbix-cli.conf
# 6. /usr/share/zabbix-cli/zabbix-cli.conf
#

config_file_list = ['/usr/share/zabbix-cli/zabbix-cli.fixed.conf',
'/etc/zabbix-cli/zabbix-cli.fixed.conf',
self.conf.config_file_from_parameter,
os.getenv('HOME') + '/.zabbix-cli/zabbix-cli.conf',
'/etc/zabbix-cli/zabbix-cli.conf',
'/usr/share/zabbix-cli/zabbix-cli.conf']

for file in config_file_list:
if os.path.isfile(file):

result_columns [result_columns_key] = {1:'*' + file}
result_columns_key = result_columns_key + 1

#
# Generate output
#
self.generate_output(result_columns,
['Active configuration files'],
['Active configuration files'],
[''],
FRAME)


#
# Generate information with all the configuration parameters
#

result_columns = {}

result_columns [0] = {1:'zabbix_api_url',2:self.conf.zabbix_api_url}
result_columns [1] = {1:'system_id',2:self.conf.system_id}
result_columns [2] = {1:'default_hostgroup',2:self.conf.default_hostgroup}
result_columns [3] = {1:'default_admin_usergroup',2:self.conf.default_admin_usergroup}
result_columns [4] = {1:'default_create_user_usergroup',2:self.conf.default_create_user_usergroup}
result_columns [5] = {1:'default_notification_users_usergroup',2:self.conf.default_notification_users_usergroup}
result_columns [6] = {1:'default_directory_exports',2:self.conf.default_directory_exports}
result_columns [7] = {1:'default_export_format',2:self.conf.default_export_format}
result_columns [8] = {1:'include_timestamp_export_filename',2:self.conf.include_timestamp_export_filename}
result_columns [9] = {1:'use_colors',2:self.conf.use_colors}
result_columns [10] = {1:'use_auth_token_file',2:self.conf.use_auth_token_file}
result_columns [11] = {1:'logging',2:self.conf.logging}
result_columns [12] = {1:'log_level',2:self.conf.log_level}
result_columns [13] = {1:'log_file',2:self.conf.log_file}

#
# Generate output
#
self.generate_output(result_columns,
['Configuration parameter','Value'],
['Value'],
['Configuration parameter'],
FRAME)



# ############################################
# Method show_hostgroups
Expand All @@ -599,7 +688,7 @@ def do_show_hostgroups(self,args):
def do_show_hostgroup(self,args):
'''
DESCRIPTION:
This command show hostgroups information
This command shows hostgroup information
COMMAND:
show_hostgroup [hostgroup]
Expand Down

0 comments on commit f35162c

Please sign in to comment.