Func common modules and APIs

Source: Internet
Author: User
Tags file copy

Func common modules and APIs

    1. Func provides a very rich range of functional modules, including:

Commandmodule (Execute command)

Copyfilemodule (copy file)

Cpumodule (CPU information)

Diskmodule (disk information)

Filetrackermodule (file tracking)

Iptablesmodule (iptables Management)

Mountmodule (Mount Mount)

Nagiosservermodule (Nagios Management)

Networktest (Network test)

Processmodule (Process Management)

Sysctlmodule (sysctl Management)

Snmpmodule (SNMP information management) and so on:

See more modules: https://fedoraproject.org/wiki/Infrastructure/Fedorahosted-retirement

Command line call module format:

func< target host >call<module_name (module name) ><method_name (method name) ><module_args (module parameter) >

For example, run "df–m" to view the managed side memory, such as:

[[Email protected] ~]# func compute call command Run "df-m"

(' Compute ',

[0,

  ' filesystem              1M-blocks  Used Available use% mounted on\n/dev/mapper/centos-root    459828  2131    457697& nbsp;  1%/\ndevtmpfs                      3861     0      3861    0%/dev\ntmpfs                         3871     0      3871   0%/dev/shm\ntmpfs                         3871    57       3815   2%/run\ntmpfs           & NBsp;            3871     0       3871   0%/sys/fs/cgroup\n/dev/sda1                      494   184        311  38%/boot\ntmpfs                          775     0        775   0%/run/user/0\n ',

‘‘])

Note: [[email protected] ~]# func "*" Call command Run "df-m" separate "*" for all controlled end

[[Email protected] ~]# func "Com*ute?" Call command Run "df-m" here "*" stands for any number of characters. “? "Represents a single arbitrary character

Func "compute1;compute2" call command Run "df-m" multiple target hosts are separated using semicolons

    1. Frequently used modules detailed

1. Execute Command Module

(1) function

Commandmodule implementation of Linux remote command call execution

(2) command line mode

[[Email protected] ~]# func "*" Call command Run "uname-a"

(3) API mode

[email protected] ~]# cat funcommand.py

#!/usr/bin/python

Import Func.overlord.client as Func

Client = func. Client ("*")

Print Client.command.run ("Free-m")

[email protected] ~]# python funcommand.py

{' Compute ': [0, ' total used free shared Buff/cache available\nmem:7741 6356 684 6669\nswap:16383 0 16383\n ', ']}

2. File Copy Module

a) function

Copyfilemodule implementation of the master side to the target host copy files, similar to the SCP function

b) command-line mode

[[Email protected] ~]# func "*" Copyfile-f/root/start.sh--remotepath/root/start.sh

c) API mode

[email protected] ~]# cat funccopyfile.py

#!/usr/bin/python

Import Func.overlord.client as Func

Client = func. Client ("*")

Client.local.copyfile.send ("/root/start.sh", "/tmp/start.sh")

    1. CPU Information Module

1. function

Cpumodule Gets the remote host CPU information, which supports sampling averages by time (seconds), as in the following example parameter ' 10 '

2. Command mode

[[Email protected] ~]# func "*" Call CPU Usage 10

3. API mode

Print Client.cpu.usage (10)

    1. Disk Information Module

1. function

The Diskmodule implementation gets the disk partition information for the remote host, with the parameter partition label, such as the/data partition.

2. Command mode

[[Email protected] ~]# func "*" Call CPU Usage 10

3. API mode

Print Client.cpu.usage (10)

    1. Copy remote file module

1. function

Getfilemodul implements pull remote Linux hosts to specify files to the master side directory and does not support command-line mode.

2. API mode

Client.local.getfile.get ("/root/a.txt", "/tmp/")

    1. Iptables Management Module

1. function

iptables implement remote host iptables configuration.

2. Command line mode

[[Email protected] ~]# func "*" Call iptables.port drop_to 192.168.128.0/24 UDP src

3. API mode

Client.iptables.port.drop_to (8080, "192.168.128.55", "TCP", "DST")

    1. System Hardware Information Module

1. function

Hardwaremodule returns the remote host system hardware information.

2. Command line mode

[[Email protected] ~]# func "*" Call iptables.port drop_to 192.168.128.0/24 UDP src

3. API mode

Print Client.hardware.info (with_devices=true)

Print Client.hardware.hal_info ()

    1. System Mount Management Module

1. function

Mountmodule implementation of remote host Linux system mount, uninstall partition management.

2. Command line mode

[[Email protected] ~]# func "*" Call mount List

3. API mode

Print Client.mount.list ()

    1. System Process Management Module

1. function

Processmodule enables remote host Linux process management.

2. Command line mode

[[Email protected] ~]# func "*" Call process info "aux"

3. API mode

Print Client.process.info ("aux")

    1. System Service Management Module

4. function

Servicesmodule implementation of remote host Linux system service management.

5. Command line mode

[[Email protected] ~]# func "*" Call service start SNMPD

6. API mode

Print Client.service.start ("Nginx")

Func common modules and APIs

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.