Why Is This So Hard?How do I Monitor a UPS? (check_apcupsd)

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Moneer81
Posts: 21
Joined: Mon Dec 07, 2015 2:55 pm

Re: Why Is This So Hard?How do I Monitor a UPS? (check_apcup

Post by Moneer81 »

Moneer81 wrote:
rkennedy wrote:Try running -
[ccode]
yum install apcupsd -y
[/code]
I will try that here in a bit
Thank you! That installed the missing component in /sbin/

Trying to run the plugin from the command line now always gives me this error:

./check_apcupsd: line 213: [: -lt: unary operator expected

Example: (note that I changed the host name for privacy. also, using port 23 here because that happens to be open on this test ups, but eventually we'll obviously turn off that port)

# ./check_apcupsd -h ups-test-1.myuniversity.edu -w 80 -c 70 -p 23 bcharge
./check_apcupsd: line 168: [: -lt: unary operator expected
./check_apcupsd: line 174: [: -lt: unary operator expected


Checking any of the other arguments (like itemp,loadpct,timeleft, etc.) gives the same exact result (but obviously the error usually points to a different line)
Moneer81
Posts: 21
Joined: Mon Dec 07, 2015 2:55 pm

Re: Why Is This So Hard?How do I Monitor a UPS? (check_apcup

Post by Moneer81 »

lmiltchev wrote:First you will need to make sure this works from the command line. Have you tried something like this?

Code: Select all

/usr/local/nagios/libexec/check_apcupsd.sh -h <device IP address> -w <warning threshold> -c <critical threshold> -p <port number> bcharge
I am not sure what port needs to be used, but you can run nmap against the device to see which ports are open.

Code: Select all

nmap <device IP address>
Run the following command and show the output:

Code: Select all

ll -d /usr/sbin/apcaccess

I used a different port scanner and showed me which ports were open but here is the output of NMAP which was identical to what my port scanner showed:

Starting Nmap 6.47 ( http://nmap.org ) at 2016-03-04 08:59 CST
Nmap scan report for ups-test-1.myuniversity.edu (172.24.162.60)
Host is up (0.0026s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
23/tcp open telnet
80/tcp open http
443/tcp open https

Nmap done: 1 IP address (1 host up) scanned in 8.46 seconds

That's why I ended up using "-p 23" when I ran the command (see my other post above this one).

Also, did you mean to have me run:
ll -d /sbin/apcaccess instead of ll -d /usr/sbin/apcaccess?
The latter returned an error because /sbin/ is not in the /usr/ directory but the former returned this:

# ll -d /sbin/apcaccess
-rwxr-xr-x 1 root root 31768 Nov 21 2014 /sbin/apcaccess


Thank you for all of your help so far!
Moneer81
Posts: 21
Joined: Mon Dec 07, 2015 2:55 pm

Re: Why Is This So Hard?How do I Monitor a UPS? (check_apcup

Post by Moneer81 »

Box293 wrote:
Moneer81 wrote:
Box293 wrote:Is this a UPS connected to your XI server, or a remote one on the network?
On the network. Nagios XI can see it and ping it and it is currently a monitored host in XI.
I'm pretty sure the plugin you're trying is for locally connected UPS that is running an APC agent, this is not the most common method.

Have a look at this plugin instead:
https://exchange.nagios.org/directory/P ... ps/details
It connects to the UPS via SNMP, so you'll need to configure SNMP on the UPS management interface.

And even more basic is this list of SNMP checks:
https://exchange.nagios.org/directory/P ... ad/details
(ignore the command[xxxx]= bits at the start)


Wow ok ok so your post gave me the first glimmer of hope. I used the plugin that you suggested and I actually got something! I did not know that the one I was using is for a locally connected UPS systems only!

-------
# ./check_snmp_apc_ups -H ups-test-1.myuniversity.edu -C public
Status is OK - Smart-UPS 750 - BATTERY:(capacity 100%, temperature 42 C, runtime 45 minutes, 00.00) INPUT:(voltage 125 V, frequency 60 Hz) OUTPUT:(voltage 111 V, frequency 60 Hz, load 23%) SELF TEST:(Passed on 03/03/2016) LAST EVENT:(No events)
-------


So this works well. Now the question is (and I am sorry for being such a noob) how do I utilize this in XI? For some reason I assumed that I can use this plugin (or any other for that matter) as a service in CCM or use it as a check command. How can leverage a plugin beyond the command line?

Thanks again so much for the helpful tip.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Why Is This So Hard?How do I Monitor a UPS? (check_apcup

Post by Box293 »

Excellent, glad we could get you working.

Follow the steps in this guide which explains how to create a service for it:
https://support.nagios.com/kb/article.php?id=235

Once you understand how this works, a lot of how Nagios works in the backend will start to fall in place and become simpler.

... one day I'll get around to writing a how-to book on Nagios XI, I just need the time!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Moneer81
Posts: 21
Joined: Mon Dec 07, 2015 2:55 pm

Re: Why Is This So Hard?How do I Monitor a UPS? (check_apcup

Post by Moneer81 »

Box293 wrote:Excellent, glad we could get you working.

Follow the steps in this guide which explains how to create a service for it:
https://support.nagios.com/kb/article.php?id=235

Once you understand how this works, a lot of how Nagios works in the backend will start to fall in place and become simpler.

... one day I'll get around to writing a how-to book on Nagios XI, I just need the time!

If you write a book, I will be your first customer!

So I was wondering if there is a trick to making the service show up with all the other services when you define it. I added a host (a UPS), then defined a service (using the plugin that you pointed me to) and also defined a second service for that host (SNMP Traps) but when I look under Service Status Summary, I can't see those two services. Not sure what I am missing here. I followed the instructions in the guide that you linked.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Why Is This So Hard?How do I Monitor a UPS? (check_apcup

Post by tgriep »

Can you find them if you search for them on the service details screen?
The are grouped by the config name, so it the config name doesn't match, it will not be grouped with the host.
If you cannot find it, go back and edit it and make sure the Active check box is checked, save and apply the config and them it should show up.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Why Is This So Hard?How do I Monitor a UPS? (check_apcup

Post by lmiltchev »

I added a host (a UPS), then defined a service (using the plugin that you pointed me to) and also defined a second service for that host (SNMP Traps) but when I look under Service Status Summary, I can't see those two services.
Go to Configure->Core Configuration Manager->Services, and click on your service. Verify that:

1. The service is active
The "Active" check-box under the "Common Settings" tab should be selected.


2. The service is added to your host.
Click on "Manage Hosts" (under the "Common Settings" tab), and make sure you see your host under "Assigned".

Apply Configuration. Did this help?
Be sure to check out our Knowledgebase for helpful articles and solutions!
bwallace
Posts: 1145
Joined: Tue Nov 17, 2015 1:57 pm

Re: Why Is This So Hard?How do I Monitor a UPS? (check_apcup

Post by bwallace »

Additionally, did you encounter any errors during 'Apply Configuration''?

Does the audit log reveal any clues?
Admin > System Information > Audit Log
Be sure to check out the Knowledgebase for helpful articles and solutions!
Moneer81
Posts: 21
Joined: Mon Dec 07, 2015 2:55 pm

Re: Why Is This So Hard?How do I Monitor a UPS? (check_apcup

Post by Moneer81 »

tgriep wrote:Can you find them if you search for them on the service details screen?
The are grouped by the config name, so it the config name doesn't match, it will not be grouped with the host.
If you cannot find it, go back and edit it and make sure the Active check box is checked, save and apply the config and them it should show up.
Yes they have the same config name, and the Active box is checked.
Moneer81
Posts: 21
Joined: Mon Dec 07, 2015 2:55 pm

Re: Why Is This So Hard?How do I Monitor a UPS? (check_apcup

Post by Moneer81 »

lmiltchev wrote:
I added a host (a UPS), then defined a service (using the plugin that you pointed me to) and also defined a second service for that host (SNMP Traps) but when I look under Service Status Summary, I can't see those two services.
Go to Configure->Core Configuration Manager->Services, and click on your service. Verify that:

1. The service is active
The "Active" check-box under the "Common Settings" tab should be selected.


2. The service is added to your host.
Click on "Manage Hosts" (under the "Common Settings" tab), and make sure you see your host under "Assigned".

Apply Configuration. Did this help?
I have already done that. The is checked, and it is assigned to the correct host.

I did not encounter any errors and I did apply the configuration.

If I go to CCM, I see 25 services.

If I go to Service Status, I just see 23 services.

I really really want to like Nagios but it has been such a frustrating experience for a newbie...
Locked