|
MythTV master
|
#include "mythmiscutil.h"#include <array>#include <cerrno>#include <cstdlib>#include <iostream>#include <thread>#include <unistd.h>#include <fcntl.h>#include <sched.h>#include <sys/stat.h>#include "compat.h"#include <QtGlobal>#include <QtProcessorDetection>#include <QtSystemDetection>#include <QReadWriteLock>#include <QNetworkProxy>#include <QStringList>#include <QDataStream>#include <QUdpSocket>#include <QFileInfo>#include <QFile>#include <QDir>#include <QUrl>#include <QHostAddress>#include <QRegularExpression>#include <QRegularExpressionMatchIterator>#include "mythcorecontext.h"#include "exitcodes.h"#include "mythlogging.h"#include "mythsocket.h"#include "filesysteminfo.h"#include "mythsystemlegacy.h"Go to the source code of this file.
Functions | |
| bool | getUptime (std::chrono::seconds &uptime) |
| Returns uptime statistics. More... | |
| bool | getMemStats (int &totalMB, int &freeMB, int &totalVM, int &freeVM) |
| Returns memory statistics in megabytes. More... | |
| loadArray | getLoadAvgs (void) |
| Returns the system load averages. More... | |
| bool | RemoteGetLoad (loadArray &load) |
| bool | RemoteGetUptime (std::chrono::seconds &uptime) |
| bool | RemoteGetMemStats (int &totalMB, int &freeMB, int &totalVM, int &freeVM) |
| bool | ping (const QString &host, std::chrono::milliseconds timeout) |
| Can we ping host within timeout seconds? More... | |
| bool | telnet (const QString &host, int port) |
| Can we talk to port on host? More... | |
| QString | createTempFile (QString name_template, bool dir) |
| bool | makeFileAccessible (const QString &filename) |
| QString | getResponse (const QString &query, const QString &def) |
| In an interactive shell, prompt the user to input a string. More... | |
| int | intResponse (const QString &query, int def) |
| In an interactive shell, prompt the user to input a number. More... | |
| QString | getSymlinkTarget (const QString &start_file, QStringList *intermediaries, unsigned maxLinks) |
| bool | IsMACAddress (const QString &MAC) |
| QString | FileHash (const QString &filename) |
| bool | WakeOnLAN (const QString &MAC) |
| bool | MythWakeup (const QString &wakeUpCommand, uint flags, std::chrono::seconds timeout) |
| bool | IsPulseAudioRunning (void) |
| Is A/V Sync destruction daemon is running on this host? More... | |
| bool | myth_nice (int val) |
| void | myth_yield (void) |
| bool | myth_ioprio (int) |
| Allows setting the I/O priority of the current process/thread. More... | |
| bool | MythRemoveDirectory (QDir &aDir) |
| void | setHttpProxy (void) |
| Get network proxy settings from OS, and use for [Q]Http[Comms]. More... | |
| QString createTempFile | ( | QString | name_template, |
| bool | dir | ||
| ) |
Definition at line 372 of file mythmiscutil.cpp.
Referenced by DBUtil::CreateTemporaryDBConf(), and FillData::GrabData().
| QString FileHash | ( | const QString & | filename | ) |
Definition at line 595 of file mythmiscutil.cpp.
Referenced by V2Video::AddVideo(), RemoteFile::GetFileHash(), V2Content::GetHash(), MainServer::HandleQueryFileHash(), FileServerHandler::HandleQueryFileHash(), UpdateHashes(), and VideoMetadata::VideoFileHash().
| getLoadAvgs | ( | void | ) |
Returns the system load averages.
Definition at line 173 of file mythmiscutil.cpp.
Referenced by StatusBox::doMachineStatus(), HttpStatus::FillStatusXML(), V2Status::FillStatusXML(), V2Status::GetBackendStatus(), MainServer::HandleQueryLoad(), BaseRequestHandler::HandleQueryLoad(), and NetworkControl::processQuery().
| getMemStats | ( | int & | totalMB, |
| int & | freeMB, | ||
| int & | totalVM, | ||
| int & | freeVM | ||
| ) |
Returns memory statistics in megabytes.
Memory Statistics are not supported (by MythTV) on NT or DOS.
keep values as B not MiB, int64_t (or size_t?)
Definition at line 106 of file mythmiscutil.cpp.
Referenced by StatusBox::doMachineStatus(), MainServer::HandleQueryMemStats(), BaseRequestHandler::HandleQueryMemStats(), and NetworkControl::processQuery().
| QString getResponse | ( | const QString & | query, |
| const QString & | def | ||
| ) |
In an interactive shell, prompt the user to input a string.
Definition at line 457 of file mythmiscutil.cpp.
Referenced by intResponse(), ChannelData::promptForChannelUpdates(), MythContext::Impl::PromptForDatabaseParams(), and SchemaUpgradeWizard::PromptForUpgrade().
| QString getSymlinkTarget | ( | const QString & | start_file, |
| QStringList * | intermediaries, | ||
| unsigned | maxLinks | ||
| ) |
Definition at line 498 of file mythmiscutil.cpp.
Referenced by CompleteJob(), anonymous_namespace{mainserver.cpp}::delete_file_immediately(), MainServer::DeleteFile(), ProgramInfo::DiscoverRecordingDirectory(), MythMediaDevice::findMountPath(), MediaMonitor::MediaMonitor(), MythMediaDevice::MythMediaDevice(), and DeleteThread::ProcessNew().
| bool getUptime | ( | std::chrono::seconds & | uptime | ) |
Returns uptime statistics.
Definition at line 63 of file mythmiscutil.cpp.
Referenced by StatusBox::doMachineStatus(), MainServer::HandleQueryUptime(), BaseRequestHandler::HandleQueryUptime(), and NetworkControl::processQuery().
| int intResponse | ( | const QString & | query, |
| int | def | ||
| ) |
In an interactive shell, prompt the user to input a number.
Definition at line 487 of file mythmiscutil.cpp.
Referenced by MythContext::Impl::PromptForDatabaseParams().
| bool IsMACAddress | ( | const QString & | MAC | ) |
Definition at line 550 of file mythmiscutil.cpp.
Referenced by MythWakeup(), and Scheduler::WakeUpSlave().
| bool IsPulseAudioRunning | ( | void | ) |
Is A/V Sync destruction daemon is running on this host?
Definition at line 685 of file mythmiscutil.cpp.
Referenced by AudioOutput::OpenAudio(), and PulseHandler::Suspend().
| bool makeFileAccessible | ( | const QString & | filename | ) |
Definition at line 442 of file mythmiscutil.cpp.
Referenced by V2Content::GetPreviewImage(), and PreviewGenerator::SavePreview().
| bool myth_ioprio | ( | int | val | ) |
Allows setting the I/O priority of the current process/thread.
range -1..8, smaller is higher priority
As of November 14th, 2010 this only works on Linux when using the CFQ I/O Scheduler. The range is -1 to 8, with -1 being real-time priority 0 through 7 being standard best-time priorities and 8 being the idle priority. The deadline and noop I/O Schedulers will ignore this but are much less likely to starve video playback to feed the transcoder or flagger. (noop is only recommended for SSDs.)
Since a process needs to have elevated priviledges to use either the real-time or idle priority this will try priorities 0 or 7 respectively if -1 or 8 do not work. It will not report an error on these conditions as they will be the common case.
Only Linux on i386, ppc, x86_64 and ia64 are currently supported. This is a no-op on all other architectures and platforms.
Definition at line 802 of file mythmiscutil.cpp.
Referenced by JobQueue::DoTranscodeThread(), JobQueue::DoUserJobThread(), MythSystemLegacyUnix::Fork(), and main().
| bool myth_nice | ( | int | val | ) |
Definition at line 703 of file mythmiscutil.cpp.
Referenced by JobQueue::DoTranscodeThread(), JobQueue::DoUserJobThread(), MythSystemLegacyUnix::Fork(), MythPlayer::InitFrameInterval(), and main().
| void myth_yield | ( | void | ) |
Definition at line 717 of file mythmiscutil.cpp.
| bool MythRemoveDirectory | ( | QDir & | aDir | ) |
Definition at line 806 of file mythmiscutil.cpp.
Referenced by NativeArchive::doNativeArchive(), MythBurn::MythBurn(), MythRemoveDirectory(), MainServer::OpenAndUnlink(), and DeleteThread::ProcessNew().
Definition at line 677 of file mythmiscutil.cpp.
Referenced by MythCoreContext::ConnectCommandSocket(), MSqlDatabase::OpenDatabase(), and MythContext::Impl::TestDBconnection().
| bool ping | ( | const QString & | host, |
| std::chrono::milliseconds | timeout | ||
| ) |
Can we ping host within timeout seconds?
Different operating systems use different parameters to specify a timeout to the ping command. FreeBSD and derivatives use '-t'; Linux and derivatives use '-w'. Using the right parameter also eliminates the need for the old behavior of falling back to pinging the localhost with and without a timeout, in order to characterize whether the right parameter was used in the first place.
Definition at line 248 of file mythmiscutil.cpp.
Referenced by setHttpProxy().
Definition at line 183 of file mythmiscutil.cpp.
Referenced by StatusBox::doMachineStatus().
| bool RemoteGetMemStats | ( | int & | totalMB, |
| int & | freeMB, | ||
| int & | totalVM, | ||
| int & | freeVM | ||
| ) |
Definition at line 218 of file mythmiscutil.cpp.
Referenced by StatusBox::doMachineStatus().
| bool RemoteGetUptime | ( | std::chrono::seconds & | uptime | ) |
Definition at line 198 of file mythmiscutil.cpp.
Referenced by StatusBox::doMachineStatus().
| void setHttpProxy | ( | void | ) |
Get network proxy settings from OS, and use for [Q]Http[Comms].
The HTTP_PROXY environment var. is parsed for values like; "proxy-host", "proxy-host:8080", "http://host:8080" and "http"//user:password@host:1080", and that is used for any Qt-based Http fetches. We also test connectivity here with ping and telnet, and warn if it fails.
If there is was no env. var, we use Qt to get proxy settings from the OS, and search through them for a proxy server we can connect to.
Definition at line 850 of file mythmiscutil.cpp.
Referenced by main().
| bool telnet | ( | const QString & | host, |
| int | port | ||
| ) |
Can we talk to port on host?
Definition at line 281 of file mythmiscutil.cpp.
Referenced by setHttpProxy().
| bool WakeOnLAN | ( | const QString & | MAC | ) |
Definition at line 636 of file mythmiscutil.cpp.
Referenced by MythWakeup(), and Scheduler::WakeUpSlave().