<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Perl script needed in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-needed/m-p/4779516#M640904</link>
    <description>Hi All!&lt;BR /&gt;&lt;BR /&gt;Here is what I have currently - &lt;BR /&gt;&lt;BR /&gt;curl &lt;A href="http://host.domain.com:8000/Jboss/Service.jbs/america?method=geturls" target="_blank"&gt;http://host.domain.com:8000/Jboss/Service.jbs/america?method=geturls&lt;/A&gt;|grep host.domain.com |awk '{print $1,$3}'&lt;BR /&gt;&lt;BR /&gt;"OrderApp" "&lt;A href="http://host.domain.com:8100/apps/Orderinfo" target="_blank"&gt;http://host.domain.com:8100/apps/Orderinfo&lt;/A&gt;";&lt;BR /&gt;"EmailAppTest" "&lt;A href="http://host.domain.com:5100/apps/email" target="_blank"&gt;http://host.domain.com:5100/apps/email&lt;/A&gt;";&lt;BR /&gt;...&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;I need to strip out the following words - &lt;BR /&gt;&lt;BR /&gt;OrderApp host.domain.com 8100 &lt;BR /&gt;EmailAppTest host.domain.com 5100&lt;BR /&gt;...&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;So appname , host &amp;amp; port from above.&lt;BR /&gt;Then once I have that I can echo that to generate properties files through a while loop.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Allan.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Thu, 21 Apr 2011 19:16:41 GMT</pubDate>
    <dc:creator>Allanm</dc:creator>
    <dc:date>2011-04-21T19:16:41Z</dc:date>
    <item>
      <title>Perl script needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-needed/m-p/4779513#M640901</link>
      <description>Hi!&lt;BR /&gt;&lt;BR /&gt;I have a curl call which gets me the following output:&lt;BR /&gt;&lt;BR /&gt;curl &lt;A href="http://hostname1.qa.com:8888/getlist" target="_blank"&gt;http://hostname1.qa.com:8888/getlist&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;OUTPUT - &lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt; "token" = "201119041112";&lt;BR /&gt; "apps" = {&lt;BR /&gt;                 "PaymentApp" = "&lt;A href="http://hostname1.qa.com:2333/cgi-bin/Jboss/PaymentApp-EMEA.woa/paymentInfo" target="_blank"&gt;http://hostname1.qa.com:2333/cgi-bin/Jboss/PaymentApp-EMEA.woa/paymentInfo&lt;/A&gt;";&lt;BR /&gt;  "OrderConsumer" = "&lt;A href="http://hostname.qa2.com:2345/apps/orders" target="_blank"&gt;http://hostname.qa2.com:2345/apps/orders&lt;/A&gt;";&lt;BR /&gt;...&lt;BR /&gt; };&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Based on the curl call which is being made to a specific URL ,  I need to parse out URL entries which are of similar pattern as the URL to which the call was made (&lt;A href="http://hostname1.qa.com)" target="_blank"&gt;http://hostname1.qa.com)&lt;/A&gt; - &lt;BR /&gt;&lt;BR /&gt;I need to scrub out only entries which have hostname1 in them.&lt;BR /&gt;&lt;BR /&gt;Then I need to populate a couple of properties files which look like this with the appname (e.g. PaymentApp) , URL(&lt;A href="http://hostname1.qa.com:2333)," target="_blank"&gt;http://hostname1.qa.com:2333),&lt;/A&gt; host(hostname1.qa.com) , port(e.g. 2333) , env (e.g. qa) information that I gathered from above - &lt;BR /&gt;&lt;BR /&gt;file1 - &lt;BR /&gt;&lt;BR /&gt;define service{&lt;BR /&gt; host_name $hostname&lt;BR /&gt; use    generic-service&lt;BR /&gt; servicegroups preprod apps&lt;BR /&gt; service_description $appname&lt;BR /&gt; is_volatile   0&lt;BR /&gt; check_period   24x7&lt;BR /&gt; max_check_attempts  3&lt;BR /&gt; normal_check_interval  2&lt;BR /&gt; retry_check_interval  1&lt;BR /&gt; contact_groups   admin&lt;BR /&gt; notification_interval  120&lt;BR /&gt; notification_period  24x7&lt;BR /&gt; notification_options  w,u,c,r&lt;BR /&gt; process_perf_data 0&lt;BR /&gt; check_command   url-check_$env_$port&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;file2 -&lt;BR /&gt;&lt;BR /&gt;define command{&lt;BR /&gt;command_name    url-check_$env_$port&lt;BR /&gt;command_line    $USER1$/url-check -H $hostname -p $port -r added --regex=alive -t 4&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I have a way of doing this in shell and now looking for a way to do this in perl.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Allan.</description>
      <pubDate>Wed, 20 Apr 2011 05:31:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-needed/m-p/4779513#M640901</guid>
      <dc:creator>Allanm</dc:creator>
      <dc:date>2011-04-20T05:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-needed/m-p/4779514#M640902</link>
      <description>Hi Allan:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; I have a way of doing this in shell and now looking for a way to do this in perl.&lt;BR /&gt;&lt;BR /&gt;OK, so...&lt;BR /&gt;&lt;BR /&gt;If I had to guess, I'd guess that this is all about Nagios and a plan to refactor shell scripts into pure Perl.  Correct?&lt;BR /&gt;&lt;BR /&gt;It's not going to help you (or me) if I provide full-blown solutions for you.  You will be better served by trying and learning by trail-and-error.  If you are serious, and you haven't already looked here, do so:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.perl.org/learn.html" target="_blank"&gt;http://www.perl.org/learn.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 20 Apr 2011 11:39:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-needed/m-p/4779514#M640902</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-04-20T11:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-needed/m-p/4779515#M640903</link>
      <description>&lt;!--!*#--&gt;Hi Allan,&lt;BR /&gt;&lt;BR /&gt;although the curl output already seems to be quite ordered which maybe suggests to better make up some parsing grammar and feed modules like Parse::RecDescent or similar with it, one could tinker up some weird regexp like this to capture the items you are interested in:&lt;BR /&gt;&lt;BR /&gt;open CURL, "/usr/bin/curl $fetchurl |" &lt;BR /&gt;    or die "cannot pipe from curl\n";&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    if (my ($app, $url, $host, $env, $port) = $_ =~&lt;BR /&gt;    m{"([^"]+)"\s+=\s+"?(http://(hostname1)\.([^.]+)\.[^:]+:(\d+)/.*)}) {&lt;BR /&gt;&lt;BR /&gt;      # process $app, $host, $url, $port, $env etc. here        &lt;BR /&gt;&lt;BR /&gt;  &lt;BR /&gt;    }&lt;BR /&gt;close CURL;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;However, I would reconsider if you really want to define a separate Nagios service object for each parsed URL.&lt;BR /&gt;I probably would rather define a single service object and use a check_multi check command on it.&lt;BR /&gt;(see &lt;A href="http://my-plugin.de/wiki/projects/check_multi/start" target="_blank"&gt;http://my-plugin.de/wiki/projects/check_multi/start&lt;/A&gt; , sorry not clickable to preserve code spacing)&lt;BR /&gt;&lt;BR /&gt;You could also define custom variable macros which you could refer to as e.g. $_HOSTMY_CUSTOM_MACRO$ in a single service definition.&lt;BR /&gt;See  &lt;A href="http://nagios.sourceforge.net/docs/3_0/customobjectvars.html" target="_blank"&gt;http://nagios.sourceforge.net/docs/3_0/customobjectvars.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;And don't forget that you can pass arguments to your check command as well like&lt;BR /&gt;&lt;BR /&gt;define service {&lt;BR /&gt;   ...&lt;BR /&gt;   check_command   url-check!$_HOSTENV$!$_HOSTPORT$ &lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;But probably there isn't much gain because this way you would have a host of host definitions.&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Apr 2011 13:00:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-needed/m-p/4779515#M640903</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2011-04-20T13:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-needed/m-p/4779516#M640904</link>
      <description>Hi All!&lt;BR /&gt;&lt;BR /&gt;Here is what I have currently - &lt;BR /&gt;&lt;BR /&gt;curl &lt;A href="http://host.domain.com:8000/Jboss/Service.jbs/america?method=geturls" target="_blank"&gt;http://host.domain.com:8000/Jboss/Service.jbs/america?method=geturls&lt;/A&gt;|grep host.domain.com |awk '{print $1,$3}'&lt;BR /&gt;&lt;BR /&gt;"OrderApp" "&lt;A href="http://host.domain.com:8100/apps/Orderinfo" target="_blank"&gt;http://host.domain.com:8100/apps/Orderinfo&lt;/A&gt;";&lt;BR /&gt;"EmailAppTest" "&lt;A href="http://host.domain.com:5100/apps/email" target="_blank"&gt;http://host.domain.com:5100/apps/email&lt;/A&gt;";&lt;BR /&gt;...&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;I need to strip out the following words - &lt;BR /&gt;&lt;BR /&gt;OrderApp host.domain.com 8100 &lt;BR /&gt;EmailAppTest host.domain.com 5100&lt;BR /&gt;...&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;So appname , host &amp;amp; port from above.&lt;BR /&gt;Then once I have that I can echo that to generate properties files through a while loop.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Allan.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Apr 2011 19:16:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-needed/m-p/4779516#M640904</guid>
      <dc:creator>Allanm</dc:creator>
      <dc:date>2011-04-21T19:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-needed/m-p/4779517#M640905</link>
      <description>Hi Allan:&lt;BR /&gt;&lt;BR /&gt;# perl -nle 'm{(OrderApp|EmailAppTest)".*?//(.*):(\d+)/} and print "$1 $2 $3"' file&lt;BR /&gt;&lt;BR /&gt;...or from a pipe, of course, in lieu of a file...&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 21 Apr 2011 19:49:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-needed/m-p/4779517#M640905</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-04-21T19:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-needed/m-p/4779518#M640906</link>
      <description>Thanks JRF!&lt;BR /&gt;&lt;BR /&gt;The matching can differ so I need a generic solution. &lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Allan.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Apr 2011 20:02:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-needed/m-p/4779518#M640906</guid>
      <dc:creator>Allanm</dc:creator>
      <dc:date>2011-04-21T20:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-needed/m-p/4779519#M640907</link>
      <description>Hi (again) Allan:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; The matching can differ so I need a generic solution. &lt;BR /&gt;&lt;BR /&gt;Of course, you said that.  Try:&lt;BR /&gt;&lt;BR /&gt;# perl -nle 'm{"(.*?)".*?//(.*):(\d+)/} and print "$1 $2 $3"' file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 21 Apr 2011 20:17:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-needed/m-p/4779519#M640907</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-04-21T20:17:57Z</dc:date>
    </item>
  </channel>
</rss>

