Page 1 of 3

NCPA runs from CLI but not web

Posted: Mon Jul 12, 2021 3:07 pm
by infofedsec
Trying to add hosts using NCPA. The agent is installed and running on the remote host and I can check the CPU via the CLI but on the web UI it times out. I'm guessing its a permissions issue but I've compared the files to a different installation thats came from the image you provide so I know those permissions are correct. They are the same so I'm hoping I can get some help in figuring out exactly where i need to look

Re: NCPA runs from CLI but not web

Posted: Tue Jul 13, 2021 10:26 am
by infofedsec
i just found this in my install, im not sure if this is affecting it. this is my /usr/local/nagiosxi/var/xi-sys.cfg file

Code: Select all

apachegroup='apache'
apacheuser='apache'
chownbin='/bin/chown'
groupaddbin='/usr/sbin/groupadd'
groupdelbin='/usr/sbin/groupdel'
htpasswdbin='/usr/bin/htpasswd'
httpdconfdir='/etc/httpd/conf.d'
httpdconf='/etc/httpd/conf/httpd.conf'
httpdroot='/var/www/html'
httpd='httpd'
ntpd='ntpd'
crond='crond'
mkdirbin='/bin/mkdir'
mrtgcfg='/etc/mrtg/mrtg.cfg'
pgsqlrootpass='postgres'
pgsqlpass='nagiosxi'
nagioscmdgroup='nagcmd'
nagiosgroup='nagios'
nagiosuser='nagios'
nagioswebpwd='nagiosadmin'
nagioswebuser='nagiosadmin'
phpconfd='/etc/php.d'
phpini='/etc/php.ini'
proddir='/usr/local/nagiosxi'
useraddbin='/usr/sbin/useradd'
usermodbin='/usr/sbin/usermod'
userdelbin='/usr/sbin/userdel'
mibsdir='/usr/share/snmp/mibs'
phpconfdcli='/etc/php.d'

mysqlpass='nagiosxi'

