Forum Discussion

  • Anonymous's avatar
    Anonymous

    Better quality images are definitely needed there.

    However, I recommend against extending snmp. It's messy, performance is not great, and requires stuff on the remote side to work. Better to use Expect or JSch scripted DSs. I've a couple of examples I can link when I get back to the office in a few minutes. 

  • Anonymous's avatar
    Anonymous

    Here you go: https://github.com/sweenig/lmcommunity/blob/master/PiJuice/collect.groovy

    In this script, I compose the python script within my groovy script. Then the groovy script connects to the server via SSH, runs the script on the command line, grabs the output, then extracts the data from the returned json. 

    //SETUP PORTION OMITTED (it's in the linked github repo)
    pythonScript = """import json
    from pijuice import PiJuice
    x=PiJuice(1,0x14)
    output = {}
    output["charge"] = x.status.GetChargeLevel()
    output["status"] = x.status.GetStatus()
    output["temp"] = x.status.GetBatteryTemperature()
    output["voltage"] = x.status.GetBatteryVoltage()
    output["current"] = x.status.GetBatteryCurrent()
    output["iovoltage"] = x.status.GetIoVoltage()
    output["iocurrent"] = x.status.GetIoCurrent()
    print(json.dumps(output))
    """
    
    power_input_status = ["NOT_PRESENT": 0, "BAD": 1, "WEAK": 2, "PRESENT": 3]
    battery_status = ["NORMAL": 0, "CHARGING_FROM_IN": 1, "CHARGING_FROM_5V_IO": 2, "NOT_PRESENT": 3]
    
    try {
      def userCmd = getCommandOutput("python3 -c \"${pythonScript.replaceAll("\"","'").replaceAll("\n",";")}\"")
      data = new JsonSlurper().parseText(userCmd)
      println("5v_power_input_status: ${power_input_status[data.status.data.powerInput5vIo]}")
      println("charge: ${data.charge.data}")
      println("battery_status: ${battery_status[data.status.data.battery]}")
      println("power_input_status: ${power_input_status[data.status.data.powerInput]}")
      return 0
    }
    catch (Exception e) {println "Unexpected Exception : " + e; return 1}
    
    //FUNCTIONS OMITTED (it's in the linked github repo)

     

  • Hi Stu, if we don't have an ssh user/pass then we need to still use the old method?
    What's a simple OOTB snmp DS that I can use to clone, change the OID to poll to create this custom DS? Its for monitoring MISP jobs status?