DX NetOps

Expand all | Collapse all

Update Spectrum Set Script

  • 1.  Update Spectrum Set Script

    Posted Nov 19, 2014 11:06 AM

    Where in the SetScript in Spectrum can I add the field to include the location of a device that trigger the alarm?  I want to be able to have Spectrum include the physical address of the device when it sends out an alert from SANM. This way the help desk will know that the device that they have been alerted on is located at 123 Main Street, Anytown, USA.  I know that this will involve me editing the location attribute for the device but instead of having to edit the attribute of a 1000 devices could I not just edit the attribute of the global collection to reflect the street address for all devices in that collection and have SAMN include that address on the ticket?



  • 2.  Re: Update Spectrum Set Script

    Posted Nov 19, 2014 11:33 AM

    I believe the setscript file is in the <Spectrum root>\Notifier directory.



  • 3.  Re: Update Spectrum Set Script

    Posted Nov 19, 2014 11:37 AM

    Thanks.  I know where it is at but I want the script to include a new piece of information. I want the alert to show the physical street address of the device that the alert is for.



  • 4.  Re: Update Spectrum Set Script

    Broadcom Employee
    Posted Nov 19, 2014 11:41 AM

    Hi,

         You can add the attribute handle as an EXTRA_ATTRS_AS_ENVVARS=  variable in the .alarmrc file and then add an entry for it in the SetScript.  The SetScript has a good explanation of how to utilize it.

    Cheers

    Jay

     

    Here is the excerpt from the SetScript:


    # Two ways have been added that allows the specification of additional
    # attributes for AlarmNotifier.  You have the option of passing the
    # attributes as environment variables or as arguments, which is reflected
    # in the two new config parameters:
    #
    # EXTRA_ATTRS_AS_ENVVARS and EXTRA_ATTRS_AS_ARGS
    #
    # For most attributes, either method is acceptable, but for multi-line text
    # attributes or for very long attribute values it is recommended to specify
    # these as EXTRA_ATTRS_AS_ENVVARS because of command-line length limitations
    # and Windows behavior that truncates the command-line at the first newline
    # character.

    # If EXTRA_ATTRS_AS_ENVVARS have been specified, they can be just referenced
    # by prepending # SANM_ to the value in the config file, ie:
    #
    #  EXTRA_ATTRS_AS_ENVVARS=0x100c5,0x11f84  means that
    #
    #  $SANM_0x100c5 and $SANM_0x11f84 environment variables to be set, which
    #  can be then be referenced in this script like:
    #
    # IFDESC=$SANM_0x100c5
    # IFALIAS=$SANM_0x11f84
    #
    #  Note: Windows will uppercase these variables, so they need to be referenced
    #        that way - ie. $SANM_0X100C5 and $SANM_0X11F84.
    #
    # Alternatively, if EXTRA_ATTRS_AS_ARGS have been specified, they will be
    # added to the command-line.  For example:
    #
    #  EXTRA_ATTRS_AS_ARGS=0x100c5,0x11f84   means that
    #
    #  the values of these attributes will be added to be argument list passed
    # to this script, and can be referenced like this:
    #
    # IFDESC=$1
    # IFALIAS=$2



  • 5.  Re: Update Spectrum Set Script

    Posted Nov 19, 2014 01:07 PM

    My bad, I miss read the question. 



  • 6.  Re: Update Spectrum Set Script

    Posted Nov 19, 2014 01:53 PM

    Do you know if your devices have the addresses set in their SNMP sysLocation mibs?  If so, then the SANM env vars trick in the setScript would be very simple to pull this in.  (sysLocation = 0x1102e)

     

    If the devices are not populated with this information in their local configs, I would suggest picking a different attribute in Spectrum instead of updating the sysLocation attribute.  By using something else, if your network admins ever DO populate the sysLocation settings on the devices that won’t step on any work you did to organize your collections or alert information in Spectrum.



  • 7.  Re: Update Spectrum Set Script

    Posted Nov 19, 2014 02:14 PM

    is there any way I can get by without having to worry about editing the SNMP location? I have too many devices to have to touch every single device. I was hoping that I could either add an attribute or edit an existing attribute in a global collection so that every device in that collection would have the same location attribute and then be able to have SAMN pull in that attribute and include that device location as part of the alert that it sends out.  Right now when SAMN send out an alert once important piece of information is "Where is that device" is missing



  • 8.  Re: Update Spectrum Set Script

    Posted Nov 20, 2014 09:00 AM

    You can include static text in your notifications, but then I think you need to use a different SANM policy for each physical address.  Then, each SANM policy would need the associated filters for where to send the notifications.



  • 9.  Re: Update Spectrum Set Script

    Broadcom Employee
    Posted Nov 20, 2014 09:09 AM

    There are several ways you could do this.  You can use a different attribute (Notes field, one of the USER_ ones used by Report Manager for asset information, make your own in Model Type Editor, etc.) in Spectrum to hold the location value you'd like and pass that attribute along the way Jason mentioned above.  You could also make use of the Location (World, Region, Site, etc.) hierarchy in Spectrum and pass that along.  I don't have Spectrum in front of me right now but if you like, I'll see if I can post some examples later on.

     

    -Rob



  • 10.  Re: Update Spectrum Set Script

    Posted Nov 20, 2014 06:30 PM

    Can you post more information about the location hierarchy? Here is what I am trying to accomplish. I have a very large network spread out over the US with over 100 remote sites. I have a collection/Network Container for each site. 


    Ex. BMW of Beverly Hills

    In that container I have all the devices that belong to that site. I have too many devices to go through each and fill in the SNMP Location.


    Whenever a device triggers an alert I get the alert but no where in the ticket is the location for the help desk. 


    What I am hoping I can do is to assign the collection the site name, address, etc so that when ever a device in that collection triggers an alert the site information is contained in the alert sent out by the SANM



  • 11.  Re: Update Spectrum Set Script

    Broadcom Employee
    Posted Nov 20, 2014 07:11 PM

    In Spectrum, there is a location based hierarchy under what is called "World":

     

     

    You can create a hierarchy of countries, sites/regions, buildings, floors/rooms, etc.  There is clip art included in Spectrum with various maps, rooms, racks, etc.  You can also import PNG files from Google maps, floor plans, etc.  The one advantage of it is you can build a nice map view with a "push pin" view and have a location based view that includes roll ups (is it all of California that is having issues, etc.).  In my quick example, the attribute of interest for SANM is LocationModelNameString (0x129e9):

     

     

    The advantage to using this is that the out of the box AlarmNotifier scripts will use this information:

     

    Alarm Notification from SPECTRUM

     

    Alarm SET:

     

    Date:             11/04/2014

    Time:             10:21:57

    DeviceType:       Cisco AirCt 2504K9

    Mtype:            GnCiscoDev

    ModelName:        Sim21614:WLC1

    AlarmID:          6754

    Severity:         MINOR

    ProbableCauseID:  10203

    RepairPerson:   

    AlarmStatus:     

    SpectroSERVER:    speclinux

    Landscape:        0x400000

    ModelHandle:      0x4000fb

    ModelTypeHandle:  0x2100cb

    IPAddress:        10.241.248.128

    SecurityString: 

    AlarmState:       EXISTING

    Acknowledged:     FALSE

    UserClearable:    TRUE

    Location:         World:United States:California:Beverly Hills:BMW of Beverly Hills:Wiring Closet

    AlarmAge:         0

    NotificationData:

     

    ProbableCause:    DIFFERENT TYPE MODEL

     

    The drawback to this approach is that you need to maintain a separate hierarchy of devices.  The location views predate Global Collections and don't populate based on searches, etc.  They're not as popular as they used to be but they can be very useful since you can use them in SANM policies are filter on hierarchy (California notifications covering multiple sites):

     

     

    Hopefully this works for you.  If not, I can show the attribute based approach.

     

    -Rob



  • 12.  Re: Update Spectrum Set Script

    Posted Nov 20, 2014 07:24 PM

    What does the attribute approach look like? And what are the pros and cons between the two choices? Your help is greatly appreciated 



  • 13.  Re: Update Spectrum Set Script

    Broadcom Employee
    Posted Nov 20, 2014 11:26 PM

    The attribute approach is based on setting an attribute value on a model (Location - 0x2300d, DeviceLocation - 0x118cd, or perhaps a different one such as notes, etc.) and passing that to AlarmNotifier.  The pro for this approach is if you have a CMDB or some other location where you have a mapping of device and location, you can script the update of these attributes.  The downside is that the attribute needs to be set on ever device that you want a location value on.  With a hierarchy approach, you can still script this but now you're creating relationships between container models and device models which might be a little trickier to script.  You're also counting on a hierarchy of containers which, depending on the number of locations and devices per location could get unwieldy.  If you have 200 devices each at a different location, you'll need at least 200 containers for them to reside in.  With the attribute approach, you can put them in the same container and still be aware of the location.

     

    I almost forgot to mention that if you need a location value of something like "273 CORPORATE DR PORTSMOUTH, NH03801-6807" to do something like integrate with Google Maps, etc., then you'll probably need to do this via the attribute based approach.  In a hierarchy, you'll get something like "World:United States:New Hampshire:Portsmouth:273 Corporate Drive".  I suppose you could name your final container "273 CORPORATE DR PORTSMOUTH, NH 03801-6807" and try to parse the model name string but it seems a bit silly.



  • 14.  Re: Update Spectrum Set Script

    Posted Nov 21, 2014 03:31 PM

    Could you show me an example of this?  We are going to be rolling out Spectrum to our managed services provider and I want to provide as much information including a dealership's physical street address not only within Spectrum but also in a alert ticket that SANM would generate.



  • 15.  Re: Update Spectrum Set Script

    Posted Nov 20, 2014 07:38 PM

    Your setup looks a like lot mine . I just use World/Dealership and leave out the state. I assume the config would be the same?



  • 16.  Re: Update Spectrum Set Script

    Broadcom Employee
    Posted Nov 20, 2014 08:00 PM

    I would think so.  There are some rules to location hierarchy that you have to follow.  They make sense when you think about it.  First, you can't have the same device in two different locations at the same time.  Second, you can't things like countries inside of rooms, etc.  There are also restrictions on which containers (room, etc.) that device models can be placed directly in.  There is no connectivity shown in the location views either.  That's only in the hierarchy under Universe and Global Collections. 



  • 17.  Re: Update Spectrum Set Script

    Posted Nov 20, 2014 08:33 PM

    There's clip art in Spectrum? Show all that which you described? Where the heck is it?



  • 18.  Re: Update Spectrum Set Script

    Broadcom Employee
    Posted Nov 20, 2014 09:57 PM

    Put your view into edit mode, click on the "Modify Topology Background Color, Image..." icon, select the Background Image radio button on the left, then Browse through the available images:

     



  • 19.  Re: Update Spectrum Set Script

    Posted Nov 20, 2014 10:00 PM

    Am I required to  use " In my quick example, the attribute of interest for SANM is LocationModelNameString (0x129e9):" on a per device level or collection?

     

    My sites are under UniverseScreen Shot 2014-11-20 at 9.58.31 PM.png

     

    Should I be putting them under Universe/World/State/City??



  • 20.  Re: Update Spectrum Set Script

    Broadcom Employee
    Posted Nov 20, 2014 11:16 PM

    The location hierarchy (World) is a different one than the topology hierarchy (Universe).  The original idea behind this was that you'd see logical network and subnet containers in the Universe hierarchy, physical views in the World hierarchy and organizational (precursor to service views) views under TopOrg.  Networks have changed over the years, so you see less of that and more location/customer/service described in the regular topology view like what you have.  To use what I had in my example, you'd have to (re)create a hierarchy under World, in addition to keeping things maintained under Universe.  If you're up for that, great.  If not, and you'd rather have the topology containers you have defined ("Acura101, "Autobahn Annex", etc.) appear as the location you can use a different attribute:  TopologyModelNameString (0x129e7).  Here is an example of that:

     

     

    Notice how Universe and World are two different branches and how Sim21614:WLC appear under both the Universe hierarchy and the World hierarchy?

     

    Anyway, the default Notifier scripts don't include this attribute.  Here is what I did to get this result:

     

    Alarm Notification from SPECTRUM

     

    Alarm SET:

     

    Date:             11/20/2014

    Time:             23:04:10

    DeviceType:       Rad Data Communications Ltd.RT

    Mtype:            GnSNMPDev

    ModelName:        Sim20682:hubmux01

    AlarmID:          5103

    Severity:         CRITICAL

    ProbableCauseID:  10009

    RepairPerson:   

    AlarmStatus:     

    SpectroSERVER:    speclinux

    Landscape:        0x400000

    ModelHandle:      0x400061

    ModelTypeHandle:  0x3d0002

    IPAddress:        1.241.250.234

    SecurityString: 

    AlarmState:       NEW

    Acknowledged:     FALSE

    UserClearable:    FALSE

    Location:       

    Topology string:  Universe:Example Topology Location

    AlarmAge:         0

    NotificationData:

     

    ProbableCause:    DEVICE HAS STOPPED RESPONDING TO POLLS

     

    Modify your .alarmrc to add the new attribute:

     

    USE_NEW_INTERFACE=true

    EXTRA_ATTRS_AS_ENVVARS=

    EXTRA_ATTRS_AS_ARGS=0x0023000e,0x129e7

    UPDATE_ATTRS=

    GET_PROBABLE_CAUSES=true

     

    I chose to do this as an argument passed to the scripts but you could have done this as environment variable also.  It will change how you modify the Set/Update/ClearScript(s) though:

     

    # Alternatively, if EXTRA_ATTRS_AS_ARGS have been specified, they will be

    # added to the command-line.  For example:

    #

    #  EXTRA_ATTRS_AS_ARGS=0x100c5,0x11f84   means that

    #

    #  the values of these attributes will be added to be argument list passed

    # to this script, and can be referenced like this:

    #

    # IFDESC=$1

    # IFALIAS=$2

     

    DTYPE="$1"

    TOPOLOC="$2"

     

    I called the script variable TOPOLOC.  Again, you can call it whatever you like as long as your consistent.

     

    ###########################################################################

    #  The following parameters contain values only when

    #  the SPECTRUM Alarm Notification Manager is enabled.

    ###########################################################################

    if [ "$SANM" ]

    then

    echo "Location:        " $LOCATION

    echo "Topology string: " $TOPOLOC

    echo "AlarmAge:        " $AGE

    echo "NotificationData:" $NOTIFDATA

    echo ""                                         # insert blank line

    fi

     

    Then I add in the echo line to output the value of TopologyModelNameString.  Again, you don't have to do it exactly the way I did it here.

     

    The value of TopologyModelNameString, as well as LocationModelNameString, OrganizationModelNameString (TopOrg), and CollectionsModelNameString (GlobalCollection membership) are automatically determined for models based on what containers they live in.  You don't need to set anything and the values will update based on moving items around different containers.



  • 21.  Re: Update Spectrum Set Script

    Posted Nov 21, 2014 02:55 PM

    You have shown me more than any support call has ever done but if I want to make sure that I get this right.  As you can see, I have my dealerships listed underneath Universe. Which I now think probably was not the most ideal place.  Going forward, what is the best practice method so that I can edit one attribute of a collection so that all devices in that collection will show the physical street address in the SANM alert .  I want the ticket to show ex.1234 Main Street, Anytown US. So where do I configure Spectrum to actually show the street address?  I am hoping there is a way to somehow I edit just one item to show the street address for any and all devices in that collection/container.  Does that make sense?



  • 22.  Re: Update Spectrum Set Script

    Broadcom Employee
    Posted Nov 21, 2014 04:00 PM

    Glad I could help.  To be fair, I would consider most of the content I've shared to be more appropriate for an education class, consulting engagement, workshop/"brain picking" session with a presales engineer, or a thread on the community.  Not that there aren't plenty of folks in support who couldn't, wouldn't, and frequently do go into this detail but they're typically dealing with more urgent care (server down, patch fail, something is broken, etc.) type requests.  I hope my explanation above didn't mislead, so I'll be clear here:  all of your monitored devices belong in the Universe (topology) hierarchy at a minimum.  That's where Spectrum "looks" to figure out neighbor relationships and determine root cause.  All of the other hierarchies such as Word (physical location), TopOrg (organization) are optional.

     

    The actual "best practice" is to have sysLocation populated on your devices as part of the change management/device provisioning process.  Having said that, I'll respond later on when I get in front of Spectrum with an answer appropriate to your situation.



  • 23.  Re: Update Spectrum Set Script

    Posted Nov 21, 2014 04:07 PM

    Thanks and I completely understand. You have, in this one post, explained more and shown me more something about Spectrum that I did not I wasn't sure about how to configure.  Spectrum is a HUGE change coming from the world of Solarwinds



  • 24.  Re: Update Spectrum Set Script

    Broadcom Employee
    Posted Nov 23, 2014 11:10 PM

    How about this?

     

    ============================================================

     

    Alarm Notification from SPECTRUM

     

    Alarm SET:

     

    Date:             08/13/2014

    Time:             13:16:59

    DeviceType:       Rad Data Communications Ltd.RT

    Mtype:            GnSNMPDev

    ModelName:        Sim20682:hubmux01

    AlarmID:          185

    Severity:         MINOR

    ProbableCauseID:  10203

    RepairPerson:   

    AlarmStatus:     

    SpectroSERVER:    speclinux

    Landscape:        0x400000

    ModelHandle:      0x400061

    ModelTypeHandle:  0x3d0002

    IPAddress:        10.241.250.234

    SecurityString: 

    AlarmState:       EXISTING

    Acknowledged:     FALSE

    UserClearable:    TRUE

    Location:     123 Main Street Anytown, ST USA

    AlarmAge:         0

    NotificationData:

     

    ProbableCause:    DIFFERENT TYPE MODEL

     

    Since you have your Topology containers organized by location, I figured I would see if I could take advantage of that by using the TopologyModelNameString with the address appended to it:

     

     

    The tilde ~ will serve as a delimiter in the notifier scripts:

     

    We pass TopologyModelNameString like we did before but we use the cut command to take what's after the tilde and save that in a new variable:

     

    DTYPE="$1"

    TOPOLOC="$2"

    PARSELOC=`echo $TOPOLOC | cut -d'~' -f2 -`

     

    And later in the script, we comment out the default location and add in an entry for our new location variable:

     

    # echo "Location:    " $LOCATION
    echo "Location:" $PARSELOC

     

    And the output is what I had above.

     

    Let me know what you think of this.



  • 25.  Re: Update Spectrum Set Script

    Posted Nov 23, 2014 11:22 PM

    Thanks. I will try this tomorrow after I figure out why the archive server decided to stop running after the 9.4.1 upgrade 



  • 26.  Re: Update Spectrum Set Script

    Posted Nov 24, 2014 04:18 PM

    So let me see if I have this right.  To being with I edited the Setscript to include

    DTYPE="$1"

    TOPOLOC="$2"

    PARSELOC='echo $TOPOLOC | cut -d'~' -f2 -`

    echo_info()

    {

    echo ""

    echo "============================================================"

    echo " "

    echo "Alarm Notification from SPECTRUM"

    echo " "

    echo "Alarm SET:"

    echo ""

    echo "Date:            " $DATE

    echo "Time:            " $TIME

    echo "DeviceType:      " $DTYPE

     

    ==================================

     

    if [ "$SANM" ]

    then

    #echo "Location:        " $LOCATION

    echo "Location:         "$PARSELOC

    echo "AlarmAge:        " $AGE

    echo "NotificationData:" $NOTIFDATA

     

    With the Setscript edited all I should need to do now is to just edit the location containers to include the street address as shown here

    Hope I got this right.



  • 27.  Re: Update Spectrum Set Script

    Broadcom Employee
    Posted Nov 25, 2014 09:18 AM

    Make sure that you have the correct punctuation in the PARSELOC line.  It's a back tick, not an apostrophe.  We're telling the script to execute a command and put the results of that command into a variable.  Also don't forget about the .alarmrc modification:

     

    Modify your .alarmrc to add the new attribute:

     

    USE_NEW_INTERFACE=true

    EXTRA_ATTRS_AS_ENVVARS=

    EXTRA_ATTRS_AS_ARGS=0x0023000e,0x129e7

    UPDATE_ATTRS=

    GET_PROBABLE_CAUSES=true



  • 28.  Re: Update Spectrum Set Script

    Posted Nov 25, 2014 09:48 AM

    Corrected the typo and edited the .alarmrc file.  Now to just continue to add the site addresses after the ~ and wait for an alarm.  Thanks for all your help.



  • 29.  Re: Update Spectrum Set Script

    Broadcom Employee
    Posted Nov 25, 2014 10:27 AM

    Great.  I don't remember if you need to restart AlarmNotifier after editing the .alarmrc but I always do.  Make sure that you never have any tildes ~ in your site address either, otherwise you're just going to get what's in between the two tildes for the address.  Let us know how it works out.



  • 30.  Re: Update Spectrum Set Script

    Posted Nov 25, 2014 10:50 AM

    Now I am confused. Where do I NOT have any tides in my site address either? I used your example as a guide.



  • 31.  Re: Update Spectrum Set Script

    Broadcom Employee
    Posted Nov 25, 2014 11:00 AM

    What you have is correct.  But if the container was named "Acura101 ~ 24650 Calabasas Road, Calabasas CA ~ across the street from the gas station", you wouldn't see the "across the street from the gas station" part in your notification.  We're using tildes as the field delimiter in the script, so that would appear as a separate field.  I was just pointing that out in case you ran into that down the road, not based on the examples used here so far.



  • 32.  Re: Update Spectrum Set Script

    Posted Nov 26, 2014 07:58 AM

    Looks like I am still not getting the location in the alarm.

     

    DTYPE="$1"

    TOPOLOC="$2"

    PARSELOC=`echo $TOPOLOC | cut -d'~' -f2 -`

    echo_info()

    {

    echo ""

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------

    hen

    #echo "Location:        " $LOCATION

    echo "Location:         " $PARSELOC

    echo "AlarmAge:        " $AGE

     

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------

    USE_NEW_INTERFACE=true

    EXTRA_ATTRS_AS_ENVVARS=0x202000e,0x129e7



  • 33.  Re: Update Spectrum Set Script

    Broadcom Employee
    Posted Nov 26, 2014 01:01 PM

    I see the problem.  It's an inconsistency between what's in your .alarmrc and what's in your scripts.  For what I suggested to work, your .alarmrc has to have

     

    USE_NEW_INTERFACE=true

    EXTRA_ATTRS_AS_ENVVARS=

    EXTRA_ATTRS_AS_ARGS=0x0023000e,0x129e7

     

    You have

     

    USE_NEW_INTERFACE=true

    EXTRA_ATTRS_AS_ENVVARS=0x202000e,0x129e7

     

    So, you're passing the attributes as environment variables and not as arguments to the scripts.  That means you either need to change your .alarmrc or modify the scripts:

     

    DTYPE=$SANM_0x20200e

    TOPOLOC=$SANM_0x129e7

    PARSELOC=`echo $TOPOLOC | cut -d'~' -f2 -`

     

    Personally, I'd just change the .alarmrc to what I have since that's how I tested it.  I show the SANM environment variable method just for reference.  Either way is correct but it needs to be consistent.



  • 34.  Re: Update Spectrum Set Script

    Posted Nov 26, 2014 06:05 PM

    This is what the  my .alarmrc looks like:

     

    USE_NEW_INTERFACE=true

    EXTRA_ATTRS_AS_ENVVARS=

    EXTRA_ATTRS_AS_ARGS=0x0023000e,0x129e7

     

    and this is my SetScript:

    DTYPE="$1"

    TOPOLOC="$2"

    PARSELOC=`echo $TOPOLOC | cut -d'~' -f2 -`

    echo_info()

    {

    echo ""

    echo "============================================================"

     

    if [ "$SANM" ]

    then

    #echo "Location:        " $LOCATION

    echo "Location:         " $PARSELOC

    echo "AlarmAge:        " $AGE

     

    Am I blind and still missing something?



  • 35.  Re: Update Spectrum Set Script

    Broadcom Employee
    Posted Nov 26, 2014 07:51 PM

    Do you have a SANM policy in place? 



  • 36.  Re: Update Spectrum Set Script

    Posted Nov 26, 2014 08:05 PM

    Yes the default policy



  • 37.  Re: Update Spectrum Set Script

    Posted Nov 26, 2014 08:48 PM

    Should there be any spaces between the  tide and the site name and address 


    Location ~ address or

    Location~address??



  • 38.  Re: Update Spectrum Set Script

    Broadcom Employee
    Posted Dec 04, 2014 10:11 AM

    In the examples that I tested out, I had spaces.  It shouldn't matter but I found that it made it more readable.  Could you please post your complete SetScript here so I could see if there's anything off?  I'm also watching your other thread on multiple notifications for the same alarm and wonder if something else is going on.  I suspect that you have multiple instances of AlarmNotifier running. 



  • 39.  Re: Update Spectrum Set Script

    Posted Dec 04, 2014 11:53 AM

    I am actually getting my alarms with the locations now but I will include it for you.

     

    #!/bin/sh

    #

    #

    #  CA Technologies, Inc.

    #  One CA Plaza

    #  Islandia, NY 11749 USA

    #

    #  Copyright (c) 2014 CA Technologies, Inc.

    #  All rights reserved.

    #

    #  IN NO EVENT SHALL CA TECHNOLOGIES INCORPORATED BE LIABLE FOR

    #  ANY INCIDENTAL, INDIRECT, SPECIAL, OR CONSEQUENTIAL DAMAGES

    #  WHATSOEVER (INCLUDING BUT NOT LIMITED TO LOST PROFITS) ARISING OUT

    #  OF OR RELATED TO THIS SOFTWARE, EVEN IF CA TECHNOLOGIES INCORPORATED

    #  HAS BEEN ADVISED OF, KNOWN, OR SHOULD HAVE KNOWN, THE POSSIBILITY OF

    #  SUCH DAMAGES.

    #

    #

     

    ###############################################################################

    #

    #  SetScript - default script executed by AlarmNotifier for an alarm set.

    #

    ###############################################################################

    ###############################################################################

    #

    #  MAIL Facility

    #

    #  If a user wishes to send a mail message for the alarm then set SENDMAIL to

    #  "True" and set VARFORMAIL to "RepairPerson" or "NotificationData" (or

    #  "Both") depending on who you want the mail sent to.

    #

    #  Note: You can only send mail to users listed in $NOTIFDATA if the

    #  SPECTRUM Alarm Notification Manager (SANM) is enabled. If VARFORMAIL is

    #  set to "NotificationData" and SANM is not enabled then mail is not sent.

    #

    #  Note: The argument $REPAIRPERSON( actually $TROUBLE_SHOOTER_EMAIL ) and/or

    #        $NOTIFDATA MUST be valid Login IDS and email addresses respectively

    #        in order for the script to send mail them.

    #

    #  Note: Ensure Mail is configured as described in the AlarmNotifier User

    #  Guide if you are running AlarmNotifier on Windows with mail enabled.

    #

    ##############################################################################

    SENDMAIL=True              #True or False

    VARFORMAIL=Both     #RepairPerson, NotificationData, or Both

     

    case `/bin/uname` in

            "Windows_NT") MAIL="mail";;

     

            "Linux") MAIL="mail";;

     

            "SunOS") MAIL="mailx";;

    esac

     

    DATE=$1

    TIME=$2

    MTYPE=$3

     

    # use quotes to avoid mis-interpreting special chars - like '

    # If model name isn't correct when passed as an arg, you can also

    # try using $SANM_MODEL_NAME to avoid issues with shell escape

    # characters.

    # This has been see on Windows where C:\ is changed to C:\\

    MNAME="$4"

     

    AID=$5

    SEV=$6

    CAUSE=$7

    REPAIRPERSON="$8"

     

    if [ "$USE_NEW_INTERFACE" = "TRUE" ]

    then

        # ALARMSTATUS now being passed via environment variable

        shift 8

    else

        STATUS=$9

        shift 9

    fi

     

    SERVER=$1

    LANDSCAPE=$2

     

     

    MHANDLE=$3

    MTHANDLE=$4

    IPADDRESS=$5

    SECSTR=$6

    ALARMSTATE=$7

    ACKD=$8

    CLEARABLE=$9

     

    shift 9

     

    #FLASH_GREEN=$1

     

    if [ "$USE_NEW_INTERFACE" = "TRUE" ]

    then

        # PCAUSE and EVENTMSG now passed via environment variables

        LOCATION="$2"

        AGE=$3

        NOTIFDATA=$4

        PID=$5

        SANM=$6

        shift 6

    else

        PCAUSE=`echo "$2" | tr '\350' '\012' | tr '\351' '"'`

        LOCATION="$3"

        AGE=$4

        NOTIFDATA=$5

        EVENTMSG=`echo "$6" | tr '\350' '\012' | tr '\351' '"'`

        PID=$7

        SANM=$8

        shift 8

    fi

     

    # Information on specifying additional attributes, which requires

    # USE_NEW_INTERFACE=true :

     

    # Two ways have been added that allows the specification of additional

    # attributes for AlarmNotifier.  You have the option of passing the

    # attributes as environment variables or as arguments, which is reflected

    # in the two new config parameters:

    #

    # EXTRA_ATTRS_AS_ENVVARS and EXTRA_ATTRS_AS_ARGS

    #

    # For most attributes, either method is acceptable, but for multi-line text

    # attributes or for very long attribute values it is recommended to specify

    # these as EXTRA_ATTRS_AS_ENVVARS because of command-line length limitations

    # and Windows behavior that truncates the command-line at the first newline

    # character.

     

    # If EXTRA_ATTRS_AS_ENVVARS have been specified, they can be just referenced

    # by prepending # SANM_ to the value in the config file, ie:

    #

    #  EXTRA_ATTRS_AS_ENVVARS=0x100c5,0x11f84  means that

    #

    #  $SANM_0x100c5 and $SANM_0x11f84 environment variables to be set, which

    #  can be then be referenced in this script like:

    #

    # IFDESC=$SANM_0x100c5

    # IFALIAS=$SANM_0x11f84

    #

    #  Note: Windows will uppercase these variables, so they need to be referenced

    #        that way - ie. $SANM_0X100C5 and $SANM_0X11F84.

    #

    # Alternatively, if EXTRA_ATTRS_AS_ARGS have been specified, they will be

    # added to the command-line.  For example:

    #

    #  EXTRA_ATTRS_AS_ARGS=0x100c5,0x11f84   means that

    #

    #  the values of these attributes will be added to be argument list passed

    # to this script, and can be referenced like this:

    #

    # IFDESC=$1

    # IFALIAS=$2

     

    DTYPE="$1"

    TOPOLOC="$2"

    PARSELOC=` echo $TOPOLOC | cut -d'~' -f2 -`

    echo_info()

    {

    echo ""

    echo "============================================================"

    echo " "

    echo "Alarm Notification from SPECTRUM"

    echo " "

    echo "Alarm SET:"

    echo ""

    echo "Date:            " $DATE

    echo "Time:            " $TIME

    echo "DeviceType:      " $DTYPE

    echo "Mtype:           " $MTYPE

    echo "ModelName:       " $MNAME

    echo "AlarmID:         " $AID

     

    # If you wish to see the global alarm ID printed out you need to set

    # ENABLE_CORRELATION to "true" and USE_NEW_INTERFACE to "true" in the

    # configuration file.

    if [ "$ENABLE_CORRELATION" = "TRUE" ] && [ "$USE_NEW_INTERFACE" = "TRUE" ]

    then

        echo "Global AlarmID:  " $GLOBAL_ALARM_ID

    fi

     

    # If you wish to see correlation related information, you need to set

    # ENABLE_CORRELATION to "true" and SHOW_SYMPTOM_ALARMS to "true" in

    # the configuration file.

    if [ "$SYMPTOM_ALARM_LIST" ]

    then

        echo "CorrelationAlarmType:       " CAUSE

        echo "SYMPTOMGlobalAlarmIDList:   " $SYMPTOM_ALARM_LIST

    fi

     

    if [ "$CAUSE_ALARM_LIST" ]

    then

        echo "CorrelationAlarmType:       " SYMPTOM

        echo "CAUSEGlobalAlarmIDList:     " $CAUSE_ALARM_LIST

    fi

     

    # If you wish to see the UNIX alarm time printed out you need to set

    # USE_NEW_INTERFACE to true in the configuration file and uncomment

    # the following line.

    #echo "Raw Alarm Time: "  $RAW_ALARM_TIME

     

    echo "Severity:        " $SEV

    echo "ProbableCauseID: " $CAUSE

    #echo "RepairPerson:    " $REPAIRPERSON

    echo "AlarmStatus:      $STATUS"

    #echo "SpectroSERVER:   " $SERVER

    #echo "Landscape:       " $LANDSCAPE

    #echo "ModelHandle:     " $MHANDLE

    echo "ModelTypeHandle: " $MTHANDLE

    echo "IPAddress:       " $IPADDRESS

    #echo "SecurityString:  " $SECSTR

    echo "AlarmState:      " $ALARMSTATE

    echo "Acknowledged:    " $ACKD

    echo "UserClearable:   " $CLEARABLE

     

    ###########################################################################

    #  When notifying on management lost (0x12dc7), customer (0x12bf6) and/or

    #  service (0x12bf7) impact attributes please pass them as environment variables

    #  and print in quotes, as they will usually contain multiple

    #  lines:

    #

    #  echo "ManagementImpactLost:   $SANM_0x12dc7"

    #  echo "ServiceImpact:          $SANM_0x12bf7"

    #  echo "CustomerImpact:         $SANM_0x12bf6"

    #

    #  Or on Windows:

    #

    #  echo "ManagementImpactLost:   $SANM_0X12DC7"

    #  echo "ServiceImpact:          $SANM_0X12BF7"

    #  echo "CustomerImpact:         $SANM_0X12BF6"

    ###########################################################################

     

    ###########################################################################

    #  The following parameters contain values only when

    #  the SPECTRUM Alarm Notification Manager is enabled.

    ###########################################################################

    if [ "$SANM" ]

    then

    #echo "Location:        " $LOCATION

    echo "Location:        "$PARSELOC

    echo "AlarmAge:        " $AGE

    echo "NotificationData:" $NOTIFDATA

    echo ""                                         # insert blank line

    fi

     

    # This variable has substituted placeholder chars, echo them inside quotes

    echo "ProbableCause:    $PCAUSE"

    echo ""                                         # insert blank line

    # This variable has substituted placeholder chars, echo them inside quotes

    echo "EventMessage:     $EVENTMSG"

    echo ""

     

    echo "============================================================"

    }

     

    parse_notifdata()

    {

       LIST=`echo "$NOTIFDATA" | tr ',:' '  '`

       SKIP=false

       for ITEM in $LIST

       do

          if [ "$ITEM" = "or" ]

          then

             SKIP=true

          else

             if [ "$SKIP" = "false" ]

             then

                OUTLIST="$OUTLIST $ITEM"

             else

                SKIP=false

             fi

          fi

       done

       echo $OUTLIST

    }

     

    if [ "$SENDMAIL" = "True" ]

    then

       RECIPIENTS=$VARFORMAIL

       if [ "$VARFORMAIL" = "NotificationData" ]

       then

          RCVRS=`parse_notifdata`

       fi

       if [ "$VARFORMAIL" = "RepairPerson" ]

       then

          RCVRS="$TROUBLE_SHOOTER_EMAIL"

       fi

       if [ "$VARFORMAIL" = "Both" ]

       then

          RCVRS=`parse_notifdata`

          RCVRS="$RCVRS $TROUBLE_SHOOTER_EMAIL"

          RECIPIENTS="NotificationData/RepairPerson"

       fi

     

       if [ "$RCVRS" -a "$RCVRS" != " " ]

       then

          echo " "

          echo "*******************************************************************"

          echo "Sending mail to $RECIPIENTS:"

          echo ""

          echo "($RCVRS)"

          echo "*******************************************************************"

          echo_info | tee -i /tmp/set_alarm.$PID

          $MAIL -s "A $SEV alarm has occurred on $SERVER (Model Name=$MNAME)(Model Type=$MTYPE)" $RCVRS < /tmp/set_alarm.$PID

          rm -f /tmp/set_alarm.$PID

       else

          echo " "

          echo "*****************************************************"

          echo "NO $RECIPIENTS assigned - no mail sent"

          echo "*****************************************************"

          echo_info

       fi

     

    else

       echo_info

    fi



  • 40.  Re: Update Spectrum Set Script

    Broadcom Employee
    Posted Dec 04, 2014 12:06 PM

    Progress!  When I reread your original post, I saw the part about integrating with a ticketing system and thought that some more changes needed to be made to pass the location field to the command that's opening the tickets.  Glad to hear that it's working now. 



  • 41.  Re: Update Spectrum Set Script

    Posted Dec 04, 2014 01:10 PM

    At some point it would be nice to one day integrate Spectrum with SOI so SOI could pass alarms to a help desk ticketing system. We'll need a CA consultant for that