This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, time, re | |
import paramiko | |
from zbxsend import Metric, send_to_zabbix | |
#Параметры для подключения по ssh | |
username='root' # ssh: login | |
ssh_key='/root/.ssh/id_dsa.pub' # ssh: password | |
port=22 # ssh: port | |
back_servs = [ea1-wal-backups, ea1-wal-backup2, ea1-wal-backup3, ea1-wal-backup4] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const findFile = (node, fn, pathToFile = '') => { | |
const filePath = path.join(pathToFile, node.name); | |
if (node.type === 'directory') { | |
return node.children | |
.map(element => findFile(element, fn, filePath)) | |
.reduce((res, found) => [...res, ...found], []); | |
} | |
if (fn(node)) { | |
return [filePath]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const countSize = (node) => { | |
reduce((size, element) => { | |
if (element.type === 'file') { | |
return (size + element.meta.size); | |
} | |
return size; | |
}, node, 0); | |
export default (tree) => { | |
const duIt = tree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default (backendUrl, currentUrl) => { | |
return new Promise((resolve, reject) => { | |
get(backendUrl) | |
.then(response => { | |
if (response.status !== 200) { | |
reject(new Error(response.status)); | |
return; | |
} | |
const parseJs = JSON.parse(response.data); | |
const checkLoad = Promise.all(parseJs.map(element => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const readFileAsync = file => new Promise((resolve, reject) => { | |
fs.readFile(file, (err, data) => err ? reject(err) : resolve(data)); | |
}); | |
const records = async (req, res) => { | |
await readFileAsync('phonebook.txt'); | |
const count = readBook.toString().split('\n').length - 1; | |
const str = `Welcome to The Phonebook\nRecords count: ${count}`; | |
res.write(str); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class BtnGroup extends React.Component { | |
state = { | |
active: null | |
}; | |
onClick = (id) => { | |
this.setState({ active: id }); | |
} | |
render() { |