hi,

for a nagios (monitoring system) check I need to scrape a web site
(this is for a network device, a UPS, whatever). This particular
device only offers some functionality through a web interface.

I get the content of the site using WWW::Mechanize after login in
(this is really simple using the submit_form method, by the way).

Then I save the text of the website in a variable like this:

my $text = $mech->text();

if ( $text =~ /critical alarm/i ) {
    print "Bingo\n";
}

This works, if I unplug something I get the critical alarm, I replug
the stuff and the string does not match anymore.

$text has this (very long line):

APC | UPS Network Management Card 2Skip to Main ContentUPS Network
Management Card 2Smart-UPS/Matrix Application 1user | English | Log
Off | Help |    HomeStatusUPSNetworkControlUPSSecuritySession
ManagementNetworkReset/Reboot ConfigurationPower SettingsShutdownUPS
GeneralSelf-Test ScheduleSchedulingPowerChute ClientsSync ControlThird
Party SupportEnergyWiseSecuritySession ManagementPing ResponseLocal
UsersManagementDefault SettingsRemote
UsersAuthenticationRADIUSFirewall ConfigurationActive PolicyActive
RulesCreate/Edit PolicyLoad PolicyTestNetworkTCP/IPIPv4 SettingsIPv6
SettingsPort SpeedDNS ConfigurationTestWebAccessSSL
CertificateConsoleAccessSSH Host KeySNMPv1AccessAccess
ControlSNMPv3AccessUser ProfilesAccess ControlFTP
serverNotificationEvent ActionsBy EventBy
GroupE-mailServerRecipientsSSL CertificatesTestSNMP TrapsTrap
ReceiversTestRemote
MonitoringGeneralIdentificationDate/TimeModeDaylight SavingsUser
Config FileQuick LinksLogsSyslogServersSettingsTestTestsUPSNetworkLed
BlinkLogsEventsLogReverse
LookupSizeDataLogIntervalRotationSizeFirewallAboutUPSNetworkSupport
Smart-UPS 1400 RM: 1 Critical Alarm PresentA site wiring fault exists.
 Recent Device Events  DateTimeEventMore Events ›   Knowledge Base |
Schneider Electric Product Center | Schneider Electric Downloads ©
2012, Schneider Electric. All rights reserved.

I am only interested in the text '1 Critical Alarm PresentA site
wiring fault exists'; is it possible to match this is a simple way (in
fact, the text after 'Critical Alarm Present' may vary, it would be
awesome to be able to get that easily. Otherwise I am afraid I will
have to start parsing html with HTML::TableExtract

--
Groeten,
natxo

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to