Otrs Api配置&&Curl测试

CMDB字段参考

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{
    "ConfigItem": [
        {
            "CurInciState": "Operational", 
            "ConfigItemID": "1", 
            "InciStateType": "operational", 
            "CurInciStateType": "operational", 
            "Number": "4722000001", 
            "CreateBy": "1", 
            "CurDeplState": "Production", 
            "LastVersionID": "5", 
            "DeplState": "Production", 
            "CreateTime": "2018-06-01 02:53:44", 
            "DefinitionID": "1", 
            "VersionID": "5", 
            "DeplStateType": "productive", 
            "CIXMLData": {
                "SerialNumber": "ABC513VEFG", 
                "Ram": "16G", 
                "WarrantyExpirationDate": "2018-05-31", 
                "Vendor": "", 
                "CPU": [
                    "6核", 
                    ""
                ], 
                "Model": "ProLiant DL380 Gen9", 
                "Owner": "", 
                "NIC": {
                    "NIC": "10.0.0.1", 
                    "IPoverDHCP": "No"
                }, 
                "Type": "", 
                "HardDisk": {
                    "HardDisk": "200G", 
                    "Capacity": ""
                }, 
                "GraphicAdapter": "", 
                "FQDN": "", 
                "OperatingSystem": "", 
                "Description": ""
            }, 
            "Class": "Computer", 
            "InciState": "Operational", 
            "CurDeplStateType": "productive", 
            "Name": "yz-o12-10.0.0.1"
        }
    ]
}

工单字段参考

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{
    "Ticket": [
        {
            "Age": 17572057, 
            "PriorityID": "3", 
            "ServiceID": "", 
            "Type": "Unclassified", 
            "Responsible": "root@localhost", 
            "StateID": "1", 
            "ResponsibleID": "1", 
            "ChangeBy": "1", 
            "EscalationTime": "0", 
            "Changed": "2018-05-31 23:33:25", 
            "OwnerID": "1", 
            "RealTillTimeNotUsed": "0", 
            "GroupID": "2", 
            "Owner": "root@localhost", 
            "CustomerID": "", 
            "TypeID": "1", 
            "Created": "2017-11-09 15:08:10", 
            "Priority": "3 normal", 
            "UntilTime": 0, 
            "EscalationUpdateTime": "0", 
            "Queue": "Raw", 
            "QueueID": "2", 
            "State": "new", 
            "Title": "testtest", 
            "CreateBy": "1", 
            "TicketID": "3", 
            "StateType": "new", 
            "UnlockTimeout": "0", 
            "EscalationResponseTime": "0", 
            "EscalationSolutionTime": "0", 
            "LockID": "1", 
            "ArchiveFlag": "n", 
            "TicketNumber": "2017110947000013", 
            "CreateTimeUnix": "1510211290", 
            "Lock": "unlock", 
            "SLAID": "", 
            "CustomerUserID": "it@mulinux.com"
        }
    ]
}

工单查询json参考

1
2
3
4
5
{
    "Ticket": {
        "Queues": "Postmaster"
    }
}

搜索扩展信息json参考

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
{
  "UserLogin": "root@localhost",
  "Password": "123456",
  "ConfigItem": {
		"Class":"应用",
		"CIXMLData":{
			"CODE":"226"
		}
	} 	
}

操作工单API

获取工单详细信息
1
curl "http://localhost/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket/3?UserLogin=root@localhost&Password=123456"
创建工单
1
curl "http://localhost/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket?UserLogin=root@localhost&Password=123456" -H "Content-Type: application/json" -d "{\"Ticket\":{\"Title\":\"REST Create Test\", \"Type\": \"Unclassified\", \"Queue\":\"Raw\",\"State\":\"open\",\"Priority\":\"3 normal\",\"CustomerUser\":\"customer\"},\"Article\":{\"Subject\":\"Rest Create Test\",\"Body\":\"This is only a test\",\"ContentType\":\"text/plain; charset=utf8\"}}"  -X POST
更新工单
1
curl "http://localhost/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket/3?UserLogin=root@localhost&Password=123456" -H "Content-Type: application/json" -d "{\"Ticket\":{\"Queue\":\"Postmaster\"}}"  -X PATCH
搜索工单
1
curl "http://localhost/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket?UserLogin=root@localhost&Password=123456&Queue=PostMaster"

