Tuesday, March 13, 2012

vFoglight Cisco UCS Cartridge

Here is all of the code which you will need to get things running. I have stopped the development of this cartridge and turning it over to capable hands at Quest. Below are the files

Cisco UCS Files

vFoglight Alarms with Counts (Groovy Script)

Using the script editor located in Administration > Tooling > Script Console. Best to go ahead and save these for running at a later date when you need them. This will give you all of the alarms in the system along with the number of times it has triggered.

alarmService = server.get("AlarmService")
currentAlarms = alarmService.getCurrentAlarms();
def alarms = [] as TreeMap;
def result = new StringBuilder();
for (currentAlarm in currentAlarms)
  {
      def alarmName = currentAlarm.getSourceName()
      def alarmEntry = alarms[alarmName]
      if(alarmEntry == null)
      {
         alarms[alarmName] = 1
      }
         else
      {
         alarms[alarmName] = alarmEntry + 1
      }
   }
for (alarm in alarms.entrySet())
   {
      result.append(alarm.getKey()).append(" ").append(alarm.getValue()).append("\n")
   }
return result

vFoglight Purge Stale Objects (Groovy Script)

Using the script editor located in Administration > Tooling > Script Console. Best to go ahead and save these for running at a later date when you need them. On line "10" you can enter the number of days to go back to remove the script below will purge objects "30" days old. Also on line "17" you can show the items to purge instead of deleting them.

// Script Purpose: Remove Stale Objects from vFoglight Database
// Script Platform: Foglight Managment Servers running on Windows or Linux
// Script Created by: chris.walker@quest.com
// Script Last Updated: 10.13.2011 
// Script Version: 11.10.13
// Please see PDF documentation that should have come with this script for usage information
// Note: The script formating was compressed to save page space in the PDF. Sorry this does make it harder to read.

// Modify the line below to change the number of days
staleDays='30';// Exmple: Deleted object with stale data that is older than "30" days
// Set these to 1 if you want to delete the stale data in the respected topology type list
//   Set to 0 if you do not want to delete the data
VMWare=1; // VMWare Data
GPI=1; // Guest Process Investigation Data
OSTypes=1; // OS Topology Types Used by vFoglight - Physical Disk
// If you just want to view a list of object that should be purged change this flag to 0. Set to 1 to actually purge data
PurgeData=0;

// Following is a list of vFoglight Topology Objects that will be purged of stale data
VMwareList = ['VMWVirtualMachine', 'VMWVirtualMachineHostCPUs', 'VMWVirtualMachineMemory', 'VMWVirtualMachineHostNetwork', 'VMWVirtualMachineNetworkInterface', 'VMWVMDiskLayout', 'VMWVirtualCenter', 'VMWDatastore', 'VMWESXServer', 'VMWESXServerPhysicalDisk', 'VMWCluster', 'VMWDatacenter', 'VMWAgent', 'VMWVirtualMachineLogicalDisk', 'VMWVirtualMachineHostStorage', 'VMWSnapshot', 'VMWSnapshotDiskInfo', 'VMWSnapshotFolder', 'VMWResourcePool'];
// Following is a list of Guest Process Topology Objects that will be purged of stale data
GPIList=['GuestProcessModel', 'GuestProcessAgent', 'GuestProcessDefaultAgentConfig'];
// Following is a list of Physical Topology Objects that are used by vFoglight and will be purged of stale data
OSList=['Host', 'HostCPUs', 'HostNetwork', 'HostStorage', 'IPAddress', 'LogicalDisk', 'PhysicalDisk', 'Processor', 'NetworkInterface', 'Memory'];
// Function used to purge data
def purgeStale(TopoName, staleAge, Purge) {
  def dataSvc = server.get("DataService");
  def topSvc = server.get("TopologyService");
  def objects = server.get("QueryService").queryTopologyObjects(TopoName);
  def staleTime = System.currentTimeMillis() - (staleAge.toInteger() * 24 * 60 * 60 * 1000L);
  def staleObjects = [];
  objects.each({ if (it.lastUpdated.time < staleTime) staleObjects << it });
  // Print stale Oject List to Log
  print "Stale objects:";
  for (obj in staleObjects) {
   print obj.longName + " " + obj.lastUpdated;}
  // Delete the objects if PurgeData Flag is set
  if (Purge==1) {
    def batchSize = 100;
    def idx = 0;
    while (idx < staleObjects.size()) {
     def endPos = Math.min(idx + batchSize, staleObjects.size());
     def batch = staleObjects.subList(idx, endPos);
     topSvc.deleteObjects(new HashSet(batch));
     idx = endPos;}
    print "*** Successfully Purged: " + staleObjects.size() + " stale objects. ***";} 
  else {
    print "*** No objects Purged (use PurgeData flage in script to actually purge objects) ***";
    print "*** Number of Stale Objects Identified but not Purged: " + staleObjects.size() + " ***";}
}// End purgeStale Function
// Start of Code to loop through Topology Types
// Put info in the FMS Log File
print "** Start VFDelete-stale.groovy script v11.10.13 **";
// Purge Stale Data for Foglight VMWare Cartridge
if (VMWare==1) {
  print "* Processing VMware Topology Objects"
  // Loop through each of the Topology Types
  for (Topo in VMwareList) {
    print "Removing Stale Objects for Topology: " + Topo;
    purgeStale(Topo, staleDays, PurgeData);}
}
// Purge Stale Data for Foglight Guest Process Investigation (GPI) Cartridge
if (GPI==1) {
  print "* Processing GPI Topology Objects";
  // Loop through each of the Topology Types
  for (Topo in GPIList){
    print "Removing Stale Objects for Topology: " + Topo;
    purgeStale(Topo, staleDays, PurgeData);}
}
if (OSTypes==1){
  print "* Processing OS Topology Objects";
  // Loop through each of the Topology Types
  for (Topo in OSList){
    print "Removing Stale Objects for Topology: " + Topo;
    purgeStale(Topo, staleDays, PurgeData);}
}
print "** Finished Run of VFDelete-stale.groovy script v11.10.13 **";
return "Done...";

vFoglight Purge Alarms (Groovy Script)

Using the script editor located in Administration > Tooling > Script Console. Best to go ahead and save these for running at a later date when you need them. On line "4" you can enter the number of day to go back and delete. This script will only remove 10,000 alarms at a time so you might want to make a rule to prune down the alarms.

def alarmSvc = server.AlarmService;
def LOG = org.apache.log4j.Logger.getLogger("Alarm Purge Rule")
def now = new Date();
def cutoff = now - 180;
def Anchor = now - 2000;
def alarms = alarmSvc.getAlarms(Anchor, cutoff);

for (alarm in alarms) {
 alarmSvc.purgeAlarm(alarm.getID());
}
LOG.info("Purged " + alarms.size() + " alarms older than " + cutoff);
return "Purged " + alarms.size() + " alarms older than " + cutoff;

vFoglight Count Alarms (Groovy Script)

Using the script editor located in Administration > Tooling > Script Console. Best to go ahead and save these for running at a later date when you need them.

import groovy.sql.Sql;
import com.quest.nitro.service.util.JDBCHelper;
msg = new StringBuilder();
try{
sql = new Sql(JDBCHelper.getDataSource());
msg.append("Alarms Table Count: \n")
msg.append(sql.rows("select count(*) from alarm_alarm"));
}catch (Exception ex){
msg.append("Exception"+ex);
}
return msg.toString();

Raspberry Pi Zero W - Wireless Configuation

create the file under "boot" folder wpa_supplicant.conf country=GB ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev u...