APC UPS Data Center & Enterprise Solutions Forum
Schneider, APC support forum to share knowledge about installation and configuration for Data Center and Business Power UPSs, Accessories, Software, Services.
Posted: โ2021-06-28 03:18 AM . Last Modified: โ2024-03-18 04:45 AM
Link copied. Please paste this link to share this article on your social media post.
Posted: โ2021-06-28 03:18 AM . Last Modified: โ2024-03-18 04:45 AM
I'd like to be able to grab the pages from the PDU webserver via the command line, say using wget. I have succeeded in downloading config.ini over ftp with wget, but have had no joy with the olgroups.htm page. Can you help, please?
Below is a snip of my attempt. I've replaced the host and IP to protect the innocent, and limited tries to 1, since the default is 20 and they all fail ๐
"
wget --debug -t 1 -x --no-check-certificate [https://pdu-host/olgroups.htm]
Setting --tries (tries) to 1
Setting --force-directories (dirstruct) to 1
Setting --check-certificate (checkcertificate) to 0
DEBUG output created by Wget 1.10.2 (Red Hat modified) on linux-gnu.
--09:12:15-- [https://pdu-host/olgroups.htm]
Resolving pdu-host... w.x.y.z
Caching pdu-host => w.x.y.z
Connecting to pri-pdu-1|w.x.y.z|:443... connected.
Created socket 3.
Releasing 0x085e67a0 (new refcount 1).
Initiating SSL handshake.
Handshake successful; connected socket 3 to SSL handle 0x085e6ba8
certificate:
WARNING: Certificate verification error for pri-pdu-1: unable to get local issuer certificate
WARNING: certificate common name `ZA0621015694' doesn't match requested host name `pri-pdu-1'.
---request begin---
GET /olgroups.htm HTTP/1.0
User-Agent: Wget/1.10.2 (Red Hat modified)
Accept: */*
Authorization: Basic YXBjOmlOME9wWWli
Host: pri-pdu-1
Connection: Keep-Alive
---request end---
HTTP request sent, awaiting response... No data received.
Closed 3/SSL 0x85e6ba8
Giving up.
"
Thanks in advance
Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: โ2021-06-28 03:18 AM . Last Modified: โ2024-03-18 04:45 AM
Alright, I've used both curl and wget to grab web pages off of an NMC running AOS 3.5.7. Here are commands I used under Cygwin for four different configurations: curl with http, curl with https, wget with http, and wget with https. I've broken up long lines with the line continuation character '\' which should work in your shell.
1. curl with http:
curl -b apccookie -c apccookie -k http://NMC_IP/logon.htm > /dev/null
curl -b apccookie -c apccookie -k http://NMC_IP/Forms/login1 \
-d login_username=apc -d login_password=apc > /dev/null
curl -b apccookie -c apccookie -k http://NMC_IP/home.htm
curl -b apccookie -c apccookie -k http://NMC_IP/logout.htm > /dev/null
2. curl with https:
curl -b apccookie -c apccookie -k https://NMC_IP/logon.htm > /dev/null
curl -b apccookie -c apccookie -k https://NMC_IP/Forms/login1 \
-d login_username=apc -d login_password=apc > /dev/null
curl -b apccookie -c apccookie -k https://NMC_IP/home.htm
curl -b apccookie -c apccookie -k https://NMC_IP/logout.htm > /dev/null
3. wget with http:
wget --load-cookies apccookie --save-cookies apccookie --keep-session-cookies \
http://NMC_IP/logon.htm -o /dev/null
wget --load-cookies apccookie --save-cookies apccookie --keep-session-cookies \
http://NMC_IP/Forms/login1 -o /dev/null \
--post-data 'login_username=apc&login_password=apc'
wget --load-cookies apccookie --save-cookies apccookie --keep-session-cookies \
http://NMC_IP/home.htm
wget --load-cookies apccookie --save-cookies apccookie --keep-session-cookies \
http://NMC_IP/logout.htm -o /dev/null
4. wget with https:
wget --load-cookies apccookie --save-cookies apccookie --keep-session-cookies \
--no-check-certificate -t 1 https://NMC_IP/logon.htm -o /dev/null
wget --load-cookies apccookie --save-cookies apccookie --keep-session-cookies \
--no-check-certificate -t 1 https://NMC_IP/Forms/login1 -o /dev/null \
--post-data 'login_username=apc&login_password=apc'
wget --load-cookies apccookie --save-cookies apccookie --keep-session-cookies \
--no-check-certificate -t 1 https://NMC_IP/home.htm
wget --load-cookies apccookie --save-cookies apccookie --keep-session-cookies \
--no-check-certificate -t 1 https://NMC_IP/logout.htm -o /dev/null
Using wget with https did have one issue: it would successfully complete the https GET or POST, but aftewards it would display an error: "Read error at byte 2872 (error:1408F119:SSL routines:SSL3_GET_RECORD:decryption failed or bad record mac).Giving up." Then it would retry over and over again. Since it was actually successful, I bypassed the problem by setting the number of retries to 1 (-t 1).Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: โ2021-06-28 03:18 AM . Last Modified: โ2024-03-18 04:45 AM
i personally have no experience with this but I will see if Cap1 (another user here) has any insight for you.
Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: โ2021-06-28 03:18 AM . Last Modified: โ2024-03-18 04:45 AM
Do you specifically need the web output?
Or are you just interested in the data that is contained within the web pages?
I can't help you with using wget to grab the web pages, however if you're just out to get the data from your PDU I would recommend utilizing SNMP to get the data you're looking for. If you use a MIB browser to view an APC PDU you'll see all the data you might want. At that point you can pick and choose which OIDs to poll and record through a script.
If you go to http://www.apcc.com/tools/download/ and select firmware upgrades - all in the first dropdown box you can find a current version of our MIB.
Link copied. Please paste this link to share this article on your social media post.
Posted: โ2021-06-28 03:18 AM . Last Modified: โ2024-03-18 04:45 AM
Link copied. Please paste this link to share this article on your social media post.
Posted: โ2021-06-28 03:18 AM . Last Modified: โ2024-03-18 04:45 AM
Many thanks to "i picKed a winna" and " APCbean".
I'm not overly fussed that I get the web page - it is the content that I seek, but the work environment is somewhat paranoid regarding security, and deploying additional software, such as the MIB browser will take much paperwork and many levels of sign-off before being finally disallowed, no doubt.
So, just to summarize my requirement, I want a command-line that I can run from Linux (Red Hat EL AS r4.5) to write content from the PDUs to text files that I can parse with awk/perl, etc. Just now I want the content from the olgroups.htm page, but its likely that I'll want other pages in future.
Any ideas?
Thanks in advance.
Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: โ2021-06-28 03:18 AM . Last Modified: โ2024-03-18 04:45 AM
If you're using Red Hat Linux, you probably already have the Net-SNMP suite of command line utilities. For instance, try using snmpget.
As for the wget log you posted, I hope you or one of the administrators will scrub your password out of the log. And speaking of password, while I'm not familiar with the PDU firmware you're using, I assume it's a 3.x.x one. Unlike the 2.x.x firmwares, the 3.x.x ones use a custom password page and a cookie rather than HTTP Basic Auth. Logging into the card via the web therefore requires doing a POST against the login page to get the cookie, and then using that to retrieve your desired page.
I'm not sure if that explains the results you're getting. On Monday I will have to try using wget to log into an NMC set up for https.
Link copied. Please paste this link to share this article on your social media post.
Link copied. Please paste this link to share this article on your social media post.
Posted: โ2021-06-28 03:18 AM . Last Modified: โ2024-03-18 04:45 AM
Alright, I've used both curl and wget to grab web pages off of an NMC running AOS 3.5.7. Here are commands I used under Cygwin for four different configurations: curl with http, curl with https, wget with http, and wget with https. I've broken up long lines with the line continuation character '\' which should work in your shell.
1. curl with http:
curl -b apccookie -c apccookie -k http://NMC_IP/logon.htm > /dev/null
curl -b apccookie -c apccookie -k http://NMC_IP/Forms/login1 \
-d login_username=apc -d login_password=apc > /dev/null
curl -b apccookie -c apccookie -k http://NMC_IP/home.htm
curl -b apccookie -c apccookie -k http://NMC_IP/logout.htm > /dev/null
2. curl with https:
curl -b apccookie -c apccookie -k https://NMC_IP/logon.htm > /dev/null
curl -b apccookie -c apccookie -k https://NMC_IP/Forms/login1 \
-d login_username=apc -d login_password=apc > /dev/null
curl -b apccookie -c apccookie -k https://NMC_IP/home.htm
curl -b apccookie -c apccookie -k https://NMC_IP/logout.htm > /dev/null
3. wget with http:
wget --load-cookies apccookie --save-cookies apccookie --keep-session-cookies \
http://NMC_IP/logon.htm -o /dev/null
wget --load-cookies apccookie --save-cookies apccookie --keep-session-cookies \
http://NMC_IP/Forms/login1 -o /dev/null \
--post-data 'login_username=apc&login_password=apc'
wget --load-cookies apccookie --save-cookies apccookie --keep-session-cookies \
http://NMC_IP/home.htm
wget --load-cookies apccookie --save-cookies apccookie --keep-session-cookies \
http://NMC_IP/logout.htm -o /dev/null
4. wget with https:
wget --load-cookies apccookie --save-cookies apccookie --keep-session-cookies \
--no-check-certificate -t 1 https://NMC_IP/logon.htm -o /dev/null
wget --load-cookies apccookie --save-cookies apccookie --keep-session-cookies \
--no-check-certificate -t 1 https://NMC_IP/Forms/login1 -o /dev/null \
--post-data 'login_username=apc&login_password=apc'
wget --load-cookies apccookie --save-cookies apccookie --keep-session-cookies \
--no-check-certificate -t 1 https://NMC_IP/home.htm
wget --load-cookies apccookie --save-cookies apccookie --keep-session-cookies \
--no-check-certificate -t 1 https://NMC_IP/logout.htm -o /dev/null
Using wget with https did have one issue: it would successfully complete the https GET or POST, but aftewards it would display an error: "Read error at byte 2872 (error:1408F119:SSL routines:SSL3_GET_RECORD:decryption failed or bad record mac).Giving up." Then it would retry over and over again. Since it was actually successful, I bypassed the problem by setting the number of retries to 1 (-t 1).Link copied. Please paste this link to share this article on your social media post.
Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.