cfg__base_url='/nagiosxi'
cfg__root_dir='/usr/local/nagiosxi'
cfg__script_dir='/usr/local/nagiosxi/scripts'
cfg__xidpe_dir='/usr/local/nagios/var/spool/xidpe/'
cfg__perfdata_spool='/usr/local/nagios/var/spool/perfdata/'
cfg__nom_checkpoints_dir='/usr/local/nagiosxi/nom/checkpoints/nagioscore/'
cfg__use_https=0
cfg__port_number=0
cfg__dbtype=''
cfg__dbserver='localhost'
cfg__db_conn_persistent=1
cfg__db_info__nagiosxi__dbtype='mysql'
cfg__db_info__nagiosxi__dbserver=''
cfg__db_info__nagiosxi__user='nagiosxi'
cfg__db_info__nagiosxi__pwd='n@gweb'
cfg__db_info__nagiosxi__db='nagiosxi'
cfg__db_info__nagiosxi__charset='utf8'
cfg__db_info__nagiosxi__dbmaint__max_auditlog_age=180
cfg__db_info__nagiosxi__dbmaint__max_commands_age=480
cfg__db_info__nagiosxi__dbmaint__max_events_age=480
cfg__db_info__nagiosxi__dbmaint__optimize_interval=60
cfg__db_info__nagiosxi__dbmaint__repair_interval=0
cfg__db_info__ndoutils__dbtype='mysql'
cfg__db_info__ndoutils__dbserver='localhost'
cfg__db_info__ndoutils__user='ndoutils'
cfg__db_info__ndoutils__pwd='n@gweb'
cfg__db_info__ndoutils__db='nagios'
cfg__db_info__ndoutils__charset='utf8'
cfg__db_info__ndoutils__dbmaint__max_externalcommands_age=7
cfg__db_info__ndoutils__dbmaint__max_logentries_age=90
cfg__db_info__ndoutils__dbmaint__max_statehistory_age=730
cfg__db_info__ndoutils__dbmaint__max_notifications_age=90
cfg__db_info__ndoutils__dbmaint__max_timedevents_age=5
cfg__db_info__ndoutils__dbmaint__max_systemcommands_age=5
cfg__db_info__ndoutils__dbmaint__max_servicechecks_age=5
cfg__db_info__ndoutils__dbmaint__max_hostchecks_age=5
cfg__db_info__ndoutils__dbmaint__max_eventhandlers_age=5
cfg__db_info__ndoutils__dbmaint__optimize_interval=60
cfg__db_info__ndoutils__dbmaint__repair_interval=0
cfg__db_info__nagiosql__dbtype='mysql'
cfg__db_info__nagiosql__dbserver='localhost'
cfg__db_info__nagiosql__user='nagiosql'
cfg__db_info__nagiosql__pwd='n@gweb'
cfg__db_info__nagiosql__db='nagiosql'
cfg__db_info__nagiosql__charset='utf8'
cfg__db_info__nagiosql__dbmaint__max_logbook_age=480
cfg__db_info__nagiosql__dbmaint__optimize_interval=60
cfg__db_info__nagiosql__dbmaint__repair_interval=0
cfg__db_prefix__ndoutils='nagios_'
cfg__db_prefix__nagiosxi='xi_'
cfg__db_prefix__nagiosql='tbl_'
cfg__component_info__nagioscore__root_dir='/usr/local/nagios'
cfg__component_info__nagioscore__cgi_dir='/usr/local/nagios/sbin'
cfg__component_info__nagioscore__import_dir='/usr/local/nagios/etc/import'
cfg__component_info__nagioscore__static_dir='/usr/local/nagios/etc/static'
cfg__component_info__nagioscore__plugin_dir='/usr/local/nagios/libexec'
cfg__component_info__nagioscore__cgi_config_file='/usr/local/nagios/etc/cgi.cfg'
cfg__component_info__nagioscore__cmd_file='/usr/local/nagios/var/rw/nagios.cmd'
cfg__component_info__nagioscore__log_file='/usr/local/nagios/var/nagios.log'
cfg__component_info__nagioscore__nom_checkpoint_interval=1440
cfg__component_info__pnp__perfdata_dir='/usr/local/nagios/share/perfdata'
cfg__component_info__pnp__share_dir='/usr/local/nagios/share/pnp'
cfg__component_info__pnp__direct_url='/nagios/pnp'
cfg__component_info__pnp__username='nagiosxi'
cfg__component_info__pnp__password='nagiosadmin'
cfg__component_info__perfdata__rrdtool_path='/usr/bin/rrdtool'
cfg__component_info__nagvis__share_dir='/usr/local/nagios/share/nagvis'
cfg__component_info__nagvis__direct_url='/nagios/nagvis'
cfg__component_info__nagvis__username='nagiosadmin'
cfg__component_info__nagvis__password='nagiosadmin'
cfg__demo_mode=0
cfg__dashlet_refresh_multiplier=1000
cfg__dashlet_refresh_rates__available_updates=86400
cfg__dashlet_refresh_rates__systat_eventqueuechart=5
cfg__dashlet_refresh_rates__sysstat_monitoringstats=30
cfg__dashlet_refresh_rates__systat_monitoringperf=30
cfg__dashlet_refresh_rates__sysstat_monitoringproc=30
cfg__dashlet_refresh_rates__perfdata_chart=60
cfg__dashlet_refresh_rates__network_outages=30
cfg__dashlet_refresh_rates__host_status_summary=60
cfg__dashlet_refresh_rates__service_status_summary=60
cfg__dashlet_refresh_rates__hostgroup_status_overview=60
cfg__dashlet_refresh_rates__hostgroup_status_grid=60
cfg__dashlet_refresh_rates__servicegroup_status_overview=60
cfg__dashlet_refresh_rates__servicegroup_status_grid=60
cfg__dashlet_refresh_rates__hostgroup_status_summary=60
cfg__dashlet_refresh_rates__servicegroup_status_summary=60
cfg__dashlet_refresh_rates__sysstat_componentstates=7
cfg__dashlet_refresh_rates__sysstat_serverstats=5
cfg__dashlet_refresh_rates__network_outages_summary=30
cfg__dashlet_refresh_rates__network_health=30
cfg__dashlet_refresh_rates__host_status_tac_summary=30
cfg__dashlet_refresh_rates__service_status_tac_summary=30
cfg__dashlet_refresh_rates__feature_status_tac_summary=30
cfg__dashlet_refresh_rates__admin_tasks=60
cfg__dashlet_refresh_rates__getting_started=60
cfg__dashlet_refresh_rates__pagetop_alert_content=30
cfg__dashlet_refresh_rates__tray_alert=30
cfg__memcached_enable=0
cfg__memcached_hosts__0='127.0.0.1'
cfg__memcached_port=11211
cfg__memcached_compress=0
cfg__memcached_ttl=10
cfg__use_basic_authentication=0
cfg__subsystem_basic_auth_username='nagiosxi'
cfg__subsystem_basic_auth_password='somepassword'
cfg__default_language='en_US'
cfg__default_theme=''
cfg__languages__en_US='English'
cfg__default_instance_id=1
cfg__default_result_records=100000
cfg__online_help_url='https://support.nagios.com/'
cfg__feedback_url='https://api.nagios.com/feedback/'
cfg__privacy_policy_url='https://www.nagios.com/legal/privacypolicy/'
cfg__db_version=113
cfg__htaccess_file='/usr/local/nagiosxi/etc/htpasswd.users'
cfg__htpasswd_path='/usr/bin/htpasswd'

