Golang Dispatch Center Kala Test

Source: Internet
Author: User
Tags snmpwalk
This is a creation in Article, where the information may have evolved or changed.

Objective

Kala is the go version of the class crontab scheduling services, the default storage bolts, with Redis storage a bit of a problem, the password is empty will throw an exception, modified kala\job\storage\redis\redis.go to increase the non-secret method.

func Newnopass(address string) *DB {    conn, err := redis.Dial("tcp", address)    if err != nil {        log.Fatal(err)    }    return &DB{        conn: conn,    }}

The password for the parameter is the default or null call to the method, or Redis when the connection is established. Dialoption generated empty structure in redigo.dial will cause panic:runtime error:invalid memory address or nil pointer dereference error.

Kala start, modify and go to build project again

//密码为空启动[slview@YFTEST1 kala]$ ./kala run -p 40001 --jobDB=redis --jobDBAddress=192.168.6.151:6379 --jobDBPassword=""INFO[0000] Starting server on port :40001...              //默认没密码,没修改前会默认密码是password。。[slview@YFTEST1 kala]$ ./kala run -p 40001 --jobDB=redis --jobDBAddress=192.168.6.151:6379INFO[0000] Starting server on port :40001...

HTTP creation job with the goal of capturing the outbound and inbound traffic for a Cisco router port every 30 seconds

//create job , get job id ,can use job-id view statuscurl http://127.0.0.1:40001/api/v1/job/ -d '{"epsilon": "PT10S", "command": "/slview/test/zhangqi/snmpwalk.sh", "name": "zhangqi_job", "schedule": "R/2017-06-08T11:15:00.819236718+08:00/PT30S"}'{"id":"6973f82d-09d2-474f-630f-16d9ad27b484"}//shell#!/bin/shmore snmpwalk.sh Dev_Ip=192.168.6.87Comm=publicFile=/slview/test/zhangqi/CI_$Dev_Ipdate >>$Filesnmpwalk -v2c -c $Comm $Dev_Ip .1.3.6.1.2.1.31.1.1.1.6.1 >>$Filesnmpwalk -v2c -c $Comm $Dev_Ip .1.3.6.1.2.1.31.1.1.1.10.1 >>$File

Check for normal dispatch, generate files every 30 seconds normally

 tail -f CI_192.168.6.87 2017年 06月 08日 星期四 11:15:00 CSTIF-MIB::ifHCInOctets.1 = Counter64: 1831783500IF-MIB::ifHCOutOctets.1 = Counter64: 10339903062017年 06月 08日 星期四 11:15:30 CSTIF-MIB::ifHCInOctets.1 = Counter64: 1831793637IF-MIB::ifHCOutOctets.1 = Counter64: 10339976482017年 06月 08日 星期四 11:16:00 CSTIF-MIB::ifHCInOctets.1 = Counter64: 1831815957IF-MIB::ifHCOutOctets.1 = Counter64: 10340102522017年 06月 08日 星期四 11:16:30 CSTIF-MIB::ifHCInOctets.1 = Counter64: 1831826698IF-MIB::ifHCOutOctets.1 = Counter64: 10340169722017年 06月 08日 星期四 11:17:00 CSTIF-MIB::ifHCInOctets.1 = Counter64: 1831851051IF-MIB::ifHCOutOctets.1 = Counter64: 10340315752017年 06月 08日 星期四 11:17:30 CSTIF-MIB::ifHCInOctets.1 = Counter64: 1831862726IF-MIB::ifHCOutOctets.1 = Counter64: 1034040076

View Redis storage, is a hset

127.0.0.1:6379> hkeys kala:jobs1) "6973f82d-09d2-474f-630f-16d9ad27b484"

You can use Curl or browser to see when the job dispatched the program, Retry is a few times

bash-4.1$ curl -s http://192.168.6.26:40001/api/v1/job/stats/6973f82d-09d2-474f-630f-16d9ad27b484/ | jq .{  "job_stats": [    {      "execution_duration": 219580517,      "success": true,      "number_of_retries": 0,      "ran_at": "2017-06-08T11:15:00.819908161+08:00",      "job_id": "6973f82d-09d2-474f-630f-16d9ad27b484"    },    {      "execution_duration": 215259152,      "success": true,      "number_of_retries": 0,      "ran_at": "2017-06-08T11:15:30.820510442+08:00",      "job_id": "6973f82d-09d2-474f-630f-16d9ad27b484"    },    {      "execution_duration": 129358057,      "success": true,      "number_of_retries": 0,      "ran_at": "2017-06-08T11:16:00.821014506+08:00",      "job_id": "6973f82d-09d2-474f-630f-16d9ad27b484"    },

Other features

Kala can set retries and epsilon, which specifies the number of retries in the repeat time, and the format follows the standard ISO8601, for example: {"Retries": 3, "epsilon": "Pt10s",。。。 }

Delete Job

Curl-xdelete http://127.0.0.1:40001/api/v1/job/6973f82d-09d2-474f-630f-16d9ad27b484/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.