操作CMDB API

获取CMDB详细信息
1
2
curl "http://localhost/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/ConfigItem/1?UserLogin=root@localhost&Password=123456"
curl "http://localhost/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/ConfigItem/1" -H "Content-Type: application/json" -d "{\"UserLogin\":\"root@localhost\",\"Password\":\"123456\"}" -X GET
创建CMDB
1
curl "http://localhost/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/ConfigItem" -H "Content-Type: application/json" -d "{\"UserLogin\":\"root@localhost\",\"Password\":\"123456\",\"ConfigItem\":{\"Class\":\"Computer\",\"DeplState\":\"Production\",\"InciState\":\"Operational\",\"Name\":\"SH-TG-C4-FB13\",\"CIXMLData\":{\"SerialNumber\":\"6CU513VRKQ\",\"Ram\":\"16G\",\"Model\":\"ProLiant DL380 Gen9\",\"NIC\":{\"NIC\":\"192.168.1.1\",\"IPoverDHCP\":\"No\"}}}}"  -X POST
更新CMDB
1
curl "http://localhost/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/ConfigItem/1" -H "Content-Type: application/json" -d "{\"UserLogin\":\"root@localhost\",\"Password\":\"123456\",\"ConfigItem\":{\"Class\":\"Computer\",\"DeplState\":\"Production\",\"InciState\":\"Operational\",\"Name\":\"SH-TG-C4-FB18\"}}"  -X PATCH
搜索CMDB
1
curl "http://localhost/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/ConfigItem" -H "Content-Type: application/json" -d "{\"UserLogin\":\"root@localhost\",\"Password\":\"123456\",\"ConfigItem\":{\"Class\":\"Computer\"}}" -X GET

Grafana5 Dashboard备份与恢复

参考资料

1
2
3
4
https://blog.dictvm.org/export-all-grafana-graphs/
https://github.com/m110/grafcli#usage
https://gist.github.com/jaimegago/11229750
https://utkarshcmu.github.io/wizzy-site/home/

安装grafcli

pip3 install grafcli

OpenVZ虚机Centos6.5安装gitlab报错

执行gitlab-ctl reconfigure后报错:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
[execute] cat: error: permission denied on key 'net.bridge.bridge-nf-call-ip6tables'
              error: permission denied on key 'net.bridge.bridge-nf-call-iptables'
              error: permission denied on key 'net.bridge.bridge-nf-call-arptables'
              /etc/sysctl.d/*.conf: No such file or directory
              net.ipv4.ip_forward = 0
              net.ipv4.tcp_syncookies = 1
    
    ================================================================================
    Error executing action `run` on resource 'execute[load sysctl conf]'
    ================================================================================

解决方法

1
2
3
4
5
6
rm -f /sbin/modprobe  
ln -s /bin/true /sbin/modprobe

rm -f /sbin/sysctl  
ln -s /bin/true /sbin/sysctl 
/sbin/sysctl -p    #不用执行

Iptables

通过nat表映射实现共享上网

开启共享上网

(1)把 /etc/sysctl.conf 中的net.ipv4.ip_forward = 1 ,改成等于1 (2)执行 iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE

Esxcli常用命令

常用命令

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
esxcli network nic list 查看网卡信息
esxcli network ip route ipv4 list 查看路由(ipv4)
esxcli network ip dns server list 查看 dns
esxcli network ip interface ipv4 get 查看ip配置(ipv4)
esxcfg-route 查看默认路由
esxcfg-nics 等价 esxcli network nic list
esxcli vm process list # 只显示开机的虚拟机列表
vim-cmd vmsvc/power.getstate <vmid> #获取电源状态
vim-cmd vmsvc/getallvms | grep <vmip> #查找ip对应的vps
vim-cmd vmsvc/power.on <vmid> #启动该id的vps power.on power.off power.reset
esxcli system time set --hour 23 --min 32 --sec 30 #设置esxi系统的时间

参考:http://blog.csdn.net/xiaoxinyu316/article/details/45172771