xiver='5.8.4'
distro='RedHatEnterpriseServer'
version='7.9'
ver='7'
architecture='x86_64'
dist='el7'
arch='x86_64'
php_extension_dir='/usr/lib64/php/modules'
mysqld='mariadb'
cfg__base_url='/nagiosxi'
cfg__root_dir='/usr/local/nagiosxi'
cfg__script_dir='/usr/local/nagiosxi/scripts'
cfg__xidpe_dir='/usr/local/nagios/var/spool/xidpe/'
cfg__perfdata_spool='/usr/local/nagios/var/spool/perfdata/'
cfg__nom_checkpoints_dir='/usr/local/nagiosxi/nom/checkpoints/nagioscore/'
cfg__use_https=0
cfg__port_number=0
cfg__dbtype=''
cfg__dbserver='localhost'
cfg__db_conn_persistent=1
cfg__db_info__nagiosxi__dbtype='mysql'
cfg__db_info__nagiosxi__dbserver=''
cfg__db_info__nagiosxi__user='nagiosxi'
cfg__db_info__nagiosxi__pwd='n@gweb'
cfg__db_info__nagiosxi__db='nagiosxi'
cfg__db_info__nagiosxi__charset='utf8'
cfg__db_info__nagiosxi__dbmaint__max_auditlog_age=180
cfg__db_info__nagiosxi__dbmaint__max_commands_age=480
cfg__db_info__nagiosxi__dbmaint__max_events_age=480
cfg__db_info__nagiosxi__dbmaint__optimize_interval=60
cfg__db_info__nagiosxi__dbmaint__repair_interval=0
cfg__db_info__ndoutils__dbtype='mysql'
cfg__db_info__ndoutils__dbserver='localhost'
cfg__db_info__ndoutils__user='ndoutils'
cfg__db_info__ndoutils__pwd='n@gweb'
cfg__db_info__ndoutils__db='nagios'
cfg__db_info__ndoutils__charset='utf8'
cfg__db_info__ndoutils__dbmaint__max_externalcommands_age=7
cfg__db_info__ndoutils__dbmaint__max_logentries_age=90
cfg__db_info__ndoutils__dbmaint__max_statehistory_age=730
cfg__db_info__ndoutils__dbmaint__max_notifications_age=90
cfg__db_info__ndoutils__dbmaint__max_timedevents_age=5
cfg__db_info__ndoutils__dbmaint__max_systemcommands_age=5
cfg__db_info__ndoutils__dbmaint__max_servicechecks_age=5
cfg__db_info__ndoutils__dbmaint__max_hostchecks_age=5
cfg__db_info__ndoutils__dbmaint__max_eventhandlers_age=5
cfg__db_info__ndoutils__dbmaint__optimize_interval=60
cfg__db_info__ndoutils__dbmaint__repair_interval=0
cfg__db_info__nagiosql__dbtype='mysql'
cfg__db_info__nagiosql__dbserver='localhost'
cfg__db_info__nagiosql__user='nagiosql'
cfg__db_info__nagiosql__pwd='n@gweb'
cfg__db_info__nagiosql__db='nagiosql'
cfg__db_info__nagiosql__charset='utf8'
cfg__db_info__nagiosql__dbmaint__max_logbook_age=480
cfg__db_info__nagiosql__dbmaint__optimize_interval=60
cfg__db_info__nagiosql__dbmaint__repair_interval=0
cfg__db_prefix__ndoutils='nagios_'
cfg__db_prefix__nagiosxi='xi_'
cfg__db_prefix__nagiosql='tbl_'
cfg__component_info__nagioscore__root_dir='/usr/local/nagios'
cfg__component_info__nagioscore__cgi_dir='/usr/local/nagios/sbin'
cfg__component_info__nagioscore__import_dir='/usr/local/nagios/etc/import'
cfg__component_info__nagioscore__static_dir='/usr/local/nagios/etc/static'
cfg__component_info__nagioscore__plugin_dir='/usr/local/nagios/libexec'
cfg__component_info__nagioscore__cgi_config_file='/usr/local/nagios/etc/cgi.cfg'
cfg__component_info__nagioscore__cmd_file='/usr/local/nagios/var/rw/nagios.cmd'
cfg__component_info__nagioscore__log_file='/usr/local/nagios/var/nagios.log'
cfg__component_info__nagioscore__nom_checkpoint_interval=1440
cfg__component_info__pnp__perfdata_dir='/usr/local/nagios/share/perfdata'
cfg__component_info__pnp__share_dir='/usr/local/nagios/share/pnp'
cfg__component_info__pnp__direct_url='/nagios/pnp'
cfg__component_info__pnp__username='nagiosxi'
cfg__component_info__pnp__password='nagiosadmin'
cfg__component_info__perfdata__rrdtool_path='/usr/bin/rrdtool'
cfg__component_info__nagvis__share_dir='/usr/local/nagios/share/nagvis'
cfg__component_info__nagvis__direct_url='/nagios/nagvis'
cfg__component_info__nagvis__username='nagiosadmin'
cfg__component_info__nagvis__password='nagiosadmin'
cfg__demo_mode=0
cfg__dashlet_refresh_multiplier=1000
cfg__dashlet_refresh_rates__available_updates=86400
cfg__dashlet_refresh_rates__systat_eventqueuechart=5
cfg__dashlet_refresh_rates__sysstat_monitoringstats=30
cfg__dashlet_refresh_rates__systat_monitoringperf=30
cfg__dashlet_refresh_rates__sysstat_monitoringproc=30
cfg__dashlet_refresh_rates__perfdata_chart=60
cfg__dashlet_refresh_rates__network_outages=30
cfg__dashlet_refresh_rates__host_status_summary=60
cfg__dashlet_refresh_rates__service_status_summary=60
cfg__dashlet_refresh_rates__hostgroup_status_overview=60
cfg__dashlet_refresh_rates__hostgroup_status_grid=60
cfg__dashlet_refresh_rates__servicegroup_status_overview=60
cfg__dashlet_refresh_rates__servicegroup_status_grid=60
cfg__dashlet_refresh_rates__hostgroup_status_summary=60
cfg__dashlet_refresh_rates__servicegroup_status_summary=60
cfg__dashlet_refresh_rates__sysstat_componentstates=7
cfg__dashlet_refresh_rates__sysstat_serverstats=5
cfg__dashlet_refresh_rates__network_outages_summary=30
cfg__dashlet_refresh_rates__network_health=30
cfg__dashlet_refresh_rates__host_status_tac_summary=30
cfg__dashlet_refresh_rates__service_status_tac_summary=30
cfg__dashlet_refresh_rates__feature_status_tac_summary=30
cfg__dashlet_refresh_rates__admin_tasks=60
cfg__dashlet_refresh_rates__getting_started=60
cfg__dashlet_refresh_rates__pagetop_alert_content=30
cfg__dashlet_refresh_rates__tray_alert=30
cfg__memcached_enable=0
cfg__memcached_hosts__0='127.0.0.1'
cfg__memcached_port=11211
cfg__memcached_compress=0
cfg__memcached_ttl=10
cfg__use_basic_authentication=0
cfg__subsystem_basic_auth_username='nagiosxi'
cfg__subsystem_basic_auth_password='somepassword'
cfg__default_language='en_US'
cfg__default_theme=''
cfg__languages__en_US='English'
cfg__default_instance_id=1
cfg__default_result_records=100000
cfg__online_help_url='https://support.nagios.com/'
cfg__feedback_url='https://api.nagios.com/feedback/'
cfg__privacy_policy_url='https://www.nagios.com/legal/privacypolicy/'
cfg__db_version=113
cfg__htaccess_file='/usr/local/nagiosxi/etc/htpasswd.users'
cfg__htpasswd_path='/usr/bin/htpasswd'
make_j_flag='4'
RPMINSTALL='1'

