December 2019

You are currently browsing the monthly archive for December 2019.

nl命令是用来为文本文件生成行号的,但最实用的用法还是在每行之前添加0。

//显示行号,默认空白行不显示
[root@xuxing ~]# nl /etc/fstab
//空白行也显示行号
[root@xuxing ~]# nl -b a  /etc/fstab
//为每行添加0,默认添加5个
[root@xuxing ~]# nl -b a -n rz /etc/fstab
//指定添加3个0,使用"-w 3"
[root@xuxing ~]# nl -b a -n rz -w 3 /etc/fstab



//示例
[root@xuxing ~]# nl -b a -n rz /etc/fstab
000001  
000002  #
000003  # /etc/fstab
000004  # Created by anaconda on Wed Dec 19 08:07:14 2018
000005  #
000006  # Accessible filesystems, by reference, are maintained under '/dev/disk'
000007  # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
000008  #
000009  /dev/mapper/centos-root /                       xfs     defaults        0 0
000010  UUID=bd47b365-3718-40a2-a835-e6ae1c5187c5 /boot                   xfs     defaults        0 0
000011  /dev/mapper/centos-swap swap                    swap    defaults        0 0
[root@xuxing ~]#

Rory

Step by step the ladder is ascended.

“Only for self-learning use, if infringement will delete.”

Tags:

学习的时候搜到管理CISCO IOX 设备的ansible模块,“iosxr_config – Manage Cisco IOS XR configuration sections“,记录下有空玩玩。

[student@workstation ~]$ ansible-doc -l | grep ios | grep cisco
[student@workstation ~]$ 
[student@workstation ~]$ ansible-doc -l | grep iosxr_config
iosxr_config                                           Manage Cisco IOS XR configuration sections          
[student@workstation ~]$ 
[student@workstation ~]$ 
[student@workstation ~]$ 
[student@workstation ~]$ 
[student@workstation ~]$ 
[student@workstation ~]$ ansible-doc iosxr_config


EXAMPLES:

- name: configure top level configuration
  iosxr_config:
    lines: hostname {{ inventory_hostname }}

- name: configure interface settings
  iosxr_config:
    lines:
      - description test interface
      - ip address 172.31.1.1 255.255.255.0
    parents: interface GigabitEthernet0/0/0/0

- name: load a config from disk and replace the current config
  iosxr_config:
    src: config.cfg
    replace: config
    backup: yes

- name: for idempotency, use full-form commands
  iosxr_config:
    lines:
      # - shut
      - shutdown
    # parents: int g0/0/0/1
    parents: interface GigabitEthernet0/0/0/1

- name: configurable backup path
  iosxr_config:
    src: config.cfg
    backup: yes
    backup_options:
      filename: backup.cfg
      dir_path: /home/user

Rory

Step by step the ladder is ascended.

Tags:

Telemetry 是一种类似SNMP技术的feature,用于远程采集网络设备上相关信息。与SNMP不同的是,SNMP是Pull Mode,需要server端主动的要求Get某些信息,而Telemetry则是一种Push Mode,可以周期性、主动的push相关信息到server上。SNMP是秒级的数据采集, 而Telemetry可以实现毫秒级的数据采集.

如何获得相应的sensor-path

与SNMP的OID类似,sensor-path代表着你想要的获得哪些信息,在XR设备上我们可以使用如下命令去判断我们需要获得的信息是哪一类,即获得关键字;然后到yang文件夹过滤相关关键字:

RP/0/RSP1/CPU0:9910-B#schema-describe show segment-routing traffic-eng forwarding policy name test-policy detail
Fri Dec 27 01:57:38.336 UTC
Action: get
Path:   RootOper.XTC.PolicyForwarding   <<< XTC

RP/0/RSP1/CPU0:9910-B#run
Fri Dec 27 01:57:42.449 UTC
[xr-vm_node0_RSP1_CPU0:~]$cd /pkg/yang/
[xr-vm_node0_RSP1_CPU0:/pkg/yang]$ls | grep xtc      <<<cfg代表配置相关,oper与show command相关
Cisco-IOS-XR-infra-xtc-agent-cfg.yang
Cisco-IOS-XR-infra-xtc-agent-oper-sub1.yang
Cisco-IOS-XR-infra-xtc-agent-oper-sub2.yang
Cisco-IOS-XR-infra-xtc-agent-oper.yang
Cisco-IOS-XR-infra-xtc-cfg.yang
Cisco-IOS-XR-infra-xtc-oper-sub1.yang
Cisco-IOS-XR-infra-xtc-oper.yang

//有用的文件:
RP/0/RP0/CPU0:XTC#run
Tue Jan 22 06:58:56.512 UTC
[xr-vm_node0_RP0_CPU0:~]$cd /pkg/telemetry/mdt/protogen
[xr-vm_node0_RP0_CPU0:/pkg/telemetry/mdt/protogen]$ls
yang_to_schema.txt

接下来就需要自己去yang文件中找一些关键词,自己把sensor path组合起来.

当然有更好的方法,可以参考我另一篇文章 ANX

Read the rest of this entry »

Tags:

#su - bin -s /bin/bash -c 'rm -rf /tmp/k3.txt' 

  
#tail -f -n 1 ned-cisco-iosxr-cli-7.13-5501.trace
Read the rest of this entry »