1 2 Previous Next 26 Replies Latest reply: Dec 24, 2012 8:30 AM by capavneesh@gmail.com RSS

mquery - hexidecimal time/date converter

Michael Funke

All,


I've been pulling out events using mquery to investigate certain things and I noticed that the dates/times come out in the hexidecimal format. I wrote a perl converter to help parse through this information and return a readable date/time value.


Regards,


Michael Funke

  • 1. RE: mquery - hexidecimal time/date converter
    nhshaikh

    Hi,

    could you tell us how to use this perl script along with mquery.

  • 2. RE: mquery - hexidecimal time/date converter
    Michael Funke

    nhshaikh,


    I created a perl script that runs mquery to extract events from the mcell db. The script is run every hour and populates a database that we keep separate in order to do event reporting. I didn't like the limited functionality of the BMC Event Management Reporting piece, so I built my own. As part of this offering, is the associated time/date converter that was mentioned in my previous posting.

    I was thinking about becoming a BMC Partner and offering these kinds of products and services at some point in addition to a few others. After I have compiled and tested it on several different OS's, you may see an announcement from me on an alternative reporting tool for event reporting. This requirement is highly needed in companies that use Impact Explorer by their operations teams to be the first responders. More detailed reporting is required in order for this to be a success.


    Regards,


    Michael Funke

  • 3. RE: mquery - hexidecimal time/date converter
    nhshaikh

    Hi,


    Can i have that script that will extract the events information and dumped into database.

    currently we are using mquery to get the details in csv format.

  • 4. mquery - hexidecimal time/date converter
    Shweta2515

    HI Michael,

     

    Can you please explain where we have to put this script and then how we can use this?

     

    Regards,

    Shweta

  • 5. Re: mquery - hexidecimal time/date converter
    Ferry Bolhar

    I also wrote a similar script some long time ago - it's called mqt.pl and looks like this:

     

    #!/usr/bin/perl -pw

     

    use POSIX 'strftime';

     

    s[(\w*(?:date|time)\w*)=(\d{10});$]

      [sprintf "%s='%s';", $1, strftime('%Y-%m-%d %H:%M:%S', localtime $2)]ie;

     

    #--------------END--------------

     

    You simply pipe this script to the output of mquery:

     

    mquery -n <cell> -f baroc | mqt.pl

     

    In all lines containing slots with 'time' or 'date' in their names and a 10-digit-epoch as value, the epoch is replaced with its text representation. Note that I've tried to preserve MRL syntax by placing the date and time string under single quotes and adding the trailing semicolon.

  • 6. Re: mquery - hexidecimal time/date converter
    rashmi_joshi01

    Hi Ferry,

     

    I too am trying to get the time converted to a readable format.

    I tried to use it in the way you mentioned but the times were in the same hex format unless I am missin something.

    trying to run the following query

     

    mquery -a EVENT -n <cellname> -w "severity: == CRITICAL AND status: == CLOSED AND date: between[20121217, 20121218]" -s "date,severity,msg,status,mc_operations,mc_notes,mc_date_modification" -v -f BAROC > xyz1309.csv | mqt.pl

     

    I want to capture the correct time format for mc_operations and mc_notes field. Please advise how do I achieve this using your script.

     

    Thanks in advance

    Rashmi

  • 7. Re: mquery - hexidecimal time/date converter
    Ferry Bolhar

    Add the names of the slots you want to process this way to the already existing names:

     

    s[\w*(?:date|time|mc_(?:operations|notes)\w*)=(\d{10});$] ...

  • 8. Re: mquery - hexidecimal time/date converter
    rashmi_joshi01

    Thanks for the information Ferry, but where will I get the report saved? Is the query that I run correct? I redirect the output to a file xyz1309.baroc and then use pipe and the script.

    mquery -a EVENT -n -w "severity: == CRITICAL AND status: == CLOSED AND date: between[20121217, 20121218]" -s "date,severity,msg,status,mc_operations,mc_notes,mc_date_modification" -v -f BAROC > xyz1309.baroc | mqt.pl

     

    It still gives the hex date. Can you please explain the step by step process I need to follow and where will I get the data?

     

    Thanks and Regards

    Rashmi Joshi

  • 9. Re: mquery - hexidecimal time/date converter
    Ferry Bolhar

    Well, these are shell basics, but anyway:

     

    If you want to save the output of mquery in a file while using my filter, the redirection operator must be the LAST item in your command line:

     

    mquery .... | mqt.pl > xyz1309.baroc

  • 10. Re: mquery - hexidecimal time/date converter
    rashmi_joshi01

    Yes, I had tried even that, but the baroc file comes as blank, if we do not want to redirect it to a file where is the data saved and how do we verify the time stamps are converted?

     

    Regards

    Rashmi

  • 11. Re: mquery - hexidecimal time/date converter
    Ferry Bolhar

    Which OS are you working under? What is the output of mquery without any piping or redirection? Have you verified that there are events matching your selection criterias?

     

    And just one note on command syntax - the -n option specifies the target cell you want to access, so it requires an argument, e.g.:

     

    -n mycell

     

    (wheren "mycell" is the cell name which must be registered in mcell.dir).

     

    In your command, the cell name is missing.Where did you get this command from?

  • 12. Re: mquery - hexidecimal time/date converter
    rashmi_joshi01

    Ferry,

     

    OS is windows and I have used mquery lot of times to get the event data and reports for the criteria I have mentioned. I had not mentioned the cell name in the post due to security reasons here but I know how to use it.

    The mquery that you mentioned, when I use it just opens the perl script and when I close the file it returns to the command prompt.

    I have placed the perl script in the perl directory. I am trying to understand why the script does not return the expected events with the time format converted.

     

    Regards

    Rashmi Joshi

  • 13. Re: mquery - hexidecimal time/date converter
    Ferry Bolhar

    It's never a good idea to post an incomplete command! How should I know that you've omitted somewhat "for security reasons"? If you actually want to omit some part, replace it with a small text, eg:

     

    -n <cellname>

     

    BTW: I can't see any risk to post a cell name here, but it's up to you... Did you have omitted further parts of the command for security reasons? If so, please post them as suggested.

     

    And my initial question was to run the mquery command WITHOUT redirection and WITHOUT the perl script. Just the mquery command, and post its output here.

  • 14. Re: mquery - hexidecimal time/date converter
    rashmi_joshi01

    Please see the output without any redirection or perl script

     

    C:\Program Files\BMC Software\ProactiveNet>mquery -a EVENT -n pncell_BPPM01 -w " severity: == CRITICAL AND status: == CLOSED AND date: between[20121217, 20121218]" -s "date" -v -f BAROC

    BMC Impact Query 8.6.02 (Build 221073454 - 24-Jun-2011)

    Copyright 1998-2011 BMC Software, Inc. as an unpublished work.  All rights reser

    ved.

1 2 Previous Next