Re: NCPA runs from CLI but not web

Posted: Tue Jul 13, 2021 11:07 am
by gsmith
Hi

You need to configure the firewall to open port 5693 on the remote machine.

Depending on your OS it will be something like this:

Code: Select all

firewall-cmd  --add-port=5693/tcp --permanent
firewall-cmd  --reload
firewall-cmd --list-ports
Let me know how it works out.

If you are having trouble getting the firewall configured let me know,
and tell me what OS you are using.

Thanks

Re: NCPA runs from CLI but not web

Posted: Tue Jul 13, 2021 12:45 pm
by infofedsec
That doesnt make sense

If the command works from the CLI of the Nagios machine but not from the web ui of the Nagios machine then its not a firewall issue

Re: NCPA runs from CLI but not web

Posted: Tue Jul 13, 2021 1:31 pm
by gsmith
Hi,

From the Nagios server command line please run:

Code: Select all

curl -k "https://192.168.23.81:5693/testconnect/?token=mytoken"
Change 192.168.23.81 to the IP of the remote machine running ncpa, and also
change the token as required.

Thanks

Re: NCPA runs from CLI but not web

Posted: Tue Jul 13, 2021 2:12 pm
by infofedsec

Code: Select all

curl -k "https://10.205.161.11:5693/testconnect/?token=(redacted)"
{
  "value": "Success."
}

