All ,
How can I find the no of hosts and services by command line on a unix machine ( red hat and Ubuntu)
on both Nagios Core and XI
Command to check no of hosts and services
Re: Command to check no of hosts and services
Quick and dirty grep commands below.
Total number of hosts being checked by Nagios:
Total number of services being checked by Nagios:
Total number of hosts being checked by Nagios:
Code: Select all
grep -w -c hoststatus /usr/local/nagios/var/status.dat
Code: Select all
grep -w -c servicestatus /usr/local/nagios/var/status.datFormer Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
Re: Command to check no of hosts and services
Thanks
I cant find status.dat but status.log
is this the same
I cant find status.dat but status.log
is this the same
-
kyang
Re: Command to check no of hosts and services
Thanks @mcapra!
A status.dat file is created when Nagios is started, and deleted when Nagios is stopped --> is Nagios started?
What is in the status.log file? Does it contain this information?
Otherwise did mcapra's command work for you? Change status.dat to status.log.
A status.dat file is created when Nagios is started, and deleted when Nagios is stopped --> is Nagios started?
What is in the status.log file? Does it contain this information?
What the path to that status.log file? --> Is it here /usr/local/nagios/varThis is the file that Nagios uses to store the current status, comment, and downtime information.
Otherwise did mcapra's command work for you? Change status.dat to status.log.
Re: Command to check no of hosts and services
Maybe? I don't recognize that file. Is this a Nagios Core 4 machine?
Give this a try:
Which should output something like this:
You'll want to point the grep command at wherever status_file is pointing. status.dat is what Nagios Core typically writes to when representing the status of your infrastructure (whats up, what's down, what check attempt, etc). If you're running mklivestatus or some other NEB module, that may impact where your status information is written.
Also as @kyang pointed out, make sure the Nagios daemon is running.
Give this a try:
Code: Select all
grep status_file /usr/local/nagios/etc/nagios.cfg
Code: Select all
[root@capra_nag data_preparation]# grep status_file /usr/local/nagios/etc/nagios.cfg
status_file=/usr/local/nagios/var/status.dat
Also as @kyang pointed out, make sure the Nagios daemon is running.
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
Re: Command to check no of hosts and services
both
on Nagios Core and Nagios XI
two different boxes
I saw this on the Nagios core machine on Ubuntu
:/usr/local/nagios/var# grep status_file /usr/local/nagios/etc/nagios.cfg
status_file=/usr/local/nagios/var/status.log
/usr/local/nagios/var# grep -w -c hoststatus status.log
430
but on the XI machine on red hat linux
grep status_file /usr/local/nagios/etc/nagios.cfg
status_file=/usr/local/nagios/var/status.log
# grep -w -c servicestatus /usr/local/nagios/var/status.dat
2355
I think they are the same files both status.log and status.dat
on Nagios Core and Nagios XI
two different boxes
I saw this on the Nagios core machine on Ubuntu
:/usr/local/nagios/var# grep status_file /usr/local/nagios/etc/nagios.cfg
status_file=/usr/local/nagios/var/status.log
/usr/local/nagios/var# grep -w -c hoststatus status.log
430
but on the XI machine on red hat linux
grep status_file /usr/local/nagios/etc/nagios.cfg
status_file=/usr/local/nagios/var/status.log
# grep -w -c servicestatus /usr/local/nagios/var/status.dat
2355
I think they are the same files both status.log and status.dat
-
kyang
Re: Command to check no of hosts and services
Are the commands working as expected? If it looks to be the same as a status.dat file as in --> status.log shows current status information.
From what @mcapra gave you. Is this what you wanted to see from the command line?
Did you have any more questions or we are okay to close this thread?
From what @mcapra gave you. Is this what you wanted to see from the command line?
Did you have any more questions or we are okay to close this thread?
Re: Command to check no of hosts and services
Please close the thread
-
kyang
Re: Command to check no of hosts and services
Sounds great! I'll be closing this topic.
If you have any more questions, feel free to create another thread!
Thank you for using the Nagios Support Forum!
If you have any more questions, feel free to create another thread!
Thank you for using the Nagios Support Forum!