Hi all,

I'm trying to get a perl script working and having a little trouble. If anyone knows of the Xymon monitoring tool, this is a server side script that I am working on.

I'm looking to check the Xymon client data to see if a partcular service is running but I can seem to get the if to work.

It's always dropping through to the "else" section whether "service.exe" is in $sections{"procs"} or not.

Any help would be very much appreciated. This is the particular piece of code,
if ( $sections{"procs"} !~ m/service.exe/ ) { $color = "yellow"; $summary = "`/bin/date` CAWA Server service is not run +ning."; $statusmsg = "&yellow service.exe not running. Possibl +e failover to ukclasce002. Inform OSG before 8:30am.\n\n" . $s ections{"procs"}; } else { $color = "green"; $summary = "`/bin/date` CAWA Server service OK $os"; $statusmsg = "&green service.exe running ok.\n\n" . $s +ections{"procs"}; }
and this is that data contained in $sections{"procs"}
PID Name 0 Idle 4 System 352 smss.exe 400 csrss.exe 424 winlogon.exe 472 services.exe 484 lsass.exe 644 vmacthlp.exe 684 svchost.exe 752 svchost.exe 816 svchost.exe 840 svchost.exe 856 svchost.exe 996 spoolsv.exe 1196 cagent32.exe 1228 xferwan.exe 1252 svchost.exe 1400 FrameworkService.exe 1832 sqlservr.exe 1868 svchost.exe 1916 sqlwriter.exe 2076 VMwareService.exe 2156 VMUpgradeHelper.exe 2208 tlmagent.exe 2320 wmiprvse.exe 2948 svchost.exe 3380 dllhost.exe 3812 wmiprvse.exe 4040 svchost.exe 2972 lpx86.exe 9900 mfevtps.exe 7904 mcshield.exe 7984 VsTskMgr.exe 4912 mfeann.exe 7112 naPrdMgr.exe 9348 explorer.exe 3176 VMwareTray.exe 3656 VMwareUser.exe 9988 UdaterUI.exe 6696 VProTray.exe 8868 ctfmon.exe 8296 WindowsSearch.exe 6656 McTray.exe 5476 VProSvc.exe 8316 SymSnapService.exe 3292 logon.scr 7876 csrss.exe 360 winlogon.exe 180 rdpclip.exe 9580 explorer.exe 1368 VMwareTray.exe 1512 VMwareUser.exe 6440 VProTray.exe 1332 shstat.exe 1552 ctfmon.exe 140 WindowsSearch.exe 5284 mmc.exe 9324 mmc.exe 8872 BBWin.exe 9712 service.exe

In reply to Check for data in array by fazedandconfused

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.