Re: NCPA runs from CLI but not web

Posted: Tue Jul 13, 2021 2:36 pm
by gsmith
OK cool.

Go to Configure, Core Config Manager. Select the CPU Usage service, you should
see a page like:
Image4.jpg
Hit the "Run Check Command" button. On the next screen make sure
the IP address is for the right remote machine and hit the "Run Check Command" button.

Is it timing out or working?

Thanks

Re: NCPA runs from CLI but not web

Posted: Tue Jul 13, 2021 2:42 pm
by infofedsec
timing out
nagios.png

Re: NCPA runs from CLI but not web

Posted: Tue Jul 13, 2021 3:03 pm
by gsmith
Take a look at /usr/local/ncpa/var/log/ncpa_listener.log on the remote machine.
Are you seeing entries coming from the Nagios server when you run the check command?

They'll look something like:

Code: Select all

2021-07-13 15:47:49,207 31867 INFO ::ffff:192.168.23.82 - - [2021-07-13 15:47:49] "GET /api/cpu/percent/?token=mytoken&warning=20&critical=40&check=1&aggregate=avg HTTP/1.1" 200 307 0.506726
where 192.168.23.82 is the IP of the Nagios XI server.

Send me that log file along with the output of:

On the Nagios XI server:

Code: Select all

cd /usr/local/nagios/var
grep -r ncpa *
Thanks

Re: NCPA runs from CLI but not web

Posted: Tue Jul 13, 2021 3:14 pm
by infofedsec
the log is empty. The remote machine is windows. when i run the command from the web ui it times out, but runs correctly from the CLI. The API on the remote machine shows it responding to the CLI command but not receiving the web ui command
